Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xdp: document xdp_do_flush() before napi_complete_done()

Document in the XDP_REDIRECT manual section that drivers must call
xdp_do_flush() before napi_complete_done(). The two reasons behind
this can be found following the links below.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/r/20221220185903.1105011-1-sbohrer@cloudflare.com
Link: https://lore.kernel.org/all/20210624160609.292325-1-toke@redhat.com/
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Magnus Karlsson and committed by
David S. Miller
68e5b6aa bed91ac0

+7 -3
+7 -3
net/core/filter.c
··· 4128 4128 * bpf_redirect_info to actually enqueue the frame into a map type-specific 4129 4129 * bulk queue structure. 4130 4130 * 4131 - * 3. Before exiting its NAPI poll loop, the driver will call xdp_do_flush(), 4132 - * which will flush all the different bulk queues, thus completing the 4133 - * redirect. 4131 + * 3. Before exiting its NAPI poll loop, the driver will call 4132 + * xdp_do_flush(), which will flush all the different bulk queues, 4133 + * thus completing the redirect. Note that xdp_do_flush() must be 4134 + * called before napi_complete_done() in the driver, as the 4135 + * XDP_REDIRECT logic relies on being inside a single NAPI instance 4136 + * through to the xdp_do_flush() call for RCU protection of all 4137 + * in-kernel data structures. 4134 4138 */ 4135 4139 /* 4136 4140 * Pointers to the map entries will be kept around for this whole sequence of