From e3c388cd8ea48dd3cdc9988126f0461b88763ec6 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Sat, 17 Apr 2010 18:31:42 +0000 Subject: When the MAC address changes, change the IPv6 link local address accordingly if one is configured and we're not a router. Else IPv6 will leak the old MAC address after "ifconfig $if lladdr random". Based on an initial diff and idea from Theo. OK deraadt, "makes sense" and help by naddy, silent agreement by claudio --- sys/net/if.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'sys/net/if.c') diff --git a/sys/net/if.c b/sys/net/if.c index 2ea274ecf03..64e34aafb64 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.212 2010/04/17 17:46:32 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.213 2010/04/17 18:31:41 stsp Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2249,6 +2249,23 @@ ifnewlladdr(struct ifnet *ifp) ifa->ifa_addr->sa_family == AF_INET) arp_ifinit((struct arpcom *)ifp, ifa); } +#ifdef INET6 + /* Update the link-local address. Don't do it if we're + * a router to avoid confusing hosts on the network. */ + if (!(ifp->if_xflags & IFXF_NOINET6) && !ip6_forwarding) { + ifa = (struct ifaddr *)in6ifa_ifpforlinklocal(ifp, 0); + if (ifa) { + in6_purgeaddr(ifa); + in6_ifattach_linklocal(ifp, NULL); + if (in6if_do_dad(ifp)) { + ifa = (struct ifaddr *) + in6ifa_ifpforlinklocal(ifp, 0); + if (ifa) + nd6_dad_start(ifa, NULL); + } + } + } +#endif if (!up) { /* go back down */ ifp->if_flags &= ~IFF_UP; -- cgit v1.2.3