Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Dec 2004 21:06:58 +0100
From:      Max Laier <max@love2party.net>
To:        Ruslan Ermilov <ru@freebsd.org>
Cc:        net@freebsd.org
Subject:   Re: Another bug with netmasked aliases (with fix)
Message-ID:  <200412082107.05872.max@love2party.net>
In-Reply-To: <20041207145932.GA1336@ip.net.ua>
References:  <20041207145932.GA1336@ip.net.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart1904829.TKSjV2iQAs
Content-Type: multipart/mixed;
  boundary="Boundary-01=_k71tBder1E5eMss"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--Boundary-01=_k71tBder1E5eMss
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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 h=
ead=20
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 =3D &ia->ia_ifa;
|       if (ifa !=3D rt->rt_ifa) {
|               IFAFREE(rt->rt_ifa);
|               ifa->ifa_refcnt++;
|               rt->rt_ifa =3D ifa;
|       }


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

=2D-=20
/"\  Best regards,                      | mlaier@freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News

--Boundary-01=_k71tBder1E5eMss
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="if_ether.c.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="if_ether.c.diff"

Index: if_ether.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/store/mlaier/fcvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.131
diff -u -r1.131 if_ether.c
=2D-- 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 =3D {sizeof(null_sdl), AF_LINK};
+	struct in_ifaddr *ia;
+	struct ifaddr *ifa;
=20
 	RT_LOCK_ASSERT(rt);
=20
@@ -250,8 +252,13 @@
 		}
 #endif
=20
=2D		if (SIN(rt_key(rt))->sin_addr.s_addr =3D=3D
=2D		    (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) {
+		TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
+			if (ia->ia_ifp =3D=3D rt->rt_ifp &&
+			    SIN(rt_key(rt))->sin_addr.s_addr =3D=3D
+			    (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 =3D loif;
=20
+		    /*
+		     * make sure to set rt->rt_ifa to the interface
+		     * address we are using, otherwise we will have trouble
+		     * with source address selection.
+		     */
+			ifa =3D &ia->ia_ifa;
+			if (ifa !=3D rt->rt_ifa) {
+				IFAFREE(rt->rt_ifa);
+				IFAREF(ifa);
+				rt->rt_ifa =3D ifa;
+			}
 		}
 		break;
=20

--Boundary-01=_k71tBder1E5eMss--

--nextPart1904829.TKSjV2iQAs
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)

iD8DBQBBt17pXyyEoT62BG0RAs+hAJ0T3L3Ztz4frN2xLplCURGbuTIurACdEVQd
F+nxiF2YyoojGvToSSoxu4U=
=HtJm
-----END PGP SIGNATURE-----

--nextPart1904829.TKSjV2iQAs--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200412082107.05872.max>