From: Jozsef Kadlecsik <kadlec@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf 1/2] netfilter: conntrack: move synack init code to helper
Date: Sat, 29 Jan 2022 21:18:54 +0100 (CET) [thread overview]
Message-ID: <903cfb5c-693c-e085-aa3b-9a3fb4401a51@netfilter.org> (raw)
In-Reply-To: <20220129164701.175221-1-fw@strlen.de>
On Sat, 29 Jan 2022, Florian Westphal wrote:
> It seems more readable to use a common helper in the followup fix rather
> than copypaste or goto.
>
> No functional change intended. The function is only called for syn-ack
> or syn in repy direction in case of simultaneous open.
>
> Cc: Jozsef Kadlecsik <kadlec@netfilter.org>
> Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>
> ---
> net/netfilter/nf_conntrack_proto_tcp.c | 47 ++++++++++++++++----------
> 1 file changed, 29 insertions(+), 18 deletions(-)
>
> diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
> index af5115e127cf..88c89e97d8a2 100644
> --- a/net/netfilter/nf_conntrack_proto_tcp.c
> +++ b/net/netfilter/nf_conntrack_proto_tcp.c
> @@ -446,6 +446,32 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
> }
> }
>
> +static void tcp_init_sender(struct ip_ct_tcp_state *sender,
> + struct ip_ct_tcp_state *receiver,
> + const struct sk_buff *skb,
> + unsigned int dataoff,
> + const struct tcphdr *tcph,
> + u32 end, u32 win)
> +{
> + /* SYN-ACK in reply to a SYN
> + * or SYN from reply direction in simultaneous open.
> + */
> + sender->td_end =
> + sender->td_maxend = end;
> + sender->td_maxwin = (win == 0 ? 1 : win);
> +
> + tcp_options(skb, dataoff, tcph, sender);
> + /* RFC 1323:
> + * Both sides must send the Window Scale option
> + * to enable window scaling in either direction.
> + */
> + if (!(sender->flags & IP_CT_TCP_FLAG_WINDOW_SCALE &&
> + receiver->flags & IP_CT_TCP_FLAG_WINDOW_SCALE)) {
> + sender->td_scale = 0;
> + receiver->td_scale = 0;
> + }
> +}
> +
> static bool tcp_in_window(struct nf_conn *ct,
> enum ip_conntrack_dir dir,
> unsigned int index,
> @@ -499,24 +525,9 @@ static bool tcp_in_window(struct nf_conn *ct,
> * Initialize sender data.
> */
> if (tcph->syn) {
> - /*
> - * SYN-ACK in reply to a SYN
> - * or SYN from reply direction in simultaneous open.
> - */
> - sender->td_end =
> - sender->td_maxend = end;
> - sender->td_maxwin = (win == 0 ? 1 : win);
> -
> - tcp_options(skb, dataoff, tcph, sender);
> - /*
> - * RFC 1323:
> - * Both sides must send the Window Scale option
> - * to enable window scaling in either direction.
> - */
> - if (!(sender->flags & IP_CT_TCP_FLAG_WINDOW_SCALE
> - && receiver->flags & IP_CT_TCP_FLAG_WINDOW_SCALE))
> - sender->td_scale =
> - receiver->td_scale = 0;
> + tcp_init_sender(sender, receiver,
> + skb, dataoff, tcph,
> + end, win);
> if (!tcph->ack)
> /* Simultaneous open */
> return true;
> --
> 2.34.1
>
>
-
E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu
PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
H-1525 Budapest 114, POB. 49, Hungary
next prev parent reply other threads:[~2022-01-29 20:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-29 16:47 [PATCH nf 1/2] netfilter: conntrack: move synack init code to helper Florian Westphal
2022-01-29 16:47 ` [PATCH nf 2/2] netfilter: conntrack: re-init state for retransmitted syn-ack Florian Westphal
2022-01-29 20:25 ` Jozsef Kadlecsik
2022-01-29 20:28 ` Florian Westphal
2022-02-04 4:42 ` Pablo Neira Ayuso
2022-01-29 20:18 ` Jozsef Kadlecsik [this message]
2022-02-04 4:42 ` [PATCH nf 1/2] netfilter: conntrack: move synack init code to helper 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=903cfb5c-693c-e085-aa3b-9a3fb4401a51@netfilter.org \
--to=kadlec@netfilter.org \
--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).