netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Disable queueing when carrier is lost
@ 2005-04-26 21:53 Tommy Christensen
  2005-04-27 12:43 ` Herbert Xu
  0 siblings, 1 reply; 14+ messages in thread
From: Tommy Christensen @ 2005-04-26 21:53 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 1080 bytes --]

A while back we had a very long thread about the queueing behavior of
netdevices in a loss-of-carrier situation. This thread had the poetic
subject: [patch 4/10] s390: network driver.

The executive summary:

Certain network drivers call netif_stop_queue() when they detect a loss
of carrier. This has some unfortunate effects on the current networking
stack, since packets are now being queued up at the qdisc level for an
unbound period of time:
  *) the socket send buffer may be exhausted, preventing transmission
     to all devices (from this particular socket)
  *) resources are held "indefinitely": memory, socket/dst/module refcounts
  *) when carrier is re-established stale packets are sent out on the
     network, which could have undesirable effects

The best solution seems to be to simply disable the queueing at the qdisc
layer when this situation arises. That approach has been implemented in
the patch below. Hasso Tepper <hasso@estpak.ee> reports succesfull testing
of the patch with Quagga.

Signed-off-by: Tommy S. Christensen <tommy.christensen@tpack.net>

[-- Attachment #2: carrier.patch --]
[-- Type: text/plain, Size: 1655 bytes --]

diff -ru linux-2.6.12-rc3/net/core/link_watch.c linux-2.6.12-work/net/core/link_watch.c
--- linux-2.6.12-rc3/net/core/link_watch.c	2005-03-04 09:55:42.000000000 +0100
+++ linux-2.6.12-work/net/core/link_watch.c	2005-04-26 22:19:22.939393488 +0200
@@ -16,6 +16,7 @@
 #include <linux/netdevice.h>
 #include <linux/if.h>
 #include <net/sock.h>
+#include <net/pkt_sched.h>
 #include <linux/rtnetlink.h>
 #include <linux/jiffies.h>
 #include <linux/spinlock.h>
@@ -74,6 +75,9 @@
 		clear_bit(__LINK_STATE_LINKWATCH_PENDING, &dev->state);
 
 		if (dev->flags & IFF_UP) {
+			if (netif_carrier_ok(dev) &&
+			    dev->qdisc_sleeping != &noop_qdisc)
+				dev_activate(dev);
 			netdev_state_change(dev);
 		}
 
diff -ru linux-2.6.12-rc3/net/sched/sch_generic.c linux-2.6.12-work/net/sched/sch_generic.c
--- linux-2.6.12-rc3/net/sched/sch_generic.c	2005-03-04 09:55:44.000000000 +0100
+++ linux-2.6.12-work/net/sched/sch_generic.c	2005-04-26 22:19:22.939393488 +0200
@@ -185,6 +185,7 @@
 static void dev_watchdog(unsigned long arg)
 {
 	struct net_device *dev = (struct net_device *)arg;
+	int check_carrier = 0;
 
 	spin_lock(&dev->xmit_lock);
 	if (dev->qdisc != &noop_qdisc) {
@@ -198,10 +199,23 @@
 			}
 			if (!mod_timer(&dev->watchdog_timer, jiffies + dev->watchdog_timeo))
 				dev_hold(dev);
-		}
+		} else
+			check_carrier = 1;
 	}
 	spin_unlock(&dev->xmit_lock);
 
+	if (check_carrier) {
+		spin_lock(&dev->queue_lock);
+		if (!netif_carrier_ok(dev) && netif_queue_stopped(dev)) {
+			struct Qdisc *qdisc;
+
+			qdisc = dev->qdisc;
+			dev->qdisc = &noop_qdisc;
+			qdisc_reset(qdisc);
+		}
+		spin_unlock(&dev->queue_lock);
+	}
+
 	dev_put(dev);
 }
 

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2005-05-02 23:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-26 21:53 [PATCH] net: Disable queueing when carrier is lost Tommy Christensen
2005-04-27 12:43 ` Herbert Xu
     [not found]   ` <426FDF8B.1030808@tpack.net>
2005-04-27 21:42     ` Herbert Xu
2005-04-27 23:27       ` Tommy Christensen
2005-04-27 23:43         ` Herbert Xu
2005-04-29  9:51           ` Tommy Christensen
2005-04-29 10:18             ` Herbert Xu
2005-04-29 12:22               ` Tommy Christensen
2005-04-29 23:45                 ` Herbert Xu
2005-04-30  0:46                   ` Herbert Xu
2005-04-30 12:59                     ` Tommy Christensen
2005-04-30 12:57                   ` Tommy Christensen
2005-05-01  8:11                     ` Herbert Xu
2005-05-02 23:00                       ` Tommy Christensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).