svn commit: r193595 - user/kmacy/releng_7_2_fcs/sys/net

Kip Macy kmacy at FreeBSD.org
Sat Jun 6 22:06:38 UTC 2009


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 <sys/param.h>  
 #include <sys/types.h>
 #include <sys/bitstring.h>
+#include <sys/condvar.h>
 #include <sys/callout.h>
+#include <sys/mbuf.h>
 #include <sys/kernel.h>  
 #include <sys/kthread.h>
 #include <sys/limits.h>
@@ -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 <net/if_var.h>
 #include <net/radix.h>
 #include <net/route.h>
+#include <net/flowtable.h>
 #include <net/vnet.h>
 
 #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);
 }
 


More information about the svn-src-user mailing list