]> git.proxmox.com Git - mirror_iproute2.git/commit
bpf: add initial support for attaching xdp progs
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 6 Dec 2016 01:21:57 +0000 (02:21 +0100)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 9 Dec 2016 20:44:12 +0000 (12:44 -0800)
commitc7272ca72009940faa79bc4db2296d27789455cd
tree3edc85d440e97a765ba312418833c63fff6625c1
parentfb24802b9c00447faff29409ffb983e24719a4c5
bpf: add initial support for attaching xdp progs

Now that we made the BPF loader generic as a library, reuse it
for loading XDP programs as well. This basically adds a minimal
start of a facility for iproute2 to load XDP programs. There
currently only exists the xdp1_user.c sample code in the kernel
tree that sets up netlink directly and an iovisor/bcc front-end.

Since we have all the necessary infrastructure in place already
from tc side, we can just reuse its loader back-end and thus
facilitate migration and usability among the two for people
familiar with tc/bpf already. Sharing maps, performing tail calls,
etc works the same way as with tc. Naturally, once kernel
configuration API evolves, we will extend new features for XDP
here as well, resp. extend dumping of related netlink attributes.

Minimal example:

  clang -target bpf -O2 -Wall -c prog.c -o prog.o
  ip [-force] link set dev em1 xdp obj prog.o       # attaching
  ip [-d] link                                      # dumping
  ip link set dev em1 xdp off                       # detaching

For the dump, intention is that in the first line for each ip
link entry, we'll see "xdp" to indicate that this device has an
XDP program attached. Once we dump some more useful information
via netlink (digest, etc), idea is that 'ip -d link' will then
display additional relevant program information below the "link/
ether [...]" output line for such devices, for example.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
include/bpf_api.h
include/bpf_elf.h
include/utils.h
ip/Makefile
ip/ipaddress.c
ip/iplink.c
ip/iplink_xdp.c [new file with mode: 0644]
ip/xdp.h [new file with mode: 0644]
lib/bpf.c
man/man8/ip-link.8.in