Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Mar 2012 11:08:40 +0000 (UTC)
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232921 - in head/sys: modules/netgraph/netflow netgraph/netflow
Message-ID:  <201203131108.q2DB8e5d040995@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: melifaro
Date: Tue Mar 13 11:08:40 2012
New Revision: 232921
URL: http://svn.freebsd.org/changeset/base/232921

Log:
  Use rt_numfibs variable instead of compile-time RT_NUMFIBS.
  
  Reviewed by:    glebius (previous version)
  Approved by:    kib(mentor), ae(mentor)

Modified:
  head/sys/modules/netgraph/netflow/Makefile
  head/sys/netgraph/netflow/netflow.c
  head/sys/netgraph/netflow/ng_netflow.c
  head/sys/netgraph/netflow/ng_netflow.h

Modified: head/sys/modules/netgraph/netflow/Makefile
==============================================================================
--- head/sys/modules/netgraph/netflow/Makefile	Tue Mar 13 10:54:14 2012	(r232920)
+++ head/sys/modules/netgraph/netflow/Makefile	Tue Mar 13 11:08:40 2012	(r232921)
@@ -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: head/sys/netgraph/netflow/netflow.c
==============================================================================
--- head/sys/netgraph/netflow/netflow.c	Tue Mar 13 10:54:14 2012	(r232920)
+++ head/sys/netgraph/netflow/netflow.c	Tue Mar 13 11:08:40 2012	(r232921)
@@ -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: head/sys/netgraph/netflow/ng_netflow.c
==============================================================================
--- head/sys/netgraph/netflow/ng_netflow.c	Tue Mar 13 10:54:14 2012	(r232920)
+++ head/sys/netgraph/netflow/ng_netflow.c	Tue Mar 13 11:08:40 2012	(r232921)
@@ -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: head/sys/netgraph/netflow/ng_netflow.h
==============================================================================
--- head/sys/netgraph/netflow/ng_netflow.h	Tue Mar 13 10:54:14 2012	(r232920)
+++ head/sys/netgraph/netflow/ng_netflow.h	Tue Mar 13 11:08:40 2012	(r232921)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203131108.q2DB8e5d040995>