From: Florian Westphal <fw@strlen.de>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Joshua Hunt <johunt@akamai.com>,
Vishwanath Pai <vpai@akamai.com>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netfilter: xt_hashlimit: fix inconsistent return type in hashlimit_mt_*
Date: Fri, 29 Aug 2025 16:16:46 +0200 [thread overview]
Message-ID: <aLG2TumWk_kgK6zN@strlen.de> (raw)
In-Reply-To: <20250829125132.2026448-1-linmq006@gmail.com>
Miaoqian Lin <linmq006@gmail.com> wrote:
> The hashlimit_mt_v1() and hashlimit_mt_v2() functions return the
> cfg_copy() error code (-EINVAL) instead of false when configuration
> copying fails. Since these functions are declared to return bool,
> -EINVAL is interpreted as true, which is misleading.
Could you please check if its possible to rework cfg_copy() to not
return anything?
> --- a/net/netfilter/xt_hashlimit.c
> +++ b/net/netfilter/xt_hashlimit.c
> @@ -806,7 +806,7 @@ hashlimit_mt_v1(const struct sk_buff *skb, struct xt_action_param *par)
>
> ret = cfg_copy(&cfg, (void *)&info->cfg, 1);
> if (ret)
> - return ret;
> + return false;
AFAICS cfg_copy cannot return an error.
You could try adding an enum for the version field to xt_hashlimit.c,
then use switch/case to let compiler complain for other values.
Or try to replace the else branch error return with BUILD_BUG(),
compiler should be able to figure this out.
You might have to add __always_inline hint.
prev parent reply other threads:[~2025-08-29 14:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 12:51 [PATCH] netfilter: xt_hashlimit: fix inconsistent return type in hashlimit_mt_* Miaoqian Lin
2025-08-29 13:18 ` Phil Sutter
2025-08-29 14:16 ` Florian Westphal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aLG2TumWk_kgK6zN@strlen.de \
--to=fw@strlen.de \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=johunt@akamai.com \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linmq006@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=vpai@akamai.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).