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

EXAMPLES

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

SEE ALSO

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