diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2010-04-17 18:31:42 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2010-04-17 18:31:42 +0000 |
commit | e3c388cd8ea48dd3cdc9988126f0461b88763ec6 (patch) | |
tree | 746c1edc14d3581634d37fd0cce8e516cddc6327 /sys | |
parent | ea4aefb8ce8ab95d109fee5427682a8176a8a58e (diff) |
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
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 19 |
1 files changed, 18 insertions, 1 deletions
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; |