xdp: fix race on generic receive path
Unlike driver mode, generic xdp receive could be triggered
by different threads on different CPU cores at the same time
leading to the fill and rx queue breakage. For example, this
could happen while sending packets from two processes to the
first interface of veth pair while the second part of it is
open with AF_XDP socket.
Need to take a lock for each generic receive to avoid race.
Fixes: c497176cb2
("xsk: add Rx receive functions and poll support")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Tested-by: William Tu <u9012063@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:

committed by
Daniel Borkmann

parent
bc2d8afecb
commit
bf0bdd1343
@@ -67,6 +67,8 @@ struct xdp_sock {
|
||||
* in the SKB destructor callback.
|
||||
*/
|
||||
spinlock_t tx_completion_lock;
|
||||
/* Protects generic receive. */
|
||||
spinlock_t rx_lock;
|
||||
u64 rx_dropped;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user