netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org, Eric Garver <eric@garver.life>
Subject: Re: [PATCH nf-next v2 2/2] netfilter: nat: force port remap to prevent shadowing well-known ports
Date: Thu, 16 Dec 2021 16:04:06 +0100	[thread overview]
Message-ID: <YbtVZplqiYb4OHic@orbyte.nwl.cc> (raw)
In-Reply-To: <20211215122026.20850-3-fw@strlen.de>

On Wed, Dec 15, 2021 at 01:20:26PM +0100, Florian Westphal wrote:
[...]
> @@ -507,11 +539,17 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple,
>  		 struct nf_conn *ct,
>  		 enum nf_nat_manip_type maniptype)
>  {
> +	bool random_port = range->flags & NF_NAT_RANGE_PROTO_RANDOM_ALL;
>  	const struct nf_conntrack_zone *zone;
>  	struct net *net = nf_ct_net(ct);
>  
>  	zone = nf_ct_zone(ct);
>  
> +	if (maniptype == NF_NAT_MANIP_SRC &&
> +	    !ct->local_origin &&
> +	    tuple_force_port_remap(orig_tuple))
> +		random_port = true;

	if (maniptype == NF_NAT_MANIP_SRC && !ct->local_origin)
		random_port = random_port || tuple_force_port_remap(orig_tuple);

Maybe? This avoids calling tuple_force_port_remap() if the flag is set.

Cheers, Phil

      parent reply	other threads:[~2021-12-16 15:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 12:20 [PATCH nf-next v2 0/2] nat: force port remap to prevent shadowing well-known ports Florian Westphal
2021-12-15 12:20 ` [PATCH nf-next v2 1/2] netfilter: conntrack: tag conntracks picked up in local out hook Florian Westphal
2021-12-15 12:20 ` [PATCH nf-next v2 2/2] netfilter: nat: force port remap to prevent shadowing well-known ports Florian Westphal
2021-12-16 14:13   ` Eric Garver
2021-12-16 15:04   ` Phil Sutter [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=YbtVZplqiYb4OHic@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=eric@garver.life \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /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).