[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <PH7PR21MB31166EEAA957F467D953D1C1CA569@PH7PR21MB3116.namprd21.prod.outlook.com>
Date: Fri, 30 Sep 2022 13:03:00 +0000
From: Haiyang Zhang <haiyangz@...rosoft.com>
To: Jakub Kicinski <kuba@...nel.org>,
Gaurav Kohli <gauravkohli@...ux.microsoft.com>
CC: KY Srinivasan <kys@...rosoft.com>,
Stephen Hemminger <sthemmin@...rosoft.com>,
"wei.liu@...nel.org" <wei.liu@...nel.org>,
Dexuan Cui <decui@...rosoft.com>,
"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH net] hv_netvsc: Fix race between VF offering and VF
association message from host
> -----Original Message-----
> From: Jakub Kicinski <kuba@...nel.org>
> Sent: Thursday, September 29, 2022 10:26 PM
> To: Gaurav Kohli <gauravkohli@...ux.microsoft.com>
> Cc: KY Srinivasan <kys@...rosoft.com>; Haiyang Zhang
> <haiyangz@...rosoft.com>; Stephen Hemminger
> <sthemmin@...rosoft.com>; wei.liu@...nel.org; Dexuan Cui
> <decui@...rosoft.com>; linux-hyperv@...r.kernel.org;
> netdev@...r.kernel.org
> Subject: Re: [PATCH net] hv_netvsc: Fix race between VF offering and VF
> association message from host
>
> On Wed, 28 Sep 2022 06:48:33 -0700 Gaurav Kohli wrote:
> > During vm boot, there might be possibility that vf registration
> > call comes before the vf association from host to vm.
> >
> > And this might break netvsc vf path, To prevent the same block
> > vf registration until vf bind message comes from host.
> >
> > Cc: stable@...r.kernel.org
> > Fixes: 00d7ddba11436 ("hv_netvsc: pair VF based on serial number")
> > Signed-off-by: Gaurav Kohli <gauravkohli@...ux.microsoft.com>
>
> Is it possible to add a timeout or such? Waiting for an external
> event while holding rtnl lock seems a little scary.
We used to have time-out in many places of this driver. But there is
no protocol guarantees of the host response time, so the time out value
cannot be set. These time-outs were removed several years ago.
> The other question is - what protects the completion and ->vf_alloc
> from races? Is there some locking? ->vf_alloc only goes from 0 to 1
> and never back?
When Vf is removed, the vf_assoc msg will set it to 0 here:
net_device_ctx->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated;
net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial;
Also, I think this condition can be changed from:
+ if (vf_is_up && !net_device_ctx->vf_alloc) {
to:
+ if (vf_is_up) {
So when VF comes up, it always wait for the completion without depending
on the vf_alloc.
Thanks,
- Haiyang
Powered by blists - more mailing lists