svn commit: r234557 - in stable/9/sys: modules/netgraph/netflow netgraph/netflow

Alexander V. Chernikov melifaro at FreeBSD.org
Sat Apr 21 19:22:54 UTC 2012


Author: melifaro
Date: Sat Apr 21 19:22:53 2012
New Revision: 234557
URL: http://svn.freebsd.org/changeset/base/234557

Log:
  MFC r232921:
  
  Use rt_numfibs variable instead of compile-time RT_NUMFIBS.
  
  Approved by:    kib(mentor)

Modified:
  stable/9/sys/modules/netgraph/netflow/Makefile
  stable/9/sys/netgraph/netflow/netflow.c
  stable/9/sys/netgraph/netflow/ng_netflow.c
  stable/9/sys/netgraph/netflow/ng_netflow.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/modules/netgraph/netflow/Makefile
==============================================================================
--- stable/9/sys/modules/netgraph/netflow/Makefile	Sat Apr 21 18:36:53 2012	(r234556)
+++ stable/9/sys/modules/netgraph/netflow/Makefile	Sat Apr 21 19:22:53 2012	(r234557)
@@ -17,8 +17,6 @@ opt_inet6.h:
 	echo "#define INET6 1" > ${.TARGET}
 .endif
 
-opt_route.h:
-	echo "#define ROUTETABLES RT_MAXFIBS" > ${.TARGET}
 .endif
 
 .include <bsd.kmod.mk>

Modified: stable/9/sys/netgraph/netflow/netflow.c
==============================================================================
--- stable/9/sys/netgraph/netflow/netflow.c	Sat Apr 21 18:36:53 2012	(r234556)
+++ stable/9/sys/netgraph/netflow/netflow.c	Sat Apr 21 19:22:53 2012	(r234557)
@@ -630,7 +630,7 @@ ng_netflow_cache_flush(priv_p priv)
 		free(priv->hash6, M_NETFLOW_HASH);
 #endif
 
-	for (i = 0; i < RT_NUMFIBS; i++) {
+	for (i = 0; i < priv->maxfibs; i++) {
 		if ((fe = priv_to_fib(priv, i)) == NULL)
 			continue;
 

Modified: stable/9/sys/netgraph/netflow/ng_netflow.c
==============================================================================
--- stable/9/sys/netgraph/netflow/ng_netflow.c	Sat Apr 21 18:36:53 2012	(r234556)
+++ stable/9/sys/netgraph/netflow/ng_netflow.c	Sat Apr 21 19:22:53 2012	(r234557)
@@ -225,6 +225,11 @@ ng_netflow_constructor(node_p node)
 	/* Initialize private data */
 	priv = malloc(sizeof(*priv), M_NETGRAPH, M_WAITOK | M_ZERO);
 
+	/* Initialize fib data */
+	priv->maxfibs = rt_numfibs;
+	priv->fib_data = malloc(sizeof(fib_export_p) * priv->maxfibs,
+	    M_NETGRAPH, M_WAITOK | M_ZERO);
+
 	/* Make node and its data point at each other */
 	NG_NODE_SET_PRIVATE(node, priv);
 	priv->node = node;
@@ -901,8 +906,10 @@ loopend:
 	
 	/* Check packet FIB */
 	fib = M_GETFIB(m);
-	if (fib >= RT_NUMFIBS) {
-		CTR2(KTR_NET, "ng_netflow_rcvdata(): packet fib %d is out of range of available fibs: 0 .. %d", fib, RT_NUMFIBS);
+	if (fib >= priv->maxfibs) {
+		CTR2(KTR_NET, "ng_netflow_rcvdata(): packet fib %d is out of "
+		    "range of available fibs: 0 .. %d",
+		    fib, priv->maxfibs);
 		goto bypass;
 	}
 
@@ -973,6 +980,7 @@ ng_netflow_rmnode(node_p node)
 	NG_NODE_SET_PRIVATE(node, NULL);
 	NG_NODE_UNREF(priv->node);
 
+	free(priv->fib_data, M_NETGRAPH);
 	free(priv, M_NETGRAPH);
 
 	return (0);

Modified: stable/9/sys/netgraph/netflow/ng_netflow.h
==============================================================================
--- stable/9/sys/netgraph/netflow/ng_netflow.h	Sat Apr 21 18:36:53 2012	(r234556)
+++ stable/9/sys/netgraph/netflow/ng_netflow.h	Sat Apr 21 19:22:53 2012	(r234557)
@@ -413,7 +413,8 @@ struct netflow {
 	struct flow_hash_entry	*hash6;
 #endif
 	/* Multiple FIB support */
-	fib_export_p		fib_data[RT_NUMFIBS]; /* array of pointers to fib-specific data */
+	fib_export_p		*fib_data; /* array of pointers to per-fib data */
+	uint16_t		maxfibs; /* number of allocated fibs */
 
 	/*
 	 * RFC 3954 clause 7.3


More information about the svn-src-stable-9 mailing list