summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-05-20 10:29:02 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-05-20 10:29:02 +0000
commitb9c0d8f7f8d5b75930aa9ee0f4120ed45a1d57b6 (patch)
treebda976d7b156ec410311fcaa7c7ca244d0fe4bfa
parent06769922fecc8d906fd23951155bd73d4ef746a4 (diff)
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@
-rw-r--r--sys/netinet6/in6_ifattach.c21
1 files 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;