Commit eefef1cf7653cd4e0aaf743c00ae8345086cdc01

Authored by Stephen Hemminger
Committed by David S. Miller
1 parent ead731837d

net: add ARP notify option for devices

This adds another inet device option to enable gratuitous ARP
when device is brought up or address change. This is handy for
clusters or virtualization.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 5 changed files with 18 additions and 0 deletions Side-by-side Diff

Documentation/networking/ip-sysctl.txt
... ... @@ -782,6 +782,12 @@
782 782 The max value from conf/{all,interface}/arp_ignore is used
783 783 when ARP request is received on the {interface}
784 784  
  785 +arp_notify - BOOLEAN
  786 + Define mode for notification of address and device changes.
  787 + 0 - (default): do nothing
  788 + 1 - Generate gratuitous arp replies when device is brought up
  789 + or hardware address changes.
  790 +
785 791 arp_accept - BOOLEAN
786 792 Define behavior when gratuitous arp replies are received:
787 793 0 - drop gratuitous arp frames
include/linux/inetdevice.h
... ... @@ -108,6 +108,7 @@
108 108 #define IN_DEV_ARPFILTER(in_dev) IN_DEV_ORCONF((in_dev), ARPFILTER)
109 109 #define IN_DEV_ARP_ANNOUNCE(in_dev) IN_DEV_MAXCONF((in_dev), ARP_ANNOUNCE)
110 110 #define IN_DEV_ARP_IGNORE(in_dev) IN_DEV_MAXCONF((in_dev), ARP_IGNORE)
  111 +#define IN_DEV_ARP_NOTIFY(in_dev) IN_DEV_MAXCONF((in_dev), ARP_NOTIFY)
111 112  
112 113 struct in_ifaddr
113 114 {
include/linux/sysctl.h
... ... @@ -490,6 +490,7 @@
490 490 NET_IPV4_CONF_ARP_IGNORE=19,
491 491 NET_IPV4_CONF_PROMOTE_SECONDARIES=20,
492 492 NET_IPV4_CONF_ARP_ACCEPT=21,
  493 + NET_IPV4_CONF_ARP_NOTIFY=22,
493 494 __NET_IPV4_CONF_MAX
494 495 };
495 496  
kernel/sysctl_check.c
... ... @@ -219,6 +219,7 @@
219 219 { NET_IPV4_CONF_ARP_IGNORE, "arp_ignore" },
220 220 { NET_IPV4_CONF_PROMOTE_SECONDARIES, "promote_secondaries" },
221 221 { NET_IPV4_CONF_ARP_ACCEPT, "arp_accept" },
  222 + { NET_IPV4_CONF_ARP_NOTIFY, "arp_notify" },
222 223 {}
223 224 };
224 225  
... ... @@ -1075,6 +1075,14 @@
1075 1075 }
1076 1076 }
1077 1077 ip_mc_up(in_dev);
  1078 + /* fall through */
  1079 + case NETDEV_CHANGEADDR:
  1080 + if (IN_DEV_ARP_NOTIFY(in_dev))
  1081 + arp_send(ARPOP_REQUEST, ETH_P_ARP,
  1082 + in_dev->ifa_list->ifa_address,
  1083 + dev,
  1084 + in_dev->ifa_list->ifa_address,
  1085 + NULL, dev->dev_addr, NULL);
1078 1086 break;
1079 1087 case NETDEV_DOWN:
1080 1088 ip_mc_down(in_dev);
... ... @@ -1439,6 +1447,7 @@
1439 1447 DEVINET_SYSCTL_RW_ENTRY(ARP_ANNOUNCE, "arp_announce"),
1440 1448 DEVINET_SYSCTL_RW_ENTRY(ARP_IGNORE, "arp_ignore"),
1441 1449 DEVINET_SYSCTL_RW_ENTRY(ARP_ACCEPT, "arp_accept"),
  1450 + DEVINET_SYSCTL_RW_ENTRY(ARP_NOTIFY, "arp_notify"),
1442 1451  
1443 1452 DEVINET_SYSCTL_FLUSHING_ENTRY(NOXFRM, "disable_xfrm"),
1444 1453 DEVINET_SYSCTL_FLUSHING_ENTRY(NOPOLICY, "disable_policy"),