diff options
author | Vlad Yasevich <vladislav.yasevich@hp.com> | 2007-03-23 14:34:36 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:28:04 -0400 |
commit | 703315712cfccfe0b45ef4aa6994527d8ee95e33 (patch) | |
tree | 618a5aced2dfd2937259b3e99f477b9d1f80e24d /net/sctp/socket.c | |
parent | a5a35e76753d27e782028843a5186f176b50dd16 (diff) |
[SCTP]: Implement SCTP_MAX_BURST socket option.
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index dda2f6700f5b..f904f2bc0f2c 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -2892,6 +2892,36 @@ static int sctp_setsockopt_partial_delivery_point(struct sock *sk, | |||
2892 | return 0; /* is this the right error code? */ | 2892 | return 0; /* is this the right error code? */ |
2893 | } | 2893 | } |
2894 | 2894 | ||
2895 | /* | ||
2896 | * 7.1.28. Set or Get the maximum burst (SCTP_MAX_BURST) | ||
2897 | * | ||
2898 | * This option will allow a user to change the maximum burst of packets | ||
2899 | * that can be emitted by this association. Note that the default value | ||
2900 | * is 4, and some implementations may restrict this setting so that it | ||
2901 | * can only be lowered. | ||
2902 | * | ||
2903 | * NOTE: This text doesn't seem right. Do this on a socket basis with | ||
2904 | * future associations inheriting the socket value. | ||
2905 | */ | ||
2906 | static int sctp_setsockopt_maxburst(struct sock *sk, | ||
2907 | char __user *optval, | ||
2908 | int optlen) | ||
2909 | { | ||
2910 | int val; | ||
2911 | |||
2912 | if (optlen != sizeof(int)) | ||
2913 | return -EINVAL; | ||
2914 | if (get_user(val, (int __user *)optval)) | ||
2915 | return -EFAULT; | ||
2916 | |||
2917 | if (val < 0) | ||
2918 | return -EINVAL; | ||
2919 | |||
2920 | sctp_sk(sk)->max_burst = val; | ||
2921 | |||
2922 | return 0; | ||
2923 | } | ||
2924 | |||
2895 | /* API 6.2 setsockopt(), getsockopt() | 2925 | /* API 6.2 setsockopt(), getsockopt() |
2896 | * | 2926 | * |
2897 | * Applications use setsockopt() and getsockopt() to set or retrieve | 2927 | * Applications use setsockopt() and getsockopt() to set or retrieve |
@@ -3012,6 +3042,9 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname, | |||
3012 | case SCTP_FRAGMENT_INTERLEAVE: | 3042 | case SCTP_FRAGMENT_INTERLEAVE: |
3013 | retval = sctp_setsockopt_fragment_interleave(sk, optval, optlen); | 3043 | retval = sctp_setsockopt_fragment_interleave(sk, optval, optlen); |
3014 | break; | 3044 | break; |
3045 | case SCTP_MAX_BURST: | ||
3046 | retval = sctp_setsockopt_maxburst(sk, optval, optlen); | ||
3047 | break; | ||
3015 | default: | 3048 | default: |
3016 | retval = -ENOPROTOOPT; | 3049 | retval = -ENOPROTOOPT; |
3017 | break; | 3050 | break; |
@@ -3171,6 +3204,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3171 | sp->default_timetolive = 0; | 3204 | sp->default_timetolive = 0; |
3172 | 3205 | ||
3173 | sp->default_rcv_context = 0; | 3206 | sp->default_rcv_context = 0; |
3207 | sp->max_burst = sctp_max_burst; | ||
3174 | 3208 | ||
3175 | /* Initialize default setup parameters. These parameters | 3209 | /* Initialize default setup parameters. These parameters |
3176 | * can be modified with the SCTP_INITMSG socket option or | 3210 | * can be modified with the SCTP_INITMSG socket option or |
@@ -4689,6 +4723,30 @@ static int sctp_getsockopt_partial_delivery_point(struct sock *sk, int len, | |||
4689 | return -ENOTSUPP; | 4723 | return -ENOTSUPP; |
4690 | } | 4724 | } |
4691 | 4725 | ||
4726 | /* | ||
4727 | * 7.1.28. Set or Get the maximum burst (SCTP_MAX_BURST) | ||
4728 | * (chapter and verse is quoted at sctp_setsockopt_maxburst()) | ||
4729 | */ | ||
4730 | static int sctp_getsockopt_maxburst(struct sock *sk, int len, | ||
4731 | char __user *optval, | ||
4732 | int __user *optlen) | ||
4733 | { | ||
4734 | int val; | ||
4735 | |||
4736 | if (len < sizeof(int)) | ||
4737 | return -EINVAL; | ||
4738 | |||
4739 | len = sizeof(int); | ||
4740 | |||
4741 | val = sctp_sk(sk)->max_burst; | ||
4742 | if (put_user(len, optlen)) | ||
4743 | return -EFAULT; | ||
4744 | if (copy_to_user(optval, &val, len)) | ||
4745 | return -EFAULT; | ||
4746 | |||
4747 | return -ENOTSUPP; | ||
4748 | } | ||
4749 | |||
4692 | SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, | 4750 | SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, |
4693 | char __user *optval, int __user *optlen) | 4751 | char __user *optval, int __user *optlen) |
4694 | { | 4752 | { |
@@ -4809,6 +4867,9 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, | |||
4809 | retval = sctp_getsockopt_partial_delivery_point(sk, len, optval, | 4867 | retval = sctp_getsockopt_partial_delivery_point(sk, len, optval, |
4810 | optlen); | 4868 | optlen); |
4811 | break; | 4869 | break; |
4870 | case SCTP_MAX_BURST: | ||
4871 | retval = sctp_getsockopt_maxburst(sk, len, optval, optlen); | ||
4872 | break; | ||
4812 | default: | 4873 | default: |
4813 | retval = -ENOPROTOOPT; | 4874 | retval = -ENOPROTOOPT; |
4814 | break; | 4875 | break; |