This adds XDP support to BCC as currently supported in net-next.
authorJan Rüth <rueth@comsys.rwth-aachen.de>
Thu, 28 Jul 2016 20:32:46 +0000 (22:32 +0200)
committerJan Rüth <rueth@comsys.rwth-aachen.de>
Thu, 28 Jul 2016 20:40:06 +0000 (22:40 +0200)
commite0724d73ee61bb9bdc6334d617f06a4d2af1ae14
tree0ccae1156c5a6ecce14f10c833bfa4dca553b6a6
parent60b082e00ee1f048338487f2377e19a649b1daa7
This adds XDP support to BCC as currently supported in net-next.

Concretely, it adds two functions to bcc, namely:
`attach_xdp` and `remove_xdp`
which allows to attach an XDP program to a device (given via its name, e.g., en0) (in the future this might change to a specific queue on a device once the kernel offers this interface)
and `remove_xdp` removes a XDP program from a device. Please note that there can currently be only one program attached to the device and attaching another program replaces the previous.

One example is available to test XDP, in networking/xdp which drops all packets an counts for which protocol a packet was dropped (this is taken from the kernel xdp1 example). Please note that you cannot use the network headers defined in <bcc/proto.h> as they cause llvm/clang to generate instructions not available on XDP layer. On XDP layer you do not have an skb yet, so you are operating on the bare packet data.

XDP support is currently limited to only some network adapters, there is the `mlx4` and there is also a patch available for the `e1000` driver.
src/cc/compat/linux/bpf.h
src/cc/compat/linux/virtual_bpf.h
src/cc/libbpf.c
src/libbpf.h
src/python/bcc/__init__.py
src/python/bcc/libbcc.py