mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
net: fix sk_wmem_schedule() and sk_rmem_schedule() errors
If sk->sk_forward_alloc is 150000, and we need to schedule 150001 bytes,
we want to allocate 1 byte more (rounded up to one page),
instead of 150001 :/
Fixes: 1da177e4c3
("Linux-2.6.12-rc2")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
3cd3399dd7
commit
7c80b038d2
1 changed files with 8 additions and 4 deletions
|
@ -1575,19 +1575,23 @@ static inline bool sk_has_account(struct sock *sk)
|
||||||
|
|
||||||
static inline bool sk_wmem_schedule(struct sock *sk, int size)
|
static inline bool sk_wmem_schedule(struct sock *sk, int size)
|
||||||
{
|
{
|
||||||
|
int delta;
|
||||||
|
|
||||||
if (!sk_has_account(sk))
|
if (!sk_has_account(sk))
|
||||||
return true;
|
return true;
|
||||||
return size <= sk->sk_forward_alloc ||
|
delta = size - sk->sk_forward_alloc;
|
||||||
__sk_mem_schedule(sk, size, SK_MEM_SEND);
|
return delta <= 0 || __sk_mem_schedule(sk, delta, SK_MEM_SEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size)
|
sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size)
|
||||||
{
|
{
|
||||||
|
int delta;
|
||||||
|
|
||||||
if (!sk_has_account(sk))
|
if (!sk_has_account(sk))
|
||||||
return true;
|
return true;
|
||||||
return size <= sk->sk_forward_alloc ||
|
delta = size - sk->sk_forward_alloc;
|
||||||
__sk_mem_schedule(sk, size, SK_MEM_RECV) ||
|
return delta <= 0 || __sk_mem_schedule(sk, delta, SK_MEM_RECV) ||
|
||||||
skb_pfmemalloc(skb);
|
skb_pfmemalloc(skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue