LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] hv_netvsc: Fix net device attach on older Windows hosts
@ 2018-05-08 17:40 Mohammed Gamal
  2018-05-08 18:13 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Mohammed Gamal @ 2018-05-08 17:40 UTC (permalink / raw)
  To: netdev, sthemmin
  Cc: kys, haiyangz, devel, vkuznets, linux-kernel, Mohammed Gamal

On older windows hosts the net_device instance is returned to
the caller of rndis_filter_device_add() without having the presence
bit set first. This would cause any subsequent calls to network device
operations (e.g. MTU change, channel change) to fail after the device
is detached once, returning -ENODEV.

Make sure we explicitly call netif_device_attach() before returning
the net_device instance to make sure the presence bit is set

Fixes: 7b2ee50c0cd5 ("hv_netvsc: common detach logic")

Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
---
 drivers/net/hyperv/rndis_filter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 6b127be..09a3c1d 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -1287,8 +1287,10 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
 		   rndis_device->hw_mac_adr,
 		   rndis_device->link_state ? "down" : "up");
 
-	if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5)
+	if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5) {
+		netif_device_attach(net);
 		return net_device;
+	}
 
 	rndis_filter_query_link_speed(rndis_device, net_device);
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hv_netvsc: Fix net device attach on older Windows hosts
  2018-05-08 17:40 [PATCH] hv_netvsc: Fix net device attach on older Windows hosts Mohammed Gamal
@ 2018-05-08 18:13 ` Stephen Hemminger
  2018-05-08 18:17   ` Mohammed Gamal
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2018-05-08 18:13 UTC (permalink / raw)
  To: Mohammed Gamal; +Cc: netdev, sthemmin, haiyangz, linux-kernel, devel, vkuznets

On Tue,  8 May 2018 19:40:47 +0200
Mohammed Gamal <mgamal@redhat.com> wrote:

> On older windows hosts the net_device instance is returned to
> the caller of rndis_filter_device_add() without having the presence
> bit set first. This would cause any subsequent calls to network device
> operations (e.g. MTU change, channel change) to fail after the device
> is detached once, returning -ENODEV.
> 
> Make sure we explicitly call netif_device_attach() before returning
> the net_device instance to make sure the presence bit is set
> 
> Fixes: 7b2ee50c0cd5 ("hv_netvsc: common detach logic")
> 
> Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
> ---
>  drivers/net/hyperv/rndis_filter.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
> index 6b127be..09a3c1d 100644
> --- a/drivers/net/hyperv/rndis_filter.c
> +++ b/drivers/net/hyperv/rndis_filter.c
> @@ -1287,8 +1287,10 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
>  		   rndis_device->hw_mac_adr,
>  		   rndis_device->link_state ? "down" : "up");
>  
> -	if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5)
> +	if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5) {
> +		netif_device_attach(net);
>  		return net_device;
> +	}

Yes, this looks right, but it might be easier to use goto existing exit
path.

diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 3b6dbacaf77d..ed941c5a0be9 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -1316,7 +1316,7 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
                   rndis_device->link_state ? "down" : "up");
 
        if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5)
-               return net_device;
+               goto out;
 
        rndis_filter_query_link_speed(rndis_device, net_device);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hv_netvsc: Fix net device attach on older Windows hosts
  2018-05-08 18:13 ` Stephen Hemminger
@ 2018-05-08 18:17   ` Mohammed Gamal
  2018-05-08 22:49     ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Mohammed Gamal @ 2018-05-08 18:17 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: netdev, sthemmin, haiyangz, linux-kernel, devel, vkuznets

On Tue, 2018-05-08 at 11:13 -0700, Stephen Hemminger wrote:
> On Tue,  8 May 2018 19:40:47 +0200
> Mohammed Gamal <mgamal@redhat.com> wrote:
> 
> > On older windows hosts the net_device instance is returned to
> > the caller of rndis_filter_device_add() without having the presence
> > bit set first. This would cause any subsequent calls to network
> > device
> > operations (e.g. MTU change, channel change) to fail after the
> > device
> > is detached once, returning -ENODEV.
> > 
> > Make sure we explicitly call netif_device_attach() before returning
> > the net_device instance to make sure the presence bit is set
> > 
> > Fixes: 7b2ee50c0cd5 ("hv_netvsc: common detach logic")
> > 
> > Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
> > ---
> >  drivers/net/hyperv/rndis_filter.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/hyperv/rndis_filter.c
> > b/drivers/net/hyperv/rndis_filter.c
> > index 6b127be..09a3c1d 100644
> > --- a/drivers/net/hyperv/rndis_filter.c
> > +++ b/drivers/net/hyperv/rndis_filter.c
> > @@ -1287,8 +1287,10 @@ struct netvsc_device
> > *rndis_filter_device_add(struct hv_device *dev,
> >  		   rndis_device->hw_mac_adr,
> >  		   rndis_device->link_state ? "down" : "up");
> >  
> > -	if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5)
> > +	if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5) {
> > +		netif_device_attach(net);
> >  		return net_device;
> > +	}
> 
> Yes, this looks right, but it might be easier to use goto existing
> exit
> path.
> 

I was just not sure if we should set max_chn and num_chn here. I will
modify the patch and resend.

> diff --git a/drivers/net/hyperv/rndis_filter.c
> b/drivers/net/hyperv/rndis_filter.c
> index 3b6dbacaf77d..ed941c5a0be9 100644
> --- a/drivers/net/hyperv/rndis_filter.c
> +++ b/drivers/net/hyperv/rndis_filter.c
> @@ -1316,7 +1316,7 @@ struct netvsc_device
> *rndis_filter_device_add(struct hv_device *dev,
>                    rndis_device->link_state ? "down" : "up");
>  
>         if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5)
> -               return net_device;
> +               goto out;
>  
>         rndis_filter_query_link_speed(rndis_device, net_device);
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hv_netvsc: Fix net device attach on older Windows hosts
  2018-05-08 18:17   ` Mohammed Gamal
@ 2018-05-08 22:49     ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2018-05-08 22:49 UTC (permalink / raw)
  To: Mohammed Gamal; +Cc: netdev, sthemmin, haiyangz, linux-kernel, devel, vkuznets

On Tue, 08 May 2018 20:17:51 +0200
Mohammed Gamal <mgamal@redhat.com> wrote:

> On Tue, 2018-05-08 at 11:13 -0700, Stephen Hemminger wrote:
> > On Tue,  8 May 2018 19:40:47 +0200
> > Mohammed Gamal <mgamal@redhat.com> wrote:
> >   
> > > On older windows hosts the net_device instance is returned to
> > > the caller of rndis_filter_device_add() without having the presence
> > > bit set first. This would cause any subsequent calls to network
> > > device
> > > operations (e.g. MTU change, channel change) to fail after the
> > > device
> > > is detached once, returning -ENODEV.
> > > 
> > > Make sure we explicitly call netif_device_attach() before returning
> > > the net_device instance to make sure the presence bit is set
> > > 
> > > Fixes: 7b2ee50c0cd5 ("hv_netvsc: common detach logic")
> > > 
> > > Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
> > > ---
> > >  drivers/net/hyperv/rndis_filter.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/net/hyperv/rndis_filter.c
> > > b/drivers/net/hyperv/rndis_filter.c
> > > index 6b127be..09a3c1d 100644
> > > --- a/drivers/net/hyperv/rndis_filter.c
> > > +++ b/drivers/net/hyperv/rndis_filter.c
> > > @@ -1287,8 +1287,10 @@ struct netvsc_device
> > > *rndis_filter_device_add(struct hv_device *dev,
> > >  		   rndis_device->hw_mac_adr,
> > >  		   rndis_device->link_state ? "down" : "up");
> > >  
> > > -	if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5)
> > > +	if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_5) {
> > > +		netif_device_attach(net);
> > >  		return net_device;
> > > +	}  
> > 
> > Yes, this looks right, but it might be easier to use goto existing
> > exit
> > path.
> >   
> 
> I was just not sure if we should set max_chn and num_chn here. I will
> modify the patch and resend.


On older code it was just a goto. At that point: num_chn = max_chn = 1

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-05-08 22:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-08 17:40 [PATCH] hv_netvsc: Fix net device attach on older Windows hosts Mohammed Gamal
2018-05-08 18:13 ` Stephen Hemminger
2018-05-08 18:17   ` Mohammed Gamal
2018-05-08 22:49     ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).