On Tuesday 07 December 2004 15:59, Ruslan Ermilov wrote:
> 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.

Took a little longer, busy times :-\

I didn't have this change in my carp patches (and was actually banging my head 
as it solves a long-standing problem) - Thanks.

Any reason you didn't include the following (also part of OpenBSD rev. 1.47)?:

|       /*
|        * make sure to set rt->rt_ifa to the interface
|        * address we are using, otherwise we will have trouble
|        * with source address selection.
|        */
|       ifa = &ia->ia_ifa;
|       if (ifa != rt->rt_ifa) {
|               IFAFREE(rt->rt_ifa);
|               ifa->ifa_refcnt++;
|               rt->rt_ifa = ifa;
|       }


Updated diff attached. Not sure if it makes any difference?

-- 
/"\  Best regards,                      | [EMAIL PROTECTED]
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | [EMAIL PROTECTED]
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
Index: if_ether.c
===================================================================
RCS file: /usr/store/mlaier/fcvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.131
diff -u -r1.131 if_ether.c
--- if_ether.c	26 Oct 2004 03:31:58 -0000	1.131
+++ if_ether.c	8 Dec 2004 20:05:41 -0000
@@ -162,6 +162,8 @@
 	struct sockaddr *gate;
 	struct llinfo_arp *la;
 	static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
+	struct in_ifaddr *ia;
+	struct ifaddr *ifa;
 
 	RT_LOCK_ASSERT(rt);
 
@@ -250,8 +252,13 @@
 		}
 #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)
@@ -268,6 +275,17 @@
 			if (useloopback)
 				rt->rt_ifp = loif;
 
+		    /*
+		     * make sure to set rt->rt_ifa to the interface
+		     * address we are using, otherwise we will have trouble
+		     * with source address selection.
+		     */
+			ifa = &ia->ia_ifa;
+			if (ifa != rt->rt_ifa) {
+				IFAFREE(rt->rt_ifa);
+				IFAREF(ifa);
+				rt->rt_ifa = ifa;
+			}
 		}
 		break;
 

Attachment: pgpIpjaZvX7zv.pgp
Description: PGP signature

Reply via email to