netgraph: Remove the rethook parameter from NG_NODE_FOREACH_HOOK.

This parameter was set to the hook that terminated the iteration
early.  However, none of the remaining callers used this argument and
it was always set to an otherwise-unused variable.
This commit is contained in:
John Baldwin 2022-04-12 14:58:59 -07:00
parent fa351643f5
commit 6d5f002ed1
4 changed files with 14 additions and 28 deletions

View File

@ -429,13 +429,11 @@ void ng_unref_node(node_p node); /* don't move this */
* iterator will stop and return a pointer to the hook that returned 0.
*/
typedef int ng_fn_eachhook(hook_p hook, void* arg);
#define _NG_NODE_FOREACH_HOOK(node, fn, arg, rethook) \
#define _NG_NODE_FOREACH_HOOK(node, fn, arg) \
do { \
hook_p _hook; \
(rethook) = NULL; \
LIST_FOREACH(_hook, &((node)->nd_hooks), hk_hooks) { \
if ((fn)(_hook, arg) == 0) { \
(rethook) = _hook; \
break; \
} \
} \
@ -456,7 +454,7 @@ static __inline int _ng_node_is_valid(node_p node, char *file, int line);
static __inline int _ng_node_not_valid(node_p node, char *file, int line);
static __inline int _ng_node_numhooks(node_p node, char *file, int line);
static __inline void _ng_node_force_writer(node_p node, char *file, int line);
static __inline hook_p _ng_node_foreach_hook(node_p node,
static __inline void _ng_node_foreach_hook(node_p node,
ng_fn_eachhook *fn, void *arg, char *file, int line);
static __inline void _ng_node_revive(node_p node, char *file, int line);
@ -569,14 +567,12 @@ _ng_node_revive(node_p node, char *file, int line)
_NG_NODE_REVIVE(node);
}
static __inline hook_p
static __inline void
_ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg,
char *file, int line)
{
hook_p hook;
_chknode(node, file, line);
_NG_NODE_FOREACH_HOOK(node, fn, arg, hook);
return (hook);
_NG_NODE_FOREACH_HOOK(node, fn, arg);
}
#define NG_NODE_NAME(node) _ng_node_name(node, _NN_)
@ -593,10 +589,8 @@ _ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg,
#define NG_NODE_REALLY_DIE(node) _ng_node_really_die(node, _NN_)
#define NG_NODE_NUMHOOKS(node) _ng_node_numhooks(node, _NN_)
#define NG_NODE_REVIVE(node) _ng_node_revive(node, _NN_)
#define NG_NODE_FOREACH_HOOK(node, fn, arg, rethook) \
do { \
rethook = _ng_node_foreach_hook(node, fn, (void *)arg, _NN_); \
} while (0)
#define NG_NODE_FOREACH_HOOK(node, fn, arg) \
_ng_node_foreach_hook(node, fn, (void *)arg, _NN_)
#else /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
@ -614,8 +608,8 @@ _ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg,
#define NG_NODE_REALLY_DIE(node) _NG_NODE_REALLY_DIE(node)
#define NG_NODE_NUMHOOKS(node) _NG_NODE_NUMHOOKS(node)
#define NG_NODE_REVIVE(node) _NG_NODE_REVIVE(node)
#define NG_NODE_FOREACH_HOOK(node, fn, arg, rethook) \
_NG_NODE_FOREACH_HOOK(node, fn, arg, rethook)
#define NG_NODE_FOREACH_HOOK(node, fn, arg) \
_NG_NODE_FOREACH_HOOK(node, fn, arg)
#endif /* NETGRAPH_DEBUG */ /*----------------------------------------------*/
/***********************************************************************

View File

@ -273,7 +273,6 @@ static int
ng_bpf_newhook(node_p node, hook_p hook, const char *name)
{
hinfo_p hip;
hook_p tmp;
int error;
/* Create hook private structure */
@ -284,7 +283,7 @@ ng_bpf_newhook(node_p node, hook_p hook, const char *name)
NG_HOOK_SET_PRIVATE(hook, hip);
/* Add our reference into other hooks data. */
NG_NODE_FOREACH_HOOK(node, ng_bpf_addrefs, hook, tmp);
NG_NODE_FOREACH_HOOK(node, ng_bpf_addrefs, hook);
/* Attach the default BPF program */
if ((error = ng_bpf_setprog(hook, &ng_bpf_default_prog)) != 0) {
@ -524,12 +523,11 @@ ng_bpf_disconnect(hook_p hook)
{
const node_p node = NG_HOOK_NODE(hook);
const hinfo_p hip = NG_HOOK_PRIVATE(hook);
hook_p tmp;
KASSERT(hip != NULL, ("%s: null info", __func__));
/* Remove our reference from other hooks data. */
NG_NODE_FOREACH_HOOK(node, ng_bpf_remrefs, hook, tmp);
NG_NODE_FOREACH_HOOK(node, ng_bpf_remrefs, hook);
free(hip->prog, M_NETGRAPH_BPF);
#ifdef BPF_JITTER

View File

@ -532,14 +532,11 @@ ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook)
}
case NGM_BRIDGE_RESET:
{
hook_p rethook;
/* Flush all entries in the hash table */
ng_bridge_remove_hosts(priv, NULL);
/* Reset all loop detection counters and stats */
NG_NODE_FOREACH_HOOK(node, ng_bridge_reset_link, NULL,
rethook);
NG_NODE_FOREACH_HOOK(node, ng_bridge_reset_link, NULL);
break;
}
case NGM_BRIDGE_GET_STATS:
@ -777,7 +774,6 @@ ng_bridge_rcvdata(hook_p hook, item_p item)
struct ng_bridge_host *host;
struct ether_header *eh;
struct ng_bridge_send_ctx ctx = { 0 };
hook_p ret;
NGI_GET_M(item, ctx.m);
@ -896,7 +892,7 @@ ng_bridge_rcvdata(hook_p hook, item_p item)
}
/* Distribute unknown, multicast, broadcast pkts to all other links */
NG_NODE_FOREACH_HOOK(node, ng_bridge_send_ctx, &ctx, ret);
NG_NODE_FOREACH_HOOK(node, ng_bridge_send_ctx, &ctx);
/* Finally send out on the first link found */
if (ctx.foundFirst != NULL) {
@ -1168,7 +1164,6 @@ ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2)
const priv_p priv = NG_NODE_PRIVATE(node);
int bucket;
int counter = 0;
hook_p ret;
/* Update host time counters and remove stale entries */
for (bucket = 0; bucket < priv->numBuckets; bucket++) {
@ -1198,7 +1193,7 @@ ng_bridge_timeout(node_p node, hook_p hook, void *arg1, int arg2)
/* Decrease loop counter on muted looped back links */
counter = 0;
NG_NODE_FOREACH_HOOK(node, ng_bridge_unmute, &counter, ret);
NG_NODE_FOREACH_HOOK(node, ng_bridge_unmute, &counter);
KASSERT(priv->numLinks == counter,
("%s: links: %d != %d", __func__, priv->numLinks, counter));

View File

@ -1263,7 +1263,6 @@ static void
ng_l2tp_seq_reset(priv_p priv)
{
struct l2tp_seq *const seq = &priv->seq;
hook_p hook;
int i;
SEQ_LOCK_ASSERT(seq);
@ -1280,7 +1279,7 @@ ng_l2tp_seq_reset(priv_p priv)
}
/* Reset session hooks' sequence number states */
NG_NODE_FOREACH_HOOK(priv->node, ng_l2tp_reset_session, NULL, hook);
NG_NODE_FOREACH_HOOK(priv->node, ng_l2tp_reset_session, NULL);
/* Reset node's sequence number state */
seq->ns = 0;