[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250214002557.27185-1-kuniyu@amazon.com>
Date: Fri, 14 Feb 2025 09:25:57 +0900
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <kuba@...nel.org>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <horms@...nel.org>,
<kuni1840@...il.com>, <kuniyu@...zon.com>, <netdev@...r.kernel.org>,
<pabeni@...hat.com>, <ychemla@...dia.com>
Subject: Re: [PATCH v4 net 2/3] net: Fix dev_net(dev) race in unregister_netdevice_notifier_dev_net().
From: Jakub Kicinski <kuba@...nel.org>
Date: Thu, 13 Feb 2025 08:32:17 -0800
> On Wed, 12 Feb 2025 15:42:05 +0900 Kuniyuki Iwashima wrote:
> > +static void rtnl_net_dev_lock(struct net_device *dev)
> > +{
> > + struct net *net;
> > +
> > +#ifdef CONFIG_NET_NS
> > +again:
> > +#endif
> > + /* netns might be being dismantled. */
> > + rcu_read_lock();
> > + net = dev_net_rcu(dev);
> > + net_passive_inc(net);
> > + rcu_read_unlock();
> > +
> > + rtnl_net_lock(net);
> > +
> > +#ifdef CONFIG_NET_NS
> > + /* dev might have been moved to another netns. */
> > + if (!net_eq(net, rcu_access_pointer(dev->nd_net.net))) {
> > + rtnl_net_unlock(net);
> > + net_passive_dec(net);
> > + goto again;
> > + }
> > +#endif
>
> Is there a plan to clean this up in net-next? Or perhaps after Eric's
> dev_net() work? Otherwise I'm tempted to suggest to use a loop, maybe:
For sure, I will post a followup patch to net-next.
Thanks!
>
> bool again;
>
> do {
> again = false;
>
> /* netns might be being dismantled. */
> rcu_read_lock();
> net = dev_net_rcu(dev);
> net_passive_inc(net);
> rcu_read_unlock();
>
> rtnl_net_lock(net);
>
> #ifdef CONFIG_NET_NS
> /* dev might have been moved to another netns. */
> if (!net_eq(net, rcu_access_pointer(dev->nd_net.net))) {
> rtnl_net_unlock(net);
> net_passive_dec(net);
> again = true;
> }
> #endif
> } while (again);
Powered by blists - more mailing lists