Lines Matching defs:hook

26 static int test_tc_bpf_basic(const struct bpf_tc_hook *hook, int fd)
37 ret = bpf_tc_attach(hook, &opts);
48 ret = bpf_tc_attach(hook, &opts);
53 ret = bpf_tc_query(hook, &opts);
64 ret = bpf_tc_detach(hook, &opts);
69 static int test_tc_bpf_api(struct bpf_tc_hook *hook, int fd)
77 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook = NULL"))
80 /* hook ifindex = 0 */
82 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook ifindex == 0"))
86 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_destroy invalid hook ifindex == 0"))
90 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook ifindex == 0"))
95 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook ifindex == 0"))
99 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook ifindex == 0"))
102 /* hook ifindex < 0 */
106 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook ifindex < 0"))
110 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_destroy invalid hook ifindex < 0"))
114 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook ifindex < 0"))
119 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook ifindex < 0"))
123 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook ifindex < 0"))
128 /* hook.attach_point invalid */
131 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook.attach_point"))
135 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_destroy invalid hook.attach_point"))
139 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook.attach_point"))
143 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook.attach_point"))
147 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook.attach_point"))
152 /* hook.attach_point valid, but parent invalid */
155 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_create invalid hook parent"))
159 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_hook_destroy invalid hook parent"))
163 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook parent"))
167 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook parent"))
171 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook parent"))
177 * attach_point of the hook.
180 if (!ASSERT_EQ(ret, -EOPNOTSUPP, "bpf_tc_hook_create invalid hook parent"))
184 if (!ASSERT_EQ(ret, -EOPNOTSUPP, "bpf_tc_hook_destroy invalid hook parent"))
188 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook parent"))
192 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook parent"))
196 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook parent"))
206 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_detach invalid hook = NULL"))
209 ret = bpf_tc_detach(hook, NULL);
213 ret = bpf_tc_detach(hook, &opts_hpr);
217 ret = bpf_tc_detach(hook, &opts_hpf);
221 ret = bpf_tc_detach(hook, &opts_hpi);
225 ret = bpf_tc_detach(hook, &opts_p);
229 ret = bpf_tc_detach(hook, &opts_h);
233 ret = bpf_tc_detach(hook, &opts_prio_max);
243 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_query invalid hook = NULL"))
246 ret = bpf_tc_query(hook, NULL);
250 ret = bpf_tc_query(hook, &opts_hpr);
254 ret = bpf_tc_query(hook, &opts_hpf);
258 ret = bpf_tc_query(hook, &opts_hpi);
262 ret = bpf_tc_query(hook, &opts_p);
266 ret = bpf_tc_query(hook, &opts_h);
270 ret = bpf_tc_query(hook, &opts_prio_max);
275 ret = bpf_tc_query(hook, &opts_hp);
285 if (!ASSERT_EQ(ret, -EINVAL, "bpf_tc_attach invalid hook = NULL"))
288 ret = bpf_tc_attach(hook, NULL);
293 ret = bpf_tc_attach(hook, &opts_hp);
297 ret = bpf_tc_attach(hook, NULL);
301 ret = bpf_tc_attach(hook, &opts_hpi);
305 ret = bpf_tc_attach(hook, &opts_pf);
309 ASSERT_OK(bpf_tc_detach(hook, &opts_pf), "bpf_tc_detach");
311 ret = bpf_tc_attach(hook, &opts_hf);
315 ASSERT_OK(bpf_tc_detach(hook, &opts_hf), "bpf_tc_detach");
317 ret = bpf_tc_attach(hook, &opts_prio_max);
321 ret = bpf_tc_attach(hook, &opts_f);
325 ASSERT_OK(bpf_tc_detach(hook, &opts_f), "bpf_tc_detach");
333 DECLARE_LIBBPF_OPTS(bpf_tc_hook, hook, .ifindex = LO_IFINDEX,
345 ret = bpf_tc_hook_create(&hook);
353 hook.attach_point = BPF_TC_CUSTOM;
354 hook.parent = TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_INGRESS);
355 ret = bpf_tc_hook_create(&hook);
356 if (!ASSERT_EQ(ret, -EOPNOTSUPP, "bpf_tc_hook_create invalid hook.attach_point"))
359 ret = test_tc_bpf_basic(&hook, cls_fd);
363 ret = bpf_tc_hook_destroy(&hook);
364 if (!ASSERT_EQ(ret, -EOPNOTSUPP, "bpf_tc_hook_destroy invalid hook.attach_point"))
367 hook.attach_point = BPF_TC_INGRESS;
368 hook.parent = 0;
369 bpf_tc_hook_destroy(&hook);
371 ret = test_tc_bpf_basic(&hook, cls_fd);
375 bpf_tc_hook_destroy(&hook);
377 hook.attach_point = BPF_TC_EGRESS;
378 ret = test_tc_bpf_basic(&hook, cls_fd);
382 bpf_tc_hook_destroy(&hook);
384 ret = test_tc_bpf_api(&hook, cls_fd);
388 bpf_tc_hook_destroy(&hook);
392 hook.attach_point = BPF_TC_INGRESS | BPF_TC_EGRESS;
393 bpf_tc_hook_destroy(&hook);