diff options
author | alexlzhu <alexlzhu@fb.com> | 2021-08-18 16:01:05 -0700 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-10-12 12:48:23 +0200 |
commit | 76dc17254f7c78eae2dec2b9b1cfb60657a7b6e7 (patch) | |
tree | eaf61330174b3b5b5647cd11ec6951f5d1609220 /src/test/test-bpf-devices.c | |
parent | d92681a65e7334297727c3048a3489c32e795e4b (diff) | |
download | systemd-76dc17254f7c78eae2dec2b9b1cfb60657a7b6e7.tar.gz |
core: remove refcount for bpf program
Currently ref count of bpf-program is kept in user space. However, the
kernel already implements its own ref count. Thus the ref count we keep for
bpf-program is redundant.
This PR removes ref count for bpf program as part of a task to simplify
bpf-program and remove redundancies, which will make the switch to
code-compiled BPF programs easier.
Part of #19270
Diffstat (limited to 'src/test/test-bpf-devices.c')
-rw-r--r-- | src/test/test-bpf-devices.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/test/test-bpf-devices.c b/src/test/test-bpf-devices.c index 2c5eb7313b..bbaa7b3605 100644 --- a/src/test/test-bpf-devices.c +++ b/src/test/test-bpf-devices.c @@ -15,7 +15,7 @@ #include "tests.h" static void test_policy_closed(const char *cgroup_path, BPFProgram **installed_prog) { - _cleanup_(bpf_program_unrefp) BPFProgram *prog = NULL; + _cleanup_(bpf_program_freep) BPFProgram *prog = NULL; unsigned wrong = 0; int r; @@ -27,7 +27,7 @@ static void test_policy_closed(const char *cgroup_path, BPFProgram **installed_p r = bpf_devices_allow_list_static(prog, cgroup_path); assert_se(r >= 0); - r = bpf_devices_apply_policy(prog, CGROUP_DEVICE_POLICY_CLOSED, true, cgroup_path, installed_prog); + r = bpf_devices_apply_policy(&prog, CGROUP_DEVICE_POLICY_CLOSED, true, cgroup_path, installed_prog); assert_se(r >= 0); const char *s; @@ -53,7 +53,7 @@ static void test_policy_closed(const char *cgroup_path, BPFProgram **installed_p } static void test_policy_strict(const char *cgroup_path, BPFProgram **installed_prog) { - _cleanup_(bpf_program_unrefp) BPFProgram *prog = NULL; + _cleanup_(bpf_program_freep) BPFProgram *prog = NULL; unsigned wrong = 0; int r; @@ -71,7 +71,7 @@ static void test_policy_strict(const char *cgroup_path, BPFProgram **installed_p r = bpf_devices_allow_list_device(prog, cgroup_path, "/dev/zero", "w"); assert_se(r >= 0); - r = bpf_devices_apply_policy(prog, CGROUP_DEVICE_POLICY_STRICT, true, cgroup_path, installed_prog); + r = bpf_devices_apply_policy(&prog, CGROUP_DEVICE_POLICY_STRICT, true, cgroup_path, installed_prog); assert_se(r >= 0); { @@ -130,7 +130,7 @@ static void test_policy_strict(const char *cgroup_path, BPFProgram **installed_p } static void test_policy_allow_list_major(const char *pattern, const char *cgroup_path, BPFProgram **installed_prog) { - _cleanup_(bpf_program_unrefp) BPFProgram *prog = NULL; + _cleanup_(bpf_program_freep) BPFProgram *prog = NULL; unsigned wrong = 0; int r; @@ -142,7 +142,7 @@ static void test_policy_allow_list_major(const char *pattern, const char *cgroup r = bpf_devices_allow_list_major(prog, cgroup_path, pattern, 'c', "rw"); assert_se(r >= 0); - r = bpf_devices_apply_policy(prog, CGROUP_DEVICE_POLICY_STRICT, true, cgroup_path, installed_prog); + r = bpf_devices_apply_policy(&prog, CGROUP_DEVICE_POLICY_STRICT, true, cgroup_path, installed_prog); assert_se(r >= 0); /* /dev/null, /dev/full have major==1, /dev/tty has major==5 */ @@ -189,7 +189,7 @@ static void test_policy_allow_list_major(const char *pattern, const char *cgroup } static void test_policy_allow_list_major_star(char type, const char *cgroup_path, BPFProgram **installed_prog) { - _cleanup_(bpf_program_unrefp) BPFProgram *prog = NULL; + _cleanup_(bpf_program_freep) BPFProgram *prog = NULL; unsigned wrong = 0; int r; @@ -201,7 +201,7 @@ static void test_policy_allow_list_major_star(char type, const char *cgroup_path r = bpf_devices_allow_list_major(prog, cgroup_path, "*", type, "rw"); assert_se(r >= 0); - r = bpf_devices_apply_policy(prog, CGROUP_DEVICE_POLICY_STRICT, true, cgroup_path, installed_prog); + r = bpf_devices_apply_policy(&prog, CGROUP_DEVICE_POLICY_STRICT, true, cgroup_path, installed_prog); assert_se(r >= 0); { @@ -220,7 +220,7 @@ static void test_policy_allow_list_major_star(char type, const char *cgroup_path } static void test_policy_empty(bool add_mismatched, const char *cgroup_path, BPFProgram **installed_prog) { - _cleanup_(bpf_program_unrefp) BPFProgram *prog = NULL; + _cleanup_(bpf_program_freep) BPFProgram *prog = NULL; unsigned wrong = 0; int r; @@ -234,7 +234,7 @@ static void test_policy_empty(bool add_mismatched, const char *cgroup_path, BPFP assert_se(r < 0); } - r = bpf_devices_apply_policy(prog, CGROUP_DEVICE_POLICY_STRICT, false, cgroup_path, installed_prog); + r = bpf_devices_apply_policy(&prog, CGROUP_DEVICE_POLICY_STRICT, false, cgroup_path, installed_prog); assert_se(r >= 0); { @@ -282,7 +282,7 @@ int main(int argc, char *argv[]) { r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, cgroup, NULL, &controller_path); assert_se(r >= 0); - _cleanup_(bpf_program_unrefp) BPFProgram *prog = NULL; + _cleanup_(bpf_program_freep) BPFProgram *prog = NULL; test_policy_closed(cgroup, &prog); test_policy_strict(cgroup, &prog); |