From owner-svn-src-head@FreeBSD.ORG Fri Nov 22 05:02:38 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CE4D91B1; Fri, 22 Nov 2013 05:02:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A438F2817; Fri, 22 Nov 2013 05:02:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAM52cLl022445; Fri, 22 Nov 2013 05:02:38 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAM52cEr022439; Fri, 22 Nov 2013 05:02:38 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201311220502.rAM52cEr022439@svn.freebsd.org> From: Luigi Rizzo Date: Fri, 22 Nov 2013 05:02:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258467 - head/sys/netpfil/ipfw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Nov 2013 05:02:38 -0000 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