diff options
author | 2015-06-16 11:09:39 +0000 | |
---|---|---|
committer | 2015-06-16 11:09:39 +0000 | |
commit | fb492c3701798fad8024e2bd164905788c83671b (patch) | |
tree | c6607492c9afd90379dbfbaae78d4ee451192462 /sys/netmpls/mpls_input.c | |
parent | Be more strict about BER and DER terminology. (diff) | |
download | wireguard-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/netmpls/mpls_input.c')
-rw-r--r-- | sys/netmpls/mpls_input.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c index 1929786cbdc..622442a79b4 100644 --- a/sys/netmpls/mpls_input.c +++ b/sys/netmpls/mpls_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_input.c,v 1.43 2015/04/10 13:58:20 dlg Exp $ */ +/* $OpenBSD: mpls_input.c,v 1.44 2015/06/16 11:09:40 mpi Exp $ */ /* * Copyright (c) 2008 Claudio Jeker <claudio@openbsd.org> @@ -77,7 +77,7 @@ mplsintr(void) void mpls_input(struct mbuf *m) { - struct ifnet *ifp = m->m_pkthdr.rcvif; + struct ifnet *ifp; struct sockaddr_mpls *smpls; struct sockaddr_mpls sa_mpls; struct shim_hdr *shim; @@ -86,7 +86,8 @@ mpls_input(struct mbuf *m) u_int8_t ttl; int i, hasbos; - if (!ISSET(ifp->if_xflags, IFXF_MPLS)) { + ifp = if_get(m->m_pkthdr.ph_ifidx); + if (ifp == NULL || !ISSET(ifp->if_xflags, IFXF_MPLS)) { m_freem(m); return; } |