net: Do not fire linkwatch events until the device is registered.

Several device drivers try to do things like netif_carrier_off()
before register_netdev() is invoked. This is bogus, but too many
drivers do this to fix them all up in one go.

Reported-by: Folkert van Heusden <folkert@vanheusden.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

+6 -1
+6 -1
net/sched/sch_generic.c
··· 270 void netif_carrier_on(struct net_device *dev) 271 { 272 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) { 273 linkwatch_fire_event(dev); 274 if (netif_running(dev)) 275 __netdev_watchdog_up(dev); ··· 287 */ 288 void netif_carrier_off(struct net_device *dev) 289 { 290 - if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) 291 linkwatch_fire_event(dev); 292 } 293 EXPORT_SYMBOL(netif_carrier_off); 294
··· 270 void netif_carrier_on(struct net_device *dev) 271 { 272 if (test_and_clear_bit(__LINK_STATE_NOCARRIER, &dev->state)) { 273 + if (dev->reg_state == NETREG_UNINITIALIZED) 274 + return; 275 linkwatch_fire_event(dev); 276 if (netif_running(dev)) 277 __netdev_watchdog_up(dev); ··· 285 */ 286 void netif_carrier_off(struct net_device *dev) 287 { 288 + if (!test_and_set_bit(__LINK_STATE_NOCARRIER, &dev->state)) { 289 + if (dev->reg_state == NETREG_UNINITIALIZED) 290 + return; 291 linkwatch_fire_event(dev); 292 + } 293 } 294 EXPORT_SYMBOL(netif_carrier_off); 295