Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Nov 2013 05:02:38 +0000 (UTC)
From:      Luigi Rizzo <luigi@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r258467 - head/sys/netpfil/ipfw
Message-ID:  <201311220502.rAM52cEr022439@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luigi
Date: Fri Nov 22 05:02:37 2013
New Revision: 258467
URL: http://svnweb.freebsd.org/changeset/base/258467

Log:
  add a counter on the struct mq (a queue of mbufs),
  and add a block for userspace compiling.

Modified:
  head/sys/netpfil/ipfw/dn_sched.h
  head/sys/netpfil/ipfw/ip_dn_io.c
  head/sys/netpfil/ipfw/ip_dn_private.h

Modified: head/sys/netpfil/ipfw/dn_sched.h
==============================================================================
--- head/sys/netpfil/ipfw/dn_sched.h	Fri Nov 22 05:01:38 2013	(r258466)
+++ head/sys/netpfil/ipfw/dn_sched.h	Fri Nov 22 05:02:37 2013	(r258467)
@@ -166,6 +166,7 @@ dn_dequeue(struct dn_queue *q)
 	if (m == NULL)
 		return NULL;
 	q->mq.head = m->m_nextpkt;
+	q->mq.count--;
 
 	/* Update stats for the queue */
 	q->ni.length--;

Modified: head/sys/netpfil/ipfw/ip_dn_io.c
==============================================================================
--- head/sys/netpfil/ipfw/ip_dn_io.c	Fri Nov 22 05:01:38 2013	(r258466)
+++ head/sys/netpfil/ipfw/ip_dn_io.c	Fri Nov 22 05:02:37 2013	(r258467)
@@ -260,10 +260,39 @@ dn_tag_get(struct mbuf *m)
 static inline void
 mq_append(struct mq *q, struct mbuf *m)
 {
+#ifdef USERSPACE
+	// buffers from netmap need to be copied
+	// XXX note that the routine is not expected to fail
+	ND("append %p to %p", m, q);
+	if (m->m_flags & M_STACK) {
+		struct mbuf *m_new;
+		void *p;
+		int l, ofs;
+
+		ofs = m->m_data - m->__m_extbuf;
+		// XXX allocate
+		MGETHDR(m_new, M_NOWAIT, MT_DATA);
+		ND("*** WARNING, volatile buf %p ext %p %d dofs %d m_new %p",
+			m, m->__m_extbuf, m->__m_extlen, ofs, m_new);
+		p = m_new->__m_extbuf;	/* new pointer */
+		l = m_new->__m_extlen;	/* new len */
+		if (l <= m->__m_extlen) {
+			panic("extlen too large");
+		}
+
+		*m_new = *m;	// copy
+		m_new->m_flags &= ~M_STACK;
+		m_new->__m_extbuf = p; // point to new buffer
+		pkt_copy(m->__m_extbuf, p, m->__m_extlen);
+		m_new->m_data = p + ofs;
+		m = m_new;
+	}
+#endif /* USERSPACE */
 	if (q->head == NULL)
 		q->head = m;
 	else
 		q->tail->m_nextpkt = m;
+	q->count++;
 	q->tail = m;
 	m->m_nextpkt = NULL;
 }
@@ -455,6 +484,7 @@ transmit_event(struct mq *q, struct dela
 		if (!DN_KEY_LEQ(pkt->output_time, now))
 			break;
 		dline->mq.head = m->m_nextpkt;
+		dline->mq.count--;
 		mq_append(q, m);
 	}
 	if (m != NULL) {

Modified: head/sys/netpfil/ipfw/ip_dn_private.h
==============================================================================
--- head/sys/netpfil/ipfw/ip_dn_private.h	Fri Nov 22 05:01:38 2013	(r258466)
+++ head/sys/netpfil/ipfw/ip_dn_private.h	Fri Nov 22 05:02:37 2013	(r258467)
@@ -83,6 +83,7 @@ SLIST_HEAD(dn_alg_head, dn_alg);
 
 struct mq {	/* a basic queue of packets*/
         struct mbuf *head, *tail;
+	int count;
 };
 
 static inline void



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311220502.rAM52cEr022439>