diff mbox

netvsc: don't access netdev->num_rx_queues directly

Message ID 20170621221714.278724-1-arnd@arndb.de
State Accepted
Commit b92b7d3312033a08cae2c879b9243c42ad7de94b
Headers show

Commit Message

Arnd Bergmann June 21, 2017, 10:16 p.m. UTC
This structure member is hidden behind CONFIG_SYSFS, and we
get a build error when that is disabled:

drivers/net/hyperv/netvsc_drv.c: In function 'netvsc_set_channels':
drivers/net/hyperv/netvsc_drv.c:754:49: error: 'struct net_device' has no member named 'num_rx_queues'; did you mean 'num_tx_queues'?
drivers/net/hyperv/netvsc_drv.c: In function 'netvsc_set_rxfh':
drivers/net/hyperv/netvsc_drv.c:1181:25: error: 'struct net_device' has no member named 'num_rx_queues'; did you mean 'num_tx_queues'?

As the value is only set once to the argument of alloc_netdev_mq(),
we can compare against that constant directly.

Fixes: ff4a44199012 ("netvsc: allow get/set of RSS indirection table")
Fixes: 2b01888d1b45 ("netvsc: allow more flexible setting of number of channels")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/net/hyperv/netvsc_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.9.0

Comments

Stephen Hemminger June 21, 2017, 11:19 p.m. UTC | #1
On Thu, 22 Jun 2017 00:16:37 +0200
Arnd Bergmann <arnd@arndb.de> wrote:

> This structure member is hidden behind CONFIG_SYSFS, and we

> get a build error when that is disabled:

> 

> drivers/net/hyperv/netvsc_drv.c: In function 'netvsc_set_channels':

> drivers/net/hyperv/netvsc_drv.c:754:49: error: 'struct net_device' has no member named 'num_rx_queues'; did you mean 'num_tx_queues'?

> drivers/net/hyperv/netvsc_drv.c: In function 'netvsc_set_rxfh':

> drivers/net/hyperv/netvsc_drv.c:1181:25: error: 'struct net_device' has no member named 'num_rx_queues'; did you mean 'num_tx_queues'?

> 

> As the value is only set once to the argument of alloc_netdev_mq(),

> we can compare against that constant directly.

> 

> Fixes: ff4a44199012 ("netvsc: allow get/set of RSS indirection table")

> Fixes: 2b01888d1b45 ("netvsc: allow more flexible setting of number of channels")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Yes this makes sense. The checks when changing values with ethtool are to avoid
to large a value > 64.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
David Miller June 22, 2017, 5:28 p.m. UTC | #2
From: Arnd Bergmann <arnd@arndb.de>

Date: Thu, 22 Jun 2017 00:16:37 +0200

> This structure member is hidden behind CONFIG_SYSFS, and we

> get a build error when that is disabled:

> 

> drivers/net/hyperv/netvsc_drv.c: In function 'netvsc_set_channels':

> drivers/net/hyperv/netvsc_drv.c:754:49: error: 'struct net_device' has no member named 'num_rx_queues'; did you mean 'num_tx_queues'?

> drivers/net/hyperv/netvsc_drv.c: In function 'netvsc_set_rxfh':

> drivers/net/hyperv/netvsc_drv.c:1181:25: error: 'struct net_device' has no member named 'num_rx_queues'; did you mean 'num_tx_queues'?

> 

> As the value is only set once to the argument of alloc_netdev_mq(),

> we can compare against that constant directly.

> 

> Fixes: ff4a44199012 ("netvsc: allow get/set of RSS indirection table")

> Fixes: 2b01888d1b45 ("netvsc: allow more flexible setting of number of channels")

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>


Applied and queued up for -stable, thank you.
diff mbox

Patch

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9a6c5864bc04..a284bfe991ba 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -751,7 +751,7 @@  static int netvsc_set_channels(struct net_device *net,
 	    channels->rx_count || channels->tx_count || channels->other_count)
 		return -EINVAL;
 
-	if (count > net->num_tx_queues || count > net->num_rx_queues)
+	if (count > net->num_tx_queues || count > VRSS_CHANNEL_MAX)
 		return -EINVAL;
 
 	if (!nvdev || nvdev->destroy)
@@ -1178,7 +1178,7 @@  static int netvsc_set_rxfh(struct net_device *dev, const u32 *indir,
 	rndis_dev = ndev->extension;
 	if (indir) {
 		for (i = 0; i < ITAB_NUM; i++)
-			if (indir[i] >= dev->num_rx_queues)
+			if (indir[i] >= VRSS_CHANNEL_MAX)
 				return -EINVAL;
 
 		for (i = 0; i < ITAB_NUM; i++)