Re: [PATCH v3 bpf-next 10/11] bpf: tcp: Support arbitrary SYN Cookie.
From: Martin KaFai Lau <martin.lau@linux.dev>
Date: 2023-11-27 23:04:46
Also in:
bpf
On 11/22/23 4:31 PM, Kuniyuki Iwashima wrote:
From: Martin KaFai Lau <martin.lau@linux.dev> Date: Wed, 22 Nov 2023 15:19:29 -0800quoted
On 11/21/23 10:42 AM, Kuniyuki Iwashima wrote:quoted
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 533a7337865a..9a67f47a5e64 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h@@ -116,9 +116,23 @@ struct sock *inet6_steal_sock(struct net *net, struct sk_buff *skb, int doff, if (!sk) return NULL; - if (!prefetched || !sk_fullsock(sk)) + if (!prefetched) return sk; + if (sk->sk_state == TCP_NEW_SYN_RECV) { +#if IS_ENABLED(CONFIG_SYN_COOKIE) + if (inet_reqsk(sk)->syncookie) { + *refcounted = false; + skb->sk = sk; + skb->destructor = sock_pfree;Instead of re-init the skb->sk and skb->destructor, can skb_steal_sock() avoid resetting them to NULL in the first place and skb_steal_sock() returns the rsk_listener instead?Yes, but we need to move skb_steal_sock() to request_sock.h or include it just
Moving it seems better than including a header in the middle. Not sure if inet_sock.h or request_sock.h is a better target.
before skb_steal_sock() in sock.h like below. When I include request_sock.h in top of sock.h, there were many build errors.