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 | |
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>
-rw-r--r-- | include/net/sctp/constants.h | 2 | ||||
-rw-r--r-- | include/net/sctp/structs.h | 1 | ||||
-rw-r--r-- | include/net/sctp/user.h | 2 | ||||
-rw-r--r-- | net/sctp/associola.c | 2 | ||||
-rw-r--r-- | net/sctp/protocol.c | 2 | ||||
-rw-r--r-- | net/sctp/socket.c | 61 |
6 files changed, 67 insertions, 3 deletions
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h index 5ddb85599863..bb37724495a5 100644 --- a/include/net/sctp/constants.h +++ b/include/net/sctp/constants.h | |||
@@ -283,7 +283,7 @@ enum { SCTP_MAX_GABS = 16 }; | |||
283 | #define SCTP_RTO_BETA 2 /* 1/4 when converted to right shifts. */ | 283 | #define SCTP_RTO_BETA 2 /* 1/4 when converted to right shifts. */ |
284 | 284 | ||
285 | /* Maximum number of new data packets that can be sent in a burst. */ | 285 | /* Maximum number of new data packets that can be sent in a burst. */ |
286 | #define SCTP_MAX_BURST 4 | 286 | #define SCTP_DEFAULT_MAX_BURST 4 |
287 | 287 | ||
288 | #define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ | 288 | #define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ |
289 | 289 | ||
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 37b4a24e589b..7b4fff93ba7f 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -276,6 +276,7 @@ struct sctp_sock { | |||
276 | __u32 default_context; | 276 | __u32 default_context; |
277 | __u32 default_timetolive; | 277 | __u32 default_timetolive; |
278 | __u32 default_rcv_context; | 278 | __u32 default_rcv_context; |
279 | int max_burst; | ||
279 | 280 | ||
280 | /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to | 281 | /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to |
281 | * the destination address every heartbeat interval. This value | 282 | * the destination address every heartbeat interval. This value |
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h index 1b3153c2cdf0..6d2b57758cca 100644 --- a/include/net/sctp/user.h +++ b/include/net/sctp/user.h | |||
@@ -101,6 +101,8 @@ enum sctp_optname { | |||
101 | #define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE | 101 | #define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE |
102 | SCTP_PARTIAL_DELIVERY_POINT, /* Set/Get partial delivery point */ | 102 | SCTP_PARTIAL_DELIVERY_POINT, /* Set/Get partial delivery point */ |
103 | #define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT | 103 | #define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT |
104 | SCTP_MAX_BURST, /* Set/Get max burst */ | ||
105 | #define SCTP_MAX_BURST SCTP_MAX_BURST | ||
104 | 106 | ||
105 | /* Internal Socket Options. Some of the sctp library functions are | 107 | /* Internal Socket Options. Some of the sctp library functions are |
106 | * implemented using these socket options. | 108 | * implemented using these socket options. |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 85af1cb70fe8..37a343e1ebb7 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -143,7 +143,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
143 | /* Initialize the maximum mumber of new data packets that can be sent | 143 | /* Initialize the maximum mumber of new data packets that can be sent |
144 | * in a burst. | 144 | * in a burst. |
145 | */ | 145 | */ |
146 | asoc->max_burst = sctp_max_burst; | 146 | asoc->max_burst = sp->max_burst; |
147 | 147 | ||
148 | /* initialize association timers */ | 148 | /* initialize association timers */ |
149 | asoc->timeouts[SCTP_EVENT_TIMEOUT_NONE] = 0; | 149 | asoc->timeouts[SCTP_EVENT_TIMEOUT_NONE] = 0; |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 7c28c9b959e2..c361deb6cea9 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -1042,7 +1042,7 @@ SCTP_STATIC __init int sctp_init(void) | |||
1042 | sctp_cookie_preserve_enable = 1; | 1042 | sctp_cookie_preserve_enable = 1; |
1043 | 1043 | ||
1044 | /* Max.Burst - 4 */ | 1044 | /* Max.Burst - 4 */ |
1045 | sctp_max_burst = SCTP_MAX_BURST; | 1045 | sctp_max_burst = SCTP_DEFAULT_MAX_BURST; |
1046 | 1046 | ||
1047 | /* Association.Max.Retrans - 10 attempts | 1047 | /* Association.Max.Retrans - 10 attempts |
1048 | * Path.Max.Retrans - 5 attempts (per destination address) | 1048 | * Path.Max.Retrans - 5 attempts (per destination address) |
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; |