Date: Wed, 21 May 2008 23:05:57 +0200 From: Max Laier <max@love2party.net> To: "Niki Denev" <nike_d@cytexbg.com> Cc: freebsd-net@freebsd.org Subject: Re: lagg0.2 style vlans on lagg(4) interface Message-ID: <200805212305.58235.max@love2party.net> In-Reply-To: <2e77fc10805211344m606886f9pd45ff7b001bc8da0@mail.gmail.com> References: <2e77fc10805211031n6c42ffd2u3dee28164094b83b@mail.gmail.com> <2e77fc10805211223l7fd69e4cwdd488bada0dc7b95@mail.gmail.com> <2e77fc10805211344m606886f9pd45ff7b001bc8da0@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 21 May 2008 22:44:42 Niki Denev wrote: > On Wed, May 21, 2008 at 8:44 PM, Max Laier <max@love2party.net> wrote: > >> It doesn't (and shouldn't have to). I'd simply add an > >> EVENTHANDLER_INVOKE(ifaddr_event, ifp) to if_setlladdr() - we do > >> that for INET[6] address already. Then vlan (and any other device > >> interested in LLaddress changes) can simply register to that > >> eventhandler and resync. > > Hi, > Does this look like a reasonable solution? > It passes my limited testing. Looks good, though I'd probably move up the _INVOKE to before the ARPs are sent out. Probably between twiddling the hardware and sending ARPs (though that needs an else-case if the interface is still down). In fact the ARPs could be sent from an event hook, too. This would get rid of INET specific code in the LL-interface code. > Niki > > diff -ur /usr/src/sys/net/if.c > /usr/src/.zfs/snapshot/vlan_lladdr_patch/sys/net/if.c > --- /usr/src/sys/net/if.c 2008-04-29 23:43:08.000000000 +0300 > +++ /usr/src/.zfs/snapshot/vlan_lladdr_patch/sys/net/if.c > 2008-05-21 22:12:33.989318352 +0300 > @@ -2647,6 +2647,11 @@ > } > #endif > } > + /* > + * Notify interested parties (clonable children like > if_vlan(4)) + * about the link layer address change > + */ > + EVENTHANDLER_INVOKE(ifaddr_event, ifp); > return (0); > } > > diff -ur /usr/src/sys/net/if_vlan.c > /usr/src/.zfs/snapshot/vlan_lladdr_patch/sys/net/if_vlan.c > --- /usr/src/sys/net/if_vlan.c 2007-10-28 18:24:16.000000000 +0200 > +++ /usr/src/.zfs/snapshot/vlan_lladdr_patch/sys/net/if_vlan.c > 2008-05-21 23:24:13.322156460 +0300 > @@ -137,6 +137,7 @@ > static MALLOC_DEFINE(M_VLAN, VLANNAME, "802.1Q Virtual LAN > Interface"); > > static eventhandler_tag ifdetach_tag; > +static eventhandler_tag ifaddr_tag; > > /* > * We have a global mutex, that is used to serialize configuration > @@ -518,6 +519,33 @@ > /* For if_link_state_change() eyes only... */ > extern void (*vlan_link_state_p)(struct ifnet *, int); > > +/* > + * Update vlan interface link layer address on > + * parent interface link layer address change. > + */ > +static int > +vlan_lladdr_update(void *arg __unused, struct ifnet *ifp) > +{ > + struct ifvlantrunk *trunk = ifp->if_vlantrunk; > + struct ifvlan *ifv; > + int i; > + > + TRUNK_LOCK(trunk); > +#ifdef VLAN_ARRAY > + for (i = 0; i < VLAN_ARRAY_SIZE; i++) > + if (trunk->vlans[i] != NULL) { > + ifv = trunk->vlans[i]; > +#else > + for (i = 0; i < (1 << trunk->hwidth); i++) { > + LIST_FOREACH(ifv, &trunk->hash[i], ifv_list) > +#endif > + bcopy(IF_LLADDR(ifp), IF_LLADDR(ifv->ifv_ifp), > + ETHER_ADDR_LEN); > + } > + TRUNK_UNLOCK(trunk); > + return 0; > +} > + > static int > vlan_modevent(module_t mod, int type, void *data) > { > @@ -528,6 +556,10 @@ > vlan_ifdetach, NULL, EVENTHANDLER_PRI_ANY); > if (ifdetach_tag == NULL) > return (ENOMEM); > + ifaddr_tag = EVENTHANDLER_REGISTER(ifaddr_event, > + vlan_lladdr_update, NULL, EVENTHANDLER_PRI_ANY); > + if (ifaddr_tag == NULL) > + return (ENOMEM); > VLAN_LOCK_INIT(); > vlan_input_p = vlan_input; > vlan_link_state_p = vlan_link_state; > @@ -546,6 +578,7 @@ > case MOD_UNLOAD: > if_clone_detach(&vlan_cloner); > EVENTHANDLER_DEREGISTER(ifnet_departure_event, > ifdetach_tag); + EVENTHANDLER_DEREGISTER(ifaddr_event, > ifaddr_tag); vlan_input_p = NULL; > vlan_link_state_p = NULL; > vlan_trunk_cap_p = NULL; -- /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805212305.58235.max>