linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [2.4 PATCH] bugfix: ARP respond on all devices
@ 2003-07-27 20:52 Bas Bloemsaat
  2003-07-27 22:12 ` David S. Miller
  2003-07-27 23:40 ` Carlos Velasco
  0 siblings, 2 replies; 84+ messages in thread
From: Bas Bloemsaat @ 2003-07-27 20:52 UTC (permalink / raw)
  To: marcelo, netdev, linux-net; +Cc: layes, torvalds, linux-kernel

Yesterday (20030726) I found out, that with two NICs on one ethernet
segment, ARPing for one IP address gave me two answers, one from each NIC
with the MAC address from each of them. They each have a seperate IP
address. First I thought the NICs where doing proxy arp on each other,
but it turned out that this wasn't the case. On closer examination it
turned out that any ARP request to a local IP resulted in a response,
even if the devices were on different subnets or ethernet segments.

I learned from the kernel sources that any NIC receiving an ARP request
for any local IP adress would respond to that request. Among others, that
has the following implications:
- when you have two NICs same ethernet segment, only one of them is used:
they both respond to any ARP request. As only the first response is ever
used (fasted router), only the NIC that responds first receives any
traffic. This NIC may or may not be bound to the destination IP. It may
not even be reachable because of iptables-rules. This also defeats a
common form of load balancing.
- when you have two NICs on seperate ethernet segments, for example on a
firewall, it is possible to probe one NIC for the IP address of the other.
This can be used to gain information about the inside network of the
firewall, which is a (minor) security risk. While this is not really
practical because every IP address has to be tried, often the inside is of
a limit range (10.x.x.x, 192.168.x.x), which makes it useful.

I think this is unwanted behaviour. This patch corrects the situation. It
makes every device only respond to ARP requests for IP addresses bound to
that device, not all local IP addresses. Proxy ARP still applies as
before.

The patch was made from 2.4.21. It patches 2.4.22-pre8 cleanly and tests
okay on both. Please apply.


diff -urN linux-2.4.21.orig/include/linux/inetdevice.h linux-2.4.21-okayclean/include/linux/inetdevice.h
--- linux-2.4.21.orig/include/linux/inetdevice.h	2002-08-03 02:39:45.000000000 +0200
+++ linux-2.4.21-okayclean/include/linux/inetdevice.h	2003-07-27 18:51:28.000000000 +0200
@@ -86,6 +86,7 @@
 extern u32		inet_select_addr(const struct net_device *dev, u32 dst, int scope);
 extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, u32 prefix, u32 mask);
 extern void		inet_forward_change(void);
+extern int 		inet_addr_local_dev(struct in_device *in_dev, u32 addr);

 static __inline__ int inet_ifa_match(u32 addr, struct in_ifaddr *ifa)
 {
diff -urN linux-2.4.21.orig/net/ipv4/arp.c linux-2.4.21-okayclean/net/ipv4/arp.c
--- linux-2.4.21.orig/net/ipv4/arp.c	2002-11-29 00:53:15.000000000 +0100
+++ linux-2.4.21-okayclean/net/ipv4/arp.c	2003-07-27 21:12:17.000000000 +0200
@@ -66,6 +66,7 @@
  *		Alexey Kuznetsov:	new arp state machine;
  *					now it is in net/core/neighbour.c.
  *		Krzysztof Halasa:	Added Frame Relay ARP support.
+ *		Bas Bloemsaat	:	(20030727) Fixed respond on all devices bug
  */

 #include <linux/types.h>
@@ -766,7 +767,9 @@
 		rt = (struct rtable*)skb->dst;
 		addr_type = rt->rt_type;

-		if (addr_type == RTN_LOCAL) {
+
+		/* check if arp is for this device */
+		if (inet_addr_local_dev(in_dev,tip)) {
 			n = neigh_event_ns(&arp_tbl, sha, &sip, dev);
 			if (n) {
 				int dont_send = 0;
@@ -778,6 +781,8 @@
 				neigh_release(n);
 			}
 			goto out;
+
+		/* check if we can and have to proxy it */
 		} else if (IN_DEV_FORWARD(in_dev)) {
 			if ((rt->rt_flags&RTCF_DNAT) ||
 			    (addr_type == RTN_UNICAST  && rt->u.dst.dev != dev &&
diff -urN linux-2.4.21.orig/net/ipv4/devinet.c linux-2.4.21-okayclean/net/ipv4/devinet.c
--- linux-2.4.21.orig/net/ipv4/devinet.c	2003-06-13 16:51:39.000000000 +0200
+++ linux-2.4.21-okayclean/net/ipv4/devinet.c	2003-07-27 18:50:19.000000000 +0200
@@ -199,6 +199,17 @@
 	return 0;
 }

+int
+inet_addr_local_dev(struct in_device *in_dev, u32 addr)
+{
+	for_ifa(in_dev) {
+		if (!(addr^ifa->ifa_address))
+			return -1;
+	} endfor_ifa(in_dev);
+
+	return 0;
+}
+
 static void
 inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, int destroy)
 {


^ permalink raw reply	[flat|nested] 84+ messages in thread

end of thread, other threads:[~2003-08-20  6:55 UTC | newest]

Thread overview: 84+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-27 20:52 [2.4 PATCH] bugfix: ARP respond on all devices Bas Bloemsaat
2003-07-27 22:12 ` David S. Miller
2003-07-28  2:31   ` Ben Greear
2003-07-28  7:33     ` Bas Bloemsaat
2003-07-27 23:40 ` Carlos Velasco
2003-07-27 23:46   ` David S. Miller
2003-07-27 23:58     ` Carlos Velasco
2003-07-27 23:58       ` David S. Miller
2003-07-28  0:11         ` Carlos Velasco
2003-07-28  0:14           ` David S. Miller
2003-07-28  0:35             ` Carlos Velasco
2003-07-28  0:36               ` David S. Miller
2003-07-28  0:53                 ` Carlos Velasco
2003-07-28  0:55                   ` David S. Miller
2003-07-28  1:23                     ` Carlos Velasco
2003-07-28  1:35                       ` David S. Miller
2003-07-28 10:43                         ` Carlos Velasco
2003-07-28 17:09                           ` Phil Oester
2003-07-28 18:56                             ` Bas Bloemsaat
2003-07-28  4:37                     ` David Lang
2003-07-28  4:39                       ` David S. Miller
2003-07-28 10:49                       ` Carlos Velasco
2003-07-28  0:57           ` Assorted 2.6.0-test2 build warnings J.C. Wren
2003-07-28 22:11             ` Randy.Dunlap
2003-07-29 10:42               ` Adrian Bunk
2003-07-29  2:51     ` [2.4 PATCH] bugfix: ARP respond on all devices Bill Davidsen
2003-07-29  4:48       ` Lamont Granquist
2003-08-04  6:10         ` Pekka Savola
2003-08-17 13:09         ` Carlos Velasco
2003-08-17 13:16           ` Carlos Velasco
2003-08-17 13:41             ` Alan Cox
2003-08-17 13:55               ` Carlos Velasco
2003-08-17 15:12                 ` Bernd Eckenfels
2003-08-17 15:28                 ` Alan Cox
2003-08-17 15:57                   ` Bas Bloemsaat
2003-08-17 15:59                   ` Carlos Velasco
2003-08-17 16:26                     ` Alan Cox
2003-08-17 16:27                       ` Carlos Velasco
2003-08-17 17:24                         ` Alan Cox
2003-08-17 22:48                           ` Willy Tarreau
2003-08-18  5:22                             ` David S. Miller
2003-08-18  6:56                               ` Willy Tarreau
2003-08-18  7:01                                 ` David S. Miller
2003-08-18  7:29                                   ` Willy Tarreau
2003-08-18  7:43                                     ` Willy Tarreau
2003-08-18  5:31                             ` David S. Miller
2003-08-18 11:39                               ` Stephan von Krawczynski
2003-08-18 11:44                                 ` David S. Miller
2003-08-18 12:34                                   ` Stephan von Krawczynski
2003-08-18 12:30                                     ` David S. Miller
2003-08-18 12:51                                       ` Mr. James W. Laferriere
2003-08-18 12:53                                       ` Stephan von Krawczynski
2003-08-18 12:55                                         ` David S. Miller
2003-08-18 13:17                                           ` Stephan von Krawczynski
2003-08-18 13:14                                             ` David S. Miller
2003-08-18 14:23                                               ` Stephan von Krawczynski
2003-08-18 14:19                                                 ` David S. Miller
2003-08-18 15:46                                                   ` Stephan von Krawczynski
2003-08-18 13:23                                           ` jamal
2003-08-18 13:21                                             ` David S. Miller
2003-08-18 13:40                                               ` Stephan von Krawczynski
2003-08-20  6:55                                             ` Bas Bloemsaat
2003-08-18 21:54                                       ` Bill Davidsen
2003-08-18 13:40                                     ` Dominik Kubla
2003-08-18 12:51                                   ` Willy Tarreau
2003-08-18 12:53                                     ` David S. Miller
2003-08-18 14:28                                       ` Willy Tarreau
2003-08-18 14:28                                         ` David S. Miller
2003-08-18 12:08                                 ` Bas Bloemsaat
2003-08-18 12:03                                   ` David S. Miller
2003-08-18 21:32                               ` Bill Davidsen
2003-08-19  3:21                                 ` Ben Greear
2003-08-19 15:22                                   ` David S. Miller
2003-08-19  7:58                                 ` Bas Bloemsaat
2003-08-18 15:49                         ` SRC IP selection in ARP request (Was: bugfix: ARP respond on all devices) Vladimir B. Savkin
2003-08-17 16:51                     ` [2.4 PATCH] bugfix: ARP respond on all devices David T Hollis
2003-08-17 16:45                       ` Carlos Velasco
2003-08-17 17:13                         ` Arjan van de Ven
2003-08-17 19:46                           ` insecure
2003-08-18  5:11                             ` David S. Miller
2003-08-18  5:29                 ` David S. Miller
2003-08-17 13:59               ` Bas Bloemsaat
2003-08-18 10:48               ` Robert Collier
2003-08-17 13:38           ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).