* [PATCH/RFA] sch_generic: fix carrier-on bug?
@ 2007-10-16 21:55 Jeff Garzik
2007-10-18 6:26 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Garzik @ 2007-10-16 21:55 UTC (permalink / raw)
To: David Miller; +Cc: netdev, LKML
While looking at a net driver with the following construct,
if (!netif_carrier_ok(dev))
netif_carrier_on(dev);
it stuck me that the netif_carrier_ok() check was redundant, since
netif_carrier_on() checks bit __LINK_STATE_NOCARRIER anyway. This is
the same reason why netif_queue_stopped() need not be called prior to
netif_wake_queue().
This is true, but there is however an unwanted side effect from assuming
that netif_carrier_on() can be called multiple times: it touches the
watchdog, regardless of pre-existing carrier state.
The fix: move watchdog-up inside the bit-cleared code path.
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
This looks like an obvious bug fix to me, but I found it by reading code
rather than hitting it in the field. Review appreciated.
net/sched/sch_generic.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 95ae119..e01d576 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -249,10 +249,11 @@ static void dev_watchdog_down(struct net_device *dev)
*/
void netif_carrier_on(struct net_device *dev)
{
- if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state))
+ if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) {
linkwatch_fire_event(dev);
- if (netif_running(dev))
- __netdev_watchdog_up(dev);
+ if (netif_running(dev))
+ __netdev_watchdog_up(dev);
+ }
}
/**
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH/RFA] sch_generic: fix carrier-on bug?
2007-10-16 21:55 [PATCH/RFA] sch_generic: fix carrier-on bug? Jeff Garzik
@ 2007-10-18 6:26 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-10-18 6:26 UTC (permalink / raw)
To: jeff; +Cc: netdev, linux-kernel
From: Jeff Garzik <jeff@garzik.org>
Date: Tue, 16 Oct 2007 17:55:55 -0400
> While looking at a net driver with the following construct,
>
> if (!netif_carrier_ok(dev))
> netif_carrier_on(dev);
>
> it stuck me that the netif_carrier_ok() check was redundant, since
> netif_carrier_on() checks bit __LINK_STATE_NOCARRIER anyway. This is
> the same reason why netif_queue_stopped() need not be called prior to
> netif_wake_queue().
>
> This is true, but there is however an unwanted side effect from assuming
> that netif_carrier_on() can be called multiple times: it touches the
> watchdog, regardless of pre-existing carrier state.
>
> The fix: move watchdog-up inside the bit-cleared code path.
>
> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
I see no problems with this patch, I'll apply it, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-10-18 6:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-16 21:55 [PATCH/RFA] sch_generic: fix carrier-on bug? Jeff Garzik
2007-10-18 6:26 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox