Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Aug 2010 10:29:11 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        net@freebsd.org
Subject:   vlan(4) interfaces have wrong interface type in sockaddr_dl address
Message-ID:  <201008031029.11284.jhb@freebsd.org>

next in thread | raw e-mail | index | archive | help
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



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