]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: make is_skb_wmem() available to modules
authorEric Dumazet <edumazet@google.com>
Tue, 12 May 2026 09:48:58 +0000 (09:48 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 May 2026 02:13:41 +0000 (19:13 -0700)
Following patch will use is_skb_wmem() from fq_codel.

Provide __sock_wfree() only if CONFIG_INET=y

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://patch.msgid.link/20260512094859.3673997-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/sock.h
include/net/tcp.h
net/core/skbuff.c
net/core/sock.c
net/core/sock_destructor.h [deleted file]
net/ipv4/inet_fragment.c
net/ipv4/tcp_output.c

index dccd3738c3687056b67c8de44fce9842dcc365ec..219917959b54582fdd3d78e8042e1bdfc43decd0 100644 (file)
@@ -1850,8 +1850,18 @@ static inline struct sock *sk_clone_lock(const struct sock *sk, const gfp_t prio
 
 struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force,
                             gfp_t priority);
-void __sock_wfree(struct sk_buff *skb);
 void sock_wfree(struct sk_buff *skb);
+#ifdef CONFIG_INET
+void __sock_wfree(struct sk_buff *skb);
+void tcp_wfree(struct sk_buff *skb);
+#endif
+static inline bool is_skb_wmem(const struct sk_buff *skb)
+{
+       return skb->destructor == sock_wfree ||
+              (IS_ENABLED(CONFIG_INET) && skb->destructor == __sock_wfree) ||
+              (IS_ENABLED(CONFIG_INET) && skb->destructor == tcp_wfree);
+}
+
 struct sk_buff *sock_omalloc(struct sock *sk, unsigned long size,
                             gfp_t priority);
 void skb_orphan_partial(struct sk_buff *skb);
index 3c4e6adb0dbdcefdfa6c95d1738e2039dede3f32..5715e60c519a79232a3bed6682aa2c9cf97be22a 100644 (file)
@@ -390,7 +390,6 @@ static inline bool tcp_release_cb_cond(struct sock *sk)
        return false;
 }
 
-void tcp_wfree(struct sk_buff *skb);
 void tcp_write_timer_handler(struct sock *sk);
 void tcp_delack_timer_handler(struct sock *sk);
 int tcp_ioctl(struct sock *sk, int cmd, int *karg);
index acca1365672c4f98b004c2548133d70c9cf5ddc1..419a4d2833b22eda9c078253390868bef82a32f9 100644 (file)
@@ -78,6 +78,7 @@
 #include <net/mpls.h>
 #include <net/mptcp.h>
 #include <net/mctp.h>
+#include <net/tcp.h>
 #include <net/can.h>
 #include <net/page_pool/helpers.h>
 #include <net/psp/types.h>
@@ -96,7 +97,6 @@
 #include "devmem.h"
 #include "net-sysfs.h"
 #include "netmem_priv.h"
-#include "sock_destructor.h"
 
 #ifdef CONFIG_SKB_EXTENSIONS
 static struct kmem_cache *skbuff_ext_cache __ro_after_init;
index b37b664b6eb92f375d6708a5a609f35f07ee2897..f362e3ce1efb672bc463c54b7a1b8f05785cba45 100644 (file)
@@ -2708,6 +2708,7 @@ EXPORT_SYMBOL(sock_wfree);
 /* This variant of sock_wfree() is used by TCP,
  * since it sets SOCK_USE_WRITE_QUEUE.
  */
+#ifdef CONFIG_INET
 void __sock_wfree(struct sk_buff *skb)
 {
        struct sock *sk = skb->sk;
@@ -2715,6 +2716,8 @@ void __sock_wfree(struct sk_buff *skb)
        if (refcount_sub_and_test(skb->truesize, &sk->sk_wmem_alloc))
                __sk_free(sk);
 }
+EXPORT_SYMBOL_GPL(__sock_wfree);
+#endif
 
 void skb_set_owner_w(struct sk_buff *skb, struct sock *sk)
 {
diff --git a/net/core/sock_destructor.h b/net/core/sock_destructor.h
deleted file mode 100644 (file)
index 2f396e6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-#ifndef _NET_CORE_SOCK_DESTRUCTOR_H
-#define _NET_CORE_SOCK_DESTRUCTOR_H
-#include <net/tcp.h>
-
-static inline bool is_skb_wmem(const struct sk_buff *skb)
-{
-       return skb->destructor == sock_wfree ||
-              skb->destructor == __sock_wfree ||
-              (IS_ENABLED(CONFIG_INET) && skb->destructor == tcp_wfree);
-}
-#endif
index 393770920abd794a47a933f2694afe3e2d08d25a..86b100694659ee51292625216113f9411b98a351 100644 (file)
@@ -24,8 +24,6 @@
 #include <net/ip.h>
 #include <net/ipv6.h>
 
-#include "../core/sock_destructor.h"
-
 /* Use skb->cb to track consecutive/adjacent fragments coming at
  * the end of the queue. Nodes in the rb-tree queue will
  * contain "runs" of one or more adjacent fragments.
index 75eb18a2ad4e7ee126806e7a7cbf3d27a452cba5..47647a99e32443a3925a9a160a2da58f530e32e1 100644 (file)
@@ -1415,6 +1415,7 @@ void tcp_wfree(struct sk_buff *skb)
 out:
        sk_free(sk);
 }
+EXPORT_SYMBOL_GPL(tcp_wfree);
 
 /* Note: Called under soft irq.
  * We can call TCP stack right away, unless socket is owned by user.