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

sctp: make ecn flag per netns and endpoint

This patch is to add ecn flag for both netns_sctp and sctp_endpoint,
net->sctp.ecn_enable is set 1 by default, and ep->ecn_enable will
be initialized with net->sctp.ecn_enable.

asoc->peer.ecn_capable will be set during negotiation only when
ep->ecn_enable is set on both sides.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xin Long and committed by
David S. Miller
1b0b8114 7add83d9

+21 -5
+3
include/net/netns/sctp.h
··· 128 128 /* Flag to indicate if stream interleave is enabled */ 129 129 int intl_enable; 130 130 131 + /* Flag to indicate if ecn is enabled */ 132 + int ecn_enable; 133 + 131 134 /* 132 135 * Policy to control SCTP IPv4 address scoping 133 136 * 0 - Disable IPv4 address scoping
+2 -1
include/net/sctp/structs.h
··· 1322 1322 /* SCTP-AUTH: endpoint shared keys */ 1323 1323 struct list_head endpoint_shared_keys; 1324 1324 __u16 active_key_id; 1325 - __u8 auth_enable:1, 1325 + __u8 ecn_enable:1, 1326 + auth_enable:1, 1326 1327 intl_enable:1, 1327 1328 prsctp_enable:1, 1328 1329 asconf_enable:1,
+1
net/sctp/endpointola.c
··· 106 106 */ 107 107 ep->prsctp_enable = net->sctp.prsctp_enable; 108 108 ep->reconf_enable = net->sctp.reconf_enable; 109 + ep->ecn_enable = net->sctp.ecn_enable; 109 110 110 111 /* Remember who we are attached to. */ 111 112 ep->base.sk = sk;
+3
net/sctp/protocol.c
··· 1254 1254 /* Disable AUTH by default. */ 1255 1255 net->sctp.auth_enable = 0; 1256 1256 1257 + /* Enable ECN by default. */ 1258 + net->sctp.ecn_enable = 1; 1259 + 1257 1260 /* Set SCOPE policy to enabled */ 1258 1261 net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE; 1259 1262
+12 -4
net/sctp/sm_make_chunk.c
··· 244 244 245 245 chunksize = sizeof(init) + addrs_len; 246 246 chunksize += SCTP_PAD4(SCTP_SAT_LEN(num_types)); 247 - chunksize += sizeof(ecap_param); 247 + 248 + if (asoc->ep->ecn_enable) 249 + chunksize += sizeof(ecap_param); 248 250 249 251 if (asoc->ep->prsctp_enable) 250 252 chunksize += sizeof(prsctp_param); ··· 337 335 sctp_addto_chunk(retval, sizeof(sat), &sat); 338 336 sctp_addto_chunk(retval, num_types * sizeof(__u16), &types); 339 337 340 - sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param); 338 + if (asoc->ep->ecn_enable) 339 + sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param); 341 340 342 341 /* Add the supported extensions parameter. Be nice and add this 343 342 * fist before addiding the parameters for the extensions themselves ··· 2600 2597 break; 2601 2598 2602 2599 case SCTP_PARAM_ECN_CAPABLE: 2603 - asoc->peer.ecn_capable = 1; 2604 - break; 2600 + if (asoc->ep->ecn_enable) { 2601 + asoc->peer.ecn_capable = 1; 2602 + break; 2603 + } 2604 + /* Fall Through */ 2605 + goto fall_through; 2606 + 2605 2607 2606 2608 case SCTP_PARAM_ADAPTATION_LAYER_IND: 2607 2609 asoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind);