tcp: Factorise cookie-dependent fields initialisation in cookie_v[46]_check()
authorKuniyuki Iwashima <kuniyu@amazon.com>
Wed, 29 Nov 2023 02:29:24 +0000 (18:29 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 30 Nov 2023 04:16:38 +0000 (20:16 -0800)
commit8e7bab6b9652cd07a05ee0380b623c0e00e3eb00
tree51ab8ee1bc85d5af40c50c6d6cbd84b5d0a9ce47
parentde5626b95e13a054aa80f890f2a774d2fc18d855
tcp: Factorise cookie-dependent fields initialisation in cookie_v[46]_check()

We will support arbitrary SYN Cookie with BPF, and then kfunc at
TC will preallocate reqsk and initialise some fields that should
not be overwritten later by cookie_v[46]_check().

To simplify the flow in cookie_v[46]_check(), we move such fields'
initialisation to cookie_tcp_reqsk_alloc() and factorise non-BPF
SYN Cookie handling into cookie_tcp_check(), where we validate the
cookie and allocate reqsk, as done by kfunc later.

Note that we set ireq->ecn_ok in two steps, the latter of which will
be shared by the BPF case.  As cookie_ecn_ok() is one-liner, now
it's inlined.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20231129022924.96156-9-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/tcp.h
net/ipv4/syncookies.c
net/ipv6/syncookies.c