diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-11-13 16:54:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-16 01:08:05 -0500 |
commit | ed04642f753b1240fc65c2978b7365e93209972a (patch) | |
tree | 33222d72237e487050116c70849a932dc657fd24 /net/core | |
parent | 9c2b5bdee125d840b2023dcc7625353c8e5bb10c (diff) |
net: check the return value of ndo_select_queue()
Check the return value of ndo_select_queue(). If the value isn't smaller
than the real_num_tx_queues, print a warning message, and reset it to zero.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
----
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 548340b57296..32045df1da5c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1848,6 +1848,20 @@ u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb) | |||
1848 | } | 1848 | } |
1849 | EXPORT_SYMBOL(skb_tx_hash); | 1849 | EXPORT_SYMBOL(skb_tx_hash); |
1850 | 1850 | ||
1851 | static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index) | ||
1852 | { | ||
1853 | if (unlikely(queue_index >= dev->real_num_tx_queues)) { | ||
1854 | if (net_ratelimit()) { | ||
1855 | WARN(1, "%s selects TX queue %d, but " | ||
1856 | "real number of TX queues is %d\n", | ||
1857 | dev->name, queue_index, | ||
1858 | dev->real_num_tx_queues); | ||
1859 | } | ||
1860 | return 0; | ||
1861 | } | ||
1862 | return queue_index; | ||
1863 | } | ||
1864 | |||
1851 | static struct netdev_queue *dev_pick_tx(struct net_device *dev, | 1865 | static struct netdev_queue *dev_pick_tx(struct net_device *dev, |
1852 | struct sk_buff *skb) | 1866 | struct sk_buff *skb) |
1853 | { | 1867 | { |
@@ -1861,6 +1875,7 @@ static struct netdev_queue *dev_pick_tx(struct net_device *dev, | |||
1861 | 1875 | ||
1862 | if (ops->ndo_select_queue) { | 1876 | if (ops->ndo_select_queue) { |
1863 | queue_index = ops->ndo_select_queue(dev, skb); | 1877 | queue_index = ops->ndo_select_queue(dev, skb); |
1878 | queue_index = dev_cap_txqueue(dev, queue_index); | ||
1864 | } else { | 1879 | } else { |
1865 | queue_index = 0; | 1880 | queue_index = 0; |
1866 | if (dev->real_num_tx_queues > 1) | 1881 | if (dev->real_num_tx_queues > 1) |