diff options
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 323 |
1 files changed, 223 insertions, 100 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 0dbcde6758ea..6aba01b0ce4e 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -116,7 +116,7 @@ static int sctp_memory_pressure; | |||
116 | static atomic_t sctp_memory_allocated; | 116 | static atomic_t sctp_memory_allocated; |
117 | static atomic_t sctp_sockets_allocated; | 117 | static atomic_t sctp_sockets_allocated; |
118 | 118 | ||
119 | static void sctp_enter_memory_pressure(void) | 119 | static void sctp_enter_memory_pressure(struct sock *sk) |
120 | { | 120 | { |
121 | sctp_memory_pressure = 1; | 121 | sctp_memory_pressure = 1; |
122 | } | 122 | } |
@@ -956,7 +956,8 @@ out: | |||
956 | */ | 956 | */ |
957 | static int __sctp_connect(struct sock* sk, | 957 | static int __sctp_connect(struct sock* sk, |
958 | struct sockaddr *kaddrs, | 958 | struct sockaddr *kaddrs, |
959 | int addrs_size) | 959 | int addrs_size, |
960 | sctp_assoc_t *assoc_id) | ||
960 | { | 961 | { |
961 | struct sctp_sock *sp; | 962 | struct sctp_sock *sp; |
962 | struct sctp_endpoint *ep; | 963 | struct sctp_endpoint *ep; |
@@ -1111,6 +1112,8 @@ static int __sctp_connect(struct sock* sk, | |||
1111 | timeo = sock_sndtimeo(sk, f_flags & O_NONBLOCK); | 1112 | timeo = sock_sndtimeo(sk, f_flags & O_NONBLOCK); |
1112 | 1113 | ||
1113 | err = sctp_wait_for_connect(asoc, &timeo); | 1114 | err = sctp_wait_for_connect(asoc, &timeo); |
1115 | if (!err && assoc_id) | ||
1116 | *assoc_id = asoc->assoc_id; | ||
1114 | 1117 | ||
1115 | /* Don't free association on exit. */ | 1118 | /* Don't free association on exit. */ |
1116 | asoc = NULL; | 1119 | asoc = NULL; |
@@ -1128,7 +1131,8 @@ out_free: | |||
1128 | /* Helper for tunneling sctp_connectx() requests through sctp_setsockopt() | 1131 | /* Helper for tunneling sctp_connectx() requests through sctp_setsockopt() |
1129 | * | 1132 | * |
1130 | * API 8.9 | 1133 | * API 8.9 |
1131 | * int sctp_connectx(int sd, struct sockaddr *addrs, int addrcnt); | 1134 | * int sctp_connectx(int sd, struct sockaddr *addrs, int addrcnt, |
1135 | * sctp_assoc_t *asoc); | ||
1132 | * | 1136 | * |
1133 | * If sd is an IPv4 socket, the addresses passed must be IPv4 addresses. | 1137 | * If sd is an IPv4 socket, the addresses passed must be IPv4 addresses. |
1134 | * If the sd is an IPv6 socket, the addresses passed can either be IPv4 | 1138 | * If the sd is an IPv6 socket, the addresses passed can either be IPv4 |
@@ -1144,8 +1148,10 @@ out_free: | |||
1144 | * representation is termed a "packed array" of addresses). The caller | 1148 | * representation is termed a "packed array" of addresses). The caller |
1145 | * specifies the number of addresses in the array with addrcnt. | 1149 | * specifies the number of addresses in the array with addrcnt. |
1146 | * | 1150 | * |
1147 | * On success, sctp_connectx() returns 0. On failure, sctp_connectx() returns | 1151 | * On success, sctp_connectx() returns 0. It also sets the assoc_id to |
1148 | * -1, and sets errno to the appropriate error code. | 1152 | * the association id of the new association. On failure, sctp_connectx() |
1153 | * returns -1, and sets errno to the appropriate error code. The assoc_id | ||
1154 | * is not touched by the kernel. | ||
1149 | * | 1155 | * |
1150 | * For SCTP, the port given in each socket address must be the same, or | 1156 | * For SCTP, the port given in each socket address must be the same, or |
1151 | * sctp_connectx() will fail, setting errno to EINVAL. | 1157 | * sctp_connectx() will fail, setting errno to EINVAL. |
@@ -1182,11 +1188,12 @@ out_free: | |||
1182 | * addrs The pointer to the addresses in user land | 1188 | * addrs The pointer to the addresses in user land |
1183 | * addrssize Size of the addrs buffer | 1189 | * addrssize Size of the addrs buffer |
1184 | * | 1190 | * |
1185 | * Returns 0 if ok, <0 errno code on error. | 1191 | * Returns >=0 if ok, <0 errno code on error. |
1186 | */ | 1192 | */ |
1187 | SCTP_STATIC int sctp_setsockopt_connectx(struct sock* sk, | 1193 | SCTP_STATIC int __sctp_setsockopt_connectx(struct sock* sk, |
1188 | struct sockaddr __user *addrs, | 1194 | struct sockaddr __user *addrs, |
1189 | int addrs_size) | 1195 | int addrs_size, |
1196 | sctp_assoc_t *assoc_id) | ||
1190 | { | 1197 | { |
1191 | int err = 0; | 1198 | int err = 0; |
1192 | struct sockaddr *kaddrs; | 1199 | struct sockaddr *kaddrs; |
@@ -1209,13 +1216,46 @@ SCTP_STATIC int sctp_setsockopt_connectx(struct sock* sk, | |||
1209 | if (__copy_from_user(kaddrs, addrs, addrs_size)) { | 1216 | if (__copy_from_user(kaddrs, addrs, addrs_size)) { |
1210 | err = -EFAULT; | 1217 | err = -EFAULT; |
1211 | } else { | 1218 | } else { |
1212 | err = __sctp_connect(sk, kaddrs, addrs_size); | 1219 | err = __sctp_connect(sk, kaddrs, addrs_size, assoc_id); |
1213 | } | 1220 | } |
1214 | 1221 | ||
1215 | kfree(kaddrs); | 1222 | kfree(kaddrs); |
1223 | |||
1216 | return err; | 1224 | return err; |
1217 | } | 1225 | } |
1218 | 1226 | ||
1227 | /* | ||
1228 | * This is an older interface. It's kept for backward compatibility | ||
1229 | * to the option that doesn't provide association id. | ||
1230 | */ | ||
1231 | SCTP_STATIC int sctp_setsockopt_connectx_old(struct sock* sk, | ||
1232 | struct sockaddr __user *addrs, | ||
1233 | int addrs_size) | ||
1234 | { | ||
1235 | return __sctp_setsockopt_connectx(sk, addrs, addrs_size, NULL); | ||
1236 | } | ||
1237 | |||
1238 | /* | ||
1239 | * New interface for the API. The since the API is done with a socket | ||
1240 | * option, to make it simple we feed back the association id is as a return | ||
1241 | * indication to the call. Error is always negative and association id is | ||
1242 | * always positive. | ||
1243 | */ | ||
1244 | SCTP_STATIC int sctp_setsockopt_connectx(struct sock* sk, | ||
1245 | struct sockaddr __user *addrs, | ||
1246 | int addrs_size) | ||
1247 | { | ||
1248 | sctp_assoc_t assoc_id = 0; | ||
1249 | int err = 0; | ||
1250 | |||
1251 | err = __sctp_setsockopt_connectx(sk, addrs, addrs_size, &assoc_id); | ||
1252 | |||
1253 | if (err) | ||
1254 | return err; | ||
1255 | else | ||
1256 | return assoc_id; | ||
1257 | } | ||
1258 | |||
1219 | /* API 3.1.4 close() - UDP Style Syntax | 1259 | /* API 3.1.4 close() - UDP Style Syntax |
1220 | * Applications use close() to perform graceful shutdown (as described in | 1260 | * Applications use close() to perform graceful shutdown (as described in |
1221 | * Section 10.1 of [SCTP]) on ALL the associations currently represented | 1261 | * Section 10.1 of [SCTP]) on ALL the associations currently represented |
@@ -2305,74 +2345,98 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, | |||
2305 | return 0; | 2345 | return 0; |
2306 | } | 2346 | } |
2307 | 2347 | ||
2308 | /* 7.1.23. Delayed Ack Timer (SCTP_DELAYED_ACK_TIME) | 2348 | /* |
2309 | * | 2349 | * 7.1.23. Get or set delayed ack timer (SCTP_DELAYED_SACK) |
2310 | * This options will get or set the delayed ack timer. The time is set | 2350 | * |
2311 | * in milliseconds. If the assoc_id is 0, then this sets or gets the | 2351 | * This option will effect the way delayed acks are performed. This |
2312 | * endpoints default delayed ack timer value. If the assoc_id field is | 2352 | * option allows you to get or set the delayed ack time, in |
2313 | * non-zero, then the set or get effects the specified association. | 2353 | * milliseconds. It also allows changing the delayed ack frequency. |
2314 | * | 2354 | * Changing the frequency to 1 disables the delayed sack algorithm. If |
2315 | * struct sctp_assoc_value { | 2355 | * the assoc_id is 0, then this sets or gets the endpoints default |
2316 | * sctp_assoc_t assoc_id; | 2356 | * values. If the assoc_id field is non-zero, then the set or get |
2317 | * uint32_t assoc_value; | 2357 | * effects the specified association for the one to many model (the |
2318 | * }; | 2358 | * assoc_id field is ignored by the one to one model). Note that if |
2359 | * sack_delay or sack_freq are 0 when setting this option, then the | ||
2360 | * current values will remain unchanged. | ||
2361 | * | ||
2362 | * struct sctp_sack_info { | ||
2363 | * sctp_assoc_t sack_assoc_id; | ||
2364 | * uint32_t sack_delay; | ||
2365 | * uint32_t sack_freq; | ||
2366 | * }; | ||
2319 | * | 2367 | * |
2320 | * assoc_id - This parameter, indicates which association the | 2368 | * sack_assoc_id - This parameter, indicates which association the user |
2321 | * user is preforming an action upon. Note that if | 2369 | * is performing an action upon. Note that if this field's value is |
2322 | * this field's value is zero then the endpoints | 2370 | * zero then the endpoints default value is changed (effecting future |
2323 | * default value is changed (effecting future | 2371 | * associations only). |
2324 | * associations only). | ||
2325 | * | 2372 | * |
2326 | * assoc_value - This parameter contains the number of milliseconds | 2373 | * sack_delay - This parameter contains the number of milliseconds that |
2327 | * that the user is requesting the delayed ACK timer | 2374 | * the user is requesting the delayed ACK timer be set to. Note that |
2328 | * be set to. Note that this value is defined in | 2375 | * this value is defined in the standard to be between 200 and 500 |
2329 | * the standard to be between 200 and 500 milliseconds. | 2376 | * milliseconds. |
2330 | * | 2377 | * |
2331 | * Note: a value of zero will leave the value alone, | 2378 | * sack_freq - This parameter contains the number of packets that must |
2332 | * but disable SACK delay. A non-zero value will also | 2379 | * be received before a sack is sent without waiting for the delay |
2333 | * enable SACK delay. | 2380 | * timer to expire. The default value for this is 2, setting this |
2381 | * value to 1 will disable the delayed sack algorithm. | ||
2334 | */ | 2382 | */ |
2335 | 2383 | ||
2336 | static int sctp_setsockopt_delayed_ack_time(struct sock *sk, | 2384 | static int sctp_setsockopt_delayed_ack(struct sock *sk, |
2337 | char __user *optval, int optlen) | 2385 | char __user *optval, int optlen) |
2338 | { | 2386 | { |
2339 | struct sctp_assoc_value params; | 2387 | struct sctp_sack_info params; |
2340 | struct sctp_transport *trans = NULL; | 2388 | struct sctp_transport *trans = NULL; |
2341 | struct sctp_association *asoc = NULL; | 2389 | struct sctp_association *asoc = NULL; |
2342 | struct sctp_sock *sp = sctp_sk(sk); | 2390 | struct sctp_sock *sp = sctp_sk(sk); |
2343 | 2391 | ||
2344 | if (optlen != sizeof(struct sctp_assoc_value)) | 2392 | if (optlen == sizeof(struct sctp_sack_info)) { |
2345 | return - EINVAL; | 2393 | if (copy_from_user(¶ms, optval, optlen)) |
2394 | return -EFAULT; | ||
2346 | 2395 | ||
2347 | if (copy_from_user(¶ms, optval, optlen)) | 2396 | if (params.sack_delay == 0 && params.sack_freq == 0) |
2348 | return -EFAULT; | 2397 | return 0; |
2398 | } else if (optlen == sizeof(struct sctp_assoc_value)) { | ||
2399 | printk(KERN_WARNING "SCTP: Use of struct sctp_sack_info " | ||
2400 | "in delayed_ack socket option deprecated\n"); | ||
2401 | printk(KERN_WARNING "SCTP: struct sctp_sack_info instead\n"); | ||
2402 | if (copy_from_user(¶ms, optval, optlen)) | ||
2403 | return -EFAULT; | ||
2404 | |||
2405 | if (params.sack_delay == 0) | ||
2406 | params.sack_freq = 1; | ||
2407 | else | ||
2408 | params.sack_freq = 0; | ||
2409 | } else | ||
2410 | return - EINVAL; | ||
2349 | 2411 | ||
2350 | /* Validate value parameter. */ | 2412 | /* Validate value parameter. */ |
2351 | if (params.assoc_value > 500) | 2413 | if (params.sack_delay > 500) |
2352 | return -EINVAL; | 2414 | return -EINVAL; |
2353 | 2415 | ||
2354 | /* Get association, if assoc_id != 0 and the socket is a one | 2416 | /* Get association, if sack_assoc_id != 0 and the socket is a one |
2355 | * to many style socket, and an association was not found, then | 2417 | * to many style socket, and an association was not found, then |
2356 | * the id was invalid. | 2418 | * the id was invalid. |
2357 | */ | 2419 | */ |
2358 | asoc = sctp_id2assoc(sk, params.assoc_id); | 2420 | asoc = sctp_id2assoc(sk, params.sack_assoc_id); |
2359 | if (!asoc && params.assoc_id && sctp_style(sk, UDP)) | 2421 | if (!asoc && params.sack_assoc_id && sctp_style(sk, UDP)) |
2360 | return -EINVAL; | 2422 | return -EINVAL; |
2361 | 2423 | ||
2362 | if (params.assoc_value) { | 2424 | if (params.sack_delay) { |
2363 | if (asoc) { | 2425 | if (asoc) { |
2364 | asoc->sackdelay = | 2426 | asoc->sackdelay = |
2365 | msecs_to_jiffies(params.assoc_value); | 2427 | msecs_to_jiffies(params.sack_delay); |
2366 | asoc->param_flags = | 2428 | asoc->param_flags = |
2367 | (asoc->param_flags & ~SPP_SACKDELAY) | | 2429 | (asoc->param_flags & ~SPP_SACKDELAY) | |
2368 | SPP_SACKDELAY_ENABLE; | 2430 | SPP_SACKDELAY_ENABLE; |
2369 | } else { | 2431 | } else { |
2370 | sp->sackdelay = params.assoc_value; | 2432 | sp->sackdelay = params.sack_delay; |
2371 | sp->param_flags = | 2433 | sp->param_flags = |
2372 | (sp->param_flags & ~SPP_SACKDELAY) | | 2434 | (sp->param_flags & ~SPP_SACKDELAY) | |
2373 | SPP_SACKDELAY_ENABLE; | 2435 | SPP_SACKDELAY_ENABLE; |
2374 | } | 2436 | } |
2375 | } else { | 2437 | } |
2438 | |||
2439 | if (params.sack_freq == 1) { | ||
2376 | if (asoc) { | 2440 | if (asoc) { |
2377 | asoc->param_flags = | 2441 | asoc->param_flags = |
2378 | (asoc->param_flags & ~SPP_SACKDELAY) | | 2442 | (asoc->param_flags & ~SPP_SACKDELAY) | |
@@ -2382,22 +2446,40 @@ static int sctp_setsockopt_delayed_ack_time(struct sock *sk, | |||
2382 | (sp->param_flags & ~SPP_SACKDELAY) | | 2446 | (sp->param_flags & ~SPP_SACKDELAY) | |
2383 | SPP_SACKDELAY_DISABLE; | 2447 | SPP_SACKDELAY_DISABLE; |
2384 | } | 2448 | } |
2449 | } else if (params.sack_freq > 1) { | ||
2450 | if (asoc) { | ||
2451 | asoc->sackfreq = params.sack_freq; | ||
2452 | asoc->param_flags = | ||
2453 | (asoc->param_flags & ~SPP_SACKDELAY) | | ||
2454 | SPP_SACKDELAY_ENABLE; | ||
2455 | } else { | ||
2456 | sp->sackfreq = params.sack_freq; | ||
2457 | sp->param_flags = | ||
2458 | (sp->param_flags & ~SPP_SACKDELAY) | | ||
2459 | SPP_SACKDELAY_ENABLE; | ||
2460 | } | ||
2385 | } | 2461 | } |
2386 | 2462 | ||
2387 | /* If change is for association, also apply to each transport. */ | 2463 | /* If change is for association, also apply to each transport. */ |
2388 | if (asoc) { | 2464 | if (asoc) { |
2389 | list_for_each_entry(trans, &asoc->peer.transport_addr_list, | 2465 | list_for_each_entry(trans, &asoc->peer.transport_addr_list, |
2390 | transports) { | 2466 | transports) { |
2391 | if (params.assoc_value) { | 2467 | if (params.sack_delay) { |
2392 | trans->sackdelay = | 2468 | trans->sackdelay = |
2393 | msecs_to_jiffies(params.assoc_value); | 2469 | msecs_to_jiffies(params.sack_delay); |
2394 | trans->param_flags = | 2470 | trans->param_flags = |
2395 | (trans->param_flags & ~SPP_SACKDELAY) | | 2471 | (trans->param_flags & ~SPP_SACKDELAY) | |
2396 | SPP_SACKDELAY_ENABLE; | 2472 | SPP_SACKDELAY_ENABLE; |
2397 | } else { | 2473 | } |
2474 | if (params.sack_freq == 1) { | ||
2398 | trans->param_flags = | 2475 | trans->param_flags = |
2399 | (trans->param_flags & ~SPP_SACKDELAY) | | 2476 | (trans->param_flags & ~SPP_SACKDELAY) | |
2400 | SPP_SACKDELAY_DISABLE; | 2477 | SPP_SACKDELAY_DISABLE; |
2478 | } else if (params.sack_freq > 1) { | ||
2479 | trans->sackfreq = params.sack_freq; | ||
2480 | trans->param_flags = | ||
2481 | (trans->param_flags & ~SPP_SACKDELAY) | | ||
2482 | SPP_SACKDELAY_ENABLE; | ||
2401 | } | 2483 | } |
2402 | } | 2484 | } |
2403 | } | 2485 | } |
@@ -3164,10 +3246,18 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname, | |||
3164 | optlen, SCTP_BINDX_REM_ADDR); | 3246 | optlen, SCTP_BINDX_REM_ADDR); |
3165 | break; | 3247 | break; |
3166 | 3248 | ||
3249 | case SCTP_SOCKOPT_CONNECTX_OLD: | ||
3250 | /* 'optlen' is the size of the addresses buffer. */ | ||
3251 | retval = sctp_setsockopt_connectx_old(sk, | ||
3252 | (struct sockaddr __user *)optval, | ||
3253 | optlen); | ||
3254 | break; | ||
3255 | |||
3167 | case SCTP_SOCKOPT_CONNECTX: | 3256 | case SCTP_SOCKOPT_CONNECTX: |
3168 | /* 'optlen' is the size of the addresses buffer. */ | 3257 | /* 'optlen' is the size of the addresses buffer. */ |
3169 | retval = sctp_setsockopt_connectx(sk, (struct sockaddr __user *)optval, | 3258 | retval = sctp_setsockopt_connectx(sk, |
3170 | optlen); | 3259 | (struct sockaddr __user *)optval, |
3260 | optlen); | ||
3171 | break; | 3261 | break; |
3172 | 3262 | ||
3173 | case SCTP_DISABLE_FRAGMENTS: | 3263 | case SCTP_DISABLE_FRAGMENTS: |
@@ -3186,8 +3276,8 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname, | |||
3186 | retval = sctp_setsockopt_peer_addr_params(sk, optval, optlen); | 3276 | retval = sctp_setsockopt_peer_addr_params(sk, optval, optlen); |
3187 | break; | 3277 | break; |
3188 | 3278 | ||
3189 | case SCTP_DELAYED_ACK_TIME: | 3279 | case SCTP_DELAYED_ACK: |
3190 | retval = sctp_setsockopt_delayed_ack_time(sk, optval, optlen); | 3280 | retval = sctp_setsockopt_delayed_ack(sk, optval, optlen); |
3191 | break; | 3281 | break; |
3192 | case SCTP_PARTIAL_DELIVERY_POINT: | 3282 | case SCTP_PARTIAL_DELIVERY_POINT: |
3193 | retval = sctp_setsockopt_partial_delivery_point(sk, optval, optlen); | 3283 | retval = sctp_setsockopt_partial_delivery_point(sk, optval, optlen); |
@@ -3294,7 +3384,7 @@ SCTP_STATIC int sctp_connect(struct sock *sk, struct sockaddr *addr, | |||
3294 | /* Pass correct addr len to common routine (so it knows there | 3384 | /* Pass correct addr len to common routine (so it knows there |
3295 | * is only one address being passed. | 3385 | * is only one address being passed. |
3296 | */ | 3386 | */ |
3297 | err = __sctp_connect(sk, addr, af->sockaddr_len); | 3387 | err = __sctp_connect(sk, addr, af->sockaddr_len, NULL); |
3298 | } | 3388 | } |
3299 | 3389 | ||
3300 | sctp_release_sock(sk); | 3390 | sctp_release_sock(sk); |
@@ -3446,6 +3536,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3446 | sp->pathmaxrxt = sctp_max_retrans_path; | 3536 | sp->pathmaxrxt = sctp_max_retrans_path; |
3447 | sp->pathmtu = 0; // allow default discovery | 3537 | sp->pathmtu = 0; // allow default discovery |
3448 | sp->sackdelay = sctp_sack_timeout; | 3538 | sp->sackdelay = sctp_sack_timeout; |
3539 | sp->sackfreq = 2; | ||
3449 | sp->param_flags = SPP_HB_ENABLE | | 3540 | sp->param_flags = SPP_HB_ENABLE | |
3450 | SPP_PMTUD_ENABLE | | 3541 | SPP_PMTUD_ENABLE | |
3451 | SPP_SACKDELAY_ENABLE; | 3542 | SPP_SACKDELAY_ENABLE; |
@@ -3497,7 +3588,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3497 | } | 3588 | } |
3498 | 3589 | ||
3499 | /* Cleanup any SCTP per socket resources. */ | 3590 | /* Cleanup any SCTP per socket resources. */ |
3500 | SCTP_STATIC int sctp_destroy_sock(struct sock *sk) | 3591 | SCTP_STATIC void sctp_destroy_sock(struct sock *sk) |
3501 | { | 3592 | { |
3502 | struct sctp_endpoint *ep; | 3593 | struct sctp_endpoint *ep; |
3503 | 3594 | ||
@@ -3507,7 +3598,6 @@ SCTP_STATIC int sctp_destroy_sock(struct sock *sk) | |||
3507 | ep = sctp_sk(sk)->ep; | 3598 | ep = sctp_sk(sk)->ep; |
3508 | sctp_endpoint_free(ep); | 3599 | sctp_endpoint_free(ep); |
3509 | atomic_dec(&sctp_sockets_allocated); | 3600 | atomic_dec(&sctp_sockets_allocated); |
3510 | return 0; | ||
3511 | } | 3601 | } |
3512 | 3602 | ||
3513 | /* API 4.1.7 shutdown() - TCP Style Syntax | 3603 | /* API 4.1.7 shutdown() - TCP Style Syntax |
@@ -3999,70 +4089,91 @@ static int sctp_getsockopt_peer_addr_params(struct sock *sk, int len, | |||
3999 | return 0; | 4089 | return 0; |
4000 | } | 4090 | } |
4001 | 4091 | ||
4002 | /* 7.1.23. Delayed Ack Timer (SCTP_DELAYED_ACK_TIME) | 4092 | /* |
4003 | * | 4093 | * 7.1.23. Get or set delayed ack timer (SCTP_DELAYED_SACK) |
4004 | * This options will get or set the delayed ack timer. The time is set | 4094 | * |
4005 | * in milliseconds. If the assoc_id is 0, then this sets or gets the | 4095 | * This option will effect the way delayed acks are performed. This |
4006 | * endpoints default delayed ack timer value. If the assoc_id field is | 4096 | * option allows you to get or set the delayed ack time, in |
4007 | * non-zero, then the set or get effects the specified association. | 4097 | * milliseconds. It also allows changing the delayed ack frequency. |
4008 | * | 4098 | * Changing the frequency to 1 disables the delayed sack algorithm. If |
4009 | * struct sctp_assoc_value { | 4099 | * the assoc_id is 0, then this sets or gets the endpoints default |
4010 | * sctp_assoc_t assoc_id; | 4100 | * values. If the assoc_id field is non-zero, then the set or get |
4011 | * uint32_t assoc_value; | 4101 | * effects the specified association for the one to many model (the |
4012 | * }; | 4102 | * assoc_id field is ignored by the one to one model). Note that if |
4103 | * sack_delay or sack_freq are 0 when setting this option, then the | ||
4104 | * current values will remain unchanged. | ||
4105 | * | ||
4106 | * struct sctp_sack_info { | ||
4107 | * sctp_assoc_t sack_assoc_id; | ||
4108 | * uint32_t sack_delay; | ||
4109 | * uint32_t sack_freq; | ||
4110 | * }; | ||
4013 | * | 4111 | * |
4014 | * assoc_id - This parameter, indicates which association the | 4112 | * sack_assoc_id - This parameter, indicates which association the user |
4015 | * user is preforming an action upon. Note that if | 4113 | * is performing an action upon. Note that if this field's value is |
4016 | * this field's value is zero then the endpoints | 4114 | * zero then the endpoints default value is changed (effecting future |
4017 | * default value is changed (effecting future | 4115 | * associations only). |
4018 | * associations only). | ||
4019 | * | 4116 | * |
4020 | * assoc_value - This parameter contains the number of milliseconds | 4117 | * sack_delay - This parameter contains the number of milliseconds that |
4021 | * that the user is requesting the delayed ACK timer | 4118 | * the user is requesting the delayed ACK timer be set to. Note that |
4022 | * be set to. Note that this value is defined in | 4119 | * this value is defined in the standard to be between 200 and 500 |
4023 | * the standard to be between 200 and 500 milliseconds. | 4120 | * milliseconds. |
4024 | * | 4121 | * |
4025 | * Note: a value of zero will leave the value alone, | 4122 | * sack_freq - This parameter contains the number of packets that must |
4026 | * but disable SACK delay. A non-zero value will also | 4123 | * be received before a sack is sent without waiting for the delay |
4027 | * enable SACK delay. | 4124 | * timer to expire. The default value for this is 2, setting this |
4125 | * value to 1 will disable the delayed sack algorithm. | ||
4028 | */ | 4126 | */ |
4029 | static int sctp_getsockopt_delayed_ack_time(struct sock *sk, int len, | 4127 | static int sctp_getsockopt_delayed_ack(struct sock *sk, int len, |
4030 | char __user *optval, | 4128 | char __user *optval, |
4031 | int __user *optlen) | 4129 | int __user *optlen) |
4032 | { | 4130 | { |
4033 | struct sctp_assoc_value params; | 4131 | struct sctp_sack_info params; |
4034 | struct sctp_association *asoc = NULL; | 4132 | struct sctp_association *asoc = NULL; |
4035 | struct sctp_sock *sp = sctp_sk(sk); | 4133 | struct sctp_sock *sp = sctp_sk(sk); |
4036 | 4134 | ||
4037 | if (len < sizeof(struct sctp_assoc_value)) | 4135 | if (len >= sizeof(struct sctp_sack_info)) { |
4038 | return - EINVAL; | 4136 | len = sizeof(struct sctp_sack_info); |
4039 | |||
4040 | len = sizeof(struct sctp_assoc_value); | ||
4041 | 4137 | ||
4042 | if (copy_from_user(¶ms, optval, len)) | 4138 | if (copy_from_user(¶ms, optval, len)) |
4043 | return -EFAULT; | 4139 | return -EFAULT; |
4140 | } else if (len == sizeof(struct sctp_assoc_value)) { | ||
4141 | printk(KERN_WARNING "SCTP: Use of struct sctp_sack_info " | ||
4142 | "in delayed_ack socket option deprecated\n"); | ||
4143 | printk(KERN_WARNING "SCTP: struct sctp_sack_info instead\n"); | ||
4144 | if (copy_from_user(¶ms, optval, len)) | ||
4145 | return -EFAULT; | ||
4146 | } else | ||
4147 | return - EINVAL; | ||
4044 | 4148 | ||
4045 | /* Get association, if assoc_id != 0 and the socket is a one | 4149 | /* Get association, if sack_assoc_id != 0 and the socket is a one |
4046 | * to many style socket, and an association was not found, then | 4150 | * to many style socket, and an association was not found, then |
4047 | * the id was invalid. | 4151 | * the id was invalid. |
4048 | */ | 4152 | */ |
4049 | asoc = sctp_id2assoc(sk, params.assoc_id); | 4153 | asoc = sctp_id2assoc(sk, params.sack_assoc_id); |
4050 | if (!asoc && params.assoc_id && sctp_style(sk, UDP)) | 4154 | if (!asoc && params.sack_assoc_id && sctp_style(sk, UDP)) |
4051 | return -EINVAL; | 4155 | return -EINVAL; |
4052 | 4156 | ||
4053 | if (asoc) { | 4157 | if (asoc) { |
4054 | /* Fetch association values. */ | 4158 | /* Fetch association values. */ |
4055 | if (asoc->param_flags & SPP_SACKDELAY_ENABLE) | 4159 | if (asoc->param_flags & SPP_SACKDELAY_ENABLE) { |
4056 | params.assoc_value = jiffies_to_msecs( | 4160 | params.sack_delay = jiffies_to_msecs( |
4057 | asoc->sackdelay); | 4161 | asoc->sackdelay); |
4058 | else | 4162 | params.sack_freq = asoc->sackfreq; |
4059 | params.assoc_value = 0; | 4163 | |
4164 | } else { | ||
4165 | params.sack_delay = 0; | ||
4166 | params.sack_freq = 1; | ||
4167 | } | ||
4060 | } else { | 4168 | } else { |
4061 | /* Fetch socket values. */ | 4169 | /* Fetch socket values. */ |
4062 | if (sp->param_flags & SPP_SACKDELAY_ENABLE) | 4170 | if (sp->param_flags & SPP_SACKDELAY_ENABLE) { |
4063 | params.assoc_value = sp->sackdelay; | 4171 | params.sack_delay = sp->sackdelay; |
4064 | else | 4172 | params.sack_freq = sp->sackfreq; |
4065 | params.assoc_value = 0; | 4173 | } else { |
4174 | params.sack_delay = 0; | ||
4175 | params.sack_freq = 1; | ||
4176 | } | ||
4066 | } | 4177 | } |
4067 | 4178 | ||
4068 | if (copy_to_user(optval, ¶ms, len)) | 4179 | if (copy_to_user(optval, ¶ms, len)) |
@@ -4112,6 +4223,8 @@ static int sctp_getsockopt_peer_addrs_num_old(struct sock *sk, int len, | |||
4112 | if (copy_from_user(&id, optval, sizeof(sctp_assoc_t))) | 4223 | if (copy_from_user(&id, optval, sizeof(sctp_assoc_t))) |
4113 | return -EFAULT; | 4224 | return -EFAULT; |
4114 | 4225 | ||
4226 | printk(KERN_WARNING "SCTP: Use of SCTP_GET_PEER_ADDRS_NUM_OLD " | ||
4227 | "socket option deprecated\n"); | ||
4115 | /* For UDP-style sockets, id specifies the association to query. */ | 4228 | /* For UDP-style sockets, id specifies the association to query. */ |
4116 | asoc = sctp_id2assoc(sk, id); | 4229 | asoc = sctp_id2assoc(sk, id); |
4117 | if (!asoc) | 4230 | if (!asoc) |
@@ -4151,6 +4264,9 @@ static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len, | |||
4151 | 4264 | ||
4152 | if (getaddrs.addr_num <= 0) return -EINVAL; | 4265 | if (getaddrs.addr_num <= 0) return -EINVAL; |
4153 | 4266 | ||
4267 | printk(KERN_WARNING "SCTP: Use of SCTP_GET_PEER_ADDRS_OLD " | ||
4268 | "socket option deprecated\n"); | ||
4269 | |||
4154 | /* For UDP-style sockets, id specifies the association to query. */ | 4270 | /* For UDP-style sockets, id specifies the association to query. */ |
4155 | asoc = sctp_id2assoc(sk, getaddrs.assoc_id); | 4271 | asoc = sctp_id2assoc(sk, getaddrs.assoc_id); |
4156 | if (!asoc) | 4272 | if (!asoc) |
@@ -4244,6 +4360,9 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len, | |||
4244 | if (copy_from_user(&id, optval, sizeof(sctp_assoc_t))) | 4360 | if (copy_from_user(&id, optval, sizeof(sctp_assoc_t))) |
4245 | return -EFAULT; | 4361 | return -EFAULT; |
4246 | 4362 | ||
4363 | printk(KERN_WARNING "SCTP: Use of SCTP_GET_LOCAL_ADDRS_NUM_OLD " | ||
4364 | "socket option deprecated\n"); | ||
4365 | |||
4247 | /* | 4366 | /* |
4248 | * For UDP-style sockets, id specifies the association to query. | 4367 | * For UDP-style sockets, id specifies the association to query. |
4249 | * If the id field is set to the value '0' then the locally bound | 4368 | * If the id field is set to the value '0' then the locally bound |
@@ -4404,6 +4523,10 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len, | |||
4404 | if (getaddrs.addr_num <= 0 || | 4523 | if (getaddrs.addr_num <= 0 || |
4405 | getaddrs.addr_num >= (INT_MAX / sizeof(union sctp_addr))) | 4524 | getaddrs.addr_num >= (INT_MAX / sizeof(union sctp_addr))) |
4406 | return -EINVAL; | 4525 | return -EINVAL; |
4526 | |||
4527 | printk(KERN_WARNING "SCTP: Use of SCTP_GET_LOCAL_ADDRS_OLD " | ||
4528 | "socket option deprecated\n"); | ||
4529 | |||
4407 | /* | 4530 | /* |
4408 | * For UDP-style sockets, id specifies the association to query. | 4531 | * For UDP-style sockets, id specifies the association to query. |
4409 | * If the id field is set to the value '0' then the locally bound | 4532 | * If the id field is set to the value '0' then the locally bound |
@@ -5220,8 +5343,8 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, | |||
5220 | retval = sctp_getsockopt_peer_addr_params(sk, len, optval, | 5343 | retval = sctp_getsockopt_peer_addr_params(sk, len, optval, |
5221 | optlen); | 5344 | optlen); |
5222 | break; | 5345 | break; |
5223 | case SCTP_DELAYED_ACK_TIME: | 5346 | case SCTP_DELAYED_ACK: |
5224 | retval = sctp_getsockopt_delayed_ack_time(sk, len, optval, | 5347 | retval = sctp_getsockopt_delayed_ack(sk, len, optval, |
5225 | optlen); | 5348 | optlen); |
5226 | break; | 5349 | break; |
5227 | case SCTP_INITMSG: | 5350 | case SCTP_INITMSG: |