]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: make sock_inuse_add() available
authorEric Dumazet <edumazet@google.com>
Mon, 15 Nov 2021 17:11:48 +0000 (09:11 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:44:20 +0000 (07:44 +0200)
commit d477eb9004845cb2dc92ad5eed79a437738a868a upstream.

MPTCP hard codes it, let us instead provide this helper.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
[ cherry-pick from amazon-linux amazon-5.15.y/mainline ]
Link: https://github.com/amazonlinux/linux/commit/7154d8eaac16
Signed-off-by: Xiangyu Chen <xiangyu.chen@windriver.com>
Signed-off-by: He Zhe <zhe.he@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/sock.h
net/core/sock.c
net/mptcp/subflow.c

index ca3cc2b325d76bf191147694b63b8febb52fa79b..0461890f10ae779ad729f04976c23b18de92b7d9 100644 (file)
@@ -1472,6 +1472,12 @@ static inline void sock_prot_inuse_add(const struct net *net,
 {
        this_cpu_add(net->core.prot_inuse->val[prot->inuse_idx], val);
 }
+
+static inline void sock_inuse_add(const struct net *net, int val)
+{
+       this_cpu_add(*net->core.sock_inuse, val);
+}
+
 int sock_prot_inuse_get(struct net *net, struct proto *proto);
 int sock_inuse_get(struct net *net);
 #else
@@ -1479,6 +1485,10 @@ static inline void sock_prot_inuse_add(const struct net *net,
                                       const struct proto *prot, int val)
 {
 }
+
+static inline void sock_inuse_add(const struct net *net, int val)
+{
+}
 #endif
 
 
index dce2bf8dfd1de7272de8a85d421c6c2eb12270ea..7f7f02a01f2dd3aecf66a35cd19bbb8eb8d7f38c 100644 (file)
 static DEFINE_MUTEX(proto_list_mutex);
 static LIST_HEAD(proto_list);
 
-static void sock_inuse_add(struct net *net, int val);
-
 /**
  * sk_ns_capable - General socket capability test
  * @sk: Socket to use a capability on or through
@@ -3519,11 +3517,6 @@ int sock_prot_inuse_get(struct net *net, struct proto *prot)
 }
 EXPORT_SYMBOL_GPL(sock_prot_inuse_get);
 
-static void sock_inuse_add(struct net *net, int val)
-{
-       this_cpu_add(*net->core.sock_inuse, val);
-}
-
 int sock_inuse_get(struct net *net)
 {
        int cpu, res = 0;
@@ -3602,9 +3595,6 @@ static inline void release_proto_idx(struct proto *prot)
 {
 }
 
-static void sock_inuse_add(struct net *net, int val)
-{
-}
 #endif
 
 static void tw_prot_cleanup(struct timewait_sock_ops *twsk_prot)
index 7249cc9153edaac6ecc930dbd3bead16c0baa698..2bf7f65b0afe5fd9210689fc7c9a8ee9d608257b 100644 (file)
@@ -1584,9 +1584,7 @@ int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock)
         */
        sf->sk->sk_net_refcnt = 1;
        get_net(net);
-#ifdef CONFIG_PROC_FS
-       this_cpu_add(*net->core.sock_inuse, 1);
-#endif
+       sock_inuse_add(net, 1);
        err = tcp_set_ulp(sf->sk, "mptcp");
        release_sock(sf->sk);