Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c29a0bc4 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller
Browse files

[SOCK][NETNS]: Add a struct net argument to sock_prot_inuse_add and _get.



This counter is about to become per-proto-and-per-net, so we'll need 
two arguments to determine which cell in this "table" to work with.

All the places, but proc already pass proper net to it - proc will be
tuned a bit later.

Some indentation with spaces in proc files is done to keep the file
coding style consistent.

Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8efa6e93
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -635,10 +635,11 @@ static inline void sk_refcnt_debug_release(const struct sock *sk)


#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS
/* Called with local bh disabled */
/* Called with local bh disabled */
extern void sock_prot_inuse_add(struct proto *prot, int inc);
extern void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc);
extern int sock_prot_inuse_get(struct proto *proto);
extern int sock_prot_inuse_get(struct net *net, struct proto *proto);
#else
#else
static void inline sock_prot_inuse_add(struct proto *prot, int inc)
static void inline sock_prot_inuse_add(struct net *net, struct proto *prot,
		int inc)
{
{
}
}
#endif
#endif
+1 −1
Original line number Original line Diff line number Diff line
@@ -115,7 +115,7 @@ static inline void udp_lib_unhash(struct sock *sk)
	write_lock_bh(&udp_hash_lock);
	write_lock_bh(&udp_hash_lock);
	if (sk_del_node_init(sk)) {
	if (sk_del_node_init(sk)) {
		inet_sk(sk)->num = 0;
		inet_sk(sk)->num = 0;
		sock_prot_inuse_add(sk->sk_prot, -1);
		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
	}
	}
	write_unlock_bh(&udp_hash_lock);
	write_unlock_bh(&udp_hash_lock);
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -1949,13 +1949,13 @@ struct prot_inuse {
static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR);
static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR);
static DEFINE_PER_CPU(struct prot_inuse, prot_inuse);
static DEFINE_PER_CPU(struct prot_inuse, prot_inuse);


void sock_prot_inuse_add(struct proto *prot, int val)
void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
{
{
	__get_cpu_var(prot_inuse).val[prot->inuse_idx] += val;
	__get_cpu_var(prot_inuse).val[prot->inuse_idx] += val;
}
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);


int sock_prot_inuse_get(struct proto *prot)
int sock_prot_inuse_get(struct net *net, struct proto *prot)
{
{
	int cpu, idx = prot->inuse_idx;
	int cpu, idx = prot->inuse_idx;
	int res = 0;
	int res = 0;
+4 −4
Original line number Original line Diff line number Diff line
@@ -288,7 +288,7 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
	sk->sk_hash = hash;
	sk->sk_hash = hash;
	BUG_TRAP(sk_unhashed(sk));
	BUG_TRAP(sk_unhashed(sk));
	__sk_add_node(sk, &head->chain);
	__sk_add_node(sk, &head->chain);
	sock_prot_inuse_add(sk->sk_prot, 1);
	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
	write_unlock(lock);
	write_unlock(lock);


	if (twp) {
	if (twp) {
@@ -332,7 +332,7 @@ void __inet_hash_nolisten(struct sock *sk)


	write_lock(lock);
	write_lock(lock);
	__sk_add_node(sk, list);
	__sk_add_node(sk, list);
	sock_prot_inuse_add(sk->sk_prot, 1);
	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
	write_unlock(lock);
	write_unlock(lock);
}
}
EXPORT_SYMBOL_GPL(__inet_hash_nolisten);
EXPORT_SYMBOL_GPL(__inet_hash_nolisten);
@@ -354,7 +354,7 @@ static void __inet_hash(struct sock *sk)


	inet_listen_wlock(hashinfo);
	inet_listen_wlock(hashinfo);
	__sk_add_node(sk, list);
	__sk_add_node(sk, list);
	sock_prot_inuse_add(sk->sk_prot, 1);
	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
	write_unlock(lock);
	write_unlock(lock);
	wake_up(&hashinfo->lhash_wait);
	wake_up(&hashinfo->lhash_wait);
}
}
@@ -387,7 +387,7 @@ void inet_unhash(struct sock *sk)
	}
	}


	if (__sk_del_node_init(sk))
	if (__sk_del_node_init(sk))
		sock_prot_inuse_add(sk->sk_prot, -1);
		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
	write_unlock_bh(lock);
	write_unlock_bh(lock);
out:
out:
	if (sk->sk_state == TCP_LISTEN)
	if (sk->sk_state == TCP_LISTEN)
+1 −1
Original line number Original line Diff line number Diff line
@@ -91,7 +91,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,


	/* Step 2: Remove SK from established hash. */
	/* Step 2: Remove SK from established hash. */
	if (__sk_del_node_init(sk))
	if (__sk_del_node_init(sk))
		sock_prot_inuse_add(sk->sk_prot, -1);
		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);


	/* Step 3: Hash TW into TIMEWAIT chain. */
	/* Step 3: Hash TW into TIMEWAIT chain. */
	inet_twsk_add_node(tw, &ehead->twchain);
	inet_twsk_add_node(tw, &ehead->twchain);
Loading