summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2015-10-30 12:54:37 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2015-10-30 12:54:37 +0000
commitc8467f89a5663b92781c07e7812031a12f2801b5 (patch)
treeba14c6e86538863fe000d0bcb7d528ce100bfc50
parentcec717f7712015bf2b0130106c0aaf5bbdb1a684 (diff)
Add m_resethdr() to clear any state (pf, tags, flags) of an mbuf packet.
Start using it in pair(4) to clear state on the receiving interface; m_resethdr() will also be used in other parts of the stack. OK bluhm@ mikeb@
-rw-r--r--sys/kern/uipc_mbuf.c14
-rw-r--r--sys/net/if_pair.c8
-rw-r--r--sys/sys/mbuf.h5
3 files changed, 21 insertions, 6 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 79443d4cb3b..2c8f87a90da 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.208 2015/10/22 05:26:06 dlg Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.209 2015/10/30 12:54:36 reyk Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -250,6 +250,18 @@ m_inithdr(struct mbuf *m)
return (m);
}
+void
+m_resethdr(struct mbuf *m)
+{
+ /* like the previous, but keep any associated data and mbufs */
+ m->m_flags = M_PKTHDR;
+ memset(&m->m_pkthdr.pf, 0, sizeof(m->m_pkthdr.pf));
+ m->m_pkthdr.pf.prio = IFQ_DEFPRIO;
+
+ /* also delete all mbuf tags to reset the state */
+ m_tag_delete_chain(m);
+}
+
struct mbuf *
m_getclr(int nowait, int type)
{
diff --git a/sys/net/if_pair.c b/sys/net/if_pair.c
index 3d898aa7a35..a614cd7cb69 100644
--- a/sys/net/if_pair.c
+++ b/sys/net/if_pair.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pair.c,v 1.4 2015/10/25 12:59:57 mpi Exp $ */
+/* $OpenBSD: if_pair.c,v 1.5 2015/10/30 12:54:36 reyk Exp $ */
/*
* Copyright (c) 2015 Reyk Floeter <reyk@openbsd.org>
@@ -182,9 +182,11 @@ pairstart(struct ifnet *ifp)
#endif /* NBPFILTER > 0 */
ifp->if_opackets++;
- if (pairedifp != NULL)
+ if (pairedifp != NULL) {
+ if (m->m_flags & M_PKTHDR)
+ m_resethdr(m);
ml_enqueue(&ml, m);
- else
+ } else
m_freem(m);
}
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 69ec7f2fb27..ad5920764de 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.198 2015/10/22 05:26:06 dlg Exp $ */
+/* $OpenBSD: mbuf.h,v 1.199 2015/10/30 12:54:36 reyk Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -410,7 +410,8 @@ struct mbuf *m_get(int, int);
struct mbuf *m_getclr(int, int);
struct mbuf *m_gethdr(int, int);
struct mbuf *m_inithdr(struct mbuf *);
-int m_defrag(struct mbuf *, int);
+void m_resethdr(struct mbuf *);
+int m_defrag(struct mbuf *, int);
struct mbuf *m_prepend(struct mbuf *, int, int);
struct mbuf *m_pulldown(struct mbuf *, int, int, int *);
struct mbuf *m_pullup(struct mbuf *, int);