summaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2018-08-26 22:30:01 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2018-08-26 22:30:01 +0000
commit39842f8090104009ac6a98e92649ed6b3e1fa953 (patch)
tree344e69d5909d31c809f471095167514ed1947682 /sys/netinet6
parentefa5ceaa1b2aa1d274196b34ab7d27aed695262c (diff)
Do not add ::1 on non-default lo(4) as intended.
Reported by and ok sthen@
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6_ifattach.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c
index 7ea489a9bd7..2f8463e3a47 100644
--- a/sys/netinet6/in6_ifattach.c
+++ b/sys/netinet6/in6_ifattach.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_ifattach.c,v 1.109 2018/07/10 20:44:39 florian Exp $ */
+/* $OpenBSD: in6_ifattach.c,v 1.110 2018/08/26 22:30:00 mpi Exp $ */
/* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */
/*
@@ -391,10 +391,14 @@ in6_ifattach_linklocal(struct ifnet *ifp, struct in6_addr *ifid)
int
in6_ifattach_loopback(struct ifnet *ifp)
{
+ struct in6_addr in6 = in6addr_loopback;
struct in6_aliasreq ifra;
KASSERT(ifp->if_flags & IFF_LOOPBACK);
+ if (in6ifa_ifpwithaddr(ifp, &in6) != NULL)
+ return (0);
+
bzero(&ifra, sizeof(ifra));
strncpy(ifra.ifra_name, ifp->if_xname, sizeof(ifra.ifra_name));
ifra.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6);
@@ -503,14 +507,14 @@ in6_ifattach(struct ifnet *ifp)
if ((ifp->if_flags & IFF_MULTICAST) == 0)
return (EINVAL);
- /* Assign loopback address, if there's none. */
- if (ifp->if_flags & IFF_LOOPBACK) {
- struct in6_addr in6 = in6addr_loopback;
+ /*
+ * Assign loopback address if this lo(4) interface is the
+ * default for its rdomain.
+ */
+ if ((ifp->if_flags & IFF_LOOPBACK) &&
+ (ifp->if_index == rtable_loindex(ifp->if_rdomain))) {
int error;
- if (in6ifa_ifpwithaddr(ifp, &in6) != NULL)
- return (0);
-
error = in6_ifattach_loopback(ifp);
if (error)
return (error);