Another bug with netmasked aliases (with fix)

Ruslan Ermilov ru at FreeBSD.org
Tue Dec 7 06:59:37 PST 2004


Hi Max,

I played today with "netmasked aliases", and found what
appears to be another bug.

Adding an alias to the Ethernet interface with the same
netmask results in this address not being pingable from
this host -- it just spits ARP requests to the wire and
never hears back (most Ethernets are simplex devices).

I knew what the fix should look like, and then quickly
found a ready to commit solution in OpenBSD rev. 1.47.

When testing the attached patch, make sure you do *not*
have a (host) route for the alias being added.


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
Index: if_ether.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.131
diff -u -p -r1.131 if_ether.c
--- if_ether.c	26 Oct 2004 03:31:58 -0000	1.131
+++ if_ether.c	7 Dec 2004 14:24:57 -0000
@@ -162,6 +162,7 @@ arp_rtrequest(req, rt, info)
 	struct sockaddr *gate;
 	struct llinfo_arp *la;
 	static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
+	struct in_ifaddr *ia;
 
 	RT_LOCK_ASSERT(rt);
 
@@ -250,8 +251,13 @@ arp_rtrequest(req, rt, info)
 		}
 #endif
 
-		if (SIN(rt_key(rt))->sin_addr.s_addr ==
-		    (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) {
+		TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+			if (ia->ia_ifp == rt->rt_ifp &&
+			    SIN(rt_key(rt))->sin_addr.s_addr ==
+			    (IA_SIN(ia))->sin_addr.s_addr)
+				break;
+		}
+		if (ia) {
 		    /*
 		     * This test used to be
 		     *	if (loif.if_flags & IFF_UP)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20041207/7491504e/attachment.bin


More information about the freebsd-net mailing list