Skip to contentSkip to conversation

register_netdevice and sysfs changes

PATCH In review Stephen Hemminger 2 participants 4 messages May 10, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover register_netdevice and sysfs changes

This is a signed-off version of yesterday's fix, plus the bridge code no longer needs to be so tricky.
--

#1 lore raw

PATCH 1/2 netdev: do sysfs registration as part of register_netdevice

The last step of netdevice registration was being done by a delayed call, but because it was delayed, it was impossible to return any error code if the class_device registration failed.

Side effects:
* one state in registration process is unnecessary.
* register_netdevice can sleep inside class_device registration/hotplug
* code in netdev_run_todo only does unregistration so it is simpler.

include/linux/netdevice.h +1 -2
@@ -433,8 +433,7 @@
 
 	/* register/unregister state machine */
 	enum { NETREG_UNINITIALIZED=0,
-	       NETREG_REGISTERING,	/* called register_netdevice */
-	       NETREG_REGISTERED,	/* completed register todo */
+	       NETREG_REGISTERED,	/* completed register_netdevice */
 	       NETREG_UNREGISTERING,	/* called unregister_netdevice */
 	       NETREG_UNREGISTERED,	/* completed unregister todo */
 	       NETREG_RELEASED,		/* called free_netdev */
net/core/dev.c +28 -37

109 lines not on this page · raw message

--

#2 lore raw

PATCH 2/2 bridge: do sysfs registration inside rtnl

In reply to Stephen Hemminger

Now that netdevice sysfs registration is done as part of register_netdevice; bridge code no longer has to be tricky when adding it's kobjects to bridges.

net/bridge/br_if.c +7 -14
@@ -308,26 +308,19 @@
 	if (ret)
 		goto err2;
 
-	/* network device kobject is not setup until
-	 * after rtnl_unlock does it's hotplug magic.
-	 * so hold reference to avoid race.
-	 */
-	dev_hold(dev);
-	rtnl_unlock();
-
 	ret = br_sysfs_addbr(dev);
-	dev_put(dev);
-
-	if (ret) 
-		unregister_netdev(dev);
- out:
-	return ret;
+	if (ret)
+		goto err3;
+	rtnl_unlock();
+	return 0;
 
+ err3:
+	unregister_netdev(dev);
  err2:
 	free_netdev(dev);
  err1:
 	rtnl_unlock();
-	goto out;
+	return ret;
 }
 
 int br_del_bridge(const char *name)

--

maintainer
#3 lore raw
In reply to Stephen Hemminger

From: Stephen Hemminger <[email protected]>
Date: Wed, 10 May 2006 10:14:52 -0700

Quoted 2 lines

This is a signed-off version of yesterday's fix, plus the bridge code no longer needs to be so tricky.

I'll apply this stuff, thanks a lot.

Although since I have the blocking --> raw notifier fixup in my tree I'll need to fixup the rejects in the net/core/dev.c part of the first patch.

Thanks.