Skip to content

Commit 60240bc

Browse files
jalalmostafaborkmann
authored andcommitted
xsk: Inherit need_wakeup flag for shared sockets
The flag for need_wakeup is not set for xsks with `XDP_SHARED_UMEM` flag and of different queue ids and/or devices. They should inherit the flag from the first socket buffer pool since no flags can be specified once `XDP_SHARED_UMEM` is specified. Fixes: b5aea28 ("xsk: Add shared umem support between queue ids") Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/bpf/20220921135701.10199-1-jalal.a.mostapha@gmail.com
1 parent 8addbfc commit 60240bc

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

include/net/xsk_buff_pool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ struct xsk_buff_pool *xp_create_and_assign_umem(struct xdp_sock *xs,
9595
struct xdp_umem *umem);
9696
int xp_assign_dev(struct xsk_buff_pool *pool, struct net_device *dev,
9797
u16 queue_id, u16 flags);
98-
int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
98+
int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
9999
struct net_device *dev, u16 queue_id);
100100
int xp_alloc_tx_descs(struct xsk_buff_pool *pool, struct xdp_sock *xs);
101101
void xp_destroy(struct xsk_buff_pool *pool);

net/xdp/xsk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,8 +954,8 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
954954
goto out_unlock;
955955
}
956956

957-
err = xp_assign_dev_shared(xs->pool, umem_xs->umem,
958-
dev, qid);
957+
err = xp_assign_dev_shared(xs->pool, umem_xs, dev,
958+
qid);
959959
if (err) {
960960
xp_destroy(xs->pool);
961961
xs->pool = NULL;

net/xdp/xsk_buff_pool.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,18 @@ int xp_assign_dev(struct xsk_buff_pool *pool,
212212
return err;
213213
}
214214

215-
int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_umem *umem,
215+
int xp_assign_dev_shared(struct xsk_buff_pool *pool, struct xdp_sock *umem_xs,
216216
struct net_device *dev, u16 queue_id)
217217
{
218218
u16 flags;
219+
struct xdp_umem *umem = umem_xs->umem;
219220

220221
/* One fill and completion ring required for each queue id. */
221222
if (!pool->fq || !pool->cq)
222223
return -EINVAL;
223224

224225
flags = umem->zc ? XDP_ZEROCOPY : XDP_COPY;
225-
if (pool->uses_need_wakeup)
226+
if (umem_xs->pool->uses_need_wakeup)
226227
flags |= XDP_USE_NEED_WAKEUP;
227228

228229
return xp_assign_dev(pool, dev, queue_id, flags);

0 commit comments

Comments
 (0)