(In my eyes) strange arp behaviour

Florian Heinz (sky@real-linux.de)
Wed, 29 Dec 1999 16:52:39 +0100


Hi,

I have a machine connected with 2 network-cards to the same hub... I've
assigned the IP 192.168.0.1 to one card and 192.168.0.2 to the other.

Now when an arp-request for, e.g. 192.168.0.1 arrives, _both_ cards
reply with their own HW-address.

I think this behaviour comes because the arp-code only checks if the
IP-address is local, but _not_ if it's assigned to the device which
replies.

I don't think this behaviour is correct.. I've wrote a quick fix for it.
Well, it works fine for me, possibly it breaks some other cases... who
knows ;)

--- arp.old.c Wed Oct 20 02:14:02 1999
+++ arp.c Wed Dec 29 16:40:40 1999
@@ -661,6 +661,17 @@

if (arp->ar_op == __constant_htons(ARPOP_REQUEST) &&
ip_route_input(skb, tip, sip, 0, dev) == 0) {
+
+ /* This block prevents devices to reply to arp-requests for
IPs
+ * which are local, but not assigned to the
device */
+ struct in_ifaddr *myaddr = in_dev->ifa_list;
+ while (myaddr) {
+ if (myaddr->ifa_local == tip)
+ break;
+ myaddr = myaddr->ifa_next;
+ }
+ if (!myaddr)
+ goto out;

rt = (struct rtable*)skb->dst;
addr_type = rt->rt_type;

Yes, I know, there are 100 better ways and places to do this...

Any comments? (But, please, no discussions about the stupidity of
connecting two network-cards to the same hub)

FH

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/