Lines Matching refs:hook
532 typedef int (*qdisc_config_t)(struct libbpf_nla_req *req, const struct bpf_tc_hook *hook);
534 static int clsact_config(struct libbpf_nla_req *req, const struct bpf_tc_hook *hook) in clsact_config() argument
542 static int qdisc_config(struct libbpf_nla_req *req, const struct bpf_tc_hook *hook) in qdisc_config() argument
544 const char *qdisc = OPTS_GET(hook, qdisc, NULL); in qdisc_config()
546 req->tc.tcm_parent = OPTS_GET(hook, parent, TC_H_ROOT); in qdisc_config()
547 req->tc.tcm_handle = OPTS_GET(hook, handle, 0); in qdisc_config()
552 static int attach_point_to_config(struct bpf_tc_hook *hook, in attach_point_to_config() argument
555 switch (OPTS_GET(hook, attach_point, 0)) { in attach_point_to_config()
559 if (OPTS_GET(hook, parent, 0)) in attach_point_to_config()
595 static int tc_qdisc_modify(struct bpf_tc_hook *hook, int cmd, int flags) in tc_qdisc_modify() argument
601 ret = attach_point_to_config(hook, &config); in tc_qdisc_modify()
610 req.tc.tcm_ifindex = OPTS_GET(hook, ifindex, 0); in tc_qdisc_modify()
612 ret = config(&req, hook); in tc_qdisc_modify()
619 static int tc_qdisc_create_excl(struct bpf_tc_hook *hook) in tc_qdisc_create_excl() argument
621 return tc_qdisc_modify(hook, RTM_NEWQDISC, NLM_F_CREATE | NLM_F_EXCL); in tc_qdisc_create_excl()
624 static int tc_qdisc_delete(struct bpf_tc_hook *hook) in tc_qdisc_delete() argument
626 return tc_qdisc_modify(hook, RTM_DELQDISC, 0); in tc_qdisc_delete()
629 int bpf_tc_hook_create(struct bpf_tc_hook *hook) in bpf_tc_hook_create() argument
633 if (!hook || !OPTS_VALID(hook, bpf_tc_hook) || in bpf_tc_hook_create()
634 OPTS_GET(hook, ifindex, 0) <= 0) in bpf_tc_hook_create()
637 ret = tc_qdisc_create_excl(hook); in bpf_tc_hook_create()
641 static int __bpf_tc_detach(const struct bpf_tc_hook *hook,
645 int bpf_tc_hook_destroy(struct bpf_tc_hook *hook) in bpf_tc_hook_destroy() argument
647 if (!hook || !OPTS_VALID(hook, bpf_tc_hook) || in bpf_tc_hook_destroy()
648 OPTS_GET(hook, ifindex, 0) <= 0) in bpf_tc_hook_destroy()
651 switch (OPTS_GET(hook, attach_point, 0)) { in bpf_tc_hook_destroy()
654 return libbpf_err(__bpf_tc_detach(hook, NULL, true)); in bpf_tc_hook_destroy()
657 return libbpf_err(tc_qdisc_delete(hook)); in bpf_tc_hook_destroy()
732 int bpf_tc_attach(const struct bpf_tc_hook *hook, struct bpf_tc_opts *opts) in bpf_tc_attach() argument
740 if (!hook || !opts || in bpf_tc_attach()
741 !OPTS_VALID(hook, bpf_tc_hook) || in bpf_tc_attach()
745 ifindex = OPTS_GET(hook, ifindex, 0); in bpf_tc_attach()
746 parent = OPTS_GET(hook, parent, 0); in bpf_tc_attach()
747 attach_point = OPTS_GET(hook, attach_point, 0); in bpf_tc_attach()
806 static int __bpf_tc_detach(const struct bpf_tc_hook *hook, in __bpf_tc_detach() argument
814 if (!hook || in __bpf_tc_detach()
815 !OPTS_VALID(hook, bpf_tc_hook) || in __bpf_tc_detach()
819 ifindex = OPTS_GET(hook, ifindex, 0); in __bpf_tc_detach()
820 parent = OPTS_GET(hook, parent, 0); in __bpf_tc_detach()
821 attach_point = OPTS_GET(hook, attach_point, 0); in __bpf_tc_detach()
867 int bpf_tc_detach(const struct bpf_tc_hook *hook, in bpf_tc_detach() argument
875 ret = __bpf_tc_detach(hook, opts, false); in bpf_tc_detach()
879 int bpf_tc_query(const struct bpf_tc_hook *hook, struct bpf_tc_opts *opts) in bpf_tc_query() argument
886 if (!hook || !opts || in bpf_tc_query()
887 !OPTS_VALID(hook, bpf_tc_hook) || in bpf_tc_query()
891 ifindex = OPTS_GET(hook, ifindex, 0); in bpf_tc_query()
892 parent = OPTS_GET(hook, parent, 0); in bpf_tc_query()
893 attach_point = OPTS_GET(hook, attach_point, 0); in bpf_tc_query()