From owner-svn-src-user@FreeBSD.ORG Sat Jun 6 22:06:38 2009 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 7D349106566B; Sat, 6 Jun 2009 22:06:38 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6BCDA8FC08; Sat, 6 Jun 2009 22:06:38 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n56M6cVm073029; Sat, 6 Jun 2009 22:06:38 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n56M6ciV073026; Sat, 6 Jun 2009 22:06:38 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200906062206.n56M6ciV073026@svn.freebsd.org> From: Kip Macy Date: Sat, 6 Jun 2009 22:06:38 +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: r193595 - user/kmacy/releng_7_2_fcs/sys/net 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: Sat, 06 Jun 2009 22:06:38 -0000 Author: kmacy Date: Sat Jun 6 22:06:37 2009 New Revision: 193595 URL: http://svn.freebsd.org/changeset/base/193595 Log: ensure that all stale references to the interface are freed before the memory is deallocated Modified: user/kmacy/releng_7_2_fcs/sys/net/flowtable.c user/kmacy/releng_7_2_fcs/sys/net/flowtable.h user/kmacy/releng_7_2_fcs/sys/net/if.c Modified: user/kmacy/releng_7_2_fcs/sys/net/flowtable.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/flowtable.c Sat Jun 6 21:23:29 2009 (r193594) +++ user/kmacy/releng_7_2_fcs/sys/net/flowtable.c Sat Jun 6 22:06:37 2009 (r193595) @@ -36,7 +36,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include @@ -170,6 +172,10 @@ static uint32_t hashjitter; static uma_zone_t ipv4_zone; static uma_zone_t ipv6_zone; +static struct cv flowclean_cv; +static struct mtx flowclean_lock; +static uint64_t flowclean_cycles; + /* * TODO: * - Make flowtable stats per-cpu, aggregated at sysctl call time, @@ -774,6 +780,8 @@ flowtable_setup(void *arg) NULL, NULL, NULL, 64, UMA_ZONE_MAXBUCKET); uma_zone_set_max(ipv4_zone, nmbflows); uma_zone_set_max(ipv6_zone, nmbflows); + cv_init(&flowclean_cv, "flowcleanwait"); + mtx_init(&flowclean_lock, "flowclean lock", NULL, MTX_DEF); } SYSINIT(flowtable_setup, SI_SUB_KTHREAD_INIT, SI_ORDER_ANY, flowtable_setup, NULL); @@ -915,12 +923,30 @@ flowtable_cleaner(void) } ft = ft->ft_next; } + flowclean_cycles++; /* * The 20 second interval between cleaning checks * is arbitrary */ - pause("flowcleanwait", 20*hz); + mtx_lock(&flowclean_lock); + cv_broadcast(&flowclean_cv); + cv_timedwait(&flowclean_cv, &flowclean_lock, 10*hz); + mtx_unlock(&flowclean_lock); + } +} + +void +flowtable_flush(void) +{ + uint64_t start; + + mtx_lock(&flowclean_lock); + start = flowclean_cycles; + while (start == flowclean_cycles) { + cv_broadcast(&flowclean_cv); + cv_wait(&flowclean_cv, &flowclean_lock); } + mtx_unlock(&flowclean_lock); } static struct kproc_desc flow_kp = { Modified: user/kmacy/releng_7_2_fcs/sys/net/flowtable.h ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/flowtable.h Sat Jun 6 21:23:29 2009 (r193594) +++ user/kmacy/releng_7_2_fcs/sys/net/flowtable.h Sat Jun 6 22:06:37 2009 (r193595) @@ -56,6 +56,8 @@ struct flowtable *flowtable_alloc(int ne int flowtable_lookup(struct flowtable *ft, struct mbuf *m, struct route *ro); +void flowtable_flush(void); + #else static __inline struct flowtable * flowtable_alloc(int nentry, int flags) @@ -71,6 +73,13 @@ flowtable_lookup(struct flowtable *ft, s return (ENOTSUP); } + +static __inlnie void +flowtable_flush(void) +{ + ; +} + #endif #endif Modified: user/kmacy/releng_7_2_fcs/sys/net/if.c ============================================================================== --- user/kmacy/releng_7_2_fcs/sys/net/if.c Sat Jun 6 21:23:29 2009 (r193594) +++ user/kmacy/releng_7_2_fcs/sys/net/if.c Sat Jun 6 22:06:37 2009 (r193595) @@ -71,6 +71,7 @@ #include #include #include +#include #include #if defined(INET) || defined(INET6) @@ -499,7 +500,7 @@ if_alloc(u_char type) void if_free(struct ifnet *ifp) { - + flowtable_flush(); if_free_type(ifp, ifp->if_type); }