diff --git a/include/net/xdp_sock.h b/include/net/xdp_sock.h index 69b472604b86f5a8dd678a2327449f72e98ece0b..6492a7f523cd8841b1c02197809ae050e2ed6ab7 100644 --- a/include/net/xdp_sock.h +++ b/include/net/xdp_sock.h @@ -63,7 +63,7 @@ struct xdp_sock { struct xsk_queue *tx ____cacheline_aligned_in_smp; struct list_head tx_list; - /* Protects generic receive. */ + /* Reserved for kabi consistency. */ spinlock_t rx_lock; /* Statistics */ diff --git a/include/net/xsk_buff_pool.h b/include/net/xsk_buff_pool.h index 92a8e97826b96c654e938d73c11ef7e1a168d2d1..cb5b41a35433d60a7ad164069145cd66e03e8844 100644 --- a/include/net/xsk_buff_pool.h +++ b/include/net/xsk_buff_pool.h @@ -60,6 +60,9 @@ struct xsk_buff_pool { u32 heads_cnt; u16 queue_id; + /* Protects generic receive in shared and non-shared umem mode. */ + KABI_FILL_HOLE(spinlock_t rx_lock) + /* Data path members as close to free_heads at the end as possible. */ struct xsk_queue *fq ____cacheline_aligned_in_smp; struct xsk_queue *cq; diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 93c802cfb9c6ab6fbdf96a630dcd698a77eada21..569d39f19c5695e2bb01a358a0bcbe2f6a4bfbcc 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -339,13 +339,14 @@ int xsk_generic_rcv(struct xdp_sock *xs, struct xdp_buff *xdp) u32 len = xdp_get_buff_len(xdp); int err; - spin_lock_bh(&xs->rx_lock); err = xsk_rcv_check(xs, xdp, len); if (!err) { + spin_lock_bh(&xs->pool->rx_lock); err = __xsk_rcv(xs, xdp, len); xsk_flush(xs); + spin_unlock_bh(&xs->pool->rx_lock); } - spin_unlock_bh(&xs->rx_lock); + return err; } @@ -1647,7 +1648,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 e83b707da25b5134350c1d31bf6541480800a1ef..380b0b3f3d8d0c9ff2082e671ccedc1b01da2f5e 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->xskb_list); INIT_LIST_HEAD(&pool->xsk_tx_list);