From e9a5711d34051b307413bc18144830308dd53db8 Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 20 May 2014 10:29:01 +0000 Subject: [PATCH] Fix eui64 address generation, broken since the removal of the link-layer address from the per-ifp list. Found the hard way by weerd@, florian@ and stsp@, ok florian@ --- sys/netinet6/in6_ifattach.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index f1757337b6f..0999976a943 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_ifattach.c,v 1.68 2014/01/21 10:18:26 mpi Exp $ */ +/* $OpenBSD: in6_ifattach.c,v 1.69 2014/05/20 10:29:01 mpi Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -141,14 +141,12 @@ in6_get_rand_ifid(struct ifnet *ifp, struct in6_addr *in6) /* * Get interface identifier for the specified interface. - * XXX assumes single sockaddr_dl (AF_LINK address) per an interface * * in6 - upper 64bits are preserved */ int get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6) { - struct ifaddr *ifa; struct sockaddr_dl *sdl; char *addr; size_t addrlen; @@ -156,21 +154,10 @@ get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6) static u_int8_t allone[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { - if (ifa->ifa_addr->sa_family != AF_LINK) - continue; - sdl = (struct sockaddr_dl *)ifa->ifa_addr; - if (sdl == NULL) - continue; - if (sdl->sdl_alen == 0) - continue; - - goto found; - } - - return -1; + sdl = (struct sockaddr_dl *)ifp->if_sadl; + if (sdl == NULL || sdl->sdl_alen == 0) + return -1; -found: addr = LLADDR(sdl); addrlen = sdl->sdl_alen; -- 2.20.1