From owner-freebsd-net@FreeBSD.ORG Wed May 21 20:44:43 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 36EE1106566B for ; Wed, 21 May 2008 20:44:43 +0000 (UTC) (envelope-from ndenev@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.225]) by mx1.freebsd.org (Postfix) with ESMTP id 094708FC16 for ; Wed, 21 May 2008 20:44:43 +0000 (UTC) (envelope-from ndenev@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so3014583rvf.43 for ; Wed, 21 May 2008 13:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=h/o8TYcE/BuWUoQczbTL0R+CEEl1r7O34/jPbmcCw1U=; b=DxTCl7KLxaSdqnYwhYsvZsBkGqfX2maDZDT25sr+B46+37JTEAGyto4jVk2o+AkVLd5R/fjN5P+H6gd8bW+dUJP3dHgDOhLam90VbCK6bj8qNvs1n7yeEfAJXmJW19SBOy2cL3hyxcjcJq3l2aIItRfLfxnvSKUsm4tHmveRBes= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=x4vlTWyvkfpJ/M8akwleAxJVtZskxnQNKAQRdhewIFXF7Vf8cKvyUEb3kgrkzYmeFTA/oTkFS7kUtvYmKWBF2LSaC4jlgJ6e0iDMZylkX9kXj1D6vxaj3EllwZa6wZhKegsA0LS+jYZNjcv+A+u8UXGt4tHpGajUkVb54SWVrLQ= Received: by 10.141.153.17 with SMTP id f17mr5401012rvo.44.1211402682719; Wed, 21 May 2008 13:44:42 -0700 (PDT) Received: by 10.141.171.3 with HTTP; Wed, 21 May 2008 13:44:42 -0700 (PDT) Message-ID: <2e77fc10805211344m606886f9pd45ff7b001bc8da0@mail.gmail.com> Date: Wed, 21 May 2008 23:44:42 +0300 From: "Niki Denev" Sender: ndenev@gmail.com To: "Max Laier" In-Reply-To: <2e77fc10805211223l7fd69e4cwdd488bada0dc7b95@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <2e77fc10805211031n6c42ffd2u3dee28164094b83b@mail.gmail.com> <200805211944.42418.max@love2party.net> <2e77fc10805211223l7fd69e4cwdd488bada0dc7b95@mail.gmail.com> X-Google-Sender-Auth: e2b8fb199dc1defe Cc: freebsd-net@freebsd.org Subject: Re: lagg0.2 style vlans on lagg(4) interface X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 May 2008 20:44:43 -0000 On Wed, May 21, 2008 at 8:44 PM, Max Laier 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. 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;