Skip to content

Commit 1b0b811

Browse files
lxindavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7add83d commit 1b0b811

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

include/net/netns/sctp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ struct netns_sctp {
128128
/* Flag to indicate if stream interleave is enabled */
129129
int intl_enable;
130130

131+
/* Flag to indicate if ecn is enabled */
132+
int ecn_enable;
133+
131134
/*
132135
* Policy to control SCTP IPv4 address scoping
133136
* 0 - Disable IPv4 address scoping

include/net/sctp/structs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,8 @@ struct sctp_endpoint {
13221322
/* SCTP-AUTH: endpoint shared keys */
13231323
struct list_head endpoint_shared_keys;
13241324
__u16 active_key_id;
1325-
__u8 auth_enable:1,
1325+
__u8 ecn_enable:1,
1326+
auth_enable:1,
13261327
intl_enable:1,
13271328
prsctp_enable:1,
13281329
asconf_enable:1,

net/sctp/endpointola.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
106106
*/
107107
ep->prsctp_enable = net->sctp.prsctp_enable;
108108
ep->reconf_enable = net->sctp.reconf_enable;
109+
ep->ecn_enable = net->sctp.ecn_enable;
109110

110111
/* Remember who we are attached to. */
111112
ep->base.sk = sk;

net/sctp/protocol.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,9 @@ static int __net_init sctp_defaults_init(struct net *net)
12541254
/* Disable AUTH by default. */
12551255
net->sctp.auth_enable = 0;
12561256

1257+
/* Enable ECN by default. */
1258+
net->sctp.ecn_enable = 1;
1259+
12571260
/* Set SCOPE policy to enabled */
12581261
net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE;
12591262

net/sctp/sm_make_chunk.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
244244

245245
chunksize = sizeof(init) + addrs_len;
246246
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);
248250

249251
if (asoc->ep->prsctp_enable)
250252
chunksize += sizeof(prsctp_param);
@@ -335,7 +337,8 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
335337
sctp_addto_chunk(retval, sizeof(sat), &sat);
336338
sctp_addto_chunk(retval, num_types * sizeof(__u16), &types);
337339

338-
sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param);
340+
if (asoc->ep->ecn_enable)
341+
sctp_addto_chunk(retval, sizeof(ecap_param), &ecap_param);
339342

340343
/* Add the supported extensions parameter. Be nice and add this
341344
* fist before addiding the parameters for the extensions themselves
@@ -2597,8 +2600,13 @@ static int sctp_process_param(struct sctp_association *asoc,
25972600
break;
25982601

25992602
case SCTP_PARAM_ECN_CAPABLE:
2600-
asoc->peer.ecn_capable = 1;
2601-
break;
2603+
if (asoc->ep->ecn_enable) {
2604+
asoc->peer.ecn_capable = 1;
2605+
break;
2606+
}
2607+
/* Fall Through */
2608+
goto fall_through;
2609+
26022610

26032611
case SCTP_PARAM_ADAPTATION_LAYER_IND:
26042612
asoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind);

0 commit comments

Comments
 (0)