From: Tommy Christensen <tommy.christensen@tpack.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@oss.sgi.com
Subject: [PATCH] net: Disable queueing when carrier is lost
Date: Tue, 26 Apr 2005 23:53:16 +0200 [thread overview]
Message-ID: <426EB84C.90307@tpack.net> (raw)
[-- 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);
}
next reply other threads:[~2005-04-26 21:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-26 21:53 Tommy Christensen [this message]
2005-04-27 12:43 ` [PATCH] net: Disable queueing when carrier is lost 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=426EB84C.90307@tpack.net \
--to=tommy.christensen@tpack.net \
--cc=davem@davemloft.net \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).