summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2009-12-13 22:39:28 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-18 13:44:21 -0800
commit0723f2f0124da4cb5ccf260bebfa703b24c199a4 (patch)
treebf4ed258729370a8c91a5de82a5c21ed7339204c
parent945d9a8325f6bc1f9fcb4221e5f8dab93e9e6718 (diff)
downloadlwn-0723f2f0124da4cb5ccf260bebfa703b24c199a4.tar.gz
lwn-0723f2f0124da4cb5ccf260bebfa703b24c199a4.zip
net: Fix userspace RTM_NEWLINK notifications.
commit d90a909e1f3e006a1d57fe11fd417173b6494701 upstream. I received some bug reports about userspace programs having problems because after RTM_NEWLINK was received they could not immeidate access files under /proc/sys/net/ because they had not been registered yet. The problem was trivailly fixed by moving the userspace notification from rtnetlink_event to the end of register_netdevice. Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com> Cc: David Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--net/core/dev.c11
-rw-r--r--net/core/rtnetlink.c4
2 files changed, 12 insertions, 3 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 1bb5f4a8c217..42250978df88 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4808,6 +4808,11 @@ int register_netdevice(struct net_device *dev)
rollback_registered(dev);
dev->reg_state = NETREG_UNREGISTERED;
}
+ /*
+ * Prevent userspace races by waiting until the network
+ * device is fully setup before sending notifications.
+ */
+ rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
out:
return ret;
@@ -5343,6 +5348,12 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char
/* Notify protocols, that a new device appeared. */
call_netdevice_notifiers(NETDEV_REGISTER, dev);
+ /*
+ * Prevent userspace races by waiting until the network
+ * device is fully setup before sending notifications.
+ */
+ rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
+
synchronize_net();
err = 0;
out:
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index d78030f88bd0..93f18454ef1d 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1347,13 +1347,11 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi
case NETDEV_UNREGISTER:
rtmsg_ifinfo(RTM_DELLINK, dev, ~0U);
break;
- case NETDEV_REGISTER:
- rtmsg_ifinfo(RTM_NEWLINK, dev, ~0U);
- break;
case NETDEV_UP:
case NETDEV_DOWN:
rtmsg_ifinfo(RTM_NEWLINK, dev, IFF_UP|IFF_RUNNING);
break;
+ case NETDEV_REGISTER:
case NETDEV_CHANGE:
case NETDEV_GOING_DOWN:
break;