Loading...
1================
2bpftool-net
3================
4-------------------------------------------------------------------------------
5tool for inspection of netdev/tc related bpf prog attachments
6-------------------------------------------------------------------------------
7
8:Manual section: 8
9
10SYNOPSIS
11========
12
13 **bpftool** [*OPTIONS*] **net** *COMMAND*
14
15 *OPTIONS* := { [{ **-j** | **--json** }] [{ **-p** | **--pretty** }] }
16
17 *COMMANDS* :=
18 { **show** | **list** | **attach** | **detach** | **help** }
19
20NET COMMANDS
21============
22
23| **bpftool** **net** { **show** | **list** } [ **dev** *NAME* ]
24| **bpftool** **net attach** *ATTACH_TYPE* *PROG* **dev** *NAME* [ **overwrite** ]
25| **bpftool** **net detach** *ATTACH_TYPE* **dev** *NAME*
26| **bpftool** **net help**
27|
28| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
29| *ATTACH_TYPE* := { **xdp** | **xdpgeneric** | **xdpdrv** | **xdpoffload** }
30
31DESCRIPTION
32===========
33 **bpftool net { show | list }** [ **dev** *NAME* ]
34 List bpf program attachments in the kernel networking subsystem.
35
36 Currently, only device driver xdp attachments and tc filter
37 classification/action attachments are implemented, i.e., for
38 program types **BPF_PROG_TYPE_SCHED_CLS**,
39 **BPF_PROG_TYPE_SCHED_ACT** and **BPF_PROG_TYPE_XDP**.
40 For programs attached to a particular cgroup, e.g.,
41 **BPF_PROG_TYPE_CGROUP_SKB**, **BPF_PROG_TYPE_CGROUP_SOCK**,
42 **BPF_PROG_TYPE_SOCK_OPS** and **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**,
43 users can use **bpftool cgroup** to dump cgroup attachments.
44 For sk_{filter, skb, msg, reuseport} and lwt/seg6
45 bpf programs, users should consult other tools, e.g., iproute2.
46
47 The current output will start with all xdp program attachments, followed by
48 all tc class/qdisc bpf program attachments. Both xdp programs and
49 tc programs are ordered based on ifindex number. If multiple bpf
50 programs attached to the same networking device through **tc filter**,
51 the order will be first all bpf programs attached to tc classes, then
52 all bpf programs attached to non clsact qdiscs, and finally all
53 bpf programs attached to root and clsact qdisc.
54
55 **bpftool** **net attach** *ATTACH_TYPE* *PROG* **dev** *NAME* [ **overwrite** ]
56 Attach bpf program *PROG* to network interface *NAME* with
57 type specified by *ATTACH_TYPE*. Previously attached bpf program
58 can be replaced by the command used with **overwrite** option.
59 Currently, only XDP-related modes are supported for *ATTACH_TYPE*.
60
61 *ATTACH_TYPE* can be of:
62 **xdp** - try native XDP and fallback to generic XDP if NIC driver does not support it;
63 **xdpgeneric** - Generic XDP. runs at generic XDP hook when packet already enters receive path as skb;
64 **xdpdrv** - Native XDP. runs earliest point in driver's receive path;
65 **xdpoffload** - Offload XDP. runs directly on NIC on each packet reception;
66
67 **bpftool** **net detach** *ATTACH_TYPE* **dev** *NAME*
68 Detach bpf program attached to network interface *NAME* with
69 type specified by *ATTACH_TYPE*. To detach bpf program, same
70 *ATTACH_TYPE* previously used for attach must be specified.
71 Currently, only XDP-related modes are supported for *ATTACH_TYPE*.
72
73 **bpftool net help**
74 Print short help message.
75
76OPTIONS
77=======
78 .. include:: common_options.rst
79
80EXAMPLES
81========
82
83| **# bpftool net**
84
85::
86
87 xdp:
88 eth0(2) driver id 198
89
90 tc:
91 eth0(2) htb name prefix_matcher.o:[cls_prefix_matcher_htb] id 111727 act []
92 eth0(2) clsact/ingress fbflow_icmp id 130246 act []
93 eth0(2) clsact/egress prefix_matcher.o:[cls_prefix_matcher_clsact] id 111726
94 eth0(2) clsact/egress cls_fg_dscp id 108619 act []
95 eth0(2) clsact/egress fbflow_egress id 130245
96
97|
98| **# bpftool -jp net**
99
100::
101
102 [{
103 "xdp": [{
104 "devname": "eth0",
105 "ifindex": 2,
106 "mode": "driver",
107 "id": 198
108 }
109 ],
110 "tc": [{
111 "devname": "eth0",
112 "ifindex": 2,
113 "kind": "htb",
114 "name": "prefix_matcher.o:[cls_prefix_matcher_htb]",
115 "id": 111727,
116 "act": []
117 },{
118 "devname": "eth0",
119 "ifindex": 2,
120 "kind": "clsact/ingress",
121 "name": "fbflow_icmp",
122 "id": 130246,
123 "act": []
124 },{
125 "devname": "eth0",
126 "ifindex": 2,
127 "kind": "clsact/egress",
128 "name": "prefix_matcher.o:[cls_prefix_matcher_clsact]",
129 "id": 111726,
130 },{
131 "devname": "eth0",
132 "ifindex": 2,
133 "kind": "clsact/egress",
134 "name": "cls_fg_dscp",
135 "id": 108619,
136 "act": []
137 },{
138 "devname": "eth0",
139 "ifindex": 2,
140 "kind": "clsact/egress",
141 "name": "fbflow_egress",
142 "id": 130245,
143 }
144 ]
145 }
146 ]
147
148|
149| **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
150| **# bpftool net**
151
152::
153
154 xdp:
155 enp6s0np0(4) driver id 16
156
157|
158| **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
159| **# bpftool net attach xdpdrv id 20 dev enp6s0np0 overwrite**
160| **# bpftool net**
161
162::
163
164 xdp:
165 enp6s0np0(4) driver id 20
166
167|
168| **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
169| **# bpftool net detach xdpdrv dev enp6s0np0**
170| **# bpftool net**
171
172::
173
174 xdp:
1.. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2
3================
4bpftool-net
5================
6-------------------------------------------------------------------------------
7tool for inspection of networking related bpf prog attachments
8-------------------------------------------------------------------------------
9
10:Manual section: 8
11
12.. include:: substitutions.rst
13
14SYNOPSIS
15========
16
17 **bpftool** [*OPTIONS*] **net** *COMMAND*
18
19 *OPTIONS* := { |COMMON_OPTIONS| }
20
21 *COMMANDS* :=
22 { **show** | **list** | **attach** | **detach** | **help** }
23
24NET COMMANDS
25============
26
27| **bpftool** **net** { **show** | **list** } [ **dev** *NAME* ]
28| **bpftool** **net attach** *ATTACH_TYPE* *PROG* **dev** *NAME* [ **overwrite** ]
29| **bpftool** **net detach** *ATTACH_TYPE* **dev** *NAME*
30| **bpftool** **net help**
31|
32| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
33| *ATTACH_TYPE* := { **xdp** | **xdpgeneric** | **xdpdrv** | **xdpoffload** }
34
35DESCRIPTION
36===========
37 **bpftool net { show | list }** [ **dev** *NAME* ]
38 List bpf program attachments in the kernel networking subsystem.
39
40 Currently, device driver xdp attachments, tcx, netkit and old-style tc
41 classifier/action attachments, flow_dissector as well as netfilter
42 attachments are implemented, i.e., for
43 program types **BPF_PROG_TYPE_XDP**, **BPF_PROG_TYPE_SCHED_CLS**,
44 **BPF_PROG_TYPE_SCHED_ACT**, **BPF_PROG_TYPE_FLOW_DISSECTOR**,
45 **BPF_PROG_TYPE_NETFILTER**.
46
47 For programs attached to a particular cgroup, e.g.,
48 **BPF_PROG_TYPE_CGROUP_SKB**, **BPF_PROG_TYPE_CGROUP_SOCK**,
49 **BPF_PROG_TYPE_SOCK_OPS** and **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**,
50 users can use **bpftool cgroup** to dump cgroup attachments.
51 For sk_{filter, skb, msg, reuseport} and lwt/seg6
52 bpf programs, users should consult other tools, e.g., iproute2.
53
54 The current output will start with all xdp program attachments, followed by
55 all tcx, netkit, then tc class/qdisc bpf program attachments, then flow_dissector
56 and finally netfilter programs. Both xdp programs and tcx/netkit/tc programs are
57 ordered based on ifindex number. If multiple bpf programs attached
58 to the same networking device through **tc**, the order will be first
59 all bpf programs attached to tcx, netkit, then tc classes, then all bpf programs
60 attached to non clsact qdiscs, and finally all bpf programs attached
61 to root and clsact qdisc.
62
63 **bpftool** **net attach** *ATTACH_TYPE* *PROG* **dev** *NAME* [ **overwrite** ]
64 Attach bpf program *PROG* to network interface *NAME* with
65 type specified by *ATTACH_TYPE*. Previously attached bpf program
66 can be replaced by the command used with **overwrite** option.
67 Currently, only XDP-related modes are supported for *ATTACH_TYPE*.
68
69 *ATTACH_TYPE* can be of:
70 **xdp** - try native XDP and fallback to generic XDP if NIC driver does not support it;
71 **xdpgeneric** - Generic XDP. runs at generic XDP hook when packet already enters receive path as skb;
72 **xdpdrv** - Native XDP. runs earliest point in driver's receive path;
73 **xdpoffload** - Offload XDP. runs directly on NIC on each packet reception;
74
75 **bpftool** **net detach** *ATTACH_TYPE* **dev** *NAME*
76 Detach bpf program attached to network interface *NAME* with
77 type specified by *ATTACH_TYPE*. To detach bpf program, same
78 *ATTACH_TYPE* previously used for attach must be specified.
79 Currently, only XDP-related modes are supported for *ATTACH_TYPE*.
80
81 **bpftool net help**
82 Print short help message.
83
84OPTIONS
85=======
86 .. include:: common_options.rst
87
88EXAMPLES
89========
90
91| **# bpftool net**
92
93::
94
95 xdp:
96 eth0(2) driver id 198
97
98 tc:
99 eth0(2) htb name prefix_matcher.o:[cls_prefix_matcher_htb] id 111727 act []
100 eth0(2) clsact/ingress fbflow_icmp id 130246 act []
101 eth0(2) clsact/egress prefix_matcher.o:[cls_prefix_matcher_clsact] id 111726
102 eth0(2) clsact/egress cls_fg_dscp id 108619 act []
103 eth0(2) clsact/egress fbflow_egress id 130245
104
105|
106| **# bpftool -jp net**
107
108::
109
110 [{
111 "xdp": [{
112 "devname": "eth0",
113 "ifindex": 2,
114 "mode": "driver",
115 "id": 198
116 }
117 ],
118 "tc": [{
119 "devname": "eth0",
120 "ifindex": 2,
121 "kind": "htb",
122 "name": "prefix_matcher.o:[cls_prefix_matcher_htb]",
123 "id": 111727,
124 "act": []
125 },{
126 "devname": "eth0",
127 "ifindex": 2,
128 "kind": "clsact/ingress",
129 "name": "fbflow_icmp",
130 "id": 130246,
131 "act": []
132 },{
133 "devname": "eth0",
134 "ifindex": 2,
135 "kind": "clsact/egress",
136 "name": "prefix_matcher.o:[cls_prefix_matcher_clsact]",
137 "id": 111726,
138 },{
139 "devname": "eth0",
140 "ifindex": 2,
141 "kind": "clsact/egress",
142 "name": "cls_fg_dscp",
143 "id": 108619,
144 "act": []
145 },{
146 "devname": "eth0",
147 "ifindex": 2,
148 "kind": "clsact/egress",
149 "name": "fbflow_egress",
150 "id": 130245,
151 }
152 ]
153 }
154 ]
155
156|
157| **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
158| **# bpftool net**
159
160::
161
162 xdp:
163 enp6s0np0(4) driver id 16
164
165|
166| **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
167| **# bpftool net attach xdpdrv id 20 dev enp6s0np0 overwrite**
168| **# bpftool net**
169
170::
171
172 xdp:
173 enp6s0np0(4) driver id 20
174
175|
176| **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
177| **# bpftool net detach xdpdrv dev enp6s0np0**
178| **# bpftool net**
179
180::
181
182 xdp: