diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2009-11-13 22:54:04 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-16 07:08:05 +0100 |
commit | ed04642f753b1240fc65c2978b7365e93209972a (patch) | |
tree | 33222d72237e487050116c70849a932dc657fd24 /net/core/dev.c | |
parent | netxen: update MAINTAINERS (diff) | |
download | linux-ed04642f753b1240fc65c2978b7365e93209972a.tar.xz linux-ed04642f753b1240fc65c2978b7365e93209972a.zip |
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/dev.c')
-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) } EXPORT_SYMBOL(skb_tx_hash); +static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index) +{ + if (unlikely(queue_index >= dev->real_num_tx_queues)) { + if (net_ratelimit()) { + WARN(1, "%s selects TX queue %d, but " + "real number of TX queues is %d\n", + dev->name, queue_index, + dev->real_num_tx_queues); + } + return 0; + } + return queue_index; +} + static struct netdev_queue *dev_pick_tx(struct net_device *dev, struct sk_buff *skb) { @@ -1861,6 +1875,7 @@ static struct netdev_queue *dev_pick_tx(struct net_device *dev, if (ops->ndo_select_queue) { queue_index = ops->ndo_select_queue(dev, skb); + queue_index = dev_cap_txqueue(dev, queue_index); } else { queue_index = 0; if (dev->real_num_tx_queues > 1) |