1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 // Copyright (C) 2018 Facebook
14 #include <bpf/libbpf.h>
16 #include <linux/rtnetlink.h>
17 #include <linux/socket.h>
18 #include <linux/tc_act/tc_bpf.h>
19 #include <sys/socket.h>
21 #include <sys/types.h>
23 #include "bpf/nlattr.h"
25 #include "netlink_dumper.h"
28 #define SOL_NETLINK 270
31 struct ip_devname_ifindex {
37 struct ip_devname_ifindex *devices;
43 struct tc_kind_handle {
49 struct tc_kind_handle *handle_array;
61 struct bpf_attach_info {
62 __u32 flow_dissector_id;
65 enum net_attach_type {
67 NET_ATTACH_TYPE_XDP_GENERIC,
68 NET_ATTACH_TYPE_XDP_DRIVER,
69 NET_ATTACH_TYPE_XDP_OFFLOAD,
72 static const char * const attach_type_strings[] = {
73 [NET_ATTACH_TYPE_XDP] = "xdp",
74 [NET_ATTACH_TYPE_XDP_GENERIC] = "xdpgeneric",
75 [NET_ATTACH_TYPE_XDP_DRIVER] = "xdpdrv",
76 [NET_ATTACH_TYPE_XDP_OFFLOAD] = "xdpoffload",
79 static const char * const attach_loc_strings[] = {
80 [BPF_TCX_INGRESS] = "tcx/ingress",
81 [BPF_TCX_EGRESS] = "tcx/egress",
82 [BPF_NETKIT_PRIMARY] = "netkit/primary",
83 [BPF_NETKIT_PEER] = "netkit/peer",
86 const size_t net_attach_type_size = ARRAY_SIZE(attach_type_strings);
88 static enum net_attach_type parse_attach_type(const char *str)
90 enum net_attach_type type;
92 for (type = 0; type < net_attach_type_size; type++) {
93 if (attach_type_strings[type] &&
94 is_prefix(str, attach_type_strings[type]))
98 return net_attach_type_size;
101 typedef int (*dump_nlmsg_t)(void *cookie, void *msg, struct nlattr **tb);
103 typedef int (*__dump_nlmsg_t)(struct nlmsghdr *nlmsg, dump_nlmsg_t, void *cookie);
105 static int netlink_open(__u32 *nl_pid)
107 struct sockaddr_nl sa;
112 memset(&sa, 0, sizeof(sa));
113 sa.nl_family = AF_NETLINK;
115 sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
119 if (setsockopt(sock, SOL_NETLINK, NETLINK_EXT_ACK,
120 &one, sizeof(one)) < 0) {
121 p_err("Netlink error reporting not supported");
124 if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
129 addrlen = sizeof(sa);
130 if (getsockname(sock, (struct sockaddr *)&sa, &addrlen) < 0) {
135 if (addrlen != sizeof(sa)) {
136 ret = -LIBBPF_ERRNO__INTERNAL;
148 static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,
149 __dump_nlmsg_t _fn, dump_nlmsg_t fn,
152 bool multipart = true;
153 struct nlmsgerr *err;
160 len = recv(sock, buf, sizeof(buf), 0);
169 for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, (unsigned int)len);
170 nh = NLMSG_NEXT(nh, len)) {
171 if (nh->nlmsg_pid != nl_pid) {
172 ret = -LIBBPF_ERRNO__WRNGPID;
175 if (nh->nlmsg_seq != seq) {
176 ret = -LIBBPF_ERRNO__INVSEQ;
179 if (nh->nlmsg_flags & NLM_F_MULTI)
181 switch (nh->nlmsg_type) {
183 err = (struct nlmsgerr *)NLMSG_DATA(nh);
187 libbpf_nla_dump_errormsg(nh);
195 ret = _fn(nh, fn, cookie);
206 static int __dump_class_nlmsg(struct nlmsghdr *nlh,
207 dump_nlmsg_t dump_class_nlmsg,
210 struct nlattr *tb[TCA_MAX + 1], *attr;
211 struct tcmsg *t = NLMSG_DATA(nlh);
214 len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*t));
215 attr = (struct nlattr *) ((void *) t + NLMSG_ALIGN(sizeof(*t)));
216 if (libbpf_nla_parse(tb, TCA_MAX, attr, len, NULL) != 0)
217 return -LIBBPF_ERRNO__NLPARSE;
219 return dump_class_nlmsg(cookie, t, tb);
222 static int netlink_get_class(int sock, unsigned int nl_pid, int ifindex,
223 dump_nlmsg_t dump_class_nlmsg, void *cookie)
229 .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)),
230 .nlh.nlmsg_type = RTM_GETTCLASS,
231 .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
232 .t.tcm_family = AF_UNSPEC,
233 .t.tcm_ifindex = ifindex,
235 int seq = time(NULL);
237 req.nlh.nlmsg_seq = seq;
238 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
241 return netlink_recv(sock, nl_pid, seq, __dump_class_nlmsg,
242 dump_class_nlmsg, cookie);
245 static int __dump_qdisc_nlmsg(struct nlmsghdr *nlh,
246 dump_nlmsg_t dump_qdisc_nlmsg,
249 struct nlattr *tb[TCA_MAX + 1], *attr;
250 struct tcmsg *t = NLMSG_DATA(nlh);
253 len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*t));
254 attr = (struct nlattr *) ((void *) t + NLMSG_ALIGN(sizeof(*t)));
255 if (libbpf_nla_parse(tb, TCA_MAX, attr, len, NULL) != 0)
256 return -LIBBPF_ERRNO__NLPARSE;
258 return dump_qdisc_nlmsg(cookie, t, tb);
261 static int netlink_get_qdisc(int sock, unsigned int nl_pid, int ifindex,
262 dump_nlmsg_t dump_qdisc_nlmsg, void *cookie)
268 .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)),
269 .nlh.nlmsg_type = RTM_GETQDISC,
270 .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
271 .t.tcm_family = AF_UNSPEC,
272 .t.tcm_ifindex = ifindex,
274 int seq = time(NULL);
276 req.nlh.nlmsg_seq = seq;
277 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
280 return netlink_recv(sock, nl_pid, seq, __dump_qdisc_nlmsg,
281 dump_qdisc_nlmsg, cookie);
284 static int __dump_filter_nlmsg(struct nlmsghdr *nlh,
285 dump_nlmsg_t dump_filter_nlmsg,
288 struct nlattr *tb[TCA_MAX + 1], *attr;
289 struct tcmsg *t = NLMSG_DATA(nlh);
292 len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*t));
293 attr = (struct nlattr *) ((void *) t + NLMSG_ALIGN(sizeof(*t)));
294 if (libbpf_nla_parse(tb, TCA_MAX, attr, len, NULL) != 0)
295 return -LIBBPF_ERRNO__NLPARSE;
297 return dump_filter_nlmsg(cookie, t, tb);
300 static int netlink_get_filter(int sock, unsigned int nl_pid, int ifindex, int handle,
301 dump_nlmsg_t dump_filter_nlmsg, void *cookie)
307 .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)),
308 .nlh.nlmsg_type = RTM_GETTFILTER,
309 .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
310 .t.tcm_family = AF_UNSPEC,
311 .t.tcm_ifindex = ifindex,
312 .t.tcm_parent = handle,
314 int seq = time(NULL);
316 req.nlh.nlmsg_seq = seq;
317 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
320 return netlink_recv(sock, nl_pid, seq, __dump_filter_nlmsg,
321 dump_filter_nlmsg, cookie);
324 static int __dump_link_nlmsg(struct nlmsghdr *nlh,
325 dump_nlmsg_t dump_link_nlmsg, void *cookie)
327 struct nlattr *tb[IFLA_MAX + 1], *attr;
328 struct ifinfomsg *ifi = NLMSG_DATA(nlh);
331 len = nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi));
332 attr = (struct nlattr *) ((void *) ifi + NLMSG_ALIGN(sizeof(*ifi)));
333 if (libbpf_nla_parse(tb, IFLA_MAX, attr, len, NULL) != 0)
334 return -LIBBPF_ERRNO__NLPARSE;
336 return dump_link_nlmsg(cookie, ifi, tb);
339 static int netlink_get_link(int sock, unsigned int nl_pid,
340 dump_nlmsg_t dump_link_nlmsg, void *cookie)
344 struct ifinfomsg ifm;
346 .nlh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
347 .nlh.nlmsg_type = RTM_GETLINK,
348 .nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST,
349 .ifm.ifi_family = AF_PACKET,
351 int seq = time(NULL);
353 req.nlh.nlmsg_seq = seq;
354 if (send(sock, &req, req.nlh.nlmsg_len, 0) < 0)
357 return netlink_recv(sock, nl_pid, seq, __dump_link_nlmsg,
358 dump_link_nlmsg, cookie);
361 static int dump_link_nlmsg(void *cookie, void *msg, struct nlattr **tb)
363 struct bpf_netdev_t *netinfo = cookie;
364 struct ifinfomsg *ifinfo = msg;
366 if (netinfo->filter_idx > 0 && netinfo->filter_idx != ifinfo->ifi_index)
369 if (netinfo->used_len == netinfo->array_len) {
370 netinfo->devices = realloc(netinfo->devices,
371 (netinfo->array_len + 16) *
372 sizeof(struct ip_devname_ifindex));
373 if (!netinfo->devices)
376 netinfo->array_len += 16;
378 netinfo->devices[netinfo->used_len].ifindex = ifinfo->ifi_index;
379 snprintf(netinfo->devices[netinfo->used_len].devname,
380 sizeof(netinfo->devices[netinfo->used_len].devname),
383 ? libbpf_nla_getattr_str(tb[IFLA_IFNAME])
387 return do_xdp_dump(ifinfo, tb);
390 static int dump_class_qdisc_nlmsg(void *cookie, void *msg, struct nlattr **tb)
392 struct bpf_tcinfo_t *tcinfo = cookie;
393 struct tcmsg *info = msg;
395 if (tcinfo->is_qdisc) {
396 /* skip clsact qdisc */
398 strcmp(libbpf_nla_data(tb[TCA_KIND]), "clsact") == 0)
400 if (info->tcm_handle == 0)
404 if (tcinfo->used_len == tcinfo->array_len) {
405 tcinfo->handle_array = realloc(tcinfo->handle_array,
406 (tcinfo->array_len + 16) * sizeof(struct tc_kind_handle));
407 if (!tcinfo->handle_array)
410 tcinfo->array_len += 16;
412 tcinfo->handle_array[tcinfo->used_len].handle = info->tcm_handle;
413 snprintf(tcinfo->handle_array[tcinfo->used_len].kind,
414 sizeof(tcinfo->handle_array[tcinfo->used_len].kind),
417 ? libbpf_nla_getattr_str(tb[TCA_KIND])
424 static int dump_filter_nlmsg(void *cookie, void *msg, struct nlattr **tb)
426 const struct bpf_filter_t *filter_info = cookie;
428 return do_filter_dump((struct tcmsg *)msg, tb, filter_info->kind,
429 filter_info->devname, filter_info->ifindex);
432 static int __show_dev_tc_bpf_name(__u32 id, char *name, size_t len)
434 struct bpf_prog_info info = {};
435 __u32 ilen = sizeof(info);
438 fd = bpf_prog_get_fd_by_id(id);
441 ret = bpf_obj_get_info_by_fd(fd, &info, &ilen);
446 get_prog_full_name(&info, fd, name, len);
454 static void __show_dev_tc_bpf(const struct ip_devname_ifindex *dev,
455 const enum bpf_attach_type loc)
457 __u32 prog_flags[64] = {}, link_flags[64] = {}, i, j;
458 __u32 prog_ids[64] = {}, link_ids[64] = {};
459 LIBBPF_OPTS(bpf_prog_query_opts, optq);
460 char prog_name[MAX_PROG_FULL_NAME];
463 optq.prog_ids = prog_ids;
464 optq.prog_attach_flags = prog_flags;
465 optq.link_ids = link_ids;
466 optq.link_attach_flags = link_flags;
467 optq.count = ARRAY_SIZE(prog_ids);
469 ret = bpf_prog_query_opts(dev->ifindex, loc, &optq);
472 for (i = 0; i < optq.count; i++) {
474 NET_DUMP_STR("devname", "%s", dev->devname);
475 NET_DUMP_UINT("ifindex", "(%u)", dev->ifindex);
476 NET_DUMP_STR("kind", " %s", attach_loc_strings[loc]);
477 ret = __show_dev_tc_bpf_name(prog_ids[i], prog_name,
480 NET_DUMP_STR("name", " %s", prog_name);
481 NET_DUMP_UINT("prog_id", " prog_id %u ", prog_ids[i]);
482 if (prog_flags[i] || json_output) {
483 NET_START_ARRAY("prog_flags", "%s ");
484 for (j = 0; prog_flags[i] && j < 32; j++) {
485 if (!(prog_flags[i] & (1 << j)))
487 NET_DUMP_UINT_ONLY(1 << j);
491 if (link_ids[i] || json_output) {
492 NET_DUMP_UINT("link_id", "link_id %u ", link_ids[i]);
493 if (link_flags[i] || json_output) {
494 NET_START_ARRAY("link_flags", "%s ");
495 for (j = 0; link_flags[i] && j < 32; j++) {
496 if (!(link_flags[i] & (1 << j)))
498 NET_DUMP_UINT_ONLY(1 << j);
503 NET_END_OBJECT_FINAL;
507 static void show_dev_tc_bpf(struct ip_devname_ifindex *dev)
509 __show_dev_tc_bpf(dev, BPF_TCX_INGRESS);
510 __show_dev_tc_bpf(dev, BPF_TCX_EGRESS);
512 __show_dev_tc_bpf(dev, BPF_NETKIT_PRIMARY);
513 __show_dev_tc_bpf(dev, BPF_NETKIT_PEER);
516 static int show_dev_tc_bpf_classic(int sock, unsigned int nl_pid,
517 struct ip_devname_ifindex *dev)
519 struct bpf_filter_t filter_info;
520 struct bpf_tcinfo_t tcinfo;
521 int i, handle, ret = 0;
523 tcinfo.handle_array = NULL;
525 tcinfo.array_len = 0;
527 tcinfo.is_qdisc = false;
528 ret = netlink_get_class(sock, nl_pid, dev->ifindex,
529 dump_class_qdisc_nlmsg, &tcinfo);
533 tcinfo.is_qdisc = true;
534 ret = netlink_get_qdisc(sock, nl_pid, dev->ifindex,
535 dump_class_qdisc_nlmsg, &tcinfo);
539 filter_info.devname = dev->devname;
540 filter_info.ifindex = dev->ifindex;
541 for (i = 0; i < tcinfo.used_len; i++) {
542 filter_info.kind = tcinfo.handle_array[i].kind;
543 ret = netlink_get_filter(sock, nl_pid, dev->ifindex,
544 tcinfo.handle_array[i].handle,
545 dump_filter_nlmsg, &filter_info);
550 /* root, ingress and egress handle */
552 filter_info.kind = "root";
553 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
554 dump_filter_nlmsg, &filter_info);
558 handle = TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_INGRESS);
559 filter_info.kind = "clsact/ingress";
560 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
561 dump_filter_nlmsg, &filter_info);
565 handle = TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_EGRESS);
566 filter_info.kind = "clsact/egress";
567 ret = netlink_get_filter(sock, nl_pid, dev->ifindex, handle,
568 dump_filter_nlmsg, &filter_info);
573 free(tcinfo.handle_array);
577 static int query_flow_dissector(struct bpf_attach_info *attach_info)
585 fd = open("/proc/self/ns/net", O_RDONLY);
587 p_err("can't open /proc/self/ns/net: %s",
591 prog_cnt = ARRAY_SIZE(prog_ids);
592 err = bpf_prog_query(fd, BPF_FLOW_DISSECTOR, 0,
593 &attach_flags, prog_ids, &prog_cnt);
596 if (errno == EINVAL) {
597 /* Older kernel's don't support querying
598 * flow dissector programs.
603 p_err("can't query prog: %s", strerror(errno));
608 attach_info->flow_dissector_id = prog_ids[0];
613 static int net_parse_dev(int *argc, char ***argv)
617 if (is_prefix(**argv, "dev")) {
620 ifindex = if_nametoindex(**argv);
622 p_err("invalid devname %s", **argv);
626 p_err("expected 'dev', got: '%s'?", **argv);
633 static int do_attach_detach_xdp(int progfd, enum net_attach_type attach_type,
634 int ifindex, bool overwrite)
639 flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
640 if (attach_type == NET_ATTACH_TYPE_XDP_GENERIC)
641 flags |= XDP_FLAGS_SKB_MODE;
642 if (attach_type == NET_ATTACH_TYPE_XDP_DRIVER)
643 flags |= XDP_FLAGS_DRV_MODE;
644 if (attach_type == NET_ATTACH_TYPE_XDP_OFFLOAD)
645 flags |= XDP_FLAGS_HW_MODE;
647 return bpf_xdp_attach(ifindex, progfd, flags, NULL);
650 static int do_attach(int argc, char **argv)
652 enum net_attach_type attach_type;
653 int progfd, ifindex, err = 0;
654 bool overwrite = false;
656 /* parse attach args */
660 attach_type = parse_attach_type(*argv);
661 if (attach_type == net_attach_type_size) {
662 p_err("invalid net attach/detach type: %s", *argv);
667 progfd = prog_parse_fd(&argc, &argv);
671 ifindex = net_parse_dev(&argc, &argv);
678 if (is_prefix(*argv, "overwrite")) {
681 p_err("expected 'overwrite', got: '%s'?", *argv);
687 /* attach xdp prog */
688 if (is_prefix("xdp", attach_type_strings[attach_type]))
689 err = do_attach_detach_xdp(progfd, attach_type, ifindex,
692 p_err("interface %s attach failed: %s",
693 attach_type_strings[attach_type], strerror(-err));
698 jsonw_null(json_wtr);
704 static int do_detach(int argc, char **argv)
706 enum net_attach_type attach_type;
707 int progfd, ifindex, err = 0;
709 /* parse detach args */
713 attach_type = parse_attach_type(*argv);
714 if (attach_type == net_attach_type_size) {
715 p_err("invalid net attach/detach type: %s", *argv);
720 ifindex = net_parse_dev(&argc, &argv);
724 /* detach xdp prog */
726 if (is_prefix("xdp", attach_type_strings[attach_type]))
727 err = do_attach_detach_xdp(progfd, attach_type, ifindex, NULL);
730 p_err("interface %s detach failed: %s",
731 attach_type_strings[attach_type], strerror(-err));
736 jsonw_null(json_wtr);
741 static int netfilter_link_compar(const void *a, const void *b)
743 const struct bpf_link_info *nfa = a;
744 const struct bpf_link_info *nfb = b;
747 delta = nfa->netfilter.pf - nfb->netfilter.pf;
751 delta = nfa->netfilter.hooknum - nfb->netfilter.hooknum;
755 if (nfa->netfilter.priority < nfb->netfilter.priority)
757 if (nfa->netfilter.priority > nfb->netfilter.priority)
760 return nfa->netfilter.flags - nfb->netfilter.flags;
763 static void show_link_netfilter(void)
765 unsigned int nf_link_len = 0, nf_link_count = 0;
766 struct bpf_link_info *nf_link_info = NULL;
770 struct bpf_link_info info;
774 err = bpf_link_get_next_id(id, &id);
778 p_err("can't get next link: %s (id %d)", strerror(errno), id);
782 fd = bpf_link_get_fd_by_id(id);
784 p_err("can't get link by id (%u): %s", id, strerror(errno));
788 memset(&info, 0, sizeof(info));
791 err = bpf_link_get_info_by_fd(fd, &info, &len);
796 p_err("can't get link info for fd %d: %s", fd, strerror(errno));
800 if (info.type != BPF_LINK_TYPE_NETFILTER)
803 if (nf_link_count >= nf_link_len) {
804 static const unsigned int max_link_count = INT_MAX / sizeof(info);
805 struct bpf_link_info *expand;
807 if (nf_link_count > max_link_count) {
808 p_err("cannot handle more than %u links\n", max_link_count);
814 expand = realloc(nf_link_info, nf_link_len * sizeof(info));
816 p_err("realloc: %s", strerror(errno));
820 nf_link_info = expand;
823 nf_link_info[nf_link_count] = info;
827 qsort(nf_link_info, nf_link_count, sizeof(*nf_link_info), netfilter_link_compar);
829 for (id = 0; id < nf_link_count; id++) {
832 netfilter_dump_json(&nf_link_info[id], json_wtr);
834 netfilter_dump_plain(&nf_link_info[id]);
836 NET_DUMP_UINT("id", " prog_id %u", nf_link_info[id].prog_id);
843 static int do_show(int argc, char **argv)
845 struct bpf_attach_info attach_info = {};
846 int i, sock, ret, filter_idx = -1;
847 struct bpf_netdev_t dev_array;
848 unsigned int nl_pid = 0;
852 filter_idx = net_parse_dev(&argc, &argv);
855 } else if (argc != 0) {
859 ret = query_flow_dissector(&attach_info);
863 sock = netlink_open(&nl_pid);
865 fprintf(stderr, "failed to open netlink sock\n");
869 dev_array.devices = NULL;
870 dev_array.used_len = 0;
871 dev_array.array_len = 0;
872 dev_array.filter_idx = filter_idx;
875 jsonw_start_array(json_wtr);
877 NET_START_ARRAY("xdp", "%s:\n");
878 ret = netlink_get_link(sock, nl_pid, dump_link_nlmsg, &dev_array);
882 NET_START_ARRAY("tc", "%s:\n");
883 for (i = 0; i < dev_array.used_len; i++) {
884 show_dev_tc_bpf(&dev_array.devices[i]);
885 ret = show_dev_tc_bpf_classic(sock, nl_pid,
886 &dev_array.devices[i]);
893 NET_START_ARRAY("flow_dissector", "%s:\n");
894 if (attach_info.flow_dissector_id > 0)
895 NET_DUMP_UINT("id", "id %u", attach_info.flow_dissector_id);
898 NET_START_ARRAY("netfilter", "%s:\n");
899 show_link_netfilter();
904 jsonw_end_array(json_wtr);
908 jsonw_null(json_wtr);
909 libbpf_strerror(ret, err_buf, sizeof(err_buf));
910 fprintf(stderr, "Error: %s\n", err_buf);
912 free(dev_array.devices);
917 static int do_help(int argc, char **argv)
920 jsonw_null(json_wtr);
925 "Usage: %1$s %2$s { show | list } [dev <devname>]\n"
926 " %1$s %2$s attach ATTACH_TYPE PROG dev <devname> [ overwrite ]\n"
927 " %1$s %2$s detach ATTACH_TYPE dev <devname>\n"
930 " " HELP_SPEC_PROGRAM "\n"
931 " ATTACH_TYPE := { xdp | xdpgeneric | xdpdrv | xdpoffload }\n"
932 " " HELP_SPEC_OPTIONS " }\n"
934 "Note: Only xdp, tcx, tc, netkit, flow_dissector and netfilter attachments\n"
935 " are currently supported.\n"
936 " For progs attached to cgroups, use \"bpftool cgroup\"\n"
937 " to dump program attachments. For program types\n"
938 " sk_{filter,skb,msg,reuseport} and lwt/seg6, please\n"
939 " consult iproute2.\n"
946 static const struct cmd cmds[] = {
949 { "attach", do_attach },
950 { "detach", do_detach },
955 int do_net(int argc, char **argv)
957 return cmd_select(cmds, argc, argv, do_help);