]> git.hungrycats.org Git - linux/commitdiff
[NET]: Set default socket rmem/wmem values more sanely and consistently.
authorDavid S. Miller <davem@nuts.davemloft.net>
Mon, 23 Feb 2004 06:09:29 +0000 (22:09 -0800)
committerDavid S. Miller <davem@kernel.bkbits.net>
Mon, 23 Feb 2004 06:09:29 +0000 (22:09 -0800)
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.

include/linux/skbuff.h
net/core/sock.c
net/ipv4/icmp.c
net/ipv6/icmp.c

index 56590cedc22cb90e0272e5d292786e8ac37fc77d..ef9b7c57b9ca1092c75ae33b78a34edf184e65c8 100644 (file)
@@ -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
index 007ed8c8888ea2df5773029d2484325a8cb21eb6..fb48e44ad005e491ce958aa89c84b50fcc73c7a2 100644 (file)
 #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;
index 3fdaa1b78e64d08a65f2db31027f7ff27c77b3a9..266174ae70ef308c3eb67553a5fd5da224717085 100644 (file)
@@ -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;
index 09e101c8e46d7dc34d59e2b10b730d089773056c..73432df6fa962a4bf9260cfff7167252005d4e75 100644 (file)
@@ -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);
        }