From nobody Tue Apr 12 21:59:39 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 81E661AFC8CB; Tue, 12 Apr 2022 21:59:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KdKQ31n9vz4hmF; Tue, 12 Apr 2022 21:59:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649800779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=62xnIV0p+M6Y122tNZxbF+IsxKWIkOiHd1u/rkZ+a/s=; b=PCfVYSqgVkXeqWEQmLDxzeJnEyzJTgUoaBluipyXemdbt7bbnrAYelQZuwXACeLRY4D7F0 pjvW58+Pw6qd8EmCnTJbhcc7nyJ/O1vx6C7E4S+OBvNrXzzf2ebrTz67P3llF92terjfkX AK3ibACYN1adNA+Z6szwAXt9zy63PZYyd53Uc3F+56C6xLz/5XGb9tKVJmIg6wko4OI4rY LdC4SNS9M1AGZQG4UbGUlVjfyhNr8SzWAH0bdcdJRbNZpAnL9acn6ZalB4/rY8K/o/Kk1b 07Ph2GJ259DdmXU3cOul1DWBYI1s7qDmGzDbY1vFdlUixEBZUGO9lavsL7GeKg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1963B1F691; Tue, 12 Apr 2022 21:59:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23CLxdEJ035801; Tue, 12 Apr 2022 21:59:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23CLxdRk035800; Tue, 12 Apr 2022 21:59:39 GMT (envelope-from git) Date: Tue, 12 Apr 2022 21:59:39 GMT Message-Id: <202204122159.23CLxdRk035800@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 6d5f002ed118 - main - netgraph: Remove the rethook parameter from NG_NODE_FOREACH_HOOK. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6d5f002ed1187547b0b40f8b46a3db38bf89c6dc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649800779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=62xnIV0p+M6Y122tNZxbF+IsxKWIkOiHd1u/rkZ+a/s=; b=KwstsyV1wqjIsxn6+9pGkuHTEOT6ivnpP3JOZqTApcJKaRjhpfbDl6T+2X3Nt68I+2Omfp 7CkkWWBcRjg7ATyeAUzHbwQKxs2UVd/F+AC5SFvXLnRSa7gqiIgf064h3HjZkBtRHcHkxJ WRpkwyZR4CQ5jL6KEMuaIZxEacqWmDU4l9z94L/Dt7cbKiClVgpOSiofyABPd0wWT2PW1r nmqT9or0NVsSA56zZZw5Msq0Lq6QZQxChjyapqBCa/iL/OI5FdUfdsMDRR9VShvhp0mF4O woRsOdeka3y1rc7risfL+9lHtNNDU6sp6QtNdGrOMnDg+gCU8qafcyufLSfmIQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649800779; a=rsa-sha256; cv=none; b=NhGsQDS+FzdQQ4QBEIOKBH9nPbFrr01IeOtrBoGkkoJ8utmWWDoBHRYiJot3bAaSjXWBAd 2iFVILXBE+r/2o1+Aow0QxwNpXTSMxjYToKRrd27A3s0Jy7D2K5tAvu/TfF/8KRjUlffSW 7qzoQ2XtU5yGzwbPu3FnQpnLu/W+Wpq11TZS1JGWAuq6wCu2O1W6ToCgLK00AeGNarMmBV b/b2gMHn2dlJCOLGyFbm0g4KcH7Z9CEU3C2UHDoe8lkJri3VfpjlIDnrQzMp2w0b4DrVn4 FSHMhJAhKWsswC//EIfIG57ifJhAlCTIWdgiIzVYsSD3VAWBciz7PKHarss65Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=6d5f002ed1187547b0b40f8b46a3db38bf89c6dc commit 6d5f002ed1187547b0b40f8b46a3db38bf89c6dc Author: John Baldwin AuthorDate: 2022-04-12 21:58:59 +0000 Commit: John Baldwin CommitDate: 2022-04-12 21:58:59 +0000 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. --- sys/netgraph/netgraph.h | 22 ++++++++-------------- sys/netgraph/ng_bpf.c | 6 ++---- sys/netgraph/ng_bridge.c | 11 +++-------- sys/netgraph/ng_l2tp.c | 3 +-- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h index d0be5a88b088..25863784840c 100644 --- a/sys/netgraph/netgraph.h +++ b/sys/netgraph/netgraph.h @@ -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 */ /*----------------------------------------------*/ /*********************************************************************** diff --git a/sys/netgraph/ng_bpf.c b/sys/netgraph/ng_bpf.c index b9535c7c124d..26e4c1f64d5b 100644 --- a/sys/netgraph/ng_bpf.c +++ b/sys/netgraph/ng_bpf.c @@ -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 diff --git a/sys/netgraph/ng_bridge.c b/sys/netgraph/ng_bridge.c index 9f1d33ba4c85..14068878736d 100644 --- a/sys/netgraph/ng_bridge.c +++ b/sys/netgraph/ng_bridge.c @@ -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)); diff --git a/sys/netgraph/ng_l2tp.c b/sys/netgraph/ng_l2tp.c index 94617fa4dad9..edb38e4540da 100644 --- a/sys/netgraph/ng_l2tp.c +++ b/sys/netgraph/ng_l2tp.c @@ -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;