summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/ip6_input.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2016-11-14 10:32:46 +0000
committermpi <mpi@openbsd.org>2016-11-14 10:32:46 +0000
commit3a63dfc0a7570a1d3db367d368db7715b946fa77 (patch)
tree113a26f127ac2afe7bdff22e99b2a3e01b8b7259 /sys/netinet6/ip6_input.c
parentspecify ordering and precedence of location { } sections; (diff)
downloadwireguard-openbsd-3a63dfc0a7570a1d3db367d368db7715b946fa77.tar.xz
wireguard-openbsd-3a63dfc0a7570a1d3db367d368db7715b946fa77.zip
Automatically create a default lo(4) interface per rdomain.
In order to stop abusing lo0 for all rdomains, a new loopback interface will be created every time a rdomain is created. The unit number will be the same as the rdomain, i.e. lo1 will be attached to rdomain 1. If this loopback interface is already in use it wont be possible to create the corresponding rdomain. In order to know which lo(4) interface is attached to a rdomain, its index is stored in the rtable/rdomain map. This is a long overdue since the introduction of rtable/rdomain. It also fixes a recent regression due to resetting the rdomain of an incoming packet reported by semarie@, Andreas Bartelt and Nils Frohberg. ok claudio@
Diffstat (limited to 'sys/netinet6/ip6_input.c')
-rw-r--r--sys/netinet6/ip6_input.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 9ac2555e632..4688d738f8d 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.168 2016/08/24 09:41:12 mpi Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.169 2016/11/14 10:32:46 mpi Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -210,10 +210,11 @@ ip6_input(struct mbuf *m)
ip6stat.ip6s_mext1++;
} else {
if (m->m_next) {
- if (m->m_flags & M_LOOP) {
- ip6stat.ip6s_m2m[lo0ifidx]++; /*XXX*/
- } else if (ifp->if_index < nitems(ip6stat.ip6s_m2m))
- ip6stat.ip6s_m2m[ifp->if_index]++;
+ int ifidx = m->m_pkthdr.ph_ifidx;
+ if (m->m_flags & M_LOOP)
+ ifidx = rtable_loindex(m->m_pkthdr.ph_rtableid);
+ if (ifidx < nitems(ip6stat.ip6s_m2m))
+ ip6stat.ip6s_m2m[ifidx]++;
else
ip6stat.ip6s_m2m[0]++;
} else