Skip to content

Commit 58de45f

Browse files
Eric Dumazetgregkh
Eric Dumazet
authored andcommitted
net: make sock_inuse_add() available
commit d477eb9 upstream. MPTCP hard codes it, let us instead provide this helper. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Kuniyuki Iwashima <[email protected]> [ cherry-pick from amazon-linux amazon-5.15.y/mainline ] Link: amazonlinux/linux@7154d8eaac16 Signed-off-by: Xiangyu Chen <[email protected]> Signed-off-by: He Zhe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 480469f commit 58de45f

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

include/net/sock.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,13 +1472,23 @@ static inline void sock_prot_inuse_add(const struct net *net,
14721472
{
14731473
this_cpu_add(net->core.prot_inuse->val[prot->inuse_idx], val);
14741474
}
1475+
1476+
static inline void sock_inuse_add(const struct net *net, int val)
1477+
{
1478+
this_cpu_add(*net->core.sock_inuse, val);
1479+
}
1480+
14751481
int sock_prot_inuse_get(struct net *net, struct proto *proto);
14761482
int sock_inuse_get(struct net *net);
14771483
#else
14781484
static inline void sock_prot_inuse_add(const struct net *net,
14791485
const struct proto *prot, int val)
14801486
{
14811487
}
1488+
1489+
static inline void sock_inuse_add(const struct net *net, int val)
1490+
{
1491+
}
14821492
#endif
14831493

14841494

net/core/sock.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@
144144
static DEFINE_MUTEX(proto_list_mutex);
145145
static LIST_HEAD(proto_list);
146146

147-
static void sock_inuse_add(struct net *net, int val);
148-
149147
/**
150148
* sk_ns_capable - General socket capability test
151149
* @sk: Socket to use a capability on or through
@@ -3519,11 +3517,6 @@ int sock_prot_inuse_get(struct net *net, struct proto *prot)
35193517
}
35203518
EXPORT_SYMBOL_GPL(sock_prot_inuse_get);
35213519

3522-
static void sock_inuse_add(struct net *net, int val)
3523-
{
3524-
this_cpu_add(*net->core.sock_inuse, val);
3525-
}
3526-
35273520
int sock_inuse_get(struct net *net)
35283521
{
35293522
int cpu, res = 0;
@@ -3602,9 +3595,6 @@ static inline void release_proto_idx(struct proto *prot)
36023595
{
36033596
}
36043597

3605-
static void sock_inuse_add(struct net *net, int val)
3606-
{
3607-
}
36083598
#endif
36093599

36103600
static void tw_prot_cleanup(struct timewait_sock_ops *twsk_prot)

net/mptcp/subflow.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,9 +1584,7 @@ int mptcp_subflow_create_socket(struct sock *sk, struct socket **new_sock)
15841584
*/
15851585
sf->sk->sk_net_refcnt = 1;
15861586
get_net(net);
1587-
#ifdef CONFIG_PROC_FS
1588-
this_cpu_add(*net->core.sock_inuse, 1);
1589-
#endif
1587+
sock_inuse_add(net, 1);
15901588
err = tcp_set_ulp(sf->sk, "mptcp");
15911589
release_sock(sf->sk);
15921590

0 commit comments

Comments
 (0)