Patchwork [1/2] pktgen: check for link down

login
register
mail settings
Submitter stephen hemminger
Date Sept. 20, 2009, 5:18 a.m.
Message ID <20090919221844.114e2e23@nehalam>
Download mbox | patch
Permalink /patch/33955/
State Deferred
Delegated to: David Miller
Headers show

Comments

stephen hemminger - Sept. 20, 2009, 5:18 a.m.
If cable is pulled, pktgen shouldn't continue slamming packets into the
device.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jesper Dangaard Brouer - Sept. 20, 2009, 3:26 p.m.
Thanks for fixing this.

Acked-by: Jesper Dangaard Brouer <hawk@comx.dk>


On Sat, 19 Sep 2009, Stephen Hemminger wrote:

> If cable is pulled, pktgen shouldn't continue slamming packets into the
> device.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> --- a/net/core/pktgen.c	2009-09-19 11:20:55.546463176 -0700
> +++ b/net/core/pktgen.c	2009-09-19 11:22:44.810509240 -0700
> @@ -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);

Hilsen
   Jesper Brouer

--
-------------------------------------------------------------------
MSc. Master of Computer Science
Dept. of Computer Science, University of Copenhagen
Author of http://www.adsl-optimizer.dk
-------------------------------------------------------------------
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
stephen hemminger - Sept. 22, 2009, 5:55 a.m.
On Sat, 19 Sep 2009 22:18:44 -0700
Stephen Hemminger <shemminger@vyatta.com> wrote:

> If cable is pulled, pktgen shouldn't continue slamming packets into the
> device.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> --- a/net/core/pktgen.c	2009-09-19 11:20:55.546463176 -0700
> +++ b/net/core/pktgen.c	2009-09-19 11:22:44.810509240 -0700
> @@ -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);

You can hold off on these two patches, I have better version
which fixes some other issues. But testing time is limited this week.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Sept. 22, 2009, 9:24 p.m.
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 21 Sep 2009 22:55:43 -0700

> 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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/net/core/pktgen.c	2009-09-19 11:20:55.546463176 -0700
+++ b/net/core/pktgen.c	2009-09-19 11:22:44.810509240 -0700
@@ -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);