svn commit: r203491 - in user/luigi/ipfw3-head/sys/netinet/ipfw: . test

Luigi Rizzo luigi at FreeBSD.org
Thu Feb 4 15:26:17 UTC 2010


Author: luigi
Date: Thu Feb  4 15:26:16 2010
New Revision: 203491
URL: http://svn.freebsd.org/changeset/base/203491

Log:
  correct handling of masks.
  try to build a tarball of test sources

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
  user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/test/Makefile

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Thu Feb  4 15:17:49 2010	(r203490)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Thu Feb  4 15:26:16 2010	(r203491)
@@ -182,7 +182,9 @@ struct dn_fsk { /* kernel side of a flow
 
 	struct ipfw_flow_id fsk_mask;
 
-	/* qht is a hash table of queues, or just a single queue */
+	/* qht is a hash table of queues, or just a single queue
+	 * a bit in fs.flags tells us which one
+	 */
 	struct dn_ht	*qht;
 	struct dn_schk *sched;		/* Sched we are linked to */
 	SLIST_ENTRY(dn_fsk) sch_chain;	/* list of fsk attached to sched */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Thu Feb  4 15:17:49 2010	(r203490)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Thu Feb  4 15:26:16 2010	(r203491)
@@ -169,6 +169,27 @@ flow_id_or(struct ipfw_flow_id *src, str
 	return dst;
 }
 
+static int
+nonzero_mask(struct ipfw_flow_id *m)
+{
+	if (m->dst_port || m->src_port || m->proto)
+		return 1;
+	if (IS_IP6_FLOW_ID(m)) {
+		return
+			m->dst_ip6.__u6_addr.__u6_addr32[0] ||
+			m->dst_ip6.__u6_addr.__u6_addr32[1] ||
+			m->dst_ip6.__u6_addr.__u6_addr32[2] ||
+			m->dst_ip6.__u6_addr.__u6_addr32[3] ||
+			m->src_ip6.__u6_addr.__u6_addr32[0] ||
+			m->src_ip6.__u6_addr.__u6_addr32[1] ||
+			m->src_ip6.__u6_addr.__u6_addr32[2] ||
+			m->src_ip6.__u6_addr.__u6_addr32[3] ||
+			m->flow_id6;
+	} else {
+		return m->dst_ip || m->src_ip;
+	}
+}
+
 /* XXX we may want a better hash function */
 static uint32_t
 flow_id_hash(struct ipfw_flow_id *id)
@@ -329,7 +350,7 @@ qht_delete(struct dn_fsk *fs, int flags)
 		fs->fs.fs_nr, flags, fs->qht);
 	if (!fs->qht)
 		return;
-	if (fs->fs.flags & DN_HAVE_MASK) {
+	if (fs->fs.flags & DN_QHT_HASH) {
 		dn_ht_scan(fs->qht, q_delete_cb, (void *)(uintptr_t)flags);
 		if (flags & DN_DESTROY) {
 			dn_ht_free(fs->qht, 0);
@@ -355,7 +376,7 @@ ipdn_q_find(struct dn_fsk *fs, struct dn
 	template._si = si;
 	template.fs = fs;
 
-	if (fs->fs.flags & DN_HAVE_MASK) {
+	if (fs->fs.flags & DN_QHT_HASH) {
 		struct ipfw_flow_id masked_id;
 		if (fs->qht == NULL) {
 			fs->qht = dn_ht_init(NULL, fs->fs.buckets,
@@ -789,7 +810,7 @@ copy_q(struct copy_args *a, struct dn_fs
 {
 	if (!fs->qht)
 		return 0;
-	if (fs->fs.flags & DN_HAVE_MASK)
+	if (fs->fs.flags & DN_QHT_HASH)
 		dn_ht_scan(fs->qht, copy_q_cb, a);
 	else
 		copy_q_cb(fs->qht, a);
@@ -805,7 +826,7 @@ copy_flowset(struct copy_args *a, struct
 	ND("flowset %d", fs->fs.fs_nr);
 	if (copy_obj(a->start, a->end, &fs->fs, "flowset", fs->fs.fs_nr))
 		return DNHT_SCAN_END;
-	ufs->oid.id = (fs->fs.flags & DN_HAVE_MASK) ?
+	ufs->oid.id = (fs->fs.flags & DN_QHT_HASH) ?
 		dn_ht_entries(fs->qht) : (fs->qht ? 1 : 0);
 	if (flags) {	/* copy queues */
 		copy_q(a, fs, 0);
@@ -930,14 +951,24 @@ fsk_attach(struct dn_fsk *fs, struct dn_
 	fs->fsk_mask = fs->fs.flow_mask;
 	if (fs->sched->sch.flags & DN_HAVE_MASK)
 		flow_id_or(&fs->sched->sch.sched_mask, &fs->fsk_mask);
-	if (!fs->qht)
-		return;
-	D("XXX TODO requeue from fs %d to sch %d",
-		fs->fs.fs_nr, s->sch.sched_nr);
-	/*
-	 * The requeue is complex -- in general we need to
-	 * reclassify every single packet.
-	 */
+	if (fs->qht) {
+		/*
+		 * we must drain qht according to the old
+		 * type, and reinsert according to the new one.
+		 * The requeue is complex -- in general we need to
+		 * reclassify every single packet.
+		 * For the time being, let's hope qht is never set
+		 * when we reach this point.
+		 */
+		D("XXX TODO requeue from fs %d to sch %d",
+			fs->fs.fs_nr, s->sch.sched_nr);
+		fs->qht = NULL;
+	}
+	/* set the new type for qht */
+	if (nonzero_mask(&fs->fsk_mask))
+		fs->fs.flags |= DN_QHT_HASH;
+	else
+		fs->fs.flags &= ~DN_QHT_HASH;
 }
 
 /* update all flowsets which may refer to this scheduler */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/test/Makefile
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/test/Makefile	Thu Feb  4 15:17:49 2010	(r203490)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/test/Makefile	Thu Feb  4 15:26:16 2010	(r203491)
@@ -31,3 +31,16 @@ main.o: mylist.h
 
 clean:
 	- rm *.o $(TARGETS) *.core
+
+ALLSRCS = $(SCHED_SRCS) dn_test.h mylist.h \
+	dn_sched.h dn_heap.h ip_dn_private.h Makefile
+TMPBASE = /tmp/testXYZ
+TMPDIR = $(TMPBASE)/test
+
+tgz:
+	-rm -rf $(TMPDIR)
+	mkdir -p $(TMPDIR)
+	-cp -p $(ALLSRCS) $(TMPDIR)
+	-(cd ..; cp -p $(ALLSRCS) $(TMPDIR))
+	ls -la  $(TMPDIR)
+	(cd $(TMPBASE); tar cvzf /tmp/test.tgz test)


More information about the svn-src-user mailing list