Skip to contentSkip to conversation

: Avoid duplicate netlink notification when changing link state

NET Thomas Graf 2 participants 2 messages Jun 5, 2007

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

When changing the link state from userspace not affecting any other flags. Two duplicate notification are being sent, once as action in the NETDEV_UP/NETDEV_DOWN notification chain and a second time when comparing old and new device flags after the change has been completed. Although harmless, the duplicates should be avoided.

net/core/dev.c +5 -3
Index: net-2.6/net/core/dev.c
===================================================================
@@ -2577,7 +2577,7 @@ unsigned dev_get_flags(const struct net_
 
 int dev_change_flags(struct net_device *dev, unsigned flags)
 {
-	int ret;
+	int ret, changes;
 	int old_flags = dev->flags;
 
 	/*
@@ -2632,8 +2632,10 @@ int dev_change_flags(struct net_device *
 		dev_set_allmulti(dev, inc);
 	}
 
-	if (old_flags ^ dev->flags)
-		rtmsg_ifinfo(RTM_NEWLINK, dev, old_flags ^ dev->flags);
+	/* Exclude state transition flags, already notified */
+	changes = (old_flags ^ dev->flags) & ~(IFF_UP | IFF_RUNNING);
+	if (changes)
+		rtmsg_ifinfo(RTM_NEWLINK, dev, changes);
 
 	return ret;
 }
maintainer
#1 lore raw

From: Thomas Graf <[email protected]>
Date: Wed, 6 Jun 2007 00:54:53 +0200

Quoted 7 lines

When changing the link state from userspace not affecting any other flags. Two duplicate notification are being sent, once as action in the NETDEV_UP/NETDEV_DOWN notification chain and a second time when comparing old and new device flags after the change has been completed. Although harmless, the duplicates should be avoided.

Thanks for fixing this, patch applied.