summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/raw_ip6.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2015-06-16 11:09:39 +0000
committermpi <mpi@openbsd.org>2015-06-16 11:09:39 +0000
commitfb492c3701798fad8024e2bd164905788c83671b (patch)
treec6607492c9afd90379dbfbaae78d4ee451192462 /sys/netinet6/raw_ip6.c
parentBe more strict about BER and DER terminology. (diff)
downloadwireguard-openbsd-fb492c3701798fad8024e2bd164905788c83671b.tar.xz
wireguard-openbsd-fb492c3701798fad8024e2bd164905788c83671b.zip
Store a unique ID, an interface index, rather than a pointer to the
receiving interface in the packet header of every mbuf. The interface pointer should now be retrieved when necessary with if_get(). If a NULL pointer is returned by if_get(), the interface has probably been destroy/removed and the mbuf should be freed. Such mechanism will simplify garbage collection of mbufs and limit problems with dangling ifp pointers. Tested by jmatthew@ and krw@, discussed with many. ok mikeb@, bluhm@, dlg@
Diffstat (limited to 'sys/netinet6/raw_ip6.c')
-rw-r--r--sys/netinet6/raw_ip6.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 83a8d75c14a..0003bd65627 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip6.c,v 1.74 2015/06/08 22:19:28 krw Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.75 2015/06/16 11:09:40 mpi Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@@ -223,10 +223,15 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
m_freem(m);
else {
u_int8_t *prvnxtp = ip6_get_prevhdr(m, *offp); /* XXX */
- in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_protounknown);
- icmp6_error(m, ICMP6_PARAM_PROB,
- ICMP6_PARAMPROB_NEXTHEADER,
- prvnxtp - mtod(m, u_int8_t *));
+ struct ifnet *ifp;
+
+ ifp = if_get(m->m_pkthdr.ph_ifidx);
+ if (ifp != NULL) {
+ in6_ifstat_inc(ifp, ifs6_in_protounknown);
+ icmp6_error(m, ICMP6_PARAM_PROB,
+ ICMP6_PARAMPROB_NEXTHEADER,
+ prvnxtp - mtod(m, u_int8_t *));
+ }
}
ip6stat.ip6s_delivered--;
}