diff options
Diffstat (limited to 'net/sctp/sm_make_chunk.c')
-rw-r--r-- | net/sctp/sm_make_chunk.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index fd8acb48c3f2..6851ee94e974 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -100,11 +100,11 @@ int sctp_chunk_iif(const struct sctp_chunk *chunk) | |||
100 | */ | 100 | */ |
101 | static const struct sctp_paramhdr ecap_param = { | 101 | static const struct sctp_paramhdr ecap_param = { |
102 | SCTP_PARAM_ECN_CAPABLE, | 102 | SCTP_PARAM_ECN_CAPABLE, |
103 | __constant_htons(sizeof(struct sctp_paramhdr)), | 103 | cpu_to_be16(sizeof(struct sctp_paramhdr)), |
104 | }; | 104 | }; |
105 | static const struct sctp_paramhdr prsctp_param = { | 105 | static const struct sctp_paramhdr prsctp_param = { |
106 | SCTP_PARAM_FWD_TSN_SUPPORT, | 106 | SCTP_PARAM_FWD_TSN_SUPPORT, |
107 | __constant_htons(sizeof(struct sctp_paramhdr)), | 107 | cpu_to_be16(sizeof(struct sctp_paramhdr)), |
108 | }; | 108 | }; |
109 | 109 | ||
110 | /* A helper to initialize to initialize an op error inside a | 110 | /* A helper to initialize to initialize an op error inside a |
@@ -224,7 +224,9 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
224 | num_ext += 2; | 224 | num_ext += 2; |
225 | } | 225 | } |
226 | 226 | ||
227 | chunksize += sizeof(aiparam); | 227 | if (sp->adaptation_ind) |
228 | chunksize += sizeof(aiparam); | ||
229 | |||
228 | chunksize += vparam_len; | 230 | chunksize += vparam_len; |
229 | 231 | ||
230 | /* Account for AUTH related parameters */ | 232 | /* Account for AUTH related parameters */ |
@@ -304,10 +306,12 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
304 | if (sctp_prsctp_enable) | 306 | if (sctp_prsctp_enable) |
305 | sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); | 307 | sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); |
306 | 308 | ||
307 | aiparam.param_hdr.type = SCTP_PARAM_ADAPTATION_LAYER_IND; | 309 | if (sp->adaptation_ind) { |
308 | aiparam.param_hdr.length = htons(sizeof(aiparam)); | 310 | aiparam.param_hdr.type = SCTP_PARAM_ADAPTATION_LAYER_IND; |
309 | aiparam.adaptation_ind = htonl(sp->adaptation_ind); | 311 | aiparam.param_hdr.length = htons(sizeof(aiparam)); |
310 | sctp_addto_chunk(retval, sizeof(aiparam), &aiparam); | 312 | aiparam.adaptation_ind = htonl(sp->adaptation_ind); |
313 | sctp_addto_chunk(retval, sizeof(aiparam), &aiparam); | ||
314 | } | ||
311 | 315 | ||
312 | /* Add SCTP-AUTH chunks to the parameter list */ | 316 | /* Add SCTP-AUTH chunks to the parameter list */ |
313 | if (sctp_auth_enable) { | 317 | if (sctp_auth_enable) { |
@@ -332,6 +336,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, | |||
332 | sctp_inithdr_t initack; | 336 | sctp_inithdr_t initack; |
333 | struct sctp_chunk *retval; | 337 | struct sctp_chunk *retval; |
334 | union sctp_params addrs; | 338 | union sctp_params addrs; |
339 | struct sctp_sock *sp; | ||
335 | int addrs_len; | 340 | int addrs_len; |
336 | sctp_cookie_param_t *cookie; | 341 | sctp_cookie_param_t *cookie; |
337 | int cookie_len; | 342 | int cookie_len; |
@@ -366,22 +371,24 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, | |||
366 | /* Calculate the total size of allocation, include the reserved | 371 | /* Calculate the total size of allocation, include the reserved |
367 | * space for reporting unknown parameters if it is specified. | 372 | * space for reporting unknown parameters if it is specified. |
368 | */ | 373 | */ |
374 | sp = sctp_sk(asoc->base.sk); | ||
369 | chunksize = sizeof(initack) + addrs_len + cookie_len + unkparam_len; | 375 | chunksize = sizeof(initack) + addrs_len + cookie_len + unkparam_len; |
370 | 376 | ||
371 | /* Tell peer that we'll do ECN only if peer advertised such cap. */ | 377 | /* Tell peer that we'll do ECN only if peer advertised such cap. */ |
372 | if (asoc->peer.ecn_capable) | 378 | if (asoc->peer.ecn_capable) |
373 | chunksize += sizeof(ecap_param); | 379 | chunksize += sizeof(ecap_param); |
374 | 380 | ||
375 | if (sctp_prsctp_enable) | 381 | if (asoc->peer.prsctp_capable) |
376 | chunksize += sizeof(prsctp_param); | 382 | chunksize += sizeof(prsctp_param); |
377 | 383 | ||
378 | if (sctp_addip_enable) { | 384 | if (asoc->peer.asconf_capable) { |
379 | extensions[num_ext] = SCTP_CID_ASCONF; | 385 | extensions[num_ext] = SCTP_CID_ASCONF; |
380 | extensions[num_ext+1] = SCTP_CID_ASCONF_ACK; | 386 | extensions[num_ext+1] = SCTP_CID_ASCONF_ACK; |
381 | num_ext += 2; | 387 | num_ext += 2; |
382 | } | 388 | } |
383 | 389 | ||
384 | chunksize += sizeof(aiparam); | 390 | if (sp->adaptation_ind) |
391 | chunksize += sizeof(aiparam); | ||
385 | 392 | ||
386 | if (asoc->peer.auth_capable) { | 393 | if (asoc->peer.auth_capable) { |
387 | auth_random = (sctp_paramhdr_t *)asoc->c.auth_random; | 394 | auth_random = (sctp_paramhdr_t *)asoc->c.auth_random; |
@@ -432,10 +439,12 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, | |||
432 | if (asoc->peer.prsctp_capable) | 439 | if (asoc->peer.prsctp_capable) |
433 | sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); | 440 | sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); |
434 | 441 | ||
435 | aiparam.param_hdr.type = SCTP_PARAM_ADAPTATION_LAYER_IND; | 442 | if (sp->adaptation_ind) { |
436 | aiparam.param_hdr.length = htons(sizeof(aiparam)); | 443 | aiparam.param_hdr.type = SCTP_PARAM_ADAPTATION_LAYER_IND; |
437 | aiparam.adaptation_ind = htonl(sctp_sk(asoc->base.sk)->adaptation_ind); | 444 | aiparam.param_hdr.length = htons(sizeof(aiparam)); |
438 | sctp_addto_chunk(retval, sizeof(aiparam), &aiparam); | 445 | aiparam.adaptation_ind = htonl(sp->adaptation_ind); |
446 | sctp_addto_chunk(retval, sizeof(aiparam), &aiparam); | ||
447 | } | ||
439 | 448 | ||
440 | if (asoc->peer.auth_capable) { | 449 | if (asoc->peer.auth_capable) { |
441 | sctp_addto_chunk(retval, ntohs(auth_random->length), | 450 | sctp_addto_chunk(retval, ntohs(auth_random->length), |