Date: Wed, 20 Jan 2010 09:11:42 +0000 (UTC) From: Luigi Rizzo <luigi@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r202681 - user/luigi/ipfw3-head/sys/netinet/ipfw Message-ID: <201001200911.o0K9Bgeh068104@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: luigi Date: Wed Jan 20 09:11:42 2010 New Revision: 202681 URL: http://svn.freebsd.org/changeset/base/202681 Log: add DN_LOCK_DESTROY, plus other small cleanups Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c Wed Jan 20 08:41:58 2010 (r202680) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c Wed Jan 20 09:11:42 2010 (r202681) @@ -76,11 +76,8 @@ heap_resize(struct dn_heap *h, int new_s { struct dn_heap_entry *p; - if (h->size >= new_size ) { - printf("--- %s: Bogus call, have %d want %d\n", - __func__, h->size, new_size); + if (h->size >= new_size ) /* have enough room */ return 0; - } new_size = (new_size + HEAP_INCREMENT ) & ~HEAP_INCREMENT; p = malloc(new_size * sizeof(*p), M_DN_HEAP, M_NOWAIT); if (p == NULL) { Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h Wed Jan 20 08:41:58 2010 (r202680) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h Wed Jan 20 09:11:42 2010 (r202681) @@ -42,7 +42,7 @@ MALLOC_DECLARE(M_DUMMYNET); mtx_init(&dn_cfg.uh_mtx, "dn_uh", NULL, MTX_DEF); \ mtx_init(&dn_cfg.bh_mtx, "dn_bh", NULL, MTX_DEF); \ } while (0) -#define DUMMYNET_LOCK_DESTROY() do { \ +#define DN_LOCK_DESTROY() do { \ mtx_destroy(&dn_cfg.uh_mtx); \ mtx_destroy(&dn_cfg.bh_mtx); \ } while (0) @@ -157,7 +157,6 @@ struct delay_line { struct new_fsk { /* kernel side of a flowset */ struct new_fs fs; SLIST_ENTRY(new_fsk) fsk_next; /* hash chain list */ - int refcnt; /* entries in qht */ /* hash table of queues, or just single queue */ struct dn_ht *_qht; @@ -228,8 +227,8 @@ struct new_sch_inst { /* kernel-side flags */ enum { /* 1 and 2 are reserved for the SCAN flags */ - DN_DELETE = 0x0004, /* destroy when refcnt=0 */ - DN_DELETE_FS = 0x0008, /* destroy when refcnt=0 */ + DN_DELETE = 0x0004, /* destroy */ + DN_DELETE_FS = 0x0008, /* destroy flowset */ DN_DETACH = 0x0010, DN_ACTIVE = 0x0020, /* object is in evheap */ DN_F_DLINE = 0x0040, /* object is a delay line */ Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Wed Jan 20 08:41:58 2010 (r202680) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Wed Jan 20 09:11:42 2010 (r202681) @@ -248,8 +248,12 @@ q_new(uintptr_t key, int flags, void *ar q->ni.id = *(struct ipfw_flow_id *)key; q->fs = fs; q->_si = template->_si; - fs->refcnt++; - + printf("-- %s fs %p si %p mask p %d f %d 0x%08x:%d -> 0x%08x:%d\n", + __FUNCTION__, q->fs, q->_si, + q->ni.id.proto, q->ni.id.flags, + q->ni.id.src_ip, q->ni.id.src_port, + q->ni.id.dst_ip, q->ni.id.dst_port); + if (fs->sched->fp->new_queue) fs->sched->fp->new_queue(q); dn_cfg.queue_count++; @@ -276,7 +280,6 @@ dn_delete_queue(struct new_queue *q, int dn_free_pkts(q->mq.head); free(q, M_DUMMYNET); dn_cfg.queue_count--; - fs->refcnt--; } } @@ -740,6 +743,20 @@ struct copy_args { }; static int +copy_flowset(struct copy_args *a, struct new_fsk *fs, int flags) +{ + struct new_fs *ufs = (struct new_fs *)(*a->start); + if (!fs) + return 0; + if (copy_obj(a->start, a->end, &fs->fs)) + return DNHT_SCAN_END; + ufs->oid.id = 0; /* XXX number of queues ? */ + if (flags) { /* copy queues */ + } + return 0; +} + +static int copy_data_helper(void *_o, void *_arg) { struct copy_args *a = _arg; @@ -749,7 +766,7 @@ copy_data_helper(void *_o, void *_arg) if (a->flags & DN_C_PIPE) { if (copy_obj(a->start, a->end, &s->pipe)) return DNHT_SCAN_END; - if (s->fs && copy_obj(a->start, a->end, &s->fs->fs)) + if (copy_flowset(a, s->fs, 0)) return DNHT_SCAN_END; } if (a->flags & DN_C_SCH) { @@ -762,13 +779,10 @@ copy_data_helper(void *_o, void *_arg) } if (a->type == DN_FS) { /* scanning flowsets */ struct new_fsk *fs = _o; - struct new_fs *ufs = - (struct new_fs *)(*a->start); /* if extra is set, only copy unlinked ones */ if (a->extra == 0 || fs->sched == NULL) { - if (copy_obj(a->start, a->end, &fs->fs)) + if (copy_flowset(a, fs, 0)) return DNHT_SCAN_END; - ufs->oid.id = fs->refcnt; } } return 0; @@ -929,12 +943,13 @@ config_fs(struct new_fs *nfs, struct dn_ if (fs == NULL) break; if (nfs->sched_nr == 0) { - printf("reuse existing number %d\n", fs->fs.sched_nr); - if (fs->fs.sched_nr == 0) { - fs = NULL; - break; + if (fs->fs.sched_nr != 0) { /* reuse */ + nfs->sched_nr = fs->fs.sched_nr; + } else { + printf("missing sched for flowset %d\n", i); + fs = NULL; + break; } - nfs->sched_nr = fs->fs.sched_nr; } dn_cfg.id++; if (bcmp(&fs->fs, nfs, sizeof(*nfs)) == 0) { @@ -1251,13 +1266,6 @@ compute_space(struct dn_id *cmd, int *to break; } *to_copy = x; - printf("have %d.%d sched %d, %d.%d pipes %d, %d.%d flows %d, " - "%d.%d si %d, %d.%d queues %d\n", - dn_cfg.schk_count, sizeof(struct new_sch), DN_SCH, - dn_cfg.schk_count, sizeof(struct new_pipe), DN_PIPE, - dn_cfg.fsk_count, sizeof(struct new_fs), DN_FS, - dn_cfg.si_count, sizeof(struct new_inst), DN_SCH_I, - dn_cfg.queue_count, sizeof(struct new_queue), DN_QUEUE); if (x & DN_C_SCH) need += dn_cfg.schk_count * sizeof(struct new_sch); if (x & DN_C_FS) @@ -1314,6 +1322,13 @@ dummynet_get(struct sockopt *sopt) } if (start == NULL) return sooptcopyout(sopt, &cmd, sizeof(cmd)); + printf("have %d:%d sched %d, %d:%d pipes %d, %d:%d flows %d, " + "%d.%d si %d, %d.%d queues %d\n", + dn_cfg.schk_count, sizeof(struct new_sch), DN_SCH, + dn_cfg.schk_count, sizeof(struct new_pipe), DN_PIPE, + dn_cfg.fsk_count, sizeof(struct new_fs), DN_FS, + dn_cfg.si_count, sizeof(struct new_inst), DN_SCH_I, + dn_cfg.queue_count, sizeof(struct new_queue), DN_QUEUE); end = start + have; sopt->sopt_valsize = sopt_valsize; bcopy(&cmd, start, sizeof(cmd));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001200911.o0K9Bgeh068104>