tcp: Move skb_steal_sock() to request_sock.h
authorKuniyuki Iwashima <kuniyu@amazon.com>
Mon, 15 Jan 2024 20:55:10 +0000 (12:55 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 23 Jan 2024 22:40:23 +0000 (14:40 -0800)
commit95e752b5299fa8c90099f7bc2aa1ee3e2e2c95ab
tree5ece4dad0462c0a9cca1edd8c594d752cd300e4c
parentb18afb6f42292a9154102fed7265ae747bbfbc57
tcp: Move skb_steal_sock() to request_sock.h

We will support arbitrary SYN Cookie with BPF.

If BPF prog validates ACK and kfunc allocates a reqsk, it will
be carried to TCP stack as skb->sk with req->syncookie 1.

In skb_steal_sock(), we need to check inet_reqsk(sk)->syncookie
to see if the reqsk is created by kfunc.  However, inet_reqsk()
is not available in sock.h.

Let's move skb_steal_sock() to request_sock.h.

While at it, we refactor skb_steal_sock() so it returns early if
skb->sk is NULL to minimise the following patch.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240115205514.68364-3-kuniyu@amazon.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/net/request_sock.h
include/net/sock.h