Commit bfaae0f0 authored by Jeff Garzik's avatar Jeff Garzik Committed by David S. Miller

[NET]: fix carrier-on bug?

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: default avatarJeff Garzik <jgarzik@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 45542479
...@@ -249,10 +249,11 @@ static void dev_watchdog_down(struct net_device *dev) ...@@ -249,10 +249,11 @@ static void dev_watchdog_down(struct net_device *dev)
*/ */
void netif_carrier_on(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); linkwatch_fire_event(dev);
if (netif_running(dev)) if (netif_running(dev))
__netdev_watchdog_up(dev); __netdev_watchdog_up(dev);
}
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment