Send the adaptation layer indication only if set by the user.

MFC after: 3 days
Discussed with: rrs
This commit is contained in:
Michael Tuexen 2013-02-11 21:02:49 +00:00
parent 485b3300cc
commit 2416af26a0
4 changed files with 26 additions and 19 deletions

View File

@ -4643,19 +4643,19 @@ sctp_send_initiate(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int so_locked
chunk_len += parameter_len;
}
/* Adaptation layer indication parameter */
/* XXX: Should we include this always? */
if (padding_len > 0) {
memset(mtod(m, caddr_t)+chunk_len, 0, padding_len);
chunk_len += padding_len;
padding_len = 0;
if (inp->sctp_ep.adaptation_layer_indicator_provided) {
if (padding_len > 0) {
memset(mtod(m, caddr_t)+chunk_len, 0, padding_len);
chunk_len += padding_len;
padding_len = 0;
}
parameter_len = (uint16_t) sizeof(struct sctp_adaptation_layer_indication);
ali = (struct sctp_adaptation_layer_indication *)(mtod(m, caddr_t)+chunk_len);
ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
ali->ph.param_length = htons(parameter_len);
ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator);
chunk_len += parameter_len;
}
parameter_len = (uint16_t) sizeof(struct sctp_adaptation_layer_indication);
ali = (struct sctp_adaptation_layer_indication *)(mtod(m, caddr_t)+chunk_len);
ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
ali->ph.param_length = htons(parameter_len);
ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator);
chunk_len += parameter_len;
if (SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly)) {
/* Add NAT friendly parameter. */
if (padding_len > 0) {
@ -5723,12 +5723,16 @@ sctp_send_initiate_ack(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
htons(inp->sctp_ep.max_open_streams_intome);
/* adaptation layer indication parameter */
ali = (struct sctp_adaptation_layer_indication *)((caddr_t)initack + sizeof(*initack));
ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
ali->ph.param_length = htons(sizeof(*ali));
ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator);
SCTP_BUF_LEN(m) += sizeof(*ali);
ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali + sizeof(*ali));
if (inp->sctp_ep.adaptation_layer_indicator_provided) {
ali = (struct sctp_adaptation_layer_indication *)((caddr_t)initack + sizeof(*initack));
ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
ali->ph.param_length = htons(sizeof(*ali));
ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator);
SCTP_BUF_LEN(m) += sizeof(*ali);
ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali + sizeof(*ali));
} else {
ecn = (struct sctp_ecn_supported_param *)((caddr_t)initack + sizeof(*initack));
}
/* ECN parameter */
if (((asoc != NULL) && (asoc->ecn_allowed == 1)) ||

View File

@ -2516,7 +2516,8 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
m->pre_open_stream_count = SCTP_BASE_SYSCTL(sctp_nr_outgoing_streams_default);
/* Add adaptation cookie */
m->adaptation_layer_indicator = 0x504C5253;
m->adaptation_layer_indicator = 0;
m->adaptation_layer_indicator_provided = 0;
/* seed random number generator */
m->random_counter = 1;

View File

@ -323,6 +323,7 @@ struct sctp_pcb {
int auto_close_time;
uint32_t initial_sequence_debug;
uint32_t adaptation_layer_indicator;
uint8_t adaptation_layer_indicator_provided;
uint32_t store_at;
uint32_t max_burst;
uint32_t fr_max_burst;

View File

@ -4617,6 +4617,7 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize,
SCTP_CHECK_AND_CAST(adap_bits, optval, struct sctp_setadaptation, optsize);
SCTP_INP_WLOCK(inp);
inp->sctp_ep.adaptation_layer_indicator = adap_bits->ssb_adaptation_ind;
inp->sctp_ep.adaptation_layer_indicator_provided = 1;
SCTP_INP_WUNLOCK(inp);
break;
}