diff options
| author | David S. Miller <davem@nuts.davemloft.net> | 2004-02-22 22:09:29 -0800 |
|---|---|---|
| committer | David S. Miller <davem@kernel.bkbits.net> | 2004-02-22 22:09:29 -0800 |
| commit | 56278f2205bca0373c1abbbd24efcce7c19e894a (patch) | |
| tree | f1cfb4656c7be760218dc285019ea6a27c47895a | |
| parent | 3394b347940da0529bd5ae7925b2064e23b9a5ae (diff) | |
[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.
| -rw-r--r-- | include/linux/skbuff.h | 3 | ||||
| -rw-r--r-- | net/core/sock.c | 10 | ||||
| -rw-r--r-- | net/ipv4/icmp.c | 8 | ||||
| -rw-r--r-- | net/ipv6/icmp.c | 8 |
4 files changed, 24 insertions, 5 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 56590cedc22c..ef9b7c57b9ca 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -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 diff --git a/net/core/sock.c b/net/core/sock.c index 007ed8c8888e..fb48e44ad005 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -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; diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 3fdaa1b78e64..266174ae70ef 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -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; diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index 09e101c8e46d..73432df6fa96 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -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); } |
