Commit 56278f22 authored by David S. Miller's avatar David S. Miller Committed by David S. Miller

[NET]: Set default socket rmem/wmem values more sanely and consistently.

1) Take into account the fact that struct sk_buff, which counts towards
   socket buffer limits, changes across different platforms.
2) Give ipv4/ipv6 ICMP sockets more accurately the wmem limits they
   want.
parent 3394b347
......@@ -274,9 +274,6 @@ struct sk_buff {
*end;
};
#define SK_WMEM_MAX 65535
#define SK_RMEM_MAX 65535
#ifdef __KERNEL__
/*
* Handling routines are only of interest to the kernel
......
......@@ -126,6 +126,16 @@
#include <net/tcp.h>
#endif
/* Take into consideration the size of the struct sk_buff overhead in the
* determination of these values, since that is non-constant across
* platforms. This makes socket queueing behavior and performance
* not depend upon such differences.
*/
#define _SK_MEM_PACKETS 256
#define _SK_MEM_OVERHEAD (sizeof(struct sk_buff) + 256)
#define SK_WMEM_MAX (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS)
#define SK_RMEM_MAX (_SK_MEM_OVERHEAD * _SK_MEM_PACKETS)
/* Run time adjustable parameters. */
__u32 sysctl_wmem_max = SK_WMEM_MAX;
__u32 sysctl_rmem_max = SK_RMEM_MAX;
......
......@@ -1115,7 +1115,13 @@ void __init icmp_init(struct net_proto_family *ops)
panic("Failed to create the ICMP control socket.\n");
per_cpu(__icmp_socket, i)->sk->sk_allocation = GFP_ATOMIC;
per_cpu(__icmp_socket, i)->sk->sk_sndbuf = SK_WMEM_MAX * 2;
/* Enough space for 2 64K ICMP packets, including
* sk_buff struct overhead.
*/
per_cpu(__icmp_socket, i)->sk->sk_sndbuf =
(2 * ((64 * 1024) + sizeof(struct sk_buff)));
inet = inet_sk(per_cpu(__icmp_socket, i)->sk);
inet->uc_ttl = -1;
inet->pmtudisc = IP_PMTUDISC_DONT;
......
......@@ -693,7 +693,13 @@ int __init icmpv6_init(struct net_proto_family *ops)
sk = per_cpu(__icmpv6_socket, i)->sk;
sk->sk_allocation = GFP_ATOMIC;
sk->sk_sndbuf = SK_WMEM_MAX * 2;
/* Enough space for 2 64K ICMP packets, including
* sk_buff struct overhead.
*/
sk->sk_sndbuf =
(2 * ((64 * 1024) + sizeof(struct sk_buff)));
sk->sk_prot->unhash(sk);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment