sctp: add reconf_enable in asoc ep and netns
authorXin Long <lucien.xin@gmail.com>
Tue, 17 Jan 2017 16:44:45 +0000 (00:44 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Jan 2017 19:55:10 +0000 (14:55 -0500)
This patch is to add reconf_enable field in all of asoc ep and netns
to indicate if they support stream reset.

When initializing, asoc reconf_enable get the default value from ep
reconf_enable which is from netns netns reconf_enable by default.

It is also to add reconf_capable in asoc peer part to know if peer
supports reconf_enable, the value is set if ext params have reconf
chunk support when processing init chunk, just as rfc6525 section
5.1.1 demands.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netns/sctp.h
include/net/sctp/structs.h
net/sctp/associola.c
net/sctp/endpointola.c
net/sctp/protocol.c
net/sctp/sm_make_chunk.c

index c501d67172b125d55108ca407f4c50a158da0e14..b7871d0183541c63d53ac9274aa93cf8982bd1fb 100644 (file)
@@ -118,6 +118,9 @@ struct netns_sctp {
        /* Flag to indicate if PR-SCTP is enabled. */
        int prsctp_enable;
 
+       /* Flag to indicate if PR-CONFIG is enabled. */
+       int reconf_enable;
+
        /* Flag to idicate if SCTP-AUTH is enabled */
        int auth_enable;
 
index 463b4d642d684b08251d9033611d620a0e284328..ee037ef15d651d462efdf0d31b9000666f4f7fea 100644 (file)
@@ -1255,7 +1255,8 @@ struct sctp_endpoint {
        struct list_head endpoint_shared_keys;
        __u16 active_key_id;
        __u8  auth_enable:1,
-             prsctp_enable:1;
+             prsctp_enable:1,
+             reconf_enable:1;
 };
 
 /* Recover the outter endpoint structure. */
@@ -1508,6 +1509,7 @@ struct sctp_association {
                        hostname_address:1, /* Peer understands DNS addresses? */
                        asconf_capable:1,   /* Does peer support ADDIP? */
                        prsctp_capable:1,   /* Can peer do PR-SCTP? */
+                       reconf_capable:1,   /* Can peer do RE-CONFIG? */
                        auth_capable:1;     /* Is peer doing SCTP-AUTH? */
 
                /* sack_needed : This flag indicates if the next received
@@ -1867,7 +1869,8 @@ struct sctp_association {
 
        __u8 need_ecne:1,       /* Need to send an ECNE Chunk? */
             temp:1,            /* Is it a temporary association? */
-            prsctp_enable:1;
+            prsctp_enable:1,
+            reconf_enable:1;
 
        __u32 strreset_outseq; /* Update after receiving response */
        __u32 strreset_inseq; /* Update after receiving request */
index fc33540d2f113546f208f0b919332f8c9c1698a7..68b99adc21a31d37f1188aafc61192b132f031db 100644 (file)
@@ -270,6 +270,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
 
        asoc->active_key_id = ep->active_key_id;
        asoc->prsctp_enable = ep->prsctp_enable;
+       asoc->reconf_enable = ep->reconf_enable;
 
        /* Save the hmacs and chunks list into this association */
        if (ep->auth_hmacs_list)
index 410ddc1e344389cae97cb86327309516b0487c96..8c589230794f9394406d2a0ad2157b7a47d75757 100644 (file)
@@ -164,6 +164,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
        ep->auth_hmacs_list = auth_hmacs;
        ep->auth_chunk_list = auth_chunks;
        ep->prsctp_enable = net->sctp.prsctp_enable;
+       ep->reconf_enable = net->sctp.reconf_enable;
 
        return ep;
 
index f9c3c37c9ae0780e6181745aa679c7e86ed4b5e4..8227bbbd077a4ad04df53886558d34c4d6a3daea 100644 (file)
@@ -1258,6 +1258,9 @@ static int __net_init sctp_defaults_init(struct net *net)
        /* Enable PR-SCTP by default. */
        net->sctp.prsctp_enable = 1;
 
+       /* Disable RECONF by default. */
+       net->sctp.reconf_enable = 0;
+
        /* Disable AUTH by default. */
        net->sctp.auth_enable = 0;
 
index df81fce088902fb42328d3d0a94dc2e6f170373a..ad3445b3408eac9791ee5645b55da68ee14e20b1 100644 (file)
@@ -270,6 +270,11 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
                num_ext += 2;
        }
 
+       if (asoc->reconf_enable) {
+               extensions[num_ext] = SCTP_CID_RECONF;
+               num_ext += 1;
+       }
+
        if (sp->adaptation_ind)
                chunksize += sizeof(aiparam);
 
@@ -434,6 +439,11 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
                num_ext += 2;
        }
 
+       if (asoc->peer.reconf_capable) {
+               extensions[num_ext] = SCTP_CID_RECONF;
+               num_ext += 1;
+       }
+
        if (sp->adaptation_ind)
                chunksize += sizeof(aiparam);
 
@@ -2012,6 +2022,11 @@ static void sctp_process_ext_param(struct sctp_association *asoc,
 
        for (i = 0; i < num_ext; i++) {
                switch (param.ext->chunks[i]) {
+               case SCTP_CID_RECONF:
+                       if (asoc->reconf_enable &&
+                           !asoc->peer.reconf_capable)
+                               asoc->peer.reconf_capable = 1;
+                       break;
                case SCTP_CID_FWD_TSN:
                        if (asoc->prsctp_enable && !asoc->peer.prsctp_capable)
                                asoc->peer.prsctp_capable = 1;