mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-03 19:55:31 +00:00
net: add netns refcount tracker to struct sock
Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
9ba74e6c9e
commit
ffa84b5ffb
@ -350,6 +350,7 @@ struct bpf_local_storage;
|
||||
* @sk_txtime_deadline_mode: set deadline mode for SO_TXTIME
|
||||
* @sk_txtime_report_errors: set report errors mode for SO_TXTIME
|
||||
* @sk_txtime_unused: unused txtime flags
|
||||
* @ns_tracker: tracker for netns reference
|
||||
*/
|
||||
struct sock {
|
||||
/*
|
||||
@ -538,6 +539,7 @@ struct sock {
|
||||
struct bpf_local_storage __rcu *sk_bpf_storage;
|
||||
#endif
|
||||
struct rcu_head sk_rcu;
|
||||
netns_tracker ns_tracker;
|
||||
};
|
||||
|
||||
enum sk_pacing {
|
||||
|
@ -1983,7 +1983,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority,
|
||||
sock_lock_init(sk);
|
||||
sk->sk_net_refcnt = kern ? 0 : 1;
|
||||
if (likely(sk->sk_net_refcnt)) {
|
||||
get_net(net);
|
||||
get_net_track(net, &sk->ns_tracker, priority);
|
||||
sock_inuse_add(net, 1);
|
||||
}
|
||||
|
||||
@ -2039,7 +2039,7 @@ static void __sk_destruct(struct rcu_head *head)
|
||||
put_pid(sk->sk_peer_pid);
|
||||
|
||||
if (likely(sk->sk_net_refcnt))
|
||||
put_net(sock_net(sk));
|
||||
put_net_track(sock_net(sk), &sk->ns_tracker);
|
||||
sk_prot_free(sk->sk_prot_creator, sk);
|
||||
}
|
||||
|
||||
@ -2126,7 +2126,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
|
||||
|
||||
/* SANITY */
|
||||
if (likely(newsk->sk_net_refcnt)) {
|
||||
get_net(sock_net(newsk));
|
||||
get_net_track(sock_net(newsk), &newsk->ns_tracker, priority);
|
||||
sock_inuse_add(sock_net(newsk), 1);
|
||||
}
|
||||
sk_node_init(&newsk->sk_node);
|
||||
|
Loading…
Reference in New Issue
Block a user