aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-08-07 03:29:57 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-15 02:32:16 -0400
commite1fc3b14f9a90d9591016749289f2c3d7b35fbf4 (patch)
tree709a6cfe1ac2d7164c9661a8c393a91d83ee6c85 /net/sctp/socket.c
parentf53b5b097e58361668b785eff9f7bcd12b4255ec (diff)
sctp: Make sysctl tunables per net
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index a6a4226a922f..d37d24ff197f 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -516,6 +516,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
516 struct sockaddr *addrs, 516 struct sockaddr *addrs,
517 int addrcnt) 517 int addrcnt)
518{ 518{
519 struct net *net = sock_net(sk);
519 struct sctp_sock *sp; 520 struct sctp_sock *sp;
520 struct sctp_endpoint *ep; 521 struct sctp_endpoint *ep;
521 struct sctp_association *asoc; 522 struct sctp_association *asoc;
@@ -530,7 +531,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
530 int i; 531 int i;
531 int retval = 0; 532 int retval = 0;
532 533
533 if (!sctp_addip_enable) 534 if (!net->sctp.addip_enable)
534 return retval; 535 return retval;
535 536
536 sp = sctp_sk(sk); 537 sp = sctp_sk(sk);
@@ -718,6 +719,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
718 struct sockaddr *addrs, 719 struct sockaddr *addrs,
719 int addrcnt) 720 int addrcnt)
720{ 721{
722 struct net *net = sock_net(sk);
721 struct sctp_sock *sp; 723 struct sctp_sock *sp;
722 struct sctp_endpoint *ep; 724 struct sctp_endpoint *ep;
723 struct sctp_association *asoc; 725 struct sctp_association *asoc;
@@ -733,7 +735,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
733 int stored = 0; 735 int stored = 0;
734 736
735 chunk = NULL; 737 chunk = NULL;
736 if (!sctp_addip_enable) 738 if (!net->sctp.addip_enable)
737 return retval; 739 return retval;
738 740
739 sp = sctp_sk(sk); 741 sp = sctp_sk(sk);
@@ -3039,6 +3041,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
3039static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval, 3041static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval,
3040 unsigned int optlen) 3042 unsigned int optlen)
3041{ 3043{
3044 struct net *net = sock_net(sk);
3042 struct sctp_sock *sp; 3045 struct sctp_sock *sp;
3043 struct sctp_association *asoc = NULL; 3046 struct sctp_association *asoc = NULL;
3044 struct sctp_setpeerprim prim; 3047 struct sctp_setpeerprim prim;
@@ -3048,7 +3051,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
3048 3051
3049 sp = sctp_sk(sk); 3052 sp = sctp_sk(sk);
3050 3053
3051 if (!sctp_addip_enable) 3054 if (!net->sctp.addip_enable)
3052 return -EPERM; 3055 return -EPERM;
3053 3056
3054 if (optlen != sizeof(struct sctp_setpeerprim)) 3057 if (optlen != sizeof(struct sctp_setpeerprim))
@@ -3285,9 +3288,10 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk,
3285 char __user *optval, 3288 char __user *optval,
3286 unsigned int optlen) 3289 unsigned int optlen)
3287{ 3290{
3291 struct net *net = sock_net(sk);
3288 struct sctp_authchunk val; 3292 struct sctp_authchunk val;
3289 3293
3290 if (!sctp_auth_enable) 3294 if (!net->sctp.auth_enable)
3291 return -EACCES; 3295 return -EACCES;
3292 3296
3293 if (optlen != sizeof(struct sctp_authchunk)) 3297 if (optlen != sizeof(struct sctp_authchunk))
@@ -3317,11 +3321,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk,
3317 char __user *optval, 3321 char __user *optval,
3318 unsigned int optlen) 3322 unsigned int optlen)
3319{ 3323{
3324 struct net *net = sock_net(sk);
3320 struct sctp_hmacalgo *hmacs; 3325 struct sctp_hmacalgo *hmacs;
3321 u32 idents; 3326 u32 idents;
3322 int err; 3327 int err;
3323 3328
3324 if (!sctp_auth_enable) 3329 if (!net->sctp.auth_enable)
3325 return -EACCES; 3330 return -EACCES;
3326 3331
3327 if (optlen < sizeof(struct sctp_hmacalgo)) 3332 if (optlen < sizeof(struct sctp_hmacalgo))
@@ -3354,11 +3359,12 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
3354 char __user *optval, 3359 char __user *optval,
3355 unsigned int optlen) 3360 unsigned int optlen)
3356{ 3361{
3362 struct net *net = sock_net(sk);
3357 struct sctp_authkey *authkey; 3363 struct sctp_authkey *authkey;
3358 struct sctp_association *asoc; 3364 struct sctp_association *asoc;
3359 int ret; 3365 int ret;
3360 3366
3361 if (!sctp_auth_enable) 3367 if (!net->sctp.auth_enable)
3362 return -EACCES; 3368 return -EACCES;
3363 3369
3364 if (optlen <= sizeof(struct sctp_authkey)) 3370 if (optlen <= sizeof(struct sctp_authkey))
@@ -3395,10 +3401,11 @@ static int sctp_setsockopt_active_key(struct sock *sk,
3395 char __user *optval, 3401 char __user *optval,
3396 unsigned int optlen) 3402 unsigned int optlen)
3397{ 3403{
3404 struct net *net = sock_net(sk);
3398 struct sctp_authkeyid val; 3405 struct sctp_authkeyid val;
3399 struct sctp_association *asoc; 3406 struct sctp_association *asoc;
3400 3407
3401 if (!sctp_auth_enable) 3408 if (!net->sctp.auth_enable)
3402 return -EACCES; 3409 return -EACCES;
3403 3410
3404 if (optlen != sizeof(struct sctp_authkeyid)) 3411 if (optlen != sizeof(struct sctp_authkeyid))
@@ -3423,10 +3430,11 @@ static int sctp_setsockopt_del_key(struct sock *sk,
3423 char __user *optval, 3430 char __user *optval,
3424 unsigned int optlen) 3431 unsigned int optlen)
3425{ 3432{
3433 struct net *net = sock_net(sk);
3426 struct sctp_authkeyid val; 3434 struct sctp_authkeyid val;
3427 struct sctp_association *asoc; 3435 struct sctp_association *asoc;
3428 3436
3429 if (!sctp_auth_enable) 3437 if (!net->sctp.auth_enable)
3430 return -EACCES; 3438 return -EACCES;
3431 3439
3432 if (optlen != sizeof(struct sctp_authkeyid)) 3440 if (optlen != sizeof(struct sctp_authkeyid))
@@ -3849,6 +3857,7 @@ out:
3849 */ 3857 */
3850SCTP_STATIC int sctp_init_sock(struct sock *sk) 3858SCTP_STATIC int sctp_init_sock(struct sock *sk)
3851{ 3859{
3860 struct net *net = sock_net(sk);
3852 struct sctp_endpoint *ep; 3861 struct sctp_endpoint *ep;
3853 struct sctp_sock *sp; 3862 struct sctp_sock *sp;
3854 3863
@@ -3878,7 +3887,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3878 sp->default_timetolive = 0; 3887 sp->default_timetolive = 0;
3879 3888
3880 sp->default_rcv_context = 0; 3889 sp->default_rcv_context = 0;
3881 sp->max_burst = sctp_max_burst; 3890 sp->max_burst = net->sctp.max_burst;
3882 3891
3883 /* Initialize default setup parameters. These parameters 3892 /* Initialize default setup parameters. These parameters
3884 * can be modified with the SCTP_INITMSG socket option or 3893 * can be modified with the SCTP_INITMSG socket option or
@@ -3886,24 +3895,24 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3886 */ 3895 */
3887 sp->initmsg.sinit_num_ostreams = sctp_max_outstreams; 3896 sp->initmsg.sinit_num_ostreams = sctp_max_outstreams;
3888 sp->initmsg.sinit_max_instreams = sctp_max_instreams; 3897 sp->initmsg.sinit_max_instreams = sctp_max_instreams;
3889 sp->initmsg.sinit_max_attempts = sctp_max_retrans_init; 3898 sp->initmsg.sinit_max_attempts = net->sctp.max_retrans_init;
3890 sp->initmsg.sinit_max_init_timeo = sctp_rto_max; 3899 sp->initmsg.sinit_max_init_timeo = net->sctp.rto_max;
3891 3900
3892 /* Initialize default RTO related parameters. These parameters can 3901 /* Initialize default RTO related parameters. These parameters can
3893 * be modified for with the SCTP_RTOINFO socket option. 3902 * be modified for with the SCTP_RTOINFO socket option.
3894 */ 3903 */
3895 sp->rtoinfo.srto_initial = sctp_rto_initial; 3904 sp->rtoinfo.srto_initial = net->sctp.rto_initial;
3896 sp->rtoinfo.srto_max = sctp_rto_max; 3905 sp->rtoinfo.srto_max = net->sctp.rto_max;
3897 sp->rtoinfo.srto_min = sctp_rto_min; 3906 sp->rtoinfo.srto_min = net->sctp.rto_min;
3898 3907
3899 /* Initialize default association related parameters. These parameters 3908 /* Initialize default association related parameters. These parameters
3900 * can be modified with the SCTP_ASSOCINFO socket option. 3909 * can be modified with the SCTP_ASSOCINFO socket option.
3901 */ 3910 */
3902 sp->assocparams.sasoc_asocmaxrxt = sctp_max_retrans_association; 3911 sp->assocparams.sasoc_asocmaxrxt = net->sctp.max_retrans_association;
3903 sp->assocparams.sasoc_number_peer_destinations = 0; 3912 sp->assocparams.sasoc_number_peer_destinations = 0;
3904 sp->assocparams.sasoc_peer_rwnd = 0; 3913 sp->assocparams.sasoc_peer_rwnd = 0;
3905 sp->assocparams.sasoc_local_rwnd = 0; 3914 sp->assocparams.sasoc_local_rwnd = 0;
3906 sp->assocparams.sasoc_cookie_life = sctp_valid_cookie_life; 3915 sp->assocparams.sasoc_cookie_life = net->sctp.valid_cookie_life;
3907 3916
3908 /* Initialize default event subscriptions. By default, all the 3917 /* Initialize default event subscriptions. By default, all the
3909 * options are off. 3918 * options are off.
@@ -3913,10 +3922,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3913 /* Default Peer Address Parameters. These defaults can 3922 /* Default Peer Address Parameters. These defaults can
3914 * be modified via SCTP_PEER_ADDR_PARAMS 3923 * be modified via SCTP_PEER_ADDR_PARAMS
3915 */ 3924 */
3916 sp->hbinterval = sctp_hb_interval; 3925 sp->hbinterval = net->sctp.hb_interval;
3917 sp->pathmaxrxt = sctp_max_retrans_path; 3926 sp->pathmaxrxt = net->sctp.max_retrans_path;
3918 sp->pathmtu = 0; // allow default discovery 3927 sp->pathmtu = 0; // allow default discovery
3919 sp->sackdelay = sctp_sack_timeout; 3928 sp->sackdelay = net->sctp.sack_timeout;
3920 sp->sackfreq = 2; 3929 sp->sackfreq = 2;
3921 sp->param_flags = SPP_HB_ENABLE | 3930 sp->param_flags = SPP_HB_ENABLE |
3922 SPP_PMTUD_ENABLE | 3931 SPP_PMTUD_ENABLE |
@@ -3967,10 +3976,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3967 3976
3968 local_bh_disable(); 3977 local_bh_disable();
3969 percpu_counter_inc(&sctp_sockets_allocated); 3978 percpu_counter_inc(&sctp_sockets_allocated);
3970 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 3979 sock_prot_inuse_add(net, sk->sk_prot, 1);
3971 if (sctp_default_auto_asconf) { 3980 if (net->sctp.default_auto_asconf) {
3972 list_add_tail(&sp->auto_asconf_list, 3981 list_add_tail(&sp->auto_asconf_list,
3973 &sock_net(sk)->sctp.auto_asconf_splist); 3982 &net->sctp.auto_asconf_splist);
3974 sp->do_auto_asconf = 1; 3983 sp->do_auto_asconf = 1;
3975 } else 3984 } else
3976 sp->do_auto_asconf = 0; 3985 sp->do_auto_asconf = 0;
@@ -5307,12 +5316,13 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len,
5307static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, 5316static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
5308 char __user *optval, int __user *optlen) 5317 char __user *optval, int __user *optlen)
5309{ 5318{
5319 struct net *net = sock_net(sk);
5310 struct sctp_hmacalgo __user *p = (void __user *)optval; 5320 struct sctp_hmacalgo __user *p = (void __user *)optval;
5311 struct sctp_hmac_algo_param *hmacs; 5321 struct sctp_hmac_algo_param *hmacs;
5312 __u16 data_len = 0; 5322 __u16 data_len = 0;
5313 u32 num_idents; 5323 u32 num_idents;
5314 5324
5315 if (!sctp_auth_enable) 5325 if (!net->sctp.auth_enable)
5316 return -EACCES; 5326 return -EACCES;
5317 5327
5318 hmacs = sctp_sk(sk)->ep->auth_hmacs_list; 5328 hmacs = sctp_sk(sk)->ep->auth_hmacs_list;
@@ -5336,10 +5346,11 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
5336static int sctp_getsockopt_active_key(struct sock *sk, int len, 5346static int sctp_getsockopt_active_key(struct sock *sk, int len,
5337 char __user *optval, int __user *optlen) 5347 char __user *optval, int __user *optlen)
5338{ 5348{
5349 struct net *net = sock_net(sk);
5339 struct sctp_authkeyid val; 5350 struct sctp_authkeyid val;
5340 struct sctp_association *asoc; 5351 struct sctp_association *asoc;
5341 5352
5342 if (!sctp_auth_enable) 5353 if (!net->sctp.auth_enable)
5343 return -EACCES; 5354 return -EACCES;
5344 5355
5345 if (len < sizeof(struct sctp_authkeyid)) 5356 if (len < sizeof(struct sctp_authkeyid))
@@ -5368,6 +5379,7 @@ static int sctp_getsockopt_active_key(struct sock *sk, int len,
5368static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, 5379static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
5369 char __user *optval, int __user *optlen) 5380 char __user *optval, int __user *optlen)
5370{ 5381{
5382 struct net *net = sock_net(sk);
5371 struct sctp_authchunks __user *p = (void __user *)optval; 5383 struct sctp_authchunks __user *p = (void __user *)optval;
5372 struct sctp_authchunks val; 5384 struct sctp_authchunks val;
5373 struct sctp_association *asoc; 5385 struct sctp_association *asoc;
@@ -5375,7 +5387,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
5375 u32 num_chunks = 0; 5387 u32 num_chunks = 0;
5376 char __user *to; 5388 char __user *to;
5377 5389
5378 if (!sctp_auth_enable) 5390 if (!net->sctp.auth_enable)
5379 return -EACCES; 5391 return -EACCES;
5380 5392
5381 if (len < sizeof(struct sctp_authchunks)) 5393 if (len < sizeof(struct sctp_authchunks))
@@ -5411,6 +5423,7 @@ num:
5411static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, 5423static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
5412 char __user *optval, int __user *optlen) 5424 char __user *optval, int __user *optlen)
5413{ 5425{
5426 struct net *net = sock_net(sk);
5414 struct sctp_authchunks __user *p = (void __user *)optval; 5427 struct sctp_authchunks __user *p = (void __user *)optval;
5415 struct sctp_authchunks val; 5428 struct sctp_authchunks val;
5416 struct sctp_association *asoc; 5429 struct sctp_association *asoc;
@@ -5418,7 +5431,7 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
5418 u32 num_chunks = 0; 5431 u32 num_chunks = 0;
5419 char __user *to; 5432 char __user *to;
5420 5433
5421 if (!sctp_auth_enable) 5434 if (!net->sctp.auth_enable)
5422 return -EACCES; 5435 return -EACCES;
5423 5436
5424 if (len < sizeof(struct sctp_authchunks)) 5437 if (len < sizeof(struct sctp_authchunks))