summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2014-05-20 10:29:01 +0000
committermpi <mpi@openbsd.org>2014-05-20 10:29:01 +0000
commite9a5711d34051b307413bc18144830308dd53db8 (patch)
treecca7a80c20eecd9fb802d7e62c2fee2030034bf2
parentcorrectly match size and buffer. from enh at google (diff)
downloadwireguard-openbsd-e9a5711d34051b307413bc18144830308dd53db8.tar.xz
wireguard-openbsd-e9a5711d34051b307413bc18144830308dd53db8.zip
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;