svn commit: r202128 - user/luigi/ipfw3-head/sys/netinet/ipfw
Luigi Rizzo
luigi at FreeBSD.org
Mon Jan 11 23:00:18 UTC 2010
Author: luigi
Date: Mon Jan 11 23:00:17 2010
New Revision: 202128
URL: http://svn.freebsd.org/changeset/base/202128
Log:
clean up a bit the pipe flush code.
Modified:
user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_fifo.c
user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c
user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h Mon Jan 11 22:57:52 2010 (r202127)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched.h Mon Jan 11 23:00:17 2010 (r202128)
@@ -144,7 +144,7 @@ SLIST_HEAD(dn_sched_head, dn_sched);
/*
* delete a queue, which we assume nobody references
*/
-int dn_delete_queue(struct new_queue *q);
+int dn_delete_queue(struct new_queue *q, int extract);
/* Allocate an hash table.
* Returns the pointer to the table
@@ -200,9 +200,9 @@ dn_return_packet(struct new_queue *q)
q->ni.length--;
q->si->ni.len_bytes -= m->m_pkthdr.len;
q->si->ni.len_bytes -= m->m_pkthdr.len;
- if (q->mq.head == NULL && q->fs && q->fs->kflags & DN_DELETE)
- dn_delete_queue(q);
-
+ if (q->mq.head == NULL && q->fs && q->fs->kflags & DN_DELETE) {
+ dn_delete_queue(q, 1 /* remove from ql_list */);
+ }
return m;
}
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_fifo.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_fifo.c Mon Jan 11 22:57:52 2010 (r202127)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_fifo.c Mon Jan 11 23:00:17 2010 (r202128)
@@ -144,23 +144,6 @@ fifo_new_sched(struct new_schk *s, struc
return 0;
}
-static int
-fifo_free_sched(struct new_sch_inst *_si)
-{
- /*
- * Delete a FIFO scheduler instance
- * - Deallocate memory if the create_scheduler_instance() function
- * allocate memory
- * - Delete the queue if exists
- */
- struct fifo_si *si = (struct fifo_si *)(_si + 1);
-
- if (si->q)
- dn_delete_queue(si->q);
-
- return 0;
-}
-
/*
* FIFO scheduler descriptor
* contains the type of the scheduler, the name, the size of the various
@@ -178,7 +161,6 @@ static struct dn_sched fifo_desc = {
.dequeue = fifo_dequeue,
.new_sched = fifo_new_sched,
- .free_sched = fifo_free_sched,
};
DECLARE_DNSCHED_MODULE(dn_fifo, &fifo_desc);
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c Mon Jan 11 22:57:52 2010 (r202127)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c Mon Jan 11 23:00:17 2010 (r202128)
@@ -143,25 +143,8 @@ fifo_new_sched(struct new_schk *s, struc
return 0;
}
-static int
-fifo_free_sched(struct new_sch_inst *_si)
-{
- /*
- * Delete a FIFO scheduler instance
- * - Deallocate memory if the create_scheduler_instance() function
- * allocate memory
- * - Delete the queue if exists
- */
- struct fifo_si *si = (struct fifo_si *)(_si + 1);
-
- if (si->q)
- dn_delete_queue(si->q);
-
- return 0;
-}
-
/*
- * FIFO scheduler descriptor
+ * WF2Q(fake) scheduler descriptor
* contains the type of the scheduler, the name, the size of the various
* structures and function pointers. If a function is not implemented,
* the pointer is initialized to NULL
@@ -177,7 +160,6 @@ static struct dn_sched fifo_desc = {
.dequeue = fifo_dequeue,
.new_sched = fifo_new_sched,
- .free_sched = fifo_free_sched,
};
DECLARE_DNSCHED_MODULE(dn_wf2qp, &fifo_desc);
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c Mon Jan 11 22:57:52 2010 (r202127)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c Mon Jan 11 23:00:17 2010 (r202128)
@@ -280,6 +280,7 @@ transmit_event(struct mq *q, struct dela
struct mbuf *m;
struct dn_pkt_tag *pkt = NULL;
+ dline->oid.subtype = 0; /* not in heap */
while ((m = dline->mq.head) != NULL) {
pkt = dn_tag_get(m);
if (!DN_KEY_LEQ(pkt->output_time, now))
@@ -287,8 +288,10 @@ transmit_event(struct mq *q, struct dela
dline->mq.head = m->m_nextpkt;
mq_append(q, m);
}
- if (m != NULL)
+ if (m != NULL) {
+ dline->oid.subtype = 1; /* in heap */
heap_insert(&dn_cfg.system_heap, pkt->output_time, dline);
+ }
}
#define div64(a, b) ((int64_t)(a) / (int64_t)(b))
@@ -437,6 +440,7 @@ create_si(struct new_schk *s, int slot)
*/
set_oid(&si->ni.oid, DN_SCH_I, 0, sizeof(struct new_inst));
set_oid(&(si->dline.oid), DN_DELAY_LINE, 0, sizeof(struct delay_line));
+ si->ni.oid.id = si->dline.oid.id = -1; /* mark outside scheduler */
si->sched = s;
si->dline.si = si;
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Mon Jan 11 22:57:52 2010 (r202127)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Mon Jan 11 23:00:17 2010 (r202128)
@@ -133,17 +133,16 @@ destroy_si(struct new_sch_inst *si)
struct delay_line *dl = &si->dline;
struct new_queue *q;
- /* XXX below we use oid.id as a marker of presence in the sysheap */
- if (si->ni.oid.id >= 0) /* is in the heap */
+ if (si->kflags & DN_ACTIVE) /* is in the heap */
heap_extract(&dn_cfg.system_heap, si);
if (s->fp->free_sched)
s->fp->free_sched(si);
- if (dl->oid.id >= 0) /* is in the heap */
+ if (dl->oid.subtype) /* is in the heap */
heap_extract(&dn_cfg.system_heap, dl);
dn_free_pkts(dl->mq.head);
while ( (q = SLIST_FIRST(&si->ql_list)) ) {
SLIST_REMOVE_HEAD(&si->ql_list, ql_next);
- dn_delete_queue(q);
+ dn_delete_queue(q, 0);
}
free(si, M_DUMMYNET);
dn_cfg.si_count--;
@@ -218,11 +217,12 @@ dn_create_queue(struct new_sch_inst *si,
* Delete a queue (helper for the schedulers)
*/
int
-dn_delete_queue(struct new_queue *q)
+dn_delete_queue(struct new_queue *q, int extract)
{
struct new_fsk *fs = q->fs;
- SLIST_REMOVE(&q->si->ql_list, q, new_queue, ql_next);
+ if (extract)
+ SLIST_REMOVE(&q->si->ql_list, q, new_queue, ql_next);
if (q->mq.head)
dn_free_pkts(q->mq.head);
if (fs->sched->fp->free_queue)
@@ -236,12 +236,13 @@ dn_delete_queue(struct new_queue *q)
}
static struct new_schk *
-destroy_schk(struct new_schk *s, int del)
+destroy_schk(struct new_schk *s)
{
int i;
struct new_sch_inst *si;
struct dn_sched *fp = s->fp;
+printf("%s slots %d\n", __FUNCTION__, s->ht_slots);
for (i = 0; i < s->ht_slots; i++) {
struct new_sch_inst_head *h = &s->ht[i];
while ((si = SLIST_FIRST(h)) != NULL) {
@@ -360,7 +361,7 @@ dummynet_flush(void)
while ( (s = SLIST_FIRST(sh)) != NULL) {
SLIST_REMOVE_HEAD(sh, next);
- destroy_schk(s, 1 /* delete */);
+ destroy_schk(s);
}
}
@@ -575,7 +576,7 @@ config_sched(struct new_sch *nsch, struc
printf("%s type %s old %p\n", __FUNCTION__, fp->name, s);
if (s && s->fp != fp) { /* type changed, hard delete */
/* preserve old pipe ? */
- s = destroy_schk(s, 1);
+ s = destroy_schk(s);
}
if (s) {
is_new = 0;
More information about the svn-src-user
mailing list