Lines Matching refs:req
222 static int libbpf_netlink_send_recv(struct libbpf_nla_req *req, in libbpf_netlink_send_recv() argument
234 req->nh.nlmsg_pid = 0; in libbpf_netlink_send_recv()
235 req->nh.nlmsg_seq = time(NULL); in libbpf_netlink_send_recv()
237 if (send(sock, req, req->nh.nlmsg_len, 0) < 0) { in libbpf_netlink_send_recv()
242 ret = libbpf_netlink_recv(sock, nl_pid, req->nh.nlmsg_seq, in libbpf_netlink_send_recv()
269 struct libbpf_nla_req req = { in libbpf_netlink_resolve_genl_family_id() local
278 err = nlattr_add(&req, CTRL_ATTR_FAMILY_NAME, name, len); in libbpf_netlink_resolve_genl_family_id()
282 return libbpf_netlink_send_recv(&req, NETLINK_GENERIC, in libbpf_netlink_resolve_genl_family_id()
291 struct libbpf_nla_req req; in __bpf_set_link_xdp_fd_replace() local
293 memset(&req, 0, sizeof(req)); in __bpf_set_link_xdp_fd_replace()
294 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); in __bpf_set_link_xdp_fd_replace()
295 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in __bpf_set_link_xdp_fd_replace()
296 req.nh.nlmsg_type = RTM_SETLINK; in __bpf_set_link_xdp_fd_replace()
297 req.ifinfo.ifi_family = AF_UNSPEC; in __bpf_set_link_xdp_fd_replace()
298 req.ifinfo.ifi_index = ifindex; in __bpf_set_link_xdp_fd_replace()
300 nla = nlattr_begin_nested(&req, IFLA_XDP); in __bpf_set_link_xdp_fd_replace()
303 ret = nlattr_add(&req, IFLA_XDP_FD, &fd, sizeof(fd)); in __bpf_set_link_xdp_fd_replace()
307 ret = nlattr_add(&req, IFLA_XDP_FLAGS, &flags, sizeof(flags)); in __bpf_set_link_xdp_fd_replace()
312 ret = nlattr_add(&req, IFLA_XDP_EXPECTED_FD, &old_fd, in __bpf_set_link_xdp_fd_replace()
317 nlattr_end_nested(&req, nla); in __bpf_set_link_xdp_fd_replace()
319 return libbpf_netlink_send_recv(&req, NETLINK_ROUTE, NULL, NULL, NULL); in __bpf_set_link_xdp_fd_replace()
433 struct libbpf_nla_req req = { in bpf_xdp_query() local
460 err = libbpf_netlink_send_recv(&req, NETLINK_ROUTE, __dump_link_nlmsg, in bpf_xdp_query()
483 memset(&req, 0, sizeof(req)); in bpf_xdp_query()
484 req.nh.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN); in bpf_xdp_query()
485 req.nh.nlmsg_flags = NLM_F_REQUEST; in bpf_xdp_query()
486 req.nh.nlmsg_type = id; in bpf_xdp_query()
487 req.gnl.cmd = NETDEV_CMD_DEV_GET; in bpf_xdp_query()
488 req.gnl.version = 2; in bpf_xdp_query()
490 err = nlattr_add(&req, NETDEV_A_DEV_IFINDEX, &ifindex, sizeof(ifindex)); in bpf_xdp_query()
494 err = libbpf_netlink_send_recv(&req, NETLINK_GENERIC, in bpf_xdp_query()
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
536 req->tc.tcm_parent = TC_H_CLSACT; in clsact_config()
537 req->tc.tcm_handle = TC_H_MAKE(TC_H_CLSACT, 0); in clsact_config()
539 return nlattr_add(req, TCA_KIND, "clsact", sizeof("clsact")); in clsact_config()
542 static int qdisc_config(struct libbpf_nla_req *req, const struct bpf_tc_hook *hook) in qdisc_config() argument
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()
549 return nlattr_add(req, TCA_KIND, qdisc, strlen(qdisc) + 1); in qdisc_config()
599 struct libbpf_nla_req req; in tc_qdisc_modify() local
605 memset(&req, 0, sizeof(req)); in tc_qdisc_modify()
606 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); in tc_qdisc_modify()
607 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; in tc_qdisc_modify()
608 req.nh.nlmsg_type = cmd; in tc_qdisc_modify()
609 req.tc.tcm_family = AF_UNSPEC; 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()
616 return libbpf_netlink_send_recv(&req, NETLINK_ROUTE, NULL, NULL, NULL); in tc_qdisc_modify()
709 static int tc_add_fd_and_name(struct libbpf_nla_req *req, int fd) in tc_add_fd_and_name() argument
721 ret = nlattr_add(req, TCA_BPF_FD, &fd, sizeof(fd)); in tc_add_fd_and_name()
729 return nlattr_add(req, TCA_BPF_NAME, name, len + 1); in tc_add_fd_and_name()
737 struct libbpf_nla_req req; in bpf_tc_attach() local
765 memset(&req, 0, sizeof(req)); in bpf_tc_attach()
766 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); in bpf_tc_attach()
767 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | in bpf_tc_attach()
769 req.nh.nlmsg_type = RTM_NEWTFILTER; in bpf_tc_attach()
770 req.tc.tcm_family = AF_UNSPEC; in bpf_tc_attach()
771 req.tc.tcm_ifindex = ifindex; in bpf_tc_attach()
772 req.tc.tcm_handle = handle; in bpf_tc_attach()
773 req.tc.tcm_info = TC_H_MAKE(priority << 16, htons(protocol)); in bpf_tc_attach()
778 req.tc.tcm_parent = parent; in bpf_tc_attach()
780 ret = nlattr_add(&req, TCA_KIND, "bpf", sizeof("bpf")); in bpf_tc_attach()
783 nla = nlattr_begin_nested(&req, TCA_OPTIONS); in bpf_tc_attach()
786 ret = tc_add_fd_and_name(&req, prog_fd); in bpf_tc_attach()
790 ret = nlattr_add(&req, TCA_BPF_FLAGS, &bpf_flags, sizeof(bpf_flags)); in bpf_tc_attach()
793 nlattr_end_nested(&req, nla); in bpf_tc_attach()
797 ret = libbpf_netlink_send_recv(&req, NETLINK_ROUTE, get_tc_info, NULL, in bpf_tc_attach()
812 struct libbpf_nla_req req; in __bpf_tc_detach() local
842 memset(&req, 0, sizeof(req)); in __bpf_tc_detach()
843 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); in __bpf_tc_detach()
844 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; in __bpf_tc_detach()
845 req.nh.nlmsg_type = RTM_DELTFILTER; in __bpf_tc_detach()
846 req.tc.tcm_family = AF_UNSPEC; in __bpf_tc_detach()
847 req.tc.tcm_ifindex = ifindex; in __bpf_tc_detach()
849 req.tc.tcm_handle = handle; in __bpf_tc_detach()
850 req.tc.tcm_info = TC_H_MAKE(priority << 16, htons(protocol)); in __bpf_tc_detach()
856 req.tc.tcm_parent = parent; in __bpf_tc_detach()
859 ret = nlattr_add(&req, TCA_KIND, "bpf", sizeof("bpf")); in __bpf_tc_detach()
864 return libbpf_netlink_send_recv(&req, NETLINK_ROUTE, NULL, NULL, NULL); in __bpf_tc_detach()
884 struct libbpf_nla_req req; in bpf_tc_query() local
909 memset(&req, 0, sizeof(req)); in bpf_tc_query()
910 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); in bpf_tc_query()
911 req.nh.nlmsg_flags = NLM_F_REQUEST; in bpf_tc_query()
912 req.nh.nlmsg_type = RTM_GETTFILTER; in bpf_tc_query()
913 req.tc.tcm_family = AF_UNSPEC; in bpf_tc_query()
914 req.tc.tcm_ifindex = ifindex; in bpf_tc_query()
915 req.tc.tcm_handle = handle; in bpf_tc_query()
916 req.tc.tcm_info = TC_H_MAKE(priority << 16, htons(protocol)); in bpf_tc_query()
921 req.tc.tcm_parent = parent; in bpf_tc_query()
923 ret = nlattr_add(&req, TCA_KIND, "bpf", sizeof("bpf")); in bpf_tc_query()
929 ret = libbpf_netlink_send_recv(&req, NETLINK_ROUTE, get_tc_info, NULL, in bpf_tc_query()