net: allow per netns sysctl_rmem and sysctl_wmem for protos
As we want to gradually implement per netns sysctl_rmem and sysctl_wmem on per protocol basis, add two new fields in struct proto, and two new helpers : sk_get_wmem0() and sk_get_rmem0() First user will be TCP. Then UDP and SCTP can be easily converted, while DECNET probably wont get this support. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
2ea7a679ca
commit
a3dcaf17ee
@@ -2346,16 +2346,18 @@ int __sk_mem_raise_allocated(struct sock *sk, int size, int amt, int kind)
|
||||
|
||||
/* guarantee minimum buffer size under pressure */
|
||||
if (kind == SK_MEM_RECV) {
|
||||
if (atomic_read(&sk->sk_rmem_alloc) < prot->sysctl_rmem[0])
|
||||
if (atomic_read(&sk->sk_rmem_alloc) < sk_get_rmem0(sk, prot))
|
||||
return 1;
|
||||
|
||||
} else { /* SK_MEM_SEND */
|
||||
int wmem0 = sk_get_wmem0(sk, prot);
|
||||
|
||||
if (sk->sk_type == SOCK_STREAM) {
|
||||
if (sk->sk_wmem_queued < prot->sysctl_wmem[0])
|
||||
if (sk->sk_wmem_queued < wmem0)
|
||||
return 1;
|
||||
} else if (refcount_read(&sk->sk_wmem_alloc) <
|
||||
prot->sysctl_wmem[0])
|
||||
} else if (refcount_read(&sk->sk_wmem_alloc) < wmem0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (sk_has_memory_pressure(sk)) {
|
||||
|
Reference in New Issue
Block a user