This series adds a helper to allow head adjusting in XDP prog. mlx4 driver has been modified to support this feature. An example is written to encapsulate a packet with an IPv4/v6 header and then XDP_TX it out.
v4: 1. Remove XDP_QUERY_FEATURES command. Instead, check the prog->xdp_adjust_head bit inside the driver itself during XDP_SETUP_PROG in patch 1of4. Thanks for everybody's ideas. 2. Nit changes on sample code per Jesper v3: 1. Check if the driver supports head adjustment before setting the xdp_prog fd to the device in patch 1of4. 2. Remove the page alignment assumption on the data_hard_start. Instead, add data_hard_start to the struct xdp_buff and the driver has to fill it if it supports head adjustment. 3. Keep the wire MTU as before in mlx4 4. Set map0_byte_count to PAGE_SIZE in patch 3of4 v2: 1. Make a variable name change in bpf_xdp_adjust_head() in patch 1 2. Ensure no less than ETH_HLEN data in bpf_xdp_adjust_head() in patch 1 3. Some clarifications in commit log messages of patch 2 and 3 Thanks, Martin Martin KaFai Lau (4): bpf: xdp: Allow head adjustment in XDP prog mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active bpf: xdp: Add XDP example for head adjustment arch/powerpc/net/bpf_jit_comp64.c | 4 +- arch/s390/net/bpf_jit_comp.c | 2 +- arch/x86/net/bpf_jit_comp.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 29 ++- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 70 +++--- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 9 +- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 3 +- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 + .../net/ethernet/netronome/nfp/nfp_net_common.c | 4 + drivers/net/ethernet/qlogic/qede/qede_main.c | 5 + include/linux/filter.h | 6 +- include/uapi/linux/bpf.h | 11 +- kernel/bpf/core.c | 2 +- kernel/bpf/syscall.c | 2 + kernel/bpf/verifier.c | 2 +- net/core/filter.c | 28 ++- samples/bpf/Makefile | 4 + samples/bpf/bpf_helpers.h | 2 + samples/bpf/bpf_load.c | 94 ++++++++ samples/bpf/bpf_load.h | 1 + samples/bpf/xdp1_user.c | 93 -------- samples/bpf/xdp_tx_iptunnel_common.h | 37 +++ samples/bpf/xdp_tx_iptunnel_kern.c | 236 +++++++++++++++++++ samples/bpf/xdp_tx_iptunnel_user.c | 256 +++++++++++++++++++++ 24 files changed, 762 insertions(+), 145 deletions(-) create mode 100644 samples/bpf/xdp_tx_iptunnel_common.h create mode 100644 samples/bpf/xdp_tx_iptunnel_kern.c create mode 100644 samples/bpf/xdp_tx_iptunnel_user.c -- 2.5.1