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 }] | { -d | --debug  }
13          }
14
15          COMMANDS := { show | list | attach | detach | help }
16

NET COMMANDS

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

DESCRIPTION

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

OPTIONS

76          -h, --help
77                 Print short help message (similar to bpftool help).
78
79          -V, --version
80                 Print version number (similar to bpftool  version),  and  op‐
81                 tional features that were included when bpftool was compiled.
82                 Optional features include linking against libbfd  to  provide
83                 the  disassembler  for  JIT-ted  programs  (bpftool prog dump
84                 jited) and usage of BPF skeletons (some features like bpftool
85                 prog  profile  or  showing pids associated to BPF objects may
86                 rely on it).
87
88          -j, --json
89                 Generate JSON output. For commands that cannot produce  JSON,
90                 this option has no effect.
91
92          -p, --pretty
93                 Generate human-readable JSON output. Implies -j.
94
95          -d, --debug
96                 Print  all logs available, even debug-level information. This
97                 includes logs from libbpf as well as from the verifier,  when
98                 attempting to load programs.
99

EXAMPLES

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

SEE ALSO

186          bpf(2),       bpf-helpers(7),       bpftool(8),      bpftool-btf(8),
187          bpftool-cgroup(8),        bpftool-feature(8),        bpftool-gen(8),
188          bpftool-iter(8),  bpftool-link(8),  bpftool-map(8), bpftool-perf(8),
189          bpftool-prog(8), bpftool-struct_ops(8)
190
191
192
193
194                                                                BPFTOOL-NET(8)
Impressum