Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Vlad Yasevich and committed by
David S. Miller
70331571 a5a35e76

+67 -3
+1 -1
include/net/sctp/constants.h
··· 283 283 #define SCTP_RTO_BETA 2 /* 1/4 when converted to right shifts. */ 284 284 285 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 288 #define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ 289 289
+1
include/net/sctp/structs.h
··· 276 276 __u32 default_context; 277 277 __u32 default_timetolive; 278 278 __u32 default_rcv_context; 279 + int max_burst; 279 280 280 281 /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to 281 282 * the destination address every heartbeat interval. This value
+2
include/net/sctp/user.h
··· 101 101 #define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE 102 102 SCTP_PARTIAL_DELIVERY_POINT, /* Set/Get partial delivery point */ 103 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 107 /* Internal Socket Options. Some of the sctp library functions are 106 108 * implemented using these socket options.
+1 -1
net/sctp/associola.c
··· 143 143 /* Initialize the maximum mumber of new data packets that can be sent 144 144 * in a burst. 145 145 */ 146 - asoc->max_burst = sctp_max_burst; 146 + asoc->max_burst = sp->max_burst; 147 147 148 148 /* initialize association timers */ 149 149 asoc->timeouts[SCTP_EVENT_TIMEOUT_NONE] = 0;
+1 -1
net/sctp/protocol.c
··· 1042 1042 sctp_cookie_preserve_enable = 1; 1043 1043 1044 1044 /* Max.Burst - 4 */ 1045 - sctp_max_burst = SCTP_MAX_BURST; 1045 + sctp_max_burst = SCTP_DEFAULT_MAX_BURST; 1046 1046 1047 1047 /* Association.Max.Retrans - 10 attempts 1048 1048 * Path.Max.Retrans - 5 attempts (per destination address)
+61
net/sctp/socket.c
··· 2892 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 2925 /* API 6.2 setsockopt(), getsockopt() 2896 2926 * 2897 2927 * Applications use setsockopt() and getsockopt() to set or retrieve ··· 3041 3011 break; 3042 3012 case SCTP_FRAGMENT_INTERLEAVE: 3043 3013 retval = sctp_setsockopt_fragment_interleave(sk, optval, optlen); 3014 + break; 3015 + case SCTP_MAX_BURST: 3016 + retval = sctp_setsockopt_maxburst(sk, optval, optlen); 3044 3017 break; 3045 3018 default: 3046 3019 retval = -ENOPROTOOPT; ··· 3204 3171 sp->default_timetolive = 0; 3205 3172 3206 3173 sp->default_rcv_context = 0; 3174 + sp->max_burst = sctp_max_burst; 3207 3175 3208 3176 /* Initialize default setup parameters. These parameters 3209 3177 * can be modified with the SCTP_INITMSG socket option or ··· 4723 4689 return -ENOTSUPP; 4724 4690 } 4725 4691 4692 + /* 4693 + * 7.1.28. Set or Get the maximum burst (SCTP_MAX_BURST) 4694 + * (chapter and verse is quoted at sctp_setsockopt_maxburst()) 4695 + */ 4696 + static int sctp_getsockopt_maxburst(struct sock *sk, int len, 4697 + char __user *optval, 4698 + int __user *optlen) 4699 + { 4700 + int val; 4701 + 4702 + if (len < sizeof(int)) 4703 + return -EINVAL; 4704 + 4705 + len = sizeof(int); 4706 + 4707 + val = sctp_sk(sk)->max_burst; 4708 + if (put_user(len, optlen)) 4709 + return -EFAULT; 4710 + if (copy_to_user(optval, &val, len)) 4711 + return -EFAULT; 4712 + 4713 + return -ENOTSUPP; 4714 + } 4715 + 4726 4716 SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, 4727 4717 char __user *optval, int __user *optlen) 4728 4718 { ··· 4866 4808 case SCTP_PARTIAL_DELIVERY_POINT: 4867 4809 retval = sctp_getsockopt_partial_delivery_point(sk, len, optval, 4868 4810 optlen); 4811 + break; 4812 + case SCTP_MAX_BURST: 4813 + retval = sctp_getsockopt_maxburst(sk, len, optval, optlen); 4869 4814 break; 4870 4815 default: 4871 4816 retval = -ENOPROTOOPT;