veth: Add XDP TX and REDIRECT
authorToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Fri, 3 Aug 2018 07:58:17 +0000 (16:58 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 10 Aug 2018 14:12:21 +0000 (16:12 +0200)
commitd1396004dd868642ea2596abe058d96dcf97990f
treec008723e6af6ff7cf5754fba291fbe65a5d25ab8
parent2539650fadbf63a431e76535a9de7bff6ea5e409
veth: Add XDP TX and REDIRECT

This allows further redirection of xdp_frames like

 NIC   -> veth--veth -> veth--veth
 (XDP)          (XDP)         (XDP)

The intermediate XDP, redirecting packets from NIC to the other veth,
reuses xdp_mem_info from NIC so that page recycling of the NIC works on
the destination veth's XDP.
In this way return_frame is not fully guarded by NAPI, since another
NAPI handler on another cpu may use the same xdp_mem_info concurrently.
Thus disable napi_direct by xdp_set_return_frame_no_direct() during the
NAPI context.

v8:
- Don't use xdp_frame pointer address for data_hard_start of xdp_buff.

v4:
- Use xdp_[set|clear]_return_frame_no_direct() instead of a flag in
  xdp_mem_info.

v3:
- Fix double free when veth_xdp_tx() returns a positive value.
- Convert xdp_xmit and xdp_redir variables into flags.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
drivers/net/veth.c