diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-06-16 11:09:41 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-06-16 11:09:41 +0000 |
commit | 3a3f3f5b2a66fdcf27f621f80a6d0a6d22bfaace (patch) | |
tree | 173fe4df0244a96c60ce236617fe5b7c539ad2f1 /sys/netinet/ipsec_input.c | |
parent | 913f86006f0c78d29161101d7aad233f8f4668df (diff) |
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/netinet/ipsec_input.c')
-rw-r--r-- | sys/netinet/ipsec_input.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c index a95dbda1a6d..013672e123f 100644 --- a/sys/netinet/ipsec_input.c +++ b/sys/netinet/ipsec_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec_input.c,v 1.132 2015/06/11 15:59:17 mikeb Exp $ */ +/* $OpenBSD: ipsec_input.c,v 1.133 2015/06/16 11:09:40 mpi Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -290,7 +290,7 @@ ipsec_common_input(struct mbuf *m, int skip, int protoff, int af, int sproto, } /* XXX This conflicts with the scoped nature of IPv6 */ - m->m_pkthdr.rcvif = encif; + m->m_pkthdr.ph_ifidx = encif->if_index; } /* Register first use, setup expiration timer. */ @@ -1019,8 +1019,12 @@ ah6_input_cb(struct mbuf *m, int off, int protoff) * more sanity checks in header chain processing. */ if (m->m_pkthdr.len < off) { + struct ifnet *ifp; + ip6stat.ip6s_tooshort++; - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated); + ifp = if_get(m->m_pkthdr.ph_ifidx); + if (ifp != NULL) + in6_ifstat_inc(ifp, ifs6_in_truncated); goto bad; } nxt = (*inet6sw[ip6_protox[nxt]].pr_input)(&m, &off, nxt); |