1xdp-loader(8)                 XDP program loader                 xdp-loader(8)
2
3
4

XDP-loader - an XDP program loader

6       XDP-loader is a simple loader for XDP programs with support for attach‐
7       ing multiple programs to the same interface. To achieve this it exposes
8       the same load and unload semantics exposed by the libxdp library.
9
10
11
12   Running xdp-loader
13       The syntax for running xdp-loader is:
14
15              xdp-loader COMMAND [options]
16
17              Where COMMAND can be one of:
18                     load        - load an XDP program on an interface
19                     unload      - unload an XDP program from an interface
20                     status      - show current XDP program status
21                     help        - show the list of available commands
22
23
24       Each  command,  and  its options are explained below. Or use xdp-loader
25       COMMAND --help to see the options for each command.
26
27

The LOAD command

29       The load command loads one or more XDP programs onto an interface.
30
31
32       The syntax for the load command is:
33
34
35       xdp-loader load [options] <ifname> <programs>
36
37
38       Where <ifname> is the name of the interface to load the programs  onto,
39       and  the  <programs> is one or more file names containing XDP programs.
40       The programs will be loaded onto the interface in the  order  of  their
41       preference, as specified by the program metadata (see libxdp(3)).
42
43
44       The supported options are:
45
46
47   -m, --mode <mode>
48       Specifies which mode to load the XDP program to be loaded in. The valid
49       values are 'native', which is the default in-driver  XDP  mode,  'skb',
50       which  causes  the so-called skb mode (also known as generic XDP) to be
51       used, 'hw' which causes the program to be offloaded to the hardware, or
52       'unspecified' which leaves it up to the kernel to pick a mode (which it
53       will do by picking native mode if the driver supports  it,  or  generic
54       mode otherwise). Note that using 'unspecified' can make it difficult to
55       predict what mode a program will end up being loaded in. For this  rea‐
56       son, the default is 'native'.
57
58
59   -p, --pin-path <path>
60       This  specifies a root path under which to pin any maps that define the
61       'pinning' attribute in their definitions. This path must be located  on
62       a  bpffs file system. If not set, maps will not be pinned, even if they
63       specify pinning in their definitions. When pinning maps, if the  pinned
64       location  for  a map already exist, the map pinned there will be reused
65       if it is compatible with the type of the map being loaded.
66
67
68   -s, --section <section>
69       Specify which ELF section to load the XDP program(s) from in each file.
70       The default is to use the first program in each file. If this option is
71       set, it applies to all programs being loaded.
72
73
74   -v, --verbose
75       Enable debug logging. Specify twice for even more verbosity.
76
77
78   -h, --help
79       Display a summary of the available options
80
81

The UNLOAD command

83       The unload command is used for unloading programs from an interface.
84
85
86       The syntax for the unload command is:
87
88
89       xdp-loader unload [options] <ifname>
90
91
92       Where <ifname> is the name of the interface to load the programs  onto.
93       Either  the  --all  or  --id options must be used to specify which pro‐
94       gram(s) to unload.
95
96
97       The supported options are:
98
99
100   -i, --id <id>
101       Unload a single program from the interface by ID. Use xdp-loader status
102       to  obtain the ID of the program being unloaded. If this program is the
103       last program loaded on the interface, the dispatcher program will  also
104       be removed, which makes the operation equivalent to specifying --all.
105
106
107   -a, --all
108       Unload  all XDP programs on the interface, as well as the multi-program
109       dispatcher.
110
111
112   -v, --verbose
113       Enable debug logging. Specify twice for even more verbosity.
114
115
116   -h, --help
117       Display a summary of the available options
118
119

The STATUS command

121       The status command displays a list of interfaces in the system, and the
122       XDP  program(s) loaded on each interface. For each interface, a list of
123       programs are shown, with the run priority and "chain actions" for  each
124       program.  See  the  section on program metadata for the meaning of this
125       metadata.
126
127
128   -v, --verbose
129       Enable debug logging. Specify twice for even more verbosity.
130
131
132   -h, --help
133       Display a summary of the available options
134
135
136

Examples

138       To load an XDP program on the eth0 interface simply do:
139
140              # xdp-loader load eth0 xdp_drop.o
141              # xdp-loader status
142
143              CURRENT XDP PROGRAM STATUS:
144
145              Interface        Prio  Program name     Mode     ID   Tag               Chain actions
146              -------------------------------------------------------------------------------------
147              lo               <no XDP program>
148              eth0                   xdp_dispatcher   native   50   d51e469e988d81da
149               =>              50    xdp_drop                  55   57cd311f2e27366b  XDP_PASS
150
151
152
153       Which shows that a dispatcher program was loaded on the interface,  and
154       the  xdp_drop  program  was installed as the first (and only) component
155       program after it. In this instance, the program does not specify any of
156       the  metadata  above,  so the defaults (priority 50 and XDP_PASS as its
157       chain call action) was used.
158
159
160       To use the automatic map pinning, include the  pinning  attribute  into
161       the map definition in the program, something like:
162
163              struct {
164                   __uint(type, BPF_MAP_TYPE_ARRAY);
165                   __uint(max_entries, 10);
166                   __type(key, __u32);
167                   __type(value, __u64);
168                   __uint(pinning, LIBBPF_PIN_BY_NAME);
169              } my_map SEC(".maps");
170
171
172       And load it with the --pin-path attribute:
173
174              # xdp-loader load eth0 my_prog.o --pin-path /sys/fs/bpf/my-prog
175
176
177       This  will  pin  the map at /sys/fs/bpf/my-prog/my_map. If this already
178       exists, the pinned map will be reused instead of creating  a  new  one,
179       which allows different BPF programs to share the map.
180
181

BUGS

183       Please  report  any bugs on Github: https://github.com/xdp-project/xdp-
184       tools/issues
185
186

AUTHOR

188       xdp-loader and this man page were written by Toke Høiland-Jørgensen.
189
190
191
192V1.1.1                         FEBRUARY  8, 2021                 xdp-loader(8)
Impressum