Skip to content

Commit

Permalink
[NET]: fix carrier-on bug?
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jeff Garzik authored and David S. Miller committed Oct 18, 2007
1 parent 4554247 commit bfaae0f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/sched/sch_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down

0 comments on commit bfaae0f

Please sign in to comment.