[2/2] xen-netfront: Update features after registering netdev

Message ID 1531407011-403-3-git-send-email-stefan.bader@canonical.com
State New
Headers show
Series
  • Untitled series #55175
Related show

Commit Message

Stefan Bader July 12, 2018, 2:50 p.m.
From: Ross Lagerwall <ross.lagerwall@citrix.com>

Update the features after calling register_netdev() otherwise the
device features are not set up correctly and it not possible to change
the MTU of the device. After this change, the features reported by
ethtool match the device's features before the commit which introduced
the issue and it is possible to change the device's MTU.

Fixes: f599c64fdf7d ("xen-netfront: Fix race between device setup and open")
Reported-by: Liam Shepherd <liam@dancer.es>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

BugLink: https://bugs.launchpad.net/bugs/1781413

(cherry picked from commit 45c8184c1bed1ca8a7f02918552063a00b909bf5)
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 drivers/net/xen-netfront.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Colin Ian King July 12, 2018, 3:08 p.m. | #1
On 12/07/18 15:50, Stefan Bader wrote:
> From: Ross Lagerwall <ross.lagerwall@citrix.com>
> 
> Update the features after calling register_netdev() otherwise the
> device features are not set up correctly and it not possible to change
> the MTU of the device. After this change, the features reported by
> ethtool match the device's features before the commit which introduced
> the issue and it is possible to change the device's MTU.
> 
> Fixes: f599c64fdf7d ("xen-netfront: Fix race between device setup and open")
> Reported-by: Liam Shepherd <liam@dancer.es>
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> Reviewed-by: Juergen Gross <jgross@suse.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> BugLink: https://bugs.launchpad.net/bugs/1781413
> 
> (cherry picked from commit 45c8184c1bed1ca8a7f02918552063a00b909bf5)
> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  drivers/net/xen-netfront.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
> index f4479b9..055e92c 100644
> --- a/drivers/net/xen-netfront.c
> +++ b/drivers/net/xen-netfront.c
> @@ -1968,10 +1968,6 @@ static int xennet_connect(struct net_device *dev)
>  	/* talk_to_netback() sets the correct number of queues */
>  	num_queues = dev->real_num_tx_queues;
>  
> -	rtnl_lock();
> -	netdev_update_features(dev);
> -	rtnl_unlock();
> -
>  	if (dev->reg_state == NETREG_UNINITIALIZED) {
>  		err = register_netdev(dev);
>  		if (err) {
> @@ -1981,6 +1977,10 @@ static int xennet_connect(struct net_device *dev)
>  		}
>  	}
>  
> +	rtnl_lock();
> +	netdev_update_features(dev);
> +	rtnl_unlock();
> +
>  	/*
>  	 * All public and private state should now be sane.  Get
>  	 * ready to start sending and receiving packets and give the driver
> 

Clean cherry pick, looks ok to me.

Acked-by: Colin Ian King <colin.king@canonical.com>

Patch

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index f4479b9..055e92c 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1968,10 +1968,6 @@  static int xennet_connect(struct net_device *dev)
 	/* talk_to_netback() sets the correct number of queues */
 	num_queues = dev->real_num_tx_queues;
 
-	rtnl_lock();
-	netdev_update_features(dev);
-	rtnl_unlock();
-
 	if (dev->reg_state == NETREG_UNINITIALIZED) {
 		err = register_netdev(dev);
 		if (err) {
@@ -1981,6 +1977,10 @@  static int xennet_connect(struct net_device *dev)
 		}
 	}
 
+	rtnl_lock();
+	netdev_update_features(dev);
+	rtnl_unlock();
+
 	/*
 	 * All public and private state should now be sane.  Get
 	 * ready to start sending and receiving packets and give the driver