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/net/if_bridge.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/net/if_bridge.c')
-rw-r--r-- | sys/net/if_bridge.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 8f66923843e..15d77b216cc 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.243 2015/06/12 15:40:06 mpi Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.244 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -1143,7 +1143,11 @@ bridgeintr_frame(struct bridge_softc *sc, struct mbuf *m) return; } - src_if = m->m_pkthdr.rcvif; + src_if = if_get(m->m_pkthdr.ph_ifidx); + if (src_if == NULL) { + m_freem(m); + return; + } sc->sc_if.if_ipackets++; sc->sc_if.if_ibytes += m->m_pkthdr.len; @@ -2464,8 +2468,11 @@ bridge_ip(struct bridge_softc *sc, int dir, struct ifnet *ifp, ip6 = mtod(m, struct ip6_hdr *); if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) { + struct ifnet *ifp; ip6stat.ip6s_badvers++; - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr); + ifp = if_get(m->m_pkthdr.ph_ifidx); + if (ifp != NULL) + in6_ifstat_inc(ifp, ifs6_in_hdrerr); goto dropit; } |