History

ipv4: add option to drop gratuitous ARP packets

In certain 802.11 wireless deployments, there will be ARP proxies that use knowledge of the network to correctly answer requests. To prevent gratuitous ARP frames on the shared medium from being a problem, on such deployments wireless needs to drop them. Enable this by providing an option called "drop_gratuitous_arp".

Johannes Berg committed 10 years ago

Commit 97daf331 parent 12b74df4 files · +17 −0Browse files

Unified · Split

4 files
  1. Documentation/networking/ip-sysctl.txt +6 −0
  2. include/uapi/linux/ip.h +1 −0
  3. net/ipv4/arp.c +8 −0
  4. net/ipv4/devinet.c +2 −0
Documentation/networking/ip-sysctl.txt+6−0
@@ -1223,6 +1223,12 @@ drop_unicast_in_l2_multicast - BOOLEAN · 1222 unmodified lines
12231223 1122, but is disabled by default for compatibility reasons.
12241224 Default: off (0)
12251225
1226+drop_gratuitous_arp - BOOLEAN
1227+ Drop all gratuitous ARP frames, for example if there's a known
1228+ good ARP proxy on the network and such frames need not be used
1229+ (or in the case of 802.11, must not be used to prevent attacks.)
1230+ Default: off (0)
1231+
12261232
12271233 tag - INTEGER
12281234 Allows you to write a number, which can be used as required.
include/uapi/linux/ip.h+1−0
@@ -166,6 +166,7 @@ enum · 165 unmodified lines
166166 IPV4_DEVCONF_IGMPV3_UNSOLICITED_REPORT_INTERVAL,
167167 IPV4_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN,
168168 IPV4_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
169+ IPV4_DEVCONF_DROP_GRATUITOUS_ARP,
169170 __IPV4_DEVCONF_MAX
170171 };
171172
net/ipv4/arp.c+8−0
@@ -735,6 +735,14 @@ static int arp_process(struct net *net, struct sock *sk, struct sk_buff *skb) · 734 unmodified lines
735735 (!IN_DEV_ROUTE_LOCALNET(in_dev) && ipv4_is_loopback(tip)))
736736 goto out;
737737
738+ /*
739+ * For some 802.11 wireless deployments (and possibly other networks),
740+ * there will be an ARP proxy and gratuitous ARP frames are attacks
741+ * and thus should not be accepted.
742+ */
743+ if (sip == tip && IN_DEV_ORCONF(in_dev, DROP_GRATUITOUS_ARP))
744+ goto out;
745+
738746 /*
739747 * Special case: We must set Frame Relay source Q.922 address
740748 */
net/ipv4/devinet.c+2−0
@@ -2185,6 +2185,8 @@ static struct devinet_sysctl_table { · 2184 unmodified lines
21852185 "igmpv3_unsolicited_report_interval"),
21862186 DEVINET_SYSCTL_RW_ENTRY(IGNORE_ROUTES_WITH_LINKDOWN,
21872187 "ignore_routes_with_linkdown"),
2188+ DEVINET_SYSCTL_RW_ENTRY(DROP_GRATUITOUS_ARP,
2189+ "drop_gratuitous_arp"),
21882190
21892191 DEVINET_SYSCTL_FLUSHING_ENTRY(NOXFRM, "disable_xfrm"),
21902192 DEVINET_SYSCTL_FLUSHING_ENTRY(NOPOLICY, "disable_policy"),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t