Use rt_numfibs variable instead of compile-time RT_NUMFIBS.

Reviewed by:    glebius (previous version)
Approved by:    kib(mentor), ae(mentor)
This commit is contained in:
melifaro 2012-03-13 11:08:40 +00:00
parent 6305fd59a4
commit d0a72d948e
4 changed files with 13 additions and 6 deletions

View File

@ -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>

View File

@ -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;

View File

@ -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);

View File

@ -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