Skip to contentSkip to conversation

check the return value of ndo_select_queue()

PATCH In review Changli Gao 2 participants 4 messages Nov 9, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 check the return value of ndo_select_queue()

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.

----
net/core/dev.c | 11 +++++++++--

1 file changed, 9 insertions(+), 2 deletions(-)
net/core/dev.c +9 -2
index b8f74cf..edf5ea6 100644
@@ -1794,10 +1794,17 @@ static struct netdev_queue *dev_pick_tx(struct net_device *dev,
 	const struct net_device_ops *ops = dev->netdev_ops;
 	u16 queue_index = 0;
 
-	if (ops->ndo_select_queue)
+	if (ops->ndo_select_queue) {
 		queue_index = ops->ndo_select_queue(dev, skb);
-	else if (dev->real_num_tx_queues > 1)
+		if (queue_index >= dev->real_num_tx_queues) {
+			printk(KERN_WARNING "%s selects TX queue %d, "
+			       "but real number of TX queues is %d\n",
+			       dev->name, queue_index, dev->real_num_tx_queues);
+			queue_index = 0;
+		}
+	} else if (dev->real_num_tx_queues > 1) {
 		queue_index = skb_tx_hash(dev, skb);
+	}
 
 	skb_set_queue_mapping(skb, queue_index);
 	return netdev_get_tx_queue(dev, queue_index);
maintainer
#1 lore raw

From: Changli Gao <[email protected]>
Date: Mon, 09 Nov 2009 15:17:17 +0800

Quoted 6 lines

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.

Make it a WARN() so that it ends up in kerneloops.org

#2 lore raw
Quoted 12 lines · David Miller

From: Changli Gao <[email protected]>
Date: Mon, 09 Nov 2009 15:17:17 +0800

Quoted 6 lines

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.

Make it a WARN() so that it ends up in kerneloops.org

Like this?
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);

Signature · 2 lines
Regards,
Changli Gao([email protected])
maintainer
#3 lore raw

From: Changli Gao <[email protected]>
Date: Mon, 9 Nov 2009 16:44:05 +0800

Quoted 9 lines · David Miller
Quoted 8 lines

From: Changli Gao <[email protected]>
Date: Mon, 09 Nov 2009 15:17:17 +0800

Quoted 5 lines

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.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Make it a WARN() so that it ends up in kerneloops.org

Like this?
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);

Yes, something like that.