diff options
| author | Eric Dumazet <edumazet@google.com> | 2024-10-10 20:48:15 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2024-10-15 03:39:36 +0300 |
| commit | 5ced52fa8f0dc23adb067f7b8a009a5ee051efb7 (patch) | |
| tree | f9c567b91223fee5b5af62f82d8fa5846600a996 /include | |
| parent | bc43a3c83cad46a27d6e3bf869acdd926bbe79ad (diff) | |
| download | linux-5ced52fa8f0dc23adb067f7b8a009a5ee051efb7.tar.xz | |
net: add skb_set_owner_edemux() helper
This can be used to attach a socket to an skb,
taking a reference on sk->sk_refcnt.
This helper might be a NOP if sk->sk_refcnt is zero.
Use it from tcp_make_synack().
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Brian Vazquez <brianvv@google.com>
Link: https://patch.msgid.link/20241010174817.1543642-4-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/net/sock.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 2f200d91ef11..bf7fa3db10ae 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1760,6 +1760,15 @@ void sock_efree(struct sk_buff *skb); #ifdef CONFIG_INET void sock_edemux(struct sk_buff *skb); void sock_pfree(struct sk_buff *skb); + +static inline void skb_set_owner_edemux(struct sk_buff *skb, struct sock *sk) +{ + skb_orphan(skb); + if (refcount_inc_not_zero(&sk->sk_refcnt)) { + skb->sk = sk; + skb->destructor = sock_edemux; + } +} #else #define sock_edemux sock_efree #endif |
