Lines Matching refs:netns

21 static __u32 query_attached_prog_id(int netns)  in query_attached_prog_id()  argument
27 err = bpf_prog_query(netns, BPF_FLOW_DISSECTOR, 0, NULL, in query_attached_prog_id()
37 static bool prog_is_attached(int netns) in prog_is_attached() argument
39 return query_attached_prog_id(netns) > 0; in prog_is_attached()
90 static void test_prog_attach_prog_attach(int netns, int prog1, int prog2) in test_prog_attach_prog_attach() argument
99 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_prog_attach_prog_attach()
107 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog2)); in test_prog_attach_prog_attach()
113 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog2)); in test_prog_attach_prog_attach()
119 CHECK_FAIL(prog_is_attached(netns)); in test_prog_attach_prog_attach()
122 static void test_link_create_link_create(int netns, int prog1, int prog2) in test_link_create_link_create() argument
127 link1 = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &opts); in test_link_create_link_create()
132 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_create_link_create()
136 link2 = bpf_link_create(prog2, netns, BPF_FLOW_DISSECTOR, &opts); in test_link_create_link_create()
141 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_create_link_create()
144 CHECK_FAIL(prog_is_attached(netns)); in test_link_create_link_create()
147 static void test_prog_attach_link_create(int netns, int prog1, int prog2) in test_prog_attach_link_create() argument
157 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_prog_attach_link_create()
161 link = bpf_link_create(prog2, netns, BPF_FLOW_DISSECTOR, &opts); in test_prog_attach_link_create()
166 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_prog_attach_link_create()
171 CHECK_FAIL(prog_is_attached(netns)); in test_prog_attach_link_create()
174 static void test_link_create_prog_attach(int netns, int prog1, int prog2) in test_link_create_prog_attach() argument
179 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &opts); in test_link_create_prog_attach()
184 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_create_prog_attach()
191 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_create_prog_attach()
194 CHECK_FAIL(prog_is_attached(netns)); in test_link_create_prog_attach()
197 static void test_link_create_prog_detach(int netns, int prog1, int prog2) in test_link_create_prog_detach() argument
202 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &opts); in test_link_create_prog_detach()
207 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_create_prog_detach()
214 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_create_prog_detach()
217 CHECK_FAIL(prog_is_attached(netns)); in test_link_create_prog_detach()
220 static void test_prog_attach_detach_query(int netns, int prog1, int prog2) in test_prog_attach_detach_query() argument
229 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_prog_attach_detach_query()
238 CHECK_FAIL(prog_is_attached(netns)); in test_prog_attach_detach_query()
241 static void test_link_create_close_query(int netns, int prog1, int prog2) in test_link_create_close_query() argument
246 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &opts); in test_link_create_close_query()
251 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_create_close_query()
255 CHECK_FAIL(prog_is_attached(netns)); in test_link_create_close_query()
258 static void test_link_update_no_old_prog(int netns, int prog1, int prog2) in test_link_update_no_old_prog() argument
264 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts); in test_link_update_no_old_prog()
269 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_no_old_prog()
277 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog2)); in test_link_update_no_old_prog()
280 CHECK_FAIL(prog_is_attached(netns)); in test_link_update_no_old_prog()
283 static void test_link_update_replace_old_prog(int netns, int prog1, int prog2) in test_link_update_replace_old_prog() argument
289 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts); in test_link_update_replace_old_prog()
294 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_replace_old_prog()
302 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog2)); in test_link_update_replace_old_prog()
305 CHECK_FAIL(prog_is_attached(netns)); in test_link_update_replace_old_prog()
308 static void test_link_update_same_prog(int netns, int prog1, int prog2) in test_link_update_same_prog() argument
314 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts); in test_link_update_same_prog()
319 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_same_prog()
327 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_same_prog()
330 CHECK_FAIL(prog_is_attached(netns)); in test_link_update_same_prog()
333 static void test_link_update_invalid_opts(int netns, int prog1, int prog2) in test_link_update_invalid_opts() argument
339 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts); in test_link_update_invalid_opts()
344 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_invalid_opts()
355 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_invalid_opts()
366 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_invalid_opts()
377 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_invalid_opts()
386 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_invalid_opts()
390 CHECK_FAIL(prog_is_attached(netns)); in test_link_update_invalid_opts()
393 static void test_link_update_invalid_prog(int netns, int prog1, int prog2) in test_link_update_invalid_prog() argument
399 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts); in test_link_update_invalid_prog()
404 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_invalid_prog()
415 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_invalid_prog()
428 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_invalid_prog()
433 CHECK_FAIL(prog_is_attached(netns)); in test_link_update_invalid_prog()
436 static void test_link_update_netns_gone(int netns, int prog1, int prog2) in test_link_update_netns_gone() argument
442 old_net = netns; in test_link_update_netns_gone()
443 netns = unshare_net(old_net); in test_link_update_netns_gone()
444 if (netns < 0) in test_link_update_netns_gone()
447 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts); in test_link_update_netns_gone()
452 CHECK_FAIL(query_attached_prog_id(netns) != query_prog_id(prog1)); in test_link_update_netns_gone()
454 close(netns); in test_link_update_netns_gone()
473 static void test_link_get_info(int netns, int prog1, int prog2) in test_link_get_info() argument
482 old_net = netns; in test_link_get_info()
483 netns = unshare_net(old_net); in test_link_get_info()
484 if (netns < 0) in test_link_get_info()
487 err = fstat(netns, &netns_stat); in test_link_get_info()
493 link = bpf_link_create(prog1, netns, BPF_FLOW_DISSECTOR, &create_opts); in test_link_get_info()
511 CHECK_FAIL(info.netns.netns_ino != netns_stat.st_ino); in test_link_get_info()
512 CHECK_FAIL(info.netns.attach_type != BPF_FLOW_DISSECTOR); in test_link_get_info()
535 CHECK_FAIL(info.netns.netns_ino != netns_stat.st_ino); in test_link_get_info()
536 CHECK_FAIL(info.netns.attach_type != BPF_FLOW_DISSECTOR); in test_link_get_info()
544 close(netns); in test_link_get_info()
546 netns = -1; in test_link_get_info()
560 CHECK_FAIL(info.netns.netns_ino != 0); in test_link_get_info()
561 CHECK_FAIL(info.netns.attach_type != BPF_FLOW_DISSECTOR); in test_link_get_info()
568 if (netns != -1) in test_link_get_info()
569 close(netns); in test_link_get_info()
572 static void run_tests(int netns) in run_tests() argument
576 void (*test_func)(int netns, int prog1, int prog2); in run_tests()
620 netns == init_net ? " (init_net)" : ""); in run_tests()
622 tests[i].test_func(netns, progs[0], progs[1]); in run_tests()