Skip to contentSkip to conversation

ipv4: arp_notify address list bug

PATCH In review Stephen Hemminger 4 participants 8 messages Oct 6, 2009 – Oct 7, 2009

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

PATCH 1/1 ipv4: arp_notify address list bug

This fixes a bug with arp_notify and also adds a small enhancement.

If arp_notify is enabled, kernel will crash if address is changed and no IP address is assigned.
http://bugzilla.kernel.org/show_bug.cgi?id=14330

The fix is to walk the (possibly empty) list when sending the gratuitous ARP's.

---
This should go to stable kernel fixes as well.

net/ipv4/devinet.c +9 -6
@@ -1077,12 +1077,15 @@ static int inetdev_event(struct notifier
 		ip_mc_up(in_dev);
 		/* fall through */
 	case NETDEV_CHANGEADDR:
-		if (IN_DEV_ARP_NOTIFY(in_dev))
-			arp_send(ARPOP_REQUEST, ETH_P_ARP,
-				 in_dev->ifa_list->ifa_address,
-				 dev,
-				 in_dev->ifa_list->ifa_address,
-				 NULL, dev->dev_addr, NULL);
+		/* Send gratitious ARP to notify of link change */
+		if (IN_DEV_ARP_NOTIFY(in_dev)) {
+			struct in_ifaddr *ifa;
+			for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next)
+				arp_send(ARPOP_REQUEST, ETH_P_ARP,
+					 ifa->ifa_address, dev,
+					 ifa->ifa_address, NULL,
+					 dev->dev_addr, NULL);
+		}
 		break;
 	case NETDEV_DOWN:
 		ip_mc_down(in_dev);
#1 lore raw

net/ipv4/devinet.c static int inetdev_event(struct notifier · line 1080

Quoted 12 lines · Stephen Hemminger

This fixes a bug with arp_notify and also adds a small enhancement.

If arp_notify is enabled, kernel will crash if address is changed and no IP address is assigned.
http://bugzilla.kernel.org/show_bug.cgi?id=14330

The fix is to walk the (possibly empty) list when sending the gratuitous ARP's.

net/ipv4/devinet.c +1 -1
-				 NULL, dev->dev_addr, NULL);
+		/* Send gratitious ARP to notify of link change */
	/* gratuitous */

net/ipv4/devinet.c static int inetdev_event(struct notifier · line 1088

Quoted 8 lines
net/ipv4/devinet.c +8 -0
+		if (IN_DEV_ARP_NOTIFY(in_dev)) {
+			struct in_ifaddr *ifa;
+			for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next)
+				arp_send(ARPOP_REQUEST, ETH_P_ARP,
+					 ifa->ifa_address, dev,
+					 ifa->ifa_address, NULL,
+					 dev->dev_addr, NULL);
+		}

This sends a broadcast storm if device has a long address list.

Maybe we should change arp_notify to an INTEGER to be able to give a limit.

If people used to set arp_notify to 1, they wont be surprised too much.

I suggest splitting patch in two parts, one to fix the bug for linux-2.6 and stable, and another one for net-next-2.6 for the enhancement ?

Thanks

maintainer
#2 lore raw

From: Eric Dumazet <[email protected]>
Date: Tue, 06 Oct 2009 05:13:00 +0200

Quoted 3 lines

I suggest splitting patch in two parts, one to fix the bug for linux-2.6 and stable, and another one for net-next-2.6 for the enhancement ?

Good idea.

#3 lore raw

PATCH 1/1 ipv4: arp_notify address list bug

From: Stephen Hemminger <[email protected]>

This fixes a bug with arp_notify.

If arp_notify is enabled, kernel will crash if address is changed and no IP address is assigned.
http://bugzilla.kernel.org/show_bug.cgi?id=14330

---
 net/ipv4/devinet.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
net/ipv4/devinet.c +10 -6
index e92f1fd..5df2f6a 100644
@@ -1077,12 +1077,16 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
 		ip_mc_up(in_dev);
 		/* fall through */
 	case NETDEV_CHANGEADDR:
-		if (IN_DEV_ARP_NOTIFY(in_dev))
-			arp_send(ARPOP_REQUEST, ETH_P_ARP,
-				 in_dev->ifa_list->ifa_address,
-				 dev,
-				 in_dev->ifa_list->ifa_address,
-				 NULL, dev->dev_addr, NULL);
+		/* Send gratuitous ARP to notify of link change */
+		if (IN_DEV_ARP_NOTIFY(in_dev)) {
+			struct in_ifaddr *ifa = in_dev->ifa_list;
+
+			if (ifa)
+				arp_send(ARPOP_REQUEST, ETH_P_ARP,
+					 ifa->ifa_address, dev,
+					 ifa->ifa_address, NULL,
+					 dev->dev_addr, NULL);
+		}
 		break;
 	case NETDEV_DOWN:
 		ip_mc_down(in_dev);
#4 lore raw
Quoted 32 lines · On Tue, 06 Oct 2009 07:20:19 +0200 Eric Dumazet <[email protected]> wrote:

From: Stephen Hemminger <[email protected]>

This fixes a bug with arp_notify.

If arp_notify is enabled, kernel will crash if address is changed and no IP address is assigned.
http://bugzilla.kernel.org/show_bug.cgi?id=14330

---
 net/ipv4/devinet.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)
net/ipv4/devinet.c +3 -6
index e92f1fd..5df2f6a 100644
@@ -1077,12 +1077,16 @@ static int inetdev_event(struct notifier_block *this, unsigned long event,
 		ip_mc_up(in_dev);
 		/* fall through */
 	case NETDEV_CHANGEADDR:
-		if (IN_DEV_ARP_NOTIFY(in_dev))
-			arp_send(ARPOP_REQUEST, ETH_P_ARP,
-				 in_dev->ifa_list->ifa_address,
-				 dev,
-				 in_dev->ifa_list->ifa_address,
-				 NULL, dev->dev_addr, NULL);
+		/* Send gratuitous ARP to notify of link change */
+		if (IN_DEV_ARP_NOTIFY(in_dev)) {
+			struct in_ifaddr *ifa = in_dev->ifa_list;

net/ipv4/devinet.c static int inetdev_event(struct notifier_block *this, unsigned long event, · line 1092

Quoted 10 lines
net/ipv4/devinet.c +7 -0
+
+			if (ifa)
+				arp_send(ARPOP_REQUEST, ETH_P_ARP,
+					 ifa->ifa_address, dev,
+					 ifa->ifa_address, NULL,
+					 dev->dev_addr, NULL);
+		}
 		break;
 	case NETDEV_DOWN:
 		ip_mc_down(in_dev);

Okay, but I can't see that sending out one per address is going to be a big storm. Can't imagine user with 100's of addresses on same interface, but I guess it is possible.

#5 lore raw
Quoted 5 lines · Stephen Hemminger

Okay, but I can't see that sending out one per address is going to be a big storm. Can't imagine user with 100's of addresses on same interface, but I guess it is possible.

I saw some setups with hundred of ip addresses.

But they probably dont change MAC addresses very often :)

Who knows...

#6 lore raw
Quoted 7 lines · On Tue, 06 Oct 2009 17:43:52 +0200 Eric Dumazet <[email protected]> wrote:
Quoted 5 lines · Stephen Hemminger

Okay, but I can't see that sending out one per address is going to be a big storm. Can't imagine user with 100's of addresses on same interface, but I guess it is possible.

Quoted 5 lines

I saw some setups with hundred of ip addresses.

But they probably dont change MAC addresses very often :)

Who knows...

Colo shared webhosts with per customer/site https/SSL certificates could be an example.

maintainer Applied
#7 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Tue, 06 Oct 2009 07:20:19 +0200

Quoted 11 lines

From: Stephen Hemminger <[email protected]>

This fixes a bug with arp_notify.

If arp_notify is enabled, kernel will crash if address is changed and no IP address is assigned.
http://bugzilla.kernel.org/show_bug.cgi?id=14330

Applied, thanks everyone.