diff options
| -rw-r--r-- | include/net/xdp_sock.h | 2 | ||||
| -rw-r--r-- | include/net/xsk_buff_pool.h | 2 | ||||
| -rw-r--r-- | net/xdp/xsk.c | 6 | ||||
| -rw-r--r-- | net/xdp/xsk_buff_pool.c | 1 |
4 files changed, 6 insertions, 5 deletions
diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h index 3057e1a4a11c..b8001d24106a 100644 --- a/include/net/xdp_sock.h +++ b/include/net/xdp_sock.h @@ -59,8 +59,6 @@ struct xdp_sock { struct xsk_queue *tx ____cacheline_aligned_in_smp; struct list_head tx_list; - /* Protects generic receive. */ - spinlock_t rx_lock; /* Statistics */ u64 rx_dropped; diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h index 996eaf1ef1a1..e436363c2192 100644 --- a/include/net/xsk_buff_pool.h +++ b/include/net/xsk_buff_pool.h @@ -48,6 +48,8 @@ struct xsk_buff_pool { refcount_t users; struct xdp_umem *umem; struct work_struct work; + /* Protects generic receive in shared and non-shared umem mode. */ + spinlock_t rx_lock; struct list_head free_list; u32 heads_cnt; u16 queue_id; diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index e3bdfc517424..e55e153377c8 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -237,13 +237,14 @@ int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp) { int err; - spin_lock_bh(&xs->rx_lock); err = xsk_rcv_check(xs, xdp); if (!err) { + spin_lock_bh(&xs->pool->rx_lock); err = __xsk_rcv(xs, xdp); xsk_flush(xs); + spin_unlock_bh(&xs->pool->rx_lock); } - spin_unlock_bh(&xs->rx_lock); + return err; } @@ -1448,7 +1449,6 @@ static int xsk_create(struct net *net, struct socket *sock, int protocol, xs = xdp_sk(sk); xs->state = XSK_READY; mutex_init(&xs->mutex); - spin_lock_init(&xs->rx_lock); INIT_LIST_HEAD(&xs->map_list); spin_lock_init(&xs->map_list_lock); diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c index 21d5fdba47c4..b2004a8bf67f 100644 --- a/net/xdp/xsk_buff_pool.c +++ b/net/xdp/xsk_buff_pool.c @@ -85,6 +85,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs, XDP_PACKET_HEADROOM; pool->umem = umem; pool->addrs = umem->addrs; + spin_lock_init(&pool->rx_lock); INIT_LIST_HEAD(&pool->free_list); INIT_LIST_HEAD(&pool->xsk_tx_list); spin_lock_init(&pool->xsk_tx_list_lock); |
