LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Duncan Roe <duncan_roe@optusnet.com.au>
To: Jan Engelhardt <jengelh@inai.de>
Cc: Florian Westphal <fw@strlen.de>,
Cole Dishington <Cole.Dishington@alliedtelesis.co.nz>,
pablo@netfilter.org, kadlec@netfilter.org, davem@davemloft.net,
kuba@kernel.org, shuah@kernel.org, linux-kernel@vger.kernel.org,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org,
Anthony Lineham <anthony.lineham@alliedtelesis.co.nz>,
Scott Parlane <scott.parlane@alliedtelesis.co.nz>,
Blair Steven <blair.steven@alliedtelesis.co.nz>
Subject: Re: [PATCH net v2] net: netfilter: Fix port selection of FTP for NF_NAT_RANGE_PROTO_SPECIFIED
Date: Wed, 8 Sep 2021 12:22:44 +1000 [thread overview]
Message-ID: <YTgedODOPAQboQlm@slk1.local.net> (raw)
In-Reply-To: <r46nn4-n993-rs28-84sr-o1qop429rr9@vanv.qr>
On Tue, Sep 07, 2021 at 05:11:42PM +0200, Jan Engelhardt wrote:
>
> On Tuesday 2021-09-07 15:54, Florian Westphal wrote:
> >> - /* Try to get same port: if not, try to change it. */
> >> - for (port = ntohs(exp->saved_proto.tcp.port); port != 0; port++) {
> >> - int ret;
> >> + if (htons(nat->range_info.min_proto.all) == 0 ||
> >> + htons(nat->range_info.max_proto.all) == 0) {
> >
> >Either use if (nat->range_info.min_proto.all || ...
> >
> >or use ntohs(). I will leave it up to you if you prefer
> >ntohs(nat->range_info.min_proto.all) == 0 or
> >nat->range_info.min_proto.all == ntohs(0).
>
> If one has the option, one should always prefer to put htons/htonl on
> the side with the constant literal;
> Propagation of constants and compile-time evaluation is the target.
>
> That works for some other functions as well (e.g.
> strlen("fixedstring")).
When comparing against constant zero, why use htons/htonl at all?
Cheers ... Duncan.
next prev parent reply other threads:[~2021-09-08 2:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-07 2:14 Cole Dishington
2021-09-07 5:14 ` kernel test robot
2021-09-07 13:54 ` Florian Westphal
2021-09-07 15:11 ` Jan Engelhardt
2021-09-08 2:22 ` Duncan Roe [this message]
2021-09-08 6:52 ` Jan Engelhardt
2021-09-07 14:11 ` kernel test robot
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=YTgedODOPAQboQlm@slk1.local.net \
--to=duncan_roe@optusnet.com.au \
--cc=Cole.Dishington@alliedtelesis.co.nz \
--cc=anthony.lineham@alliedtelesis.co.nz \
--cc=blair.steven@alliedtelesis.co.nz \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=jengelh@inai.de \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=scott.parlane@alliedtelesis.co.nz \
--cc=shuah@kernel.org \
--subject='Re: [PATCH net v2] net: netfilter: Fix port selection of FTP for NF_NAT_RANGE_PROTO_SPECIFIED' \
/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
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).