Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
0002 
0003 ================
0004 bpftool-net
0005 ================
0006 -------------------------------------------------------------------------------
0007 tool for inspection of netdev/tc related bpf prog attachments
0008 -------------------------------------------------------------------------------
0009 
0010 :Manual section: 8
0011 
0012 .. include:: substitutions.rst
0013 
0014 SYNOPSIS
0015 ========
0016 
0017         **bpftool** [*OPTIONS*] **net** *COMMAND*
0018 
0019         *OPTIONS* := { |COMMON_OPTIONS| }
0020 
0021         *COMMANDS* :=
0022         { **show** | **list** | **attach** | **detach** | **help** }
0023 
0024 NET COMMANDS
0025 ============
0026 
0027 |       **bpftool** **net** { **show** | **list** } [ **dev** *NAME* ]
0028 |       **bpftool** **net attach** *ATTACH_TYPE* *PROG* **dev** *NAME* [ **overwrite** ]
0029 |       **bpftool** **net detach** *ATTACH_TYPE* **dev** *NAME*
0030 |       **bpftool** **net help**
0031 |
0032 |       *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
0033 |       *ATTACH_TYPE* := { **xdp** | **xdpgeneric** | **xdpdrv** | **xdpoffload** }
0034 
0035 DESCRIPTION
0036 ===========
0037         **bpftool net { show | list }** [ **dev** *NAME* ]
0038                   List bpf program attachments in the kernel networking subsystem.
0039 
0040                   Currently, only device driver xdp attachments and tc filter
0041                   classification/action attachments are implemented, i.e., for
0042                   program types **BPF_PROG_TYPE_SCHED_CLS**,
0043                   **BPF_PROG_TYPE_SCHED_ACT** and **BPF_PROG_TYPE_XDP**.
0044                   For programs attached to a particular cgroup, e.g.,
0045                   **BPF_PROG_TYPE_CGROUP_SKB**, **BPF_PROG_TYPE_CGROUP_SOCK**,
0046                   **BPF_PROG_TYPE_SOCK_OPS** and **BPF_PROG_TYPE_CGROUP_SOCK_ADDR**,
0047                   users can use **bpftool cgroup** to dump cgroup attachments.
0048                   For sk_{filter, skb, msg, reuseport} and lwt/seg6
0049                   bpf programs, users should consult other tools, e.g., iproute2.
0050 
0051                   The current output will start with all xdp program attachments, followed by
0052                   all tc class/qdisc bpf program attachments. Both xdp programs and
0053                   tc programs are ordered based on ifindex number. If multiple bpf
0054                   programs attached to the same networking device through **tc filter**,
0055                   the order will be first all bpf programs attached to tc classes, then
0056                   all bpf programs attached to non clsact qdiscs, and finally all
0057                   bpf programs attached to root and clsact qdisc.
0058 
0059         **bpftool** **net attach** *ATTACH_TYPE* *PROG* **dev** *NAME* [ **overwrite** ]
0060                   Attach bpf program *PROG* to network interface *NAME* with
0061                   type specified by *ATTACH_TYPE*. Previously attached bpf program
0062                   can be replaced by the command used with **overwrite** option.
0063                   Currently, only XDP-related modes are supported for *ATTACH_TYPE*.
0064 
0065                   *ATTACH_TYPE* can be of:
0066                   **xdp** - try native XDP and fallback to generic XDP if NIC driver does not support it;
0067                   **xdpgeneric** - Generic XDP. runs at generic XDP hook when packet already enters receive path as skb;
0068                   **xdpdrv** - Native XDP. runs earliest point in driver's receive path;
0069                   **xdpoffload** - Offload XDP. runs directly on NIC on each packet reception;
0070 
0071         **bpftool** **net detach** *ATTACH_TYPE* **dev** *NAME*
0072                   Detach bpf program attached to network interface *NAME* with
0073                   type specified by *ATTACH_TYPE*. To detach bpf program, same
0074                   *ATTACH_TYPE* previously used for attach must be specified.
0075                   Currently, only XDP-related modes are supported for *ATTACH_TYPE*.
0076 
0077         **bpftool net help**
0078                   Print short help message.
0079 
0080 OPTIONS
0081 =======
0082         .. include:: common_options.rst
0083 
0084 EXAMPLES
0085 ========
0086 
0087 | **# bpftool net**
0088 
0089 ::
0090 
0091       xdp:
0092       eth0(2) driver id 198
0093 
0094       tc:
0095       eth0(2) htb name prefix_matcher.o:[cls_prefix_matcher_htb] id 111727 act []
0096       eth0(2) clsact/ingress fbflow_icmp id 130246 act []
0097       eth0(2) clsact/egress prefix_matcher.o:[cls_prefix_matcher_clsact] id 111726
0098       eth0(2) clsact/egress cls_fg_dscp id 108619 act []
0099       eth0(2) clsact/egress fbflow_egress id 130245
0100 
0101 |
0102 | **# bpftool -jp net**
0103 
0104 ::
0105 
0106     [{
0107             "xdp": [{
0108                     "devname": "eth0",
0109                     "ifindex": 2,
0110                     "mode": "driver",
0111                     "id": 198
0112                 }
0113             ],
0114             "tc": [{
0115                     "devname": "eth0",
0116                     "ifindex": 2,
0117                     "kind": "htb",
0118                     "name": "prefix_matcher.o:[cls_prefix_matcher_htb]",
0119                     "id": 111727,
0120                     "act": []
0121                 },{
0122                     "devname": "eth0",
0123                     "ifindex": 2,
0124                     "kind": "clsact/ingress",
0125                     "name": "fbflow_icmp",
0126                     "id": 130246,
0127                     "act": []
0128                 },{
0129                     "devname": "eth0",
0130                     "ifindex": 2,
0131                     "kind": "clsact/egress",
0132                     "name": "prefix_matcher.o:[cls_prefix_matcher_clsact]",
0133                     "id": 111726,
0134                 },{
0135                     "devname": "eth0",
0136                     "ifindex": 2,
0137                     "kind": "clsact/egress",
0138                     "name": "cls_fg_dscp",
0139                     "id": 108619,
0140                     "act": []
0141                 },{
0142                     "devname": "eth0",
0143                     "ifindex": 2,
0144                     "kind": "clsact/egress",
0145                     "name": "fbflow_egress",
0146                     "id": 130245,
0147                 }
0148             ]
0149         }
0150     ]
0151 
0152 |
0153 | **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
0154 | **# bpftool net**
0155 
0156 ::
0157 
0158       xdp:
0159       enp6s0np0(4) driver id 16
0160 
0161 |
0162 | **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
0163 | **# bpftool net attach xdpdrv id 20 dev enp6s0np0 overwrite**
0164 | **# bpftool net**
0165 
0166 ::
0167 
0168       xdp:
0169       enp6s0np0(4) driver id 20
0170 
0171 |
0172 | **# bpftool net attach xdpdrv id 16 dev enp6s0np0**
0173 | **# bpftool net detach xdpdrv dev enp6s0np0**
0174 | **# bpftool net**
0175 
0176 ::
0177 
0178       xdp: