Lines Matching defs:hook
542 static int attach_point_to_config(struct bpf_tc_hook *hook,
545 switch (OPTS_GET(hook, attach_point, 0)) {
549 if (OPTS_GET(hook, parent, 0))
582 static int tc_qdisc_modify(struct bpf_tc_hook *hook, int cmd, int flags)
588 ret = attach_point_to_config(hook, &config);
597 req.tc.tcm_ifindex = OPTS_GET(hook, ifindex, 0);
606 static int tc_qdisc_create_excl(struct bpf_tc_hook *hook)
608 return tc_qdisc_modify(hook, RTM_NEWQDISC, NLM_F_CREATE | NLM_F_EXCL);
611 static int tc_qdisc_delete(struct bpf_tc_hook *hook)
613 return tc_qdisc_modify(hook, RTM_DELQDISC, 0);
616 int bpf_tc_hook_create(struct bpf_tc_hook *hook)
620 if (!hook || !OPTS_VALID(hook, bpf_tc_hook) ||
621 OPTS_GET(hook, ifindex, 0) <= 0)
624 ret = tc_qdisc_create_excl(hook);
628 static int __bpf_tc_detach(const struct bpf_tc_hook *hook,
632 int bpf_tc_hook_destroy(struct bpf_tc_hook *hook)
634 if (!hook || !OPTS_VALID(hook, bpf_tc_hook) ||
635 OPTS_GET(hook, ifindex, 0) <= 0)
638 switch (OPTS_GET(hook, attach_point, 0)) {
641 return libbpf_err(__bpf_tc_detach(hook, NULL, true));
643 return libbpf_err(tc_qdisc_delete(hook));
718 int bpf_tc_attach(const struct bpf_tc_hook *hook, struct bpf_tc_opts *opts)
726 if (!hook || !opts ||
727 !OPTS_VALID(hook, bpf_tc_hook) ||
731 ifindex = OPTS_GET(hook, ifindex, 0);
732 parent = OPTS_GET(hook, parent, 0);
733 attach_point = OPTS_GET(hook, attach_point, 0);
792 static int __bpf_tc_detach(const struct bpf_tc_hook *hook,
800 if (!hook ||
801 !OPTS_VALID(hook, bpf_tc_hook) ||
805 ifindex = OPTS_GET(hook, ifindex, 0);
806 parent = OPTS_GET(hook, parent, 0);
807 attach_point = OPTS_GET(hook, attach_point, 0);
853 int bpf_tc_detach(const struct bpf_tc_hook *hook,
861 ret = __bpf_tc_detach(hook, opts, false);
865 int bpf_tc_query(const struct bpf_tc_hook *hook, struct bpf_tc_opts *opts)
872 if (!hook || !opts ||
873 !OPTS_VALID(hook, bpf_tc_hook) ||
877 ifindex = OPTS_GET(hook, ifindex, 0);
878 parent = OPTS_GET(hook, parent, 0);
879 attach_point = OPTS_GET(hook, attach_point, 0);