diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-03-27 10:30:59 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-03-27 10:30:59 +0000 |
commit | f717b944041261c893a2722a34efda2347534d69 (patch) | |
tree | df95ed5d4a865afe43569b662f308507ccc331d3 | |
parent | 4765a9879f097c62db1f6524a69875dbee6ee423 (diff) |
Store an ifp index instead of a pointer in the "struct mbuf_ext".
This is part of the plan to remove the ifp pointer from the packet
header that will allow us to stop garbage collecting mbuf(9)s when
an ifp is detached/destroyed.
ok mikeb@, lteo@, benno@
-rw-r--r-- | share/man/man9/mbuf.9 | 6 | ||||
-rw-r--r-- | sys/kern/uipc_mbuf.c | 18 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 4 |
3 files changed, 17 insertions, 11 deletions
diff --git a/share/man/man9/mbuf.9 b/share/man/man9/mbuf.9 index cf3c308ea8e..18d7392bac9 100644 --- a/share/man/man9/mbuf.9 +++ b/share/man/man9/mbuf.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mbuf.9,v 1.69 2014/03/19 10:09:19 mpi Exp $ +.\" $OpenBSD: mbuf.9,v 1.70 2014/03/27 10:30:58 mpi Exp $ .\" .\" Copyright (c) 2001 Jean-Jacques Bernard-Gundol <jjbg@openbsd.org> .\" All rights reserved. @@ -25,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: March 19 2014 $ +.Dd $Mdocdate: March 27 2014 $ .Dt MBUF 9 .Os .Sh NAME @@ -140,7 +140,7 @@ struct mbuf_ext { void *ext_arg; u_int ext_size; int ext_type; - struct ifnet* ext_ifp; + u_short ext_ifidx; int ext_backend; struct mbuf *ext_nextref; struct mbuf *ext_prevref; diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index fb481c133f1..3e3a975c8f3 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.178 2014/01/19 03:04:54 claudio Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.179 2014/03/27 10:30:58 mpi Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -402,15 +402,18 @@ void m_cluncount(struct mbuf *m, int all) { struct mbuf_ext *me; + struct ifnet *ifp; do { me = &m->m_ext; if (((m->m_flags & (M_EXT|M_CLUSTER)) != (M_EXT|M_CLUSTER)) || - (me->ext_ifp == NULL)) + (me->ext_ifidx == 0)) continue; - me->ext_ifp->if_data.ifi_mclpool[me->ext_backend].mcl_alive--; - me->ext_ifp = NULL; + ifp = if_get(me->ext_ifidx); + if (ifp != NULL) + ifp->if_data.ifi_mclpool[me->ext_backend].mcl_alive--; + me->ext_ifidx = 0; } while (all && (m = m->m_next)); } @@ -460,7 +463,10 @@ m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen) m->m_ext.ext_free = NULL; m->m_ext.ext_arg = NULL; m->m_ext.ext_backend = pi; - m->m_ext.ext_ifp = ifp; + if (ifp != NULL) + m->m_ext.ext_ifidx = ifp->if_index; + else + m->m_ext.ext_ifidx = 0; MCLINITREFERENCE(m); return (m); } @@ -1375,7 +1381,7 @@ m_print(void *v, m->m_ext.ext_buf, m->m_ext.ext_size); (*pr)("m_ext.ext_type: %x\tm_ext.ext_backend: %i\n", m->m_ext.ext_type, m->m_ext.ext_backend); - (*pr)("m_ext.ext_ifp: %p\n", m->m_ext.ext_ifp); + (*pr)("m_ext.ext_ifidx: %u\n", m->m_ext.ext_ifidx); (*pr)("m_ext.ext_free: %p\tm_ext.ext_arg: %p\n", m->m_ext.ext_free, m->m_ext.ext_arg); (*pr)("m_ext.ext_nextref: %p\tm_ext.ext_prevref: %p\n", diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 471f7bb7a35..dfcd4ecfd65 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.173 2014/03/19 10:09:20 mpi Exp $ */ +/* $OpenBSD: mbuf.h,v 1.174 2014/03/27 10:30:58 mpi Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -130,7 +130,7 @@ struct mbuf_ext { void *ext_arg; /* argument for ext_free */ u_int ext_size; /* size of buffer, for ext_free */ int ext_type; - struct ifnet* ext_ifp; + u_short ext_ifidx; /* index of the interface */ int ext_backend; /* backend pool the storage came from */ struct mbuf *ext_nextref; struct mbuf *ext_prevref; |