vlan(4) interfaces have wrong interface type in sockaddr_dl address
John Baldwin
jhb at freebsd.org
Tue Aug 3 14:30:09 UTC 2010
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
More information about the freebsd-net
mailing list