[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231124214418.GX50352@kernel.org>
Date: Fri, 24 Nov 2023 21:44:18 +0000
From: Simon Horman <horms@...nel.org>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Kuniyuki Iwashima <kuni1840@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH v1 net-next 7/8] tcp: Factorise cookie-independent fields
initialisation in cookie_v[46]_check().
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@...zon.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@...nel.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;
> +}
...
Powered by blists - more mailing lists