[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<MW4PR21MB1859765F7B3BCEA3989D577DCA472@MW4PR21MB1859.namprd21.prod.outlook.com>
Date: Thu, 17 Oct 2024 16:06:55 +0000
From: Haiyang Zhang <haiyangz@...rosoft.com>
To: Simon Horman <horms@...nel.org>
CC: "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>, KY Srinivasan
<kys@...rosoft.com>, "wei.liu@...nel.org" <wei.liu@...nel.org>, Dexuan Cui
<decui@...rosoft.com>, "edumazet@...gle.com" <edumazet@...gle.com>,
"kuba@...nel.org" <kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>,
"stephen@...workplumber.org" <stephen@...workplumber.org>,
"davem@...emloft.net" <davem@...emloft.net>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "stable@...r.kernel.org"
<stable@...r.kernel.org>
Subject: RE: [PATCH net,v2] hv_netvsc: Fix VF namespace also in synthetic NIC
NETDEV_REGISTER event
> -----Original Message-----
> From: Simon Horman <horms@...nel.org>
> Sent: Thursday, October 17, 2024 11:45 AM
> To: Haiyang Zhang <haiyangz@...rosoft.com>
> Cc: linux-hyperv@...r.kernel.org; netdev@...r.kernel.org; KY Srinivasan
> <kys@...rosoft.com>; wei.liu@...nel.org; Dexuan Cui <decui@...rosoft.com>;
> edumazet@...gle.com; kuba@...nel.org; pabeni@...hat.com;
> stephen@...workplumber.org; davem@...emloft.net; linux-
> kernel@...r.kernel.org; stable@...r.kernel.org
> Subject: Re: [PATCH net,v2] hv_netvsc: Fix VF namespace also in synthetic
> NIC NETDEV_REGISTER event
>
> On Wed, Oct 16, 2024 at 08:43:57AM -0700, Haiyang Zhang wrote:
> > The existing code moves VF to the same namespace as the synthetic NIC
> > during netvsc_register_vf(). But, if the synthetic device is moved to a
> > new namespace after the VF registration, the VF won't be moved together.
> >
> > To make the behavior more consistent, add a namespace check for
> synthetic
> > NIC's NETDEV_REGISTER event (generated during its move), and move the VF
> > if it is not in the same namespace.
> >
> > Cc: stable@...r.kernel.org
> > Fixes: c0a41b887ce6 ("hv_netvsc: move VF to same namespace as netvsc
> device")
> > Suggested-by: Stephen Hemminger <stephen@...workplumber.org>
> > Signed-off-by: Haiyang Zhang <haiyangz@...rosoft.com>
> > ---
> > v2: Move my fix to synthetic NIC's NETDEV_REGISTER event as suggested by
> Stephen.
> >
> > ---
> > drivers/net/hyperv/netvsc_drv.c | 29 +++++++++++++++++++++++++++++
> > 1 file changed, 29 insertions(+)
> >
> > diff --git a/drivers/net/hyperv/netvsc_drv.c
> b/drivers/net/hyperv/netvsc_drv.c
> > index 153b97f8ec0d..54e98356ee93 100644
> > --- a/drivers/net/hyperv/netvsc_drv.c
> > +++ b/drivers/net/hyperv/netvsc_drv.c
> > @@ -2798,6 +2798,30 @@ static struct hv_driver netvsc_drv = {
> > },
> > };
> >
> > +/* Set VF's namespace same as the synthetic NIC */
> > +static void netvsc_event_set_vf_ns(struct net_device *ndev)
> > +{
> > + struct net_device_context *ndev_ctx = netdev_priv(ndev);
> > + struct net_device *vf_netdev = rtnl_dereference(ndev_ctx-
> >vf_netdev);
> > + int ret;
>
> In Networking code it is preferred to arrange local variables in reverse
> xmas tree order - longest line to shortest.
>
> I believe that could be achieved as follows (completely untested!):
>
> struct net_device_context *ndev_ctx = netdev_priv(ndev);
> struct net_device *vf_netdev;
> int ret;
>
> vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev);
> if (!vf_netdev)
> return;
>
> With that addressed please feel free to add:
>
> Reviewed-by: Simon Horman <horms@...nel.org>
Sure, I will update them to RCT order.
Thanks,
- Haiyang
Powered by blists - more mailing lists