From owner-svn-src-user@FreeBSD.ORG Tue Jan 5 17:05:12 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 832EC1065884; Tue, 5 Jan 2010 17:05:12 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 687818FC1A; Tue, 5 Jan 2010 17:05:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o05H5Cqe058428; Tue, 5 Jan 2010 17:05:12 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05H5CNL058426; Tue, 5 Jan 2010 17:05:12 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <201001051705.o05H5CNL058426@svn.freebsd.org> From: Luigi Rizzo Date: Tue, 5 Jan 2010 17:05:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201595 - user/luigi/ipfw3-head/sys/netinet/ipfw X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jan 2010 17:05:12 -0000 Author: luigi Date: Tue Jan 5 17:05:12 2010 New Revision: 201595 URL: http://svn.freebsd.org/changeset/base/201595 Log: simplify a function Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c ============================================================================== --- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Tue Jan 5 17:04:39 2010 (r201594) +++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dummynet.c Tue Jan 5 17:05:12 2010 (r201595) @@ -38,7 +38,6 @@ __FBSDID("$FreeBSD$"); * Description of the data structures used is in ip_dummynet.h * Here you mainly find the following blocks of code: * + variable declarations; - * + heap management functions; * + scheduler and dummynet functions; * + configuration and initialization. * @@ -1624,6 +1623,7 @@ config_pipe(struct dn_pipe *p) pipe = locate_pipe(p->pipe_nr); /* locate pipe */ if (pipe == NULL) { /* new pipe */ + /* space for pipe + 3 heaps right after the pipe */ pipe = malloc(sizeof(struct dn_pipe) + 3 * sizeof(struct dn_heap), M_DUMMYNET, M_NOWAIT | M_ZERO); @@ -1633,7 +1633,6 @@ config_pipe(struct dn_pipe *p) return (ENOMEM); } - /* the heaps are right after the pipe */ pipe->scheduler_heap = (struct dn_heap *)(pipe + 1); pipe->not_eligible_heap = pipe->scheduler_heap + 1; pipe->idle_heap = pipe->scheduler_heap + 2; @@ -1820,22 +1819,21 @@ dummynet_drain(void) static int delete_pipe(struct dn_pipe *p) { - - if (p->pipe_nr == 0 && p->fs.fs_nr == 0) - return EINVAL ; - if (p->pipe_nr != 0 && p->fs.fs_nr != 0) + struct dn_pipe *pipe; + struct dn_flow_set *fs; + int err = 0; + + if (p->pipe_nr != 0 && p->fs.fs_nr != 0) /* cannot have both set */ return EINVAL ; + DUMMYNET_LOCK(); if (p->pipe_nr != 0) { /* this is an old-style pipe */ - struct dn_pipe *pipe; - struct dn_flow_set *fs; int i; - DUMMYNET_LOCK(); pipe = locate_pipe(p->pipe_nr); /* locate pipe */ if (pipe == NULL) { - DUMMYNET_UNLOCK(); - return (ENOENT); /* not found */ + err = ENOENT; /* not found */ + goto done; } /* Unlink from list of pipes. */ @@ -1857,18 +1855,14 @@ delete_pipe(struct dn_pipe *p) /* remove reference to here from extract_heap and wfq_ready_heap */ heap_scan(&extract_heap, scan_remove_pipe, (uintptr_t)pipe); heap_scan(&wfq_ready_heap, scan_remove_pipe, (uintptr_t)pipe); - DUMMYNET_UNLOCK(); - - free_pipe(pipe); } else { /* this is a WF2Q queue (dn_flow_set) */ - struct dn_flow_set *fs; + pipe = NULL; - DUMMYNET_LOCK(); fs = locate_flowset(p->fs.fs_nr); /* locate set */ if (fs == NULL) { - DUMMYNET_UNLOCK(); - return (ENOENT); /* not found */ + err = ENOENT; /* not found */ + goto done; } /* Unlink from list of flowsets. */ @@ -1879,14 +1873,15 @@ delete_pipe(struct dn_pipe *p) fs->pipe->sum -= fs->weight * fs->backlogged ; fs_remove_from_heap(fs->pipe->not_eligible_heap, fs); fs_remove_from_heap(fs->pipe->scheduler_heap, fs); -#if 1 /* XXX should i remove from idle_heap as well ? */ fs_remove_from_heap(fs->pipe->idle_heap, fs); -#endif } purge_flow_set(fs, 1); - DUMMYNET_UNLOCK(); } - return 0 ; +done: + DUMMYNET_UNLOCK(); + if (pipe) + free_pipe(pipe); + return err; } /*