aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/protocol.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r--net/sctp/protocol.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 3d036cdfae41..957c118a6068 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -51,6 +51,7 @@
51#include <linux/netdevice.h> 51#include <linux/netdevice.h>
52#include <linux/inetdevice.h> 52#include <linux/inetdevice.h>
53#include <linux/seq_file.h> 53#include <linux/seq_file.h>
54#include <linux/bootmem.h>
54#include <net/protocol.h> 55#include <net/protocol.h>
55#include <net/ip.h> 56#include <net/ip.h>
56#include <net/ipv6.h> 57#include <net/ipv6.h>
@@ -82,6 +83,10 @@ static struct sctp_af *sctp_af_v6_specific;
82struct kmem_cache *sctp_chunk_cachep __read_mostly; 83struct kmem_cache *sctp_chunk_cachep __read_mostly;
83struct kmem_cache *sctp_bucket_cachep __read_mostly; 84struct kmem_cache *sctp_bucket_cachep __read_mostly;
84 85
86extern int sysctl_sctp_mem[3];
87extern int sysctl_sctp_rmem[3];
88extern int sysctl_sctp_wmem[3];
89
85/* Return the address of the control sock. */ 90/* Return the address of the control sock. */
86struct sock *sctp_get_ctl_sock(void) 91struct sock *sctp_get_ctl_sock(void)
87{ 92{
@@ -987,6 +992,8 @@ SCTP_STATIC __init int sctp_init(void)
987 int i; 992 int i;
988 int status = -EINVAL; 993 int status = -EINVAL;
989 unsigned long goal; 994 unsigned long goal;
995 unsigned long limit;
996 int max_share;
990 int order; 997 int order;
991 998
992 /* SCTP_DEBUG sanity check. */ 999 /* SCTP_DEBUG sanity check. */
@@ -1077,6 +1084,31 @@ SCTP_STATIC __init int sctp_init(void)
1077 /* Initialize handle used for association ids. */ 1084 /* Initialize handle used for association ids. */
1078 idr_init(&sctp_assocs_id); 1085 idr_init(&sctp_assocs_id);
1079 1086
1087 /* Set the pressure threshold to be a fraction of global memory that
1088 * is up to 1/2 at 256 MB, decreasing toward zero with the amount of
1089 * memory, with a floor of 128 pages.
1090 * Note this initalizes the data in sctpv6_prot too
1091 * Unabashedly stolen from tcp_init
1092 */
1093 limit = min(num_physpages, 1UL<<(28-PAGE_SHIFT)) >> (20-PAGE_SHIFT);
1094 limit = (limit * (num_physpages >> (20-PAGE_SHIFT))) >> (PAGE_SHIFT-11);
1095 limit = max(limit, 128UL);
1096 sysctl_sctp_mem[0] = limit / 4 * 3;
1097 sysctl_sctp_mem[1] = limit;
1098 sysctl_sctp_mem[2] = sysctl_sctp_mem[0] * 2;
1099
1100 /* Set per-socket limits to no more than 1/128 the pressure threshold*/
1101 limit = (sysctl_sctp_mem[1]) << (PAGE_SHIFT - 7);
1102 max_share = min(4UL*1024*1024, limit);
1103
1104 sysctl_sctp_rmem[0] = PAGE_SIZE; /* give each asoc 1 page min */
1105 sysctl_sctp_rmem[1] = (1500 *(sizeof(struct sk_buff) + 1));
1106 sysctl_sctp_rmem[2] = max(sysctl_sctp_rmem[1], max_share);
1107
1108 sysctl_sctp_wmem[0] = SK_STREAM_MEM_QUANTUM;
1109 sysctl_sctp_wmem[1] = 16*1024;
1110 sysctl_sctp_wmem[2] = max(64*1024, max_share);
1111
1080 /* Size and allocate the association hash table. 1112 /* Size and allocate the association hash table.
1081 * The methodology is similar to that of the tcp hash tables. 1113 * The methodology is similar to that of the tcp hash tables.
1082 */ 1114 */