On Fri, Oct 30, 2015 at 01:40:19PM +0100, Alexander Bluhm wrote:
> On Fri, Oct 30, 2015 at 12:56:34PM +0100, Reyk Floeter wrote:
> > --- sys/sys/mbuf.h 22 Oct 2015 05:26:06 -0000 1.198
> > +++ sys/sys/mbuf.h 30 Oct 2015 11:30:33 -0000
> > @@ -410,6 +410,7 @@ struct mbuf *m_get(int, int);
> > struct mbuf *m_getclr(int, int);
> > struct mbuf *m_gethdr(int, int);
> > struct mbuf *m_inithdr(struct mbuf *);
> > +void m_resethdr(struct mbuf *);
> > int m_defrag(struct mbuf *, int);
>
> The m_resethdr should have the same indent as m_defrag.
>
Really? The indent of m_defrag() is wrong - many spaces and not like
the other int functions further down - but I didn't dare to touch it.
It sticks in the eye, so I'll fix m_defrag indent as well.
> > --- sys/net/if_pair.c 25 Oct 2015 12:59:57 -0000 1.4
> > +++ sys/net/if_pair.c 30 Oct 2015 11:30:33 -0000
> > @@ -30,6 +30,11 @@
> > #include <netinet/in.h>
> > #include <netinet/if_ether.h>
> >
> > +#include "pf.h"
> > +#if NPF > 0
> > +#include <net/pfvar.h>
> > +#endif
>
> I think you don't need that anymore.
>
> > @@ -182,9 +187,13 @@ pairstart(struct ifnet *ifp)
> > #endif /* NBPFILTER > 0 */
> >
> > ifp->if_opackets++;
> > - if (pairedifp != NULL)
> > + if (pairedifp != NULL) {
> > +#if NPF > 0
> > + if (m->m_flags & M_PKTHDR)
> > + m_resethdr(m);
> > +#endif
>
> Calling m_tag_delete_chain() is not pf specific, so I would do it
> without the #if NPF.
>
> Otherwise OK bluhm@
>
> Socket splicing somove() does the same thing. I will change it to
> use m_resethdr() after that got commited.
Cool.
I'm going to commit the attached diff for now.
Reyk
Index: sys/kern/uipc_mbuf.c
===================================================================
RCS file: /cvs/src/sys/kern/uipc_mbuf.c,v
retrieving revision 1.208
diff -u -p -u -p -r1.208 uipc_mbuf.c
--- sys/kern/uipc_mbuf.c 22 Oct 2015 05:26:06 -0000 1.208
+++ sys/kern/uipc_mbuf.c 30 Oct 2015 12:45:50 -0000
@@ -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)
{
Index: sys/sys/mbuf.h
===================================================================
RCS file: /cvs/src/sys/sys/mbuf.h,v
retrieving revision 1.198
diff -u -p -u -p -r1.198 mbuf.h
--- sys/sys/mbuf.h 22 Oct 2015 05:26:06 -0000 1.198
+++ sys/sys/mbuf.h 30 Oct 2015 12:45:50 -0000
@@ -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);
Index: sys/net/if_pair.c
===================================================================
RCS file: /cvs/src/sys/net/if_pair.c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 if_pair.c
--- sys/net/if_pair.c 25 Oct 2015 12:59:57 -0000 1.4
+++ sys/net/if_pair.c 30 Oct 2015 12:45:50 -0000
@@ -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);
}