Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Nov 2005 16:51:44 +0200
From:      Ruslan Ermilov <ru@freebsd.org>
To:        Marco Molteni <molter@tin.it>
Cc:        freebsd-net@freebsd.org, Bill Paul <wpaul@freebsd.org>
Subject:   Re: troubles with ng_fec on -current
Message-ID:  <20051103145144.GM63539@ip.net.ua>
In-Reply-To: <20051102193617.1013be88.molter@tin.it>
References:  <20051102193617.1013be88.molter@tin.it>

next in thread | previous in thread | raw e-mail | index | archive | help

--M2Pxvdb9QxnGd/3e
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Nov 02, 2005 at 07:36:17PM +0100, Marco Molteni wrote:
> Hi,
>=20
> I have the following setup:
>=20
> box1     box2     box3      box4
> xl0      xl0      xl0       ste0/ste1/ste2/ste3 -> fec0
> 1.1.1.1  1.1.1.2  1.1.1.3   1.1.1.4
>  |       |        |         | | | |
>  |       |        |         | | | |    =20
> =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 cisco catalyst switch
>=20
>=20
> Hosts box1,2,3,4 are running stock fbsd -current.
>=20
> box4 has a 4-port ethernet card (forgot brand, think d-link)
> recognized by the ste driver, without IP addresses. I then configure
> bonding on the ste0..3 interfaces with ng_fec, which gives me a fec0
> interface. I then configure fec0 with set_mode_mac and with IP address
> 1.1.1.4.
>=20
> The switch is configured to perform etherchannel on the 4 ports
> connected to the ste0..4 interfaces. Load "balancing" is done
> on a per source MAC address.
>=20
> Problem is when I ping box4 from the other boxes. I get a reply only
> for ping from box1. I then ran tcpdump on the 4 ste interfaces.
> Things become to get interesting.
>=20
> If tcpdump is ran in non-promiscuos mode (-p option), only ping
> (and ARP) from box1 goes thru, as if I wasn't running tcpdump at all.
> If on the other hand tcpdump is ran in promiscuos mode, then all the
> pings go thru as expected.
>=20
> Am I doing something wrong in configuring the fec0 interface or is this
> a known problem? I think I don't need to add any IP address on the
> ste interfaces themselves.
>=20
Looks like a bug.  The ng_fec code uses the MAC address of the first
real interface as the MAC address for the virtual and all other ports
in the bundle, but it lacks a call to ifp->if_init() to actually
reprogram the hardware MAC filter.  Please try this patch:

%%%
Index: ng_fec.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: /home/ncvs/src/sys/netgraph/ng_fec.c,v
retrieving revision 1.21
diff -u -p -r1.21 ng_fec.c
--- ng_fec.c	25 Aug 2005 17:00:02 -0000	1.21
+++ ng_fec.c	3 Nov 2005 14:48:27 -0000
@@ -104,7 +104,6 @@
 #include <net/if.h>
 #include <net/if_types.h>
 #include <net/if_arp.h>
-#include <net/if_dl.h>
 #include <net/if_media.h>
 #include <net/bpf.h>
 #include <net/ethernet.h>
@@ -345,8 +344,6 @@ ng_fec_addport(struct ng_fec_private *pr
 {
 	struct ng_fec_bundle	*b;
 	struct ifnet		*ifp, *bifp;
-	struct ifaddr		*ifa;
-	struct sockaddr_dl	*sdl;
 	struct ng_fec_portlist	*p, *new;
=20
 	if (priv =3D=3D NULL || iface =3D=3D NULL)
@@ -408,14 +405,8 @@ ng_fec_addport(struct ng_fec_private *pr
 	 * use its MAC address for the virtual interface (and,
 	 * by extension, all the other ports in the bundle).
 	 */
-	if (b->fec_ifcnt =3D=3D 0) {
-		ifa =3D ifaddr_byindex(ifp->if_index);
-		sdl =3D (struct sockaddr_dl *)ifa->ifa_addr;
-		bcopy(IFP2ENADDR(bifp),
-		    IFP2ENADDR(priv->ifp), ETHER_ADDR_LEN);
-		bcopy(IFP2ENADDR(bifp),
-		    LLADDR(sdl), ETHER_ADDR_LEN);
-	}
+	if (b->fec_ifcnt =3D=3D 0)
+		if_setlladdr(ifp, IFP2ENADDR(bifp), ETHER_ADDR_LEN);
=20
 	b->fec_btype =3D FEC_BTYPE_MAC;
 	new->fec_idx =3D b->fec_ifcnt;
@@ -426,10 +417,7 @@ ng_fec_addport(struct ng_fec_private *pr
 	    (char *)&new->fec_mac, ETHER_ADDR_LEN);
=20
 	/* Set up phony MAC address. */
-	ifa =3D ifaddr_byindex(bifp->if_index);
-	sdl =3D (struct sockaddr_dl *)ifa->ifa_addr;
-	bcopy(IFP2ENADDR(priv->ifp), IFP2ENADDR(bifp), ETHER_ADDR_LEN);
-	bcopy(IFP2ENADDR(priv->ifp), LLADDR(sdl), ETHER_ADDR_LEN);
+	if_setlladdr(bifp, IFP2ENADDR(ifp), ETHER_ADDR_LEN);
=20
 	/* Save original input vector */
 	new->fec_if_input =3D bifp->if_input;
@@ -453,8 +441,6 @@ ng_fec_delport(struct ng_fec_private *pr
 {
 	struct ng_fec_bundle	*b;
 	struct ifnet		*ifp, *bifp;
-	struct ifaddr		*ifa;
-	struct sockaddr_dl	*sdl;
 	struct ng_fec_portlist	*p;
=20
 	if (priv =3D=3D NULL || iface =3D=3D NULL)
@@ -487,10 +473,7 @@ ng_fec_delport(struct ng_fec_private *pr
 	(*bifp->if_ioctl)(bifp, SIOCSIFFLAGS, NULL);
=20
 	/* Restore MAC address. */
-	ifa =3D ifaddr_byindex(bifp->if_index);
-	sdl =3D (struct sockaddr_dl *)ifa->ifa_addr;
-	bcopy((char *)&p->fec_mac, IFP2ENADDR(bifp), ETHER_ADDR_LEN);
-	bcopy((char *)&p->fec_mac, LLADDR(sdl), ETHER_ADDR_LEN);
+	if_setlladdr(bifp, (u_char *)&p->fec_mac, ETHER_ADDR_LEN);
=20
 	/* Restore input vector */
 	bifp->if_input =3D p->fec_if_input;
%%%


Cheers,
--=20
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer

--M2Pxvdb9QxnGd/3e
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQFDaiQAqRfpzJluFF4RAsnxAJ4hMwch0e6CGOqWxaQM109MgGhN1ACbBbdM
R34s9ELPHsrvSucm5keZ+qk=
=WqJW
-----END PGP SIGNATURE-----

--M2Pxvdb9QxnGd/3e--



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