svn commit: r202948 - user/luigi/ipfw3-head/sys/netinet/ipfw

Luigi Rizzo luigi at FreeBSD.org
Sun Jan 24 20:35:56 UTC 2010


Author: luigi
Date: Sun Jan 24 20:35:55 2010
New Revision: 202948
URL: http://svn.freebsd.org/changeset/base/202948

Log:
  more testing support

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/Makefile
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_fifo.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_rr.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_test.h
  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_dn_sched.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/Makefile
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/Makefile	Sun Jan 24 20:15:59 2010	(r202947)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/Makefile	Sun Jan 24 20:35:55 2010	(r202948)
@@ -2,13 +2,16 @@
 
 SCHED_SRCS = test_dn_sched.c
 SCHED_SRCS += dn_sched_fifo.c
+SCHED_SRCS += dn_sched_wf2q.c
+SCHED_SRCS += dn_sched_rr.c
+SCHED_SRCS += dn_heap.c
 
 SCHED_OBJS=$(SCHED_SRCS:.c=.o)
 
 HEAP_SRCS = dn_heap.c test_dn_heap.c
 HEAP_OBJS=$(HEAP_SRCS:.c=.o)
 
-CFLAGS = -I../../ -Wall -Werror -O2
+CFLAGS = -I. -Wall -Werror -O2 -DIPFW
 TARGETS= test_heap test_sched
 
 all:	$(TARGETS)

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_fifo.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_fifo.c	Sun Jan 24 20:15:59 2010	(r202947)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_fifo.c	Sun Jan 24 20:35:55 2010	(r202948)
@@ -40,7 +40,7 @@
 #include <netinet/ipfw/ip_dn_private.h>
 #include <netinet/ipfw/dn_sched.h>
 #else
-#include "dn_test.h"
+#include <dn_test.h>
 #endif
 
 /*

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_rr.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_rr.c	Sun Jan 24 20:15:59 2010	(r202947)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_rr.c	Sun Jan 24 20:35:55 2010	(r202948)
@@ -40,7 +40,7 @@
 #include <netinet/ipfw/ip_dn_private.h>
 #include <netinet/ipfw/dn_sched.h>
 #else
-#include "dn_test.h"
+#include <dn_test.h>
 #endif
 
 #define DN_SCHED_RR	3 // XXX Where?
@@ -198,7 +198,7 @@ static int
 rr_config(struct new_schk *_schk)
 {
 	struct rr_schk *schk = (struct rr_schk *)(_schk + 1);
-	printf("%s called\n", __FUNCTION__);
+	D("called");
 
 	schk->min_q = 1;
 	schk->max_q = 1000;
@@ -212,7 +212,7 @@ rr_new_sched(struct new_sch_inst *_si)
 {
 	struct rr_si *si = (struct rr_si *)(_si + 1);
 
-	printf("%s called\n", __FUNCTION__);
+	D("called");
 	si->head = si->tail = NULL;
 
 	return 0;
@@ -221,7 +221,7 @@ rr_new_sched(struct new_sch_inst *_si)
 static int
 rr_free_sched(struct new_sch_inst *_si)
 {
-	printf("%s called\n", __FUNCTION__);
+	D("called");
 	/* Nothing to do? */
 	return 0;
 }
@@ -241,7 +241,7 @@ rr_new_queue(struct new_queue *_q)
 	struct rr_queue *q = (struct rr_queue *)_q;
 	struct rr_schk *schk = (struct rr_schk *)(_q->_si->sched + 1);
 
-	printf("%s called, schk->quantum=%d\n", __FUNCTION__, schk->q_bytes);
+	D("called, schk->quantum=%d", schk->q_bytes);
 	_q->ni.oid.subtype = DN_SCHED_RR;
 
 	q->quantum = _q->fs->fs.par[0] * schk->q_bytes;
@@ -260,7 +260,7 @@ rr_free_queue(struct new_queue *_q)
 {
 	struct rr_queue *q = (struct rr_queue *)_q;
 
-	printf("%s called\n", __FUNCTION__);
+	D("called");
 	if (q->status == 1) {
 		struct rr_si *si = (struct rr_si *)(_q->_si + 1);
 		remove_queue_q(q, si);

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c	Sun Jan 24 20:15:59 2010	(r202947)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c	Sun Jan 24 20:35:55 2010	(r202948)
@@ -41,7 +41,7 @@
 #include <netinet/ipfw/ip_dn_private.h>
 #include <netinet/ipfw/dn_sched.h>
 #else
-#include "dn_test.h"
+#include <dn_test.h>
 #endif
 
 #ifndef MAX64

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_test.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_test.h	Sun Jan 24 20:15:59 2010	(r202947)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_test.h	Sun Jan 24 20:35:55 2010	(r202948)
@@ -1,20 +1,55 @@
 /*
- * Header for testing kernel stuff in userland
+ * userspace compatibility code for dummynet schedulers`
  */
 
 #ifndef _DN_TEST_H
 #define _DN_TEST_H
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <strings.h>	/* bzero */
+#include <string.h>	/* strcmp */
 #include <errno.h>
 #include <inttypes.h>
 #include <sys/queue.h>
 #include <sys/time.h>
 
-#define MALLOC_DECLARE(x)
-#define KASSERT(x, y)	do { if (!(x)) printf y ; exit(0); } while (0)
-struct ipfw_flow_id {
+#define ND(fmt, args...) do {} while (0)
+#define D1(fmt, args...) do {} while (0)
+#define D(fmt, args...) fprintf(stderr, "%-10s " fmt "\n",      \
+	__FUNCTION__, ## args)
+#define DX(lev, fmt, args...) do {              \
+	if (debug > lev) D(fmt, ## args); } while (0)
+
+#define offsetof(t,m) (int)((&((t *)0L)->m))
+
+/* prevent include of other system headers */
+#define        _NETINET_IP_VAR_H_      /* ip_fw_args */
+#define _IPFW2_H
+#define _SYS_MBUF_H_
+
+enum	{
+	DN_QUEUE,
+};
+
+enum	{
+	DN_SCHED_FIFO,
+	DN_SCHED_WF2QP,
+};
+
+struct dn_id {
+	int type, subtype, len, id;
+};
+struct new_fs {
+	int par[1];
+};
+struct new_sch {
+};
+struct dn_flow {
+	struct dn_id oid;
+	int length, len_bytes, drops;
+};
+struct dn_link {
 };
 
 struct ip_fw_args {
@@ -25,8 +60,16 @@ struct mbuf {
 		int len;
 	} m_pkthdr;
 	struct mbuf *m_nextpkt;
-	int flow_id;
+	int flow_id;    /* for testing, index of a flow */
+	int flowset_id; /* for testing, index of a flowset */
+	void *cfg;      /* config args */
 };
+
+#define MALLOC_DECLARE(x)
+#define KASSERT(x, y)	do { if (!(x)) printf y ; exit(0); } while (0)
+struct ipfw_flow_id {
+};
+
 typedef void * module_t;
 struct _md_t {
 	const char *name;
@@ -35,12 +78,38 @@ struct _md_t {
 };
 typedef struct _md_t moduledata_t;
 #define DECLARE_MODULE(name, b, c, d)	\
-	moduledata_t *_g_##name = & name##_mod
+	moduledata_t *_g_##name = & b
 #define MODULE_DEPEND(a, b, c, d, e)
 
-#include <netinet/ip_dummynet.h>
-#include <netinet/ipfw/dn_heap.h>
-#include <netinet/ipfw/ip_dn_private.h>
-#include <netinet/ipfw/dn_sched.h>
+#ifdef IPFW
+#include <dn_heap.h>
+#include <ip_dn_private.h>
+#include <dn_sched.h>
+#else
+struct new_queue {
+	struct new_fsk *fs;             /* parent flowset. */
+	struct new_sch_inst *_si;      /* parent sched instance. */
+};
+struct new_schk {
+};
+struct new_fsk {
+	struct new_fs fs;
+	struct new_schk *sched;
+};
+struct new_sch_inst {
+	struct new_schk *sched;
+};
+struct dn_alg {
+	int type;
+	const char *name;
+	void *enqueue, *dequeue;
+	int q_datalen, si_datalen, schk_datalen;
+	int (*config)(struct new_schk *);
+	int (*new_sched)(struct new_sch_inst *);
+	int (*new_fsk)(struct new_fsk *);
+	int (*new_queue)(struct new_queue *q);
+};
+
+#endif
 
 #endif /* _DN_TEST_H */

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Sun Jan 24 20:15:59 2010	(r202947)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h	Sun Jan 24 20:35:55 2010	(r202948)
@@ -31,6 +31,20 @@
  * internal dummynet APIs.
  */
 
+/* debugging support
+ * use ND() to remove debugging, D() to print a line,
+ * DX(level, ...) to print above a certain level
+ * If you redefine D() you are expected to redefine all.
+ */
+#ifndef D
+#define ND(fmt, args...) do {} while (0)
+#define D1(fmt, args...) do {} while (0)
+#define D(fmt, args...) printf("%-10s " fmt "\n",      \
+        __FUNCTION__, ## args)
+#define DX(lev, fmt, args...) do {              \
+        if (dn_cfg.debug > lev) D(fmt, ## args); } while (0)
+#endif
+
 MALLOC_DECLARE(M_DUMMYNET);
 
 #ifndef FREE_PKT

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Sun Jan 24 20:15:59 2010	(r202947)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c	Sun Jan 24 20:35:55 2010	(r202948)
@@ -34,11 +34,6 @@ __FBSDID("$FreeBSD$");
 
 #include "opt_inet6.h"
 
-/* debug support */
-#define ND(fmt, args...) do {} while (0)
-#define D(fmt, args...) printf("%s %d: " fmt "\n",	\
-	__FUNCTION__ , __LINE__ , ## args)
-
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/test_dn_sched.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/test_dn_sched.c	Sun Jan 24 20:15:59 2010	(r202947)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/test_dn_sched.c	Sun Jan 24 20:35:55 2010	(r202948)
@@ -3,12 +3,6 @@
  */
 
 #include "dn_test.h"
-#include <netinet/ip_dummynet.h>
-#include <netinet/ipfw/dn_heap.h>
-#include <netinet/ipfw/ip_dn_private.h>
-#include <netinet/ipfw/dn_sched.h>
-
-int io_pkt_drop;
 
 void
 m_freem(struct mbuf *m)
@@ -76,6 +70,17 @@ drop:
         q->ni.drops++;
         return 1;
 }
+int
+ipdn_bound_var(int *v, int dflt, int lo, int hi, const char *msg)
+{
+        if (*v < lo) {
+                *v = dflt;
+        } else if (*v > hi) {
+                *v = hi;
+        }
+        return *v;
+}
+
 #ifndef NO_MAIN
 int
 main(int argc, char *argv[])


More information about the svn-src-user mailing list