diff options
author | malc <mlashley@gmail.com> | 2009-03-12 05:49:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-03-13 14:37:58 -0400 |
commit | 6fc791ee631728b2beddda87560f1af59e32230e (patch) | |
tree | c6fa5596160e0a3c5d03d822de165a800d3dbe35 /net/sctp/sm_make_chunk.c | |
parent | 76595024ffab3599bd28ea014f6c23c1a8c8dd2c (diff) |
sctp: add Adaptation Layer Indication parameter only when it's set
RFC5061 states:
Each adaptation layer that is defined that wishes
to use this parameter MUST specify an adaptation code point in an
appropriate RFC defining its use and meaning.
If the user has not set one - assume they don't want to sent the param
with a zero Adaptation Code Point.
Rationale - Currently the IANA defines zero as reserved - and
1 as the only valid value - so we consider zero to be unset - to save
adding a boolean to the socket structure.
Including this parameter unconditionally causes endpoints that do not
understand it to report errors unnecessarily.
Signed-off-by: Malcolm Lashley <mlashley@gmail.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/sm_make_chunk.c')
-rw-r--r-- | net/sctp/sm_make_chunk.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 9484f33730f6..6851ee94e974 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -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,6 +371,7 @@ 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. */ |
@@ -381,7 +387,8 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, | |||
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), |