Skip to contentSkip to conversation

pktgen: check for link down

PATCH In review Stephen Hemminger 3 participants 4 messages Sep 20, 2009 – Sep 22, 2009

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

PATCH 1/2 pktgen: check for link down

If cable is pulled, pktgen shouldn't continue slamming packets into the device.

net/core/pktgen.c +2 -2
@@ -1959,7 +1959,7 @@ static int pktgen_setup_dev(struct pktge
 	if (odev->type != ARPHRD_ETHER) {
 		printk(KERN_ERR "pktgen: not an ethernet device: \"%s\"\n", ifname);
 		err = -EINVAL;
-	} else if (!netif_running(odev)) {
+	} else if (!netif_running(odev) || !netif_carrier_ok(odev)) {
 		printk(KERN_ERR "pktgen: device is down: \"%s\"\n", ifname);
 		err = -ENETDOWN;
 	} else {
@@ -3410,7 +3410,7 @@ static void pktgen_xmit(struct pktgen_de
 	/* Did we saturate the queue already? */
 	if (netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq)) {
 		/* If device is down, then all queues are permnantly frozen */
-		if (netif_running(odev))
+		if (netif_running(odev) && netif_carrier_ok(odev))
 			idle(pkt_dev);
 		else
 			pktgen_stop_device(pkt_dev);
Acked-by on v1 1/2
#1 lore raw

Thanks for fixing this.

Quoted 17 lines · Stephen Hemminger

If cable is pulled, pktgen shouldn't continue slamming packets into the device.

net/core/pktgen.c +1 -1
@@ -1959,7 +1959,7 @@ static int pktgen_setup_dev(struct pktge
 	if (odev->type != ARPHRD_ETHER) {
 		printk(KERN_ERR "pktgen: not an ethernet device: \"%s\"\n", ifname);
 		err = -EINVAL;
-	} else if (!netif_running(odev)) {
+	} else if (!netif_running(odev) || !netif_carrier_ok(odev)) {
 		printk(KERN_ERR "pktgen: device is down: \"%s\"\n", ifname);
 		err = -ENETDOWN;
 	} else {

net/core/pktgen.c static void pktgen_xmit(struct pktgen_de · line 3416

Quoted 8 lines
net/core/pktgen.c +1 -1
@@ -3410,7 +3410,7 @@ static void pktgen_xmit(struct pktgen_de
 	/* Did we saturate the queue already? */
 	if (netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq)) {
 		/* If device is down, then all queues are permnantly frozen */
-		if (netif_running(odev))
+		if (netif_running(odev) && netif_carrier_ok(odev))
 			idle(pkt_dev);
 		else
 			pktgen_stop_device(pkt_dev);

Hilsen
Jesper Brouer

--
-------------------------------------------------------------------
MSc. Master of Computer Science
Dept. of Computer Science, University of Copenhagen Author of http://www.adsl-optimizer.dk
-------------------------------------------------------------------

#2 lore raw
In reply to Stephen Hemminger
Quoted 17 lines · On Sat, 19 Sep 2009 22:18:44 -0700 Stephen Hemminger <[email protected]>…

If cable is pulled, pktgen shouldn't continue slamming packets into the device.

net/core/pktgen.c +1 -1
@@ -1959,7 +1959,7 @@ static int pktgen_setup_dev(struct pktge
 	if (odev->type != ARPHRD_ETHER) {
 		printk(KERN_ERR "pktgen: not an ethernet device: \"%s\"\n", ifname);
 		err = -EINVAL;
-	} else if (!netif_running(odev)) {
+	} else if (!netif_running(odev) || !netif_carrier_ok(odev)) {
 		printk(KERN_ERR "pktgen: device is down: \"%s\"\n", ifname);
 		err = -ENETDOWN;
 	} else {

net/core/pktgen.c static void pktgen_xmit(struct pktgen_de · line 3416

Quoted 8 lines
net/core/pktgen.c +1 -1
@@ -3410,7 +3410,7 @@ static void pktgen_xmit(struct pktgen_de
 	/* Did we saturate the queue already? */
 	if (netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq)) {
 		/* If device is down, then all queues are permnantly frozen */
-		if (netif_running(odev))
+		if (netif_running(odev) && netif_carrier_ok(odev))
 			idle(pkt_dev);
 		else
 			pktgen_stop_device(pkt_dev);

You can hold off on these two patches, I have better version which fixes some other issues. But testing time is limited this week.

maintainer
#3 lore raw

From: Stephen Hemminger <[email protected]>
Date: Mon, 21 Sep 2009 22:55:43 -0700

Quoted 2 lines

You can hold off on these two patches, I have better version which fixes some other issues. But testing time is limited this week.

Ok