* [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching
@ 2024-02-20 3:12 Yunjian Wang
2024-02-20 15:59 ` Willem de Bruijn
2024-02-24 0:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Yunjian Wang @ 2024-02-20 3:12 UTC (permalink / raw)
To: willemdebruijn.kernel, jasowang, kuba, davem
Cc: netdev, linux-kernel, brouer, xudingke, Yunjian Wang
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 <wangyunjian@huawei.com>
---
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);
--
2.33.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching
2024-02-20 3:12 [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching Yunjian Wang
@ 2024-02-20 15:59 ` Willem de Bruijn
2024-02-21 2:40 ` wangyunjian
2024-02-24 0:30 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Willem de Bruijn @ 2024-02-20 15:59 UTC (permalink / raw)
To: Yunjian Wang, willemdebruijn.kernel, jasowang, kuba, davem
Cc: netdev, linux-kernel, brouer, xudingke, Yunjian Wang
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 <wangyunjian@huawei.com>
> ---
> 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;
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching
2024-02-20 15:59 ` Willem de Bruijn
@ 2024-02-21 2:40 ` wangyunjian
2024-02-21 15:03 ` Willem de Bruijn
0 siblings, 1 reply; 5+ messages in thread
From: wangyunjian @ 2024-02-21 2:40 UTC (permalink / raw)
To: Willem de Bruijn, jasowang@redhat.com, kuba@kernel.org,
davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xudingke
> -----Original Message-----
> From: Willem de Bruijn [mailto:willemdebruijn.kernel@gmail.com]
> Sent: Tuesday, February 20, 2024 11:59 PM
> To: wangyunjian <wangyunjian@huawei.com>;
> willemdebruijn.kernel@gmail.com; jasowang@redhat.com; kuba@kernel.org;
> davem@davemloft.net
> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
> brouer@redhat.com; xudingke <xudingke@huawei.com>; wangyunjian
> <wangyunjian@huawei.com>
> 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 <wangyunjian@huawei.com>
> > ---
> > 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;
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching
2024-02-21 2:40 ` wangyunjian
@ 2024-02-21 15:03 ` Willem de Bruijn
0 siblings, 0 replies; 5+ messages in thread
From: Willem de Bruijn @ 2024-02-21 15:03 UTC (permalink / raw)
To: wangyunjian, Willem de Bruijn, jasowang@redhat.com,
kuba@kernel.org, davem@davemloft.net, Jesper Dangaard Brouer
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xudingke
wangyunjian wrote:
>
>
> > -----Original Message-----
> > From: Willem de Bruijn [mailto:willemdebruijn.kernel@gmail.com]
> > Sent: Tuesday, February 20, 2024 11:59 PM
> > To: wangyunjian <wangyunjian@huawei.com>;
> > willemdebruijn.kernel@gmail.com; jasowang@redhat.com; kuba@kernel.org;
> > davem@davemloft.net
> > Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
> > brouer@redhat.com; xudingke <xudingke@huawei.com>; wangyunjian
> > <wangyunjian@huawei.com>
> > 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 <wangyunjian@huawei.com>
> > > ---
> > > 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.
Oh yes. This looks correct to me. Let's cc: the author of the patch listed as Fixed too.
>
> 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;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching
2024-02-20 3:12 [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching Yunjian Wang
2024-02-20 15:59 ` Willem de Bruijn
@ 2024-02-24 0:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-02-24 0:30 UTC (permalink / raw)
To: wangyunjian
Cc: willemdebruijn.kernel, jasowang, kuba, davem, netdev,
linux-kernel, brouer, xudingke
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 20 Feb 2024 11:12:07 +0800 you 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 <wangyunjian@huawei.com>
> ---
> drivers/net/tun.c | 1 +
> 1 file changed, 1 insertion(+)
Here is the summary with links:
- [net] tun: Fix xdp_rxq_info's queue_index when detaching
https://git.kernel.org/netdev/net/c/2a770cdc4382
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-02-24 0:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-20 3:12 [PATCH net] tun: Fix xdp_rxq_info's queue_index when detaching Yunjian Wang
2024-02-20 15:59 ` Willem de Bruijn
2024-02-21 2:40 ` wangyunjian
2024-02-21 15:03 ` Willem de Bruijn
2024-02-24 0:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox