From owner-freebsd-net@FreeBSD.ORG Tue Aug 3 14:30:09 2010 Return-Path: Delivered-To: net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57E071065686 for ; Tue, 3 Aug 2010 14:30:09 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 2A1DF8FC25 for ; Tue, 3 Aug 2010 14:30:09 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 97B7D46B8A for ; Tue, 3 Aug 2010 10:30:08 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id C9E5D8A03C for ; Tue, 3 Aug 2010 10:30:07 -0400 (EDT) From: John Baldwin To: net@freebsd.org Date: Tue, 3 Aug 2010 10:29:11 -0400 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20100217; KDE/4.4.5; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201008031029.11284.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Tue, 03 Aug 2010 10:30:07 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: Subject: vlan(4) interfaces have wrong interface type in sockaddr_dl address 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: Tue, 03 Aug 2010 14:30:09 -0000 Currently vlan(4) interfaces have an interface type of IFT_ETHER instead of IFT_L2VLAN in the sockaddr_dl that is returned by getifaddrs(3). If you do a route lookup for a route that goes across a vlan then the sockaddr_dl generated for the routing message will specify IFT_L2VLAN (you can see it as 'arp -a' shows [vlan] instead of [ethernet] for those routes). However, the address returned via getifaddrs(3) has a type of IFT_ETHER. I think this is a bug of omission in that the vlan attach code needs to update the sockaddr_dl that is initialized in ether_ifattach(). This patch does that and fixes getifaddrs(3). Any objections? Index: if_vlan.c =================================================================== --- if_vlan.c (revision 211312) +++ if_vlan.c (working copy) @@ -640,6 +640,8 @@ struct ifvlan *ifv; struct ifnet *ifp; struct ifnet *p; + struct ifaddr *ifa; + struct sockaddr_dl *sdl; struct vlanreq vlr; static const u_char eaddr[ETHER_ADDR_LEN]; /* 00:00:00:00:00:00 */ @@ -738,6 +740,9 @@ ifp->if_baudrate = 0; ifp->if_type = IFT_L2VLAN; ifp->if_hdrlen = ETHER_VLAN_ENCAP_LEN; + ifa = ifp->if_addr; + sdl = (struct sockaddr_dl *)ifa->ifa_addr; + sdl->sdl_type = IFT_L2VLAN; if (ethertag) { error = vlan_config(ifv, p, tag); -- John Baldwin