From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: fw@strlen.de, sven.auhagen@voleatech.de
Subject: Re: [PATCH nf-next] netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options
Date: Mon, 21 Mar 2022 10:46:33 +0100 [thread overview]
Message-ID: <YjhJeQsI5TWTNgI0@salvia> (raw)
In-Reply-To: <YjhJBGffCTEtOuB9@salvia>
On Mon, Mar 21, 2022 at 10:44:39AM +0100, Pablo Neira Ayuso wrote:
> On Mon, Mar 21, 2022 at 10:42:05AM +0100, Pablo Neira Ayuso wrote:
> > When tcp_options is called all flags are cleared.
> > When the IP_CT_TCP_FLAG_BE_LIBERAL is set it should be preserved
> > otherwise such connections will fail in the window check.
>
>
> This patch completes 8437a6209f76 ("netfilter: nft_flow_offload: set liberal tracking mode for tcp")
>
> I'm going to send v2 to add a wrapper function to update these flags,
> so we do not accidentally reset IP_CT_TCP_FLAG_BE_LIBERAL.
Hm. Actually I don't see a clear way to add such wrapper function, so
patch LGTM as is.
> > Signed-off-by: Sven Auhagen <sven.auhagen@voleatech.de>
> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > ---
> > Supersedes: https://patchwork.ozlabs.org/project/netfilter-devel/patch/20220318144939.69465-1-pablo@netfilter.org/ which is not correct, it breaks TCP FIN handling.
> >
> > net/netfilter/nf_conntrack_proto_tcp.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
> > index d1582b888c0d..d8599ab5f767 100644
> > --- a/net/netfilter/nf_conntrack_proto_tcp.c
> > +++ b/net/netfilter/nf_conntrack_proto_tcp.c
> > @@ -342,7 +342,7 @@ static void tcp_options(const struct sk_buff *skb,
> > return;
> >
> > state->td_scale =
> > - state->flags = 0;
> > + state->flags &= IP_CT_TCP_FLAG_BE_LIBERAL;
> >
> > while (length > 0) {
> > int opcode=*ptr++;
> > @@ -873,7 +873,7 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,
> > struct nf_tcp_net *tn = nf_tcp_pernet(net);
> > struct nf_conntrack_tuple *tuple;
> > enum tcp_conntrack new_state, old_state;
> > - unsigned int index, *timeouts;
> > + unsigned int index, flags, *timeouts;
> > enum ip_conntrack_dir dir;
> > const struct tcphdr *th;
> > struct tcphdr _tcph;
> > @@ -968,8 +968,10 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,
> > ct->proto.tcp.last_flags &= ~IP_CT_EXP_CHALLENGE_ACK;
> > ct->proto.tcp.seen[ct->proto.tcp.last_dir].flags =
> > ct->proto.tcp.last_flags;
> > + flags = ct->proto.tcp.seen[dir].flags;
> > memset(&ct->proto.tcp.seen[dir], 0,
> > sizeof(struct ip_ct_tcp_state));
> > + ct->proto.tcp.seen[dir].flags = flags & IP_CT_TCP_FLAG_BE_LIBERAL;
> > break;
> > }
> > ct->proto.tcp.last_index = index;
> > --
> > 2.30.2
> >
next prev parent reply other threads:[~2022-03-21 9:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-21 9:42 [PATCH nf-next] netfilter: nf_conntrack_tcp: preserve liberal flag in tcp options Pablo Neira Ayuso
2022-03-21 9:44 ` Pablo Neira Ayuso
2022-03-21 9:46 ` Pablo Neira Ayuso [this message]
2022-03-21 10:05 ` Pablo Neira Ayuso
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=YjhJeQsI5TWTNgI0@salvia \
--to=pablo@netfilter.org \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=sven.auhagen@voleatech.de \
/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).