diff options
-rw-r--r-- | include/net/sock.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 21db792bffa5..ea6206ccc896 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -2047,18 +2047,21 @@ static inline void sk_wake_async(struct sock *sk, int how, int band) | |||
2047 | sock_wake_async(sk->sk_socket, how, band); | 2047 | sock_wake_async(sk->sk_socket, how, band); |
2048 | } | 2048 | } |
2049 | 2049 | ||
2050 | #define SOCK_MIN_SNDBUF 2048 | 2050 | /* Since sk_{r,w}mem_alloc sums skb->truesize, even a small frame might |
2051 | /* | 2051 | * need sizeof(sk_buff) + MTU + padding, unless net driver perform copybreak. |
2052 | * Since sk_rmem_alloc sums skb->truesize, even a small frame might need | 2052 | * Note: for send buffers, TCP works better if we can build two skbs at |
2053 | * sizeof(sk_buff) + MTU + padding, unless net driver perform copybreak | 2053 | * minimum. |
2054 | */ | 2054 | */ |
2055 | #define SOCK_MIN_RCVBUF (2048 + sizeof(struct sk_buff)) | 2055 | #define TCP_SKB_MIN_TRUESIZE (2048 + sizeof(struct sk_buff)) |
2056 | |||
2057 | #define SOCK_MIN_SNDBUF (TCP_SKB_MIN_TRUESIZE * 2) | ||
2058 | #define SOCK_MIN_RCVBUF TCP_SKB_MIN_TRUESIZE | ||
2056 | 2059 | ||
2057 | static inline void sk_stream_moderate_sndbuf(struct sock *sk) | 2060 | static inline void sk_stream_moderate_sndbuf(struct sock *sk) |
2058 | { | 2061 | { |
2059 | if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) { | 2062 | if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) { |
2060 | sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued >> 1); | 2063 | sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued >> 1); |
2061 | sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF); | 2064 | sk->sk_sndbuf = max_t(u32, sk->sk_sndbuf, SOCK_MIN_SNDBUF); |
2062 | } | 2065 | } |
2063 | } | 2066 | } |
2064 | 2067 | ||