From: Simon Horman <horms@kernel.org>
To: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH v1 net-next 7/8] tcp: Factorise cookie-independent fields initialisation in cookie_v[46]_check().
Date: Fri, 24 Nov 2023 21:44:18 +0000 [thread overview]
Message-ID: <20231124214418.GX50352@kernel.org> (raw)
In-Reply-To: <20231123012521.62841-8-kuniyu@amazon.com>
On Wed, Nov 22, 2023 at 05:25:20PM -0800, Kuniyuki Iwashima wrote:
> We will support arbitrary SYN Cookie with BPF, and then some reqsk fields
> are initialised in kfunc, and others are done in cookie_v[46]_check().
>
> This patch factorises the common part as cookie_tcp_reqsk_init() and
> calls it in cookie_tcp_reqsk_alloc() to minimise the discrepancy between
> cookie_v[46]_check().
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
> net/ipv4/syncookies.c | 69 ++++++++++++++++++++++++-------------------
> net/ipv6/syncookies.c | 14 ---------
> 2 files changed, 38 insertions(+), 45 deletions(-)
>
> diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
> index 1e3783c97e28..9bca1c026525 100644
> --- a/net/ipv4/syncookies.c
> +++ b/net/ipv4/syncookies.c
> @@ -285,10 +285,44 @@ bool cookie_ecn_ok(const struct tcp_options_received *tcp_opt,
> }
> EXPORT_SYMBOL(cookie_ecn_ok);
>
> +static int cookie_tcp_reqsk_init(struct sock *sk, struct sk_buff *skb,
> + struct request_sock *req)
> +{
> + struct inet_request_sock *ireq = inet_rsk(req);
> + struct tcp_request_sock *treq = tcp_rsk(req);
> + const struct tcphdr *th = tcp_hdr(skb);
> +
> + req->num_retrans = 0;
> +
> + ireq->ir_num = ntohs(th->dest);
> + ireq->ir_rmt_port = th->source;
> + ireq->ir_iif = inet_request_bound_dev_if(sk, skb);
> + ireq->ir_mark = inet_request_mark(sk, skb);
> +
> + if (IS_ENABLED(CONFIG_SMC))
> + ireq->smc_ok = 0;
> +
> + treq->snt_synack = 0;
> + treq->tfo_listener = false;
> + treq->txhash = net_tx_rndhash();
> + treq->rcv_isn = ntohl(th->seq) - 1;
> + treq->snt_isn = ntohl(th->ack_seq) - 1;
> + treq->syn_tos = TCP_SKB_CB(skb)->ip_dsfield;
> + treq->syn_tos = TCP_SKB_CB(skb)->ip_dsfield;
Hi Iwashima-san,
The line above seems to be duplicated.
Other than that, this patch looks good to me.
Reviewed-by: Simon Horman <horms@kernel.org>
> + treq->req_usec_ts = false;
> +
> +#if IS_ENABLED(CONFIG_MPTCP)
> + treq->is_mptcp = sk_is_mptcp(sk);
> + if (treq->is_mptcp)
> + return mptcp_subflow_init_cookie_req(req, sk, skb);
> +#endif
> +
> + return 0;
> +}
...
next prev parent reply other threads:[~2023-11-24 21:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 1:25 [PATCH v1 net-next 0/8] tcp: Clean up and refactor cookie_v[46]_check() Kuniyuki Iwashima
2023-11-23 1:25 ` [PATCH v1 net-next 1/8] tcp: Clean up reverse xmas tree in cookie_v[46]_check() Kuniyuki Iwashima
2023-11-24 21:44 ` Simon Horman
2023-11-23 1:25 ` [PATCH v1 net-next 2/8] tcp: Cache sock_net(sk) " Kuniyuki Iwashima
2023-11-24 21:44 ` Simon Horman
2023-11-23 1:25 ` [PATCH v1 net-next 3/8] tcp: Clean up goto labels " Kuniyuki Iwashima
2023-11-24 21:45 ` Simon Horman
2023-11-23 1:25 ` [PATCH v1 net-next 4/8] tcp: Don't pass cookie to __cookie_v[46]_check() Kuniyuki Iwashima
2023-11-24 21:45 ` Simon Horman
2023-11-23 1:25 ` [PATCH v1 net-next 5/8] tcp: Don't initialise tp->tsoffset in tcp_get_cookie_sock() Kuniyuki Iwashima
2023-11-24 21:45 ` Simon Horman
2023-11-23 1:25 ` [PATCH v1 net-next 6/8] tcp: Move TCP-AO bits from cookie_v[46]_check() to tcp_ao_syncookie() Kuniyuki Iwashima
2023-11-24 21:46 ` Simon Horman
2023-11-23 1:25 ` [PATCH v1 net-next 7/8] tcp: Factorise cookie-independent fields initialisation in cookie_v[46]_check() Kuniyuki Iwashima
2023-11-24 21:44 ` Simon Horman [this message]
2023-11-25 1:04 ` Kuniyuki Iwashima
2023-11-23 1:25 ` [PATCH v1 net-next 8/8] tcp: Factorise cookie-dependent " Kuniyuki Iwashima
2023-11-24 21:46 ` Simon Horman
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=20231124214418.GX50352@kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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).