Yunjian Wang wrote:
> When a queue(tfile) is detached, we only update tfile's queue_index,
> but do not update xdp_rxq_info's queue_index. This patch fixes it.
>
> Fixes: 8bf5c4ee1889 ("tun: setup xdp_rxq_info")
> Signed-off-by: Yunjian Wang <[email protected]>
> ---
> drivers/net/tun.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index bc80fc1d576e..be37235af55d 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -652,6 +652,7 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
> tun->tfiles[tun->numqueues - 1]);
> ntfile = rtnl_dereference(tun->tfiles[index]);
> ntfile->queue_index = index;
> + ntfile->xdp_rxq.queue_index = index;
> rcu_assign_pointer(tun->tfiles[tun->numqueues - 1],
> NULL);
Does it matter that this value is stale when undetached?
It is replaced in tun_attach if previously attached:
/* Re-attach detached tfile, updating XDP queue_index */
WARN_ON(!xdp_rxq_info_is_reg(&tfile->xdp_rxq));
if (tfile->xdp_rxq.queue_index != tfile->queue_index)
tfile->xdp_rxq.queue_index = tfile->queue_index;
> -----Original Message-----
> From: Willem de Bruijn [mailto:[email protected]]
> Sent: Tuesday, February 20, 2024 11:59 PM
> To: wangyunjian <[email protected]>;
> [email protected]; [email protected]; [email protected];
> [email protected]
> Cc: [email protected]; [email protected];
> [email protected]; xudingke <[email protected]>; wangyunjian
> <[email protected]>
> Subject: Re: [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching
>
> Yunjian Wang wrote:
> > When a queue(tfile) is detached, we only update tfile's queue_index,
> > but do not update xdp_rxq_info's queue_index. This patch fixes it.
> >
> > Fixes: 8bf5c4ee1889 ("tun: setup xdp_rxq_info")
> > Signed-off-by: Yunjian Wang <[email protected]>
> > ---
> > drivers/net/tun.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c index
> > bc80fc1d576e..be37235af55d 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -652,6 +652,7 @@ static void __tun_detach(struct tun_file *tfile, bool
> clean)
> > tun->tfiles[tun->numqueues - 1]);
> > ntfile = rtnl_dereference(tun->tfiles[index]);
> > ntfile->queue_index = index;
> > + ntfile->xdp_rxq.queue_index = index;
> > rcu_assign_pointer(tun->tfiles[tun->numqueues - 1],
> > NULL);
>
> Does it matter that this value is stale when undetached?
Yes, the detach tfile'queue_index is not important because the re-attach will update.
But this patch is to fix the 'ntfile'(that replaces the detach tfile)'s queue_index, it is wrong.
Thanks
>
> It is replaced in tun_attach if previously attached:
>
> /* Re-attach detached tfile, updating XDP queue_index */
> WARN_ON(!xdp_rxq_info_is_reg(&tfile->xdp_rxq));
>
> if (tfile->xdp_rxq.queue_index != tfile->queue_index)
> tfile->xdp_rxq.queue_index = tfile->queue_index;