netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org, edumazet@google.com,
	ncardwell@google.com, Jaco Kroon <jaco@uls.co.za>,
	Jozsef Kadlecsik <kadlec@netfilter.org>
Subject: Re: [PATCH nf] netfilter: nf_conntrack_tcp: re-init for syn packets only
Date: Wed, 27 Apr 2022 15:49:02 +0200	[thread overview]
Message-ID: <YmlJzj82mBl77rCR@salvia> (raw)
In-Reply-To: <20220425094711.6255-1-fw@strlen.de>

On Mon, Apr 25, 2022 at 11:47:11AM +0200, Florian Westphal wrote:
> Jaco Kroon reported tcp problems that Eric Dumazet and Neal Cardwell
> pinpointed to nf_conntrack tcp_in_window() bug.
> 
> tcp trace shows following sequence:
> 
> I > R Flags [S], seq 3451342529, win 62580, options [.. tfo [|tcp]>
> R > I Flags [S.], seq 2699962254, ack 3451342530, win 65535, options [..]
> R > I Flags [P.], seq 1:89, ack 1, [..]
> 
> Note 3rd ACK is from responder to initiator so following branch is taken:
>     } else if (((state->state == TCP_CONNTRACK_SYN_SENT
>                && dir == IP_CT_DIR_ORIGINAL)
>                || (state->state == TCP_CONNTRACK_SYN_RECV
>                && dir == IP_CT_DIR_REPLY))
>                && after(end, sender->td_end)) {
> 
> ... because state == TCP_CONNTRACK_SYN_RECV and dir is REPLY.
> This causes the scaling factor to be reset to 0: window scale option
> is only present in syn(ack) packets.  This in turn makes nf_conntrack
> mark valid packets as out-of-window.
> 
> This was always broken, it exists even in original commit where
> window tracking was added to ip_conntrack (nf_conntrack predecessor)
> in 2.6.9-rc1 kernel.
> 
> Restrict to 'tcph->syn', just like the 3rd condtional added in
> commit 82b72cb94666 ("netfilter: conntrack: re-init state for retransmitted syn-ack").
> 
> Upon closer look, those conditionals/branches can be merged:
> 
> Because earlier checks prevent syn-ack from showing up in
> original direction, the 'dir' checks in the conditional quoted above are
> redundant, remove them. Return early for pure syn retransmitted in reply
> direction (simultaneous open).

Applied, thanks

  parent reply	other threads:[~2022-04-27 13:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-25  9:47 [PATCH nf] netfilter: nf_conntrack_tcp: re-init for syn packets only Florian Westphal
2022-04-25 13:41 ` Jozsef Kadlecsik
2022-04-25 14:55   ` Eric Dumazet
2022-04-27 13:49 ` Pablo Neira Ayuso [this message]
2022-06-10  8:32   ` Jaco Kroon

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=YmlJzj82mBl77rCR@salvia \
    --to=pablo@netfilter.org \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=jaco@uls.co.za \
    --cc=kadlec@netfilter.org \
    --cc=ncardwell@google.com \
    --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).