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