Lines Matching full:hook

25 static int test_tc_bpf_basic(const struct bpf_tc_hook *hook, int fd)  in test_tc_bpf_basic()  argument
36 ret = bpf_tc_attach(hook, &opts); in test_tc_bpf_basic()
47 ret = bpf_tc_attach(hook, &opts); in test_tc_bpf_basic()
52 ret = bpf_tc_query(hook, &opts); in test_tc_bpf_basic()
63 ret = bpf_tc_detach(hook, &opts); in test_tc_bpf_basic()
68 static int test_tc_bpf_api(struct bpf_tc_hook *hook, int fd) in test_tc_bpf_api() argument
76 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook = NULL")) in test_tc_bpf_api()
79 /* hook ifindex = 0 */ in test_tc_bpf_api()
81 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook ifindex == 0")) in test_tc_bpf_api()
85 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_destroy invalid hook ifindex == 0")) in test_tc_bpf_api()
89 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook ifindex == 0")) in test_tc_bpf_api()
94 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook ifindex == 0")) in test_tc_bpf_api()
98 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook ifindex == 0")) in test_tc_bpf_api()
101 /* hook ifindex < 0 */ in test_tc_bpf_api()
105 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook ifindex < 0")) in test_tc_bpf_api()
109 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_destroy invalid hook ifindex < 0")) in test_tc_bpf_api()
113 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook ifindex < 0")) in test_tc_bpf_api()
118 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook ifindex < 0")) in test_tc_bpf_api()
122 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook ifindex < 0")) in test_tc_bpf_api()
127 /* hook.attach_point invalid */ in test_tc_bpf_api()
130 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook.attach_point")) in test_tc_bpf_api()
134 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_destroy invalid hook.attach_point")) in test_tc_bpf_api()
138 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook.attach_point")) in test_tc_bpf_api()
142 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook.attach_point")) in test_tc_bpf_api()
146 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook.attach_point")) in test_tc_bpf_api()
151 /* hook.attach_point valid, but parent invalid */ in test_tc_bpf_api()
154 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook parent")) in test_tc_bpf_api()
158 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_destroy invalid hook parent")) in test_tc_bpf_api()
162 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook parent")) in test_tc_bpf_api()
166 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook parent")) in test_tc_bpf_api()
170 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook parent")) in test_tc_bpf_api()
176 * attach_point of the hook. in test_tc_bpf_api()
179 if (!ASSERT_EQ(ret, -EOPNOTSUPP, "bpf_tc_hook_create invalid hook parent")) in test_tc_bpf_api()
183 if (!ASSERT_EQ(ret, -EOPNOTSUPP, "bpf_tc_hook_destroy invalid hook parent")) in test_tc_bpf_api()
187 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook parent")) in test_tc_bpf_api()
191 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook parent")) in test_tc_bpf_api()
195 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook parent")) in test_tc_bpf_api()
205 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook = NULL")) in test_tc_bpf_api()
208 ret = bpf_tc_detach(hook, NULL); in test_tc_bpf_api()
212 ret = bpf_tc_detach(hook, &opts_hpr); in test_tc_bpf_api()
216 ret = bpf_tc_detach(hook, &opts_hpf); in test_tc_bpf_api()
220 ret = bpf_tc_detach(hook, &opts_hpi); in test_tc_bpf_api()
224 ret = bpf_tc_detach(hook, &opts_p); in test_tc_bpf_api()
228 ret = bpf_tc_detach(hook, &opts_h); in test_tc_bpf_api()
232 ret = bpf_tc_detach(hook, &opts_prio_max); in test_tc_bpf_api()
242 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook = NULL")) in test_tc_bpf_api()
245 ret = bpf_tc_query(hook, NULL); in test_tc_bpf_api()
249 ret = bpf_tc_query(hook, &opts_hpr); in test_tc_bpf_api()
253 ret = bpf_tc_query(hook, &opts_hpf); in test_tc_bpf_api()
257 ret = bpf_tc_query(hook, &opts_hpi); in test_tc_bpf_api()
261 ret = bpf_tc_query(hook, &opts_p); in test_tc_bpf_api()
265 ret = bpf_tc_query(hook, &opts_h); in test_tc_bpf_api()
269 ret = bpf_tc_query(hook, &opts_prio_max); in test_tc_bpf_api()
274 ret = bpf_tc_query(hook, &opts_hp); in test_tc_bpf_api()
284 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook = NULL")) in test_tc_bpf_api()
287 ret = bpf_tc_attach(hook, NULL); in test_tc_bpf_api()
292 ret = bpf_tc_attach(hook, &opts_hp); in test_tc_bpf_api()
296 ret = bpf_tc_attach(hook, NULL); in test_tc_bpf_api()
300 ret = bpf_tc_attach(hook, &opts_hpi); in test_tc_bpf_api()
304 ret = bpf_tc_attach(hook, &opts_pf); in test_tc_bpf_api()
308 ASSERT_OK(bpf_tc_detach(hook, &opts_pf), "bpf_tc_detach"); in test_tc_bpf_api()
310 ret = bpf_tc_attach(hook, &opts_hf); in test_tc_bpf_api()
314 ASSERT_OK(bpf_tc_detach(hook, &opts_hf), "bpf_tc_detach"); in test_tc_bpf_api()
316 ret = bpf_tc_attach(hook, &opts_prio_max); in test_tc_bpf_api()
320 ret = bpf_tc_attach(hook, &opts_f); in test_tc_bpf_api()
324 ASSERT_OK(bpf_tc_detach(hook, &opts_f), "bpf_tc_detach"); in test_tc_bpf_api()
332 DECLARE_LIBBPF_OPTS(bpf_tc_hook, hook, .ifindex = LO_IFINDEX, in test_tc_bpf()
344 ret = bpf_tc_hook_create(&hook); in test_tc_bpf()
352 hook.attach_point = BPF_TC_CUSTOM; in test_tc_bpf()
353 hook.parent = TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_INGRESS); in test_tc_bpf()
354 ret = bpf_tc_hook_create(&hook); in test_tc_bpf()
355 if (!ASSERT_EQ(ret, -EOPNOTSUPP, "bpf_tc_hook_create invalid hook.attach_point")) in test_tc_bpf()
358 ret = test_tc_bpf_basic(&hook, cls_fd); in test_tc_bpf()
362 ret = bpf_tc_hook_destroy(&hook); in test_tc_bpf()
363 if (!ASSERT_EQ(ret, -EOPNOTSUPP, "bpf_tc_hook_destroy invalid hook.attach_point")) in test_tc_bpf()
366 hook.attach_point = BPF_TC_INGRESS; in test_tc_bpf()
367 hook.parent = 0; in test_tc_bpf()
368 bpf_tc_hook_destroy(&hook); in test_tc_bpf()
370 ret = test_tc_bpf_basic(&hook, cls_fd); in test_tc_bpf()
374 bpf_tc_hook_destroy(&hook); in test_tc_bpf()
376 hook.attach_point = BPF_TC_EGRESS; in test_tc_bpf()
377 ret = test_tc_bpf_basic(&hook, cls_fd); in test_tc_bpf()
381 bpf_tc_hook_destroy(&hook); in test_tc_bpf()
383 ret = test_tc_bpf_api(&hook, cls_fd); in test_tc_bpf()
387 bpf_tc_hook_destroy(&hook); in test_tc_bpf()
391 hook.attach_point = BPF_TC_INGRESS | BPF_TC_EGRESS; in test_tc_bpf()
392 bpf_tc_hook_destroy(&hook); in test_tc_bpf()