svn commit: r202146 - user/luigi/ipfw3-head/sys/netinet/ipfw
Luigi Rizzo
luigi at FreeBSD.org
Tue Jan 12 09:07:55 UTC 2010
Author: luigi
Date: Tue Jan 12 09:07:55 2010
New Revision: 202146
URL: http://svn.freebsd.org/changeset/base/202146
Log:
move the tagging out of the main function.
add a flag for schedulers to indicate whether they can handle
multiple queues or not.
Modified:
user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h Tue Jan 12 09:06:36 2010 (r202145)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h Tue Jan 12 09:07:55 2010 (r202146)
@@ -32,6 +32,7 @@
#ifndef _DN_SCHED_H
#define _DN_SCHED_H
+#define DN_MULTIQUEUE 0x01
/*
* Descriptor for the scheduler.
* Contains all function pointers for a given scheduler
@@ -39,7 +40,8 @@
* in a global list of schedulers.
*/
struct dn_sched {
- int type; /* the scheduler type */
+ uint32_t type; /* the scheduler type */
+ uint32_t flags; /* DN_MULTIQUEUE if supports multiple queues */
const char *name; /* scheduler name */
int ref_count; /* XXX number of instances in the system */
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c Tue Jan 12 09:06:36 2010 (r202145)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c Tue Jan 12 09:07:55 2010 (r202146)
@@ -739,6 +739,27 @@ ipdn_locate_flowset(int fs_nr)
return (fs);
}
+static inline int
+tag_mbuf(struct mbuf *m, int dir, struct ip_fw_args *fwa)
+{
+ struct dn_pkt_tag *dt;
+ struct m_tag *mtag;
+
+ mtag = m_tag_get(PACKET_TAG_DUMMYNET,
+ sizeof(*dt), M_NOWAIT | M_ZERO);
+ if (mtag == NULL)
+ return 1; /* Cannot allocate packet header. */
+ m_tag_prepend(m, mtag); /* Attach to mbuf chain. */
+ dt = (struct dn_pkt_tag *)(mtag + 1);
+ dt->rule = fwa->rule;
+ dt->rule.info &= IPFW_ONEPASS; /* only keep this info */
+ dt->dn_dir = dir;
+ dt->ifp = fwa->oif;
+ /* dt->output tame is updated as we move through */
+ dt->output_time = curr_time;
+ return 0;
+}
+
/*
* dummynet hook for packets.
* We use the argument to locate the flowset fs and the sched_set sch
@@ -762,6 +783,7 @@ dummynet_io(struct mbuf **m0, int dir, s
((fwa->rule.info & IPFW_IS_PIPE) ? DN_PIPEOFFSET : 0);
DUMMYNET_LOCK();
io_pkt++;
+ now = curr_time;
/* XXX locate_flowset could be optimised with a direct ref. */
fs = ipdn_locate_flowset(fs_id);
if (fs == NULL)
@@ -772,24 +794,13 @@ dummynet_io(struct mbuf **m0, int dir, s
si = find_sch_inst(fs->sched, &(fwa->f_id));
if (si == NULL)
goto dropit;
-
- /* tag the mbuf */
- {
- struct dn_pkt_tag *dt;
- struct m_tag *mtag;
- mtag = m_tag_get(PACKET_TAG_DUMMYNET,
- sizeof(*dt), M_NOWAIT | M_ZERO);
- if (mtag == NULL)
- goto dropit; /* Cannot allocate packet header. */
- m_tag_prepend(m, mtag); /* Attach to mbuf chain. */
- dt = (struct dn_pkt_tag *)(mtag + 1);
- dt->rule = fwa->rule;
- dt->rule.info &= IPFW_ONEPASS; /* only keep this info */
- dt->dn_dir = dir;
- dt->ifp = fwa->oif;
- /* dt->output tame is updated as we move through */
- dt->output_time = now = curr_time;
- }
+ if (tag_mbuf(m, dir, fwa))
+ goto dropit;
+ /*
+ * if the scheduler has a single queue (e.g. FIFO) then
+ * call directly with NULL queue. Otherwise find a queue
+ * and pass it.
+ */
if (fs->kflags & DN_HAVE_MASK)
do_mask(&fs->fs.flow_mask, &(fwa->f_id));
if (fs->sched->fp->enqueue(si, fs, m, &(fwa->f_id))) {
More information about the svn-src-user
mailing list