treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / bpf / bpftool / Documentation / bpftool-net.rst
blob8651b00b81ea05ff6d9c7275167be87fce83d27c
1 ================
2 bpftool-net
3 ================
4 -------------------------------------------------------------------------------
5 tool for inspection of netdev/tc related bpf prog attachments
6 -------------------------------------------------------------------------------
8 :Manual section: 8
10 SYNOPSIS
11 ========
13         **bpftool** [*OPTIONS*] **net** *COMMAND*
15         *OPTIONS* := { [{ **-j** | **--json** }] [{ **-p** | **--pretty** }] }
17         *COMMANDS* :=
18         { **show** | **list** | **attach** | **detach** | **help** }
20 NET COMMANDS
21 ============
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**
28 |       *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
29 |       *ATTACH_TYPE* := { **xdp** | **xdpgeneric** | **xdpdrv** | **xdpoffload** }
31 DESCRIPTION
32 ===========
33         **bpftool net { show | list }** [ **dev** *NAME* ]
34                   List bpf program attachments in the kernel networking subsystem.
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.
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.
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*.
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;
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*.
73         **bpftool net help**
74                   Print short help message.
76 OPTIONS
77 =======
78         -h, --help
79                   Print short generic help message (similar to **bpftool help**).
81         -V, --version
82                   Print version number (similar to **bpftool version**).
84         -j, --json
85                   Generate JSON output. For commands that cannot produce JSON, this
86                   option has no effect.
88         -p, --pretty
89                   Generate human-readable JSON output. Implies **-j**.
91         -d, --debug
92                   Print all logs available from libbpf, including debug-level
93                   information.
95 EXAMPLES
96 ========
98 | **# bpftool net**
102       xdp:
103       eth0(2) driver id 198
105       tc:
106       eth0(2) htb name prefix_matcher.o:[cls_prefix_matcher_htb] id 111727 act []
107       eth0(2) clsact/ingress fbflow_icmp id 130246 act []
108       eth0(2) clsact/egress prefix_matcher.o:[cls_prefix_matcher_clsact] id 111726
109       eth0(2) clsact/egress cls_fg_dscp id 108619 act []
110       eth0(2) clsact/egress fbflow_egress id 130245
113 | **# bpftool -jp net**
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     ]
164 | **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
165 | **# bpftool net**
169       xdp:
170       enp6s0np0(4) driver id 16
173 | **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
174 | **# bpftool net attach xdpdrv id 20 dev enp6s0np0 overwrite**
175 | **# bpftool net**
179       xdp:
180       enp6s0np0(4) driver id 20
183 | **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
184 | **# bpftool net detach xdpdrv dev enp6s0np0**
185 | **# bpftool net**
189       xdp:
192 SEE ALSO
193 ========
194         **bpf**\ (2),
195         **bpf-helpers**\ (7),
196         **bpftool**\ (8),
197         **bpftool-prog**\ (8),
198         **bpftool-map**\ (8),
199         **bpftool-cgroup**\ (8),
200         **bpftool-feature**\ (8),
201         **bpftool-perf**\ (8),
202         **bpftool-btf**\ (8)