1BPFTOOL-NET(8)                                                  BPFTOOL-NET(8)
2
3
4

NAME

6       bpftool-net - tool for inspection of netdev/tc related bpf prog attach‐
7       ments
8

SYNOPSIS

10          bpftool [OPTIONS] net COMMAND
11
12          OPTIONS := { [{ -j | --json }] [{ -p | --pretty }] }
13
14          COMMANDS := { show | list | attach | detach | help }
15

NET COMMANDS

17       bpftool net { show | list } [ dev NAME ]
18       bpftool net attach ATTACH_TYPE PROG dev NAME [ overwrite ]
19       bpftool net detach ATTACH_TYPE dev NAME
20       bpftool net help
21
22       PROG := { id PROG_ID | pinned FILE | tag PROG_TAG }
23       ATTACH_TYPE := { xdp | xdpgeneric | xdpdrv | xdpoffload }
24
25

DESCRIPTION

27          bpftool net { show | list } [ dev NAME ]
28                 List bpf program attachments in the kernel networking subsys‐
29                 tem.
30
31                 Currently,  only  device driver xdp attachments and tc filter
32                 classification/action attachments are implemented, i.e.,  for
33                 program             types            BPF_PROG_TYPE_SCHED_CLS,
34                 BPF_PROG_TYPE_SCHED_ACT and BPF_PROG_TYPE_XDP.  For  programs
35                 attached      to      a      particular     cgroup,     e.g.,
36                 BPF_PROG_TYPE_CGROUP_SKB,          BPF_PROG_TYPE_CGROUP_SOCK,
37                 BPF_PROG_TYPE_SOCK_OPS   and  BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
38                 users can use bpftool cgroup to dump cgroup attachments.  For
39                 sk_{filter,  skb,  msg, reuseport} and lwt/seg6 bpf programs,
40                 users should consult other tools, e.g., iproute2.
41
42                 The current output will start with all  xdp  program  attach‐
43                 ments,  followed  by  all  tc class/qdisc bpf program attach‐
44                 ments. Both xdp programs and tc programs are ordered based on
45                 ifindex number. If multiple bpf programs attached to the same
46                 networking device through tc filter, the order will be  first
47                 all  bpf  programs  attached to tc classes, then all bpf pro‐
48                 grams attached to non clsact qdiscs, and finally all bpf pro‐
49                 grams attached to root and clsact qdisc.
50
51          bpftool net attach ATTACH_TYPE PROG dev NAME [ overwrite ]
52                 Attach  bpf  program PROG to network interface NAME with type
53                 specified by ATTACH_TYPE. Previously attached bpf program can
54                 be  replaced by the command used with overwrite option.  Cur‐
55                 rently, only XDP-related modes are supported for ATTACH_TYPE.
56
57                 ATTACH_TYPE can be of: xdp - try native XDP and  fallback  to
58                 generic  XDP  if NIC driver does not support it; xdpgeneric -
59                 Generic XDP. runs at generic XDP  hook  when  packet  already
60                 enters  receive path as skb; xdpdrv - Native XDP. runs earli‐
61                 est point in driver's receive path; xdpoffload - Offload XDP.
62                 runs directly on NIC on each packet reception;
63
64          bpftool net detach ATTACH_TYPE dev NAME
65                 Detach  bpf  program  attached to network interface NAME with
66                 type specified by ATTACH_TYPE. To detach  bpf  program,  same
67                 ATTACH_TYPE  previously  used  for  attach must be specified.
68                 Currently,  only  XDP-related   modes   are   supported   for
69                 ATTACH_TYPE.
70
71          bpftool net help
72                 Print short help message.
73

OPTIONS

75          -h, --help
76                 Print short generic help message (similar to bpftool help).
77
78          -V, --version
79                 Print version number (similar to bpftool version).
80
81          -j, --json
82                 Generate  JSON output. For commands that cannot produce JSON,
83                 this option has no effect.
84
85          -p, --pretty
86                 Generate human-readable JSON output. Implies -j.
87
88          -d, --debug
89                 Print all logs available from libbpf,  including  debug-level
90                 information.
91

EXAMPLES

93       # bpftool net
94
95
96          xdp:
97          eth0(2) driver id 198
98
99          tc:
100          eth0(2) htb name prefix_matcher.o:[cls_prefix_matcher_htb] id 111727 act []
101          eth0(2) clsact/ingress fbflow_icmp id 130246 act []
102          eth0(2) clsact/egress prefix_matcher.o:[cls_prefix_matcher_clsact] id 111726
103          eth0(2) clsact/egress cls_fg_dscp id 108619 act []
104          eth0(2) clsact/egress fbflow_egress id 130245
105
106       # bpftool -jp net
107
108
109          [{
110                  "xdp": [{
111                          "devname": "eth0",
112                          "ifindex": 2,
113                          "mode": "driver",
114                          "id": 198
115                      }
116                  ],
117                  "tc": [{
118                          "devname": "eth0",
119                          "ifindex": 2,
120                          "kind": "htb",
121                          "name": "prefix_matcher.o:[cls_prefix_matcher_htb]",
122                          "id": 111727,
123                          "act": []
124                      },{
125                          "devname": "eth0",
126                          "ifindex": 2,
127                          "kind": "clsact/ingress",
128                          "name": "fbflow_icmp",
129                          "id": 130246,
130                          "act": []
131                      },{
132                          "devname": "eth0",
133                          "ifindex": 2,
134                          "kind": "clsact/egress",
135                          "name": "prefix_matcher.o:[cls_prefix_matcher_clsact]",
136                          "id": 111726,
137                      },{
138                          "devname": "eth0",
139                          "ifindex": 2,
140                          "kind": "clsact/egress",
141                          "name": "cls_fg_dscp",
142                          "id": 108619,
143                          "act": []
144                      },{
145                          "devname": "eth0",
146                          "ifindex": 2,
147                          "kind": "clsact/egress",
148                          "name": "fbflow_egress",
149                          "id": 130245,
150                      }
151                  ]
152              }
153          ]
154
155       # bpftool net attach xdpdrv id 16 dev enp6s0np0
156       # bpftool net
157
158
159          xdp:
160          enp6s0np0(4) driver id 16
161
162       # bpftool net attach xdpdrv id 16 dev enp6s0np0
163       # bpftool net attach xdpdrv id 20 dev enp6s0np0 overwrite
164       # bpftool net
165
166
167          xdp:
168          enp6s0np0(4) driver id 20
169
170       # bpftool net attach xdpdrv id 16 dev enp6s0np0
171       # bpftool net detach xdpdrv dev enp6s0np0
172       # bpftool net
173
174
175          xdp:
176

SEE ALSO

178          bpf(2), bpf-helpers(7), bpftool(8), bpftool-prog(8), bpftool-map(8),
179          bpftool-cgroup(8),       bpftool-feature(8),        bpftool-perf(8),
180          bpftool-btf(8)
181
182
183
184
185                                                                BPFTOOL-NET(8)
Impressum