sctp: add receiver-side procedures for stream reconf asoc reset and add streams and response
Subsystems (3)
Xin Long
maintainerv2 cover sctp: add receiver-side procedures for stream reconf asoc reset and add streams and response
Patch 2/7, 4/7, 5/7, 6/7 are to implement the process of asoc reset request, add streams requests and all kinds of responses.
Patch 1/7 and 3/7 are ahead of 2/7 and 4/7 to add two event notification for asoc reset and add streams.
Patch 7/7 is the last patch for implementing rfc6525 sctp stream reconf to add sysctl and sockopt interface for users to enable sctp stream reconf.
After this patchset, sctp stream reconf will be able to work as rfc6525.
v1->v2:
- put these into a smaller group.
- rename the titles of the commits and improve some changelogs.
- improve sctp_chunk_lookup_strreset_param and reuse it in patch 4/7.
- process addstrm outreq as the ack of in addstrm inreq if strreset_chunk is not NULL in patch 4/7.
- remove the stream alloc when sending addstrm inreq, and the process in peer will response it by sending a addstrm out request back in patch 5/7.
- adjust the process of addstrm in resp to fit in the codes that only alloc streams through addstrm outreq in patch 6/7.
Xin Long (7):
sctp: add support for generating assoc reset event notification
sctp: implement receiver-side procedures for the SSN/TSN Reset Request
Parameter
sctp: add support for generating add stream change event notification
sctp: implement receiver-side procedures for the Add Outgoing Streams
Request Parameter
sctp: implement receiver-side procedures for the Add Incoming Streams
Request Parameter
sctp: implement receiver-side procedures for the Reconf Response
Parameter
sctp: add get and set sockopt for reconf_enable
include/net/sctp/sm.h | 16 ++ include/net/sctp/ulpevent.h | 8 + include/uapi/linux/sctp.h | 31 ++++ net/sctp/sm_statefuns.c | 15 +- net/sctp/socket.c | 81 +++++++++ net/sctp/stream.c | 396 +++++++++++++++++++++++++++++++++++++++++--- net/sctp/sysctl.c | 7 + net/sctp/ulpevent.c | 56 +++++++ 8 files changed, 585 insertions(+), 25 deletions(-)
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH v2 1/7 sctp: add support for generating assoc reset event notification
This patch is to add Association Reset Event described in rfc6525 section 6.1.2.
--- include/net/sctp/ulpevent.h | 4 ++++ include/uapi/linux/sctp.h | 15 +++++++++++++++ net/sctp/ulpevent.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+)
include/net/sctp/ulpevent.h +4 -0
@@ -132,6 +132,10 @@ struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event( const struct sctp_association *asoc, __u16 flags, __u16 stream_num, __u16 *stream_list, gfp_t gfp); +struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event ( +const struct sctp_association *asoc,__u16 flags, +__u32 local_tsn,__u32 remote_tsn,gfp_t gfp); +void sctp_ulpevent_read_sndrcvinfo (const struct sctp_ulpevent *event,struct msghdr *); void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
include/uapi/linux/sctp.h +15 -0
@@ -502,6 +502,17 @@ struct sctp_stream_reset_event {__u16 strreset_stream_list[]; }; +#define SCTP_ASSOC_RESET_DENIED 0x0004 +#define SCTP_ASSOC_RESET_FAILED 0x0008 +struct sctp_assoc_reset_event { +__u16 assocreset_type; +__u16 assocreset_flags; +__u32 assocreset_length; +sctp_assoc_t assocreset_assoc_id; +__u32 assocreset_local_tsn; +__u32 assocreset_remote_tsn; +}; +/* * Described in Section 7.3 * Ancillary Data and Notification Interest Options
@@ -518,6 +529,7 @@ struct sctp_event_subscribe {__u8 sctp_authentication_event;__u8 sctp_sender_dry_event;__u8 sctp_stream_reset_event; +__u8 sctp_assoc_reset_event; };/*
@@ -543,6 +555,7 @@ union sctp_notification {struct sctp_authkey_event sn_authkey_event;struct sctp_sender_dry_event sn_sender_dry_event;struct sctp_stream_reset_event sn_strreset_event; +struct sctp_assoc_reset_event sn_assocreset_event; };/* Section 5.3.1
@@ -572,6 +585,8 @@ enum sctp_sn_type {#define SCTP_SENDER_DRY_EVENT SCTP_SENDER_DRY_EVENT SCTP_STREAM_RESET_EVENT,#define SCTP_STREAM_RESET_EVENT SCTP_STREAM_RESET_EVENT + SCTP_ASSOC_RESET_EVENT, +#define SCTP_ASSOC_RESET_EVENT SCTP_ASSOC_RESET_EVENT };/* Notification error codes used to fill up the error fields in some
net/sctp/ulpevent.c +28 -0
@@ -883,6 +883,34 @@ struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(return event; } +struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event ( +const struct sctp_association *asoc,__u16 flags,__u32 local_tsn, +__u32 remote_tsn,gfp_t gfp) +{ +struct sctp_assoc_reset_event *areset; +struct sctp_ulpevent *event; +struct sk_buff *skb; + + event =sctp_ulpevent_new (sizeof (struct sctp_assoc_reset_event ), +MSG_NOTIFICATION , gfp); +if (!event) +return NULL ; + + skb =sctp_event2skb (event); + areset = (struct sctp_assoc_reset_event *) +skb_put (skb,sizeof (struct sctp_assoc_reset_event )); + + areset->assocreset_type =SCTP_ASSOC_RESET_EVENT ; + areset->assocreset_flags = flags; + areset->assocreset_length =sizeof (struct sctp_assoc_reset_event ); +sctp_ulpevent_set_owner (event, asoc); + areset->assocreset_assoc_id =sctp_assoc2id (asoc); + areset->assocreset_local_tsn = local_tsn; + areset->assocreset_remote_tsn = remote_tsn; + +return event; +} +/* Return the notification type, assuming this is a notification * event. */
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH v2 2/7 sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter
This patch is to implement Receiver-Side Procedures for the SSN/TSN Reset Request Parameter described in rfc6525 section 6.2.4.
The process is kind of complicate, it's wonth having some comments from section 6.2.4 in the codes.
--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)
include/net/sctp/sm.h +4 -0
@@ -293,6 +293,10 @@ struct sctp_chunk *sctp_process_strreset_inreq(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */
net/sctp/sm_statefuns.c +3 -0
@@ -3872,6 +3872,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_IN_REQUEST ) reply =sctp_process_strreset_inreq ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_TSN_REQUEST ) + reply =sctp_process_strreset_tsnreq ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */
net/sctp/stream.c +79 -0
82 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH v2 3/7 sctp: add support for generating add stream change event notification
This patch is to add Stream Change Event described in rfc6525 section 6.1.3.
--- include/net/sctp/ulpevent.h | 4 ++++ include/uapi/linux/sctp.h | 15 +++++++++++++++ net/sctp/ulpevent.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+)
include/net/sctp/ulpevent.h +4 -0
@@ -136,6 +136,10 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event( const struct sctp_association *asoc, __u16 flags, __u32 local_tsn, __u32 remote_tsn, gfp_t gfp); +struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event ( +const struct sctp_association *asoc,__u16 flags, +__u32 strchange_instrms,__u32 strchange_outstrms,gfp_t gfp); +void sctp_ulpevent_read_sndrcvinfo (const struct sctp_ulpevent *event,struct msghdr *); void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
include/uapi/linux/sctp.h +15 -0
@@ -513,6 +513,17 @@ struct sctp_assoc_reset_event {__u32 assocreset_remote_tsn; }; +#define SCTP_ASSOC_CHANGE_DENIED 0x0004 +#define SCTP_ASSOC_CHANGE_FAILED 0x0008 +struct sctp_stream_change_event { +__u16 strchange_type; +__u16 strchange_flags; +__u32 strchange_length; +sctp_assoc_t strchange_assoc_id; +__u16 strchange_instrms; +__u16 strchange_outstrms; +}; +/* * Described in Section 7.3 * Ancillary Data and Notification Interest Options
@@ -530,6 +541,7 @@ struct sctp_event_subscribe {__u8 sctp_sender_dry_event;__u8 sctp_stream_reset_event;__u8 sctp_assoc_reset_event; +__u8 sctp_stream_change_event; };/*
@@ -556,6 +568,7 @@ union sctp_notification {struct sctp_sender_dry_event sn_sender_dry_event;struct sctp_stream_reset_event sn_strreset_event;struct sctp_assoc_reset_event sn_assocreset_event; +struct sctp_stream_change_event sn_strchange_event; };/* Section 5.3.1
@@ -587,6 +600,8 @@ enum sctp_sn_type {#define SCTP_STREAM_RESET_EVENT SCTP_STREAM_RESET_EVENT SCTP_ASSOC_RESET_EVENT,#define SCTP_ASSOC_RESET_EVENT SCTP_ASSOC_RESET_EVENT + SCTP_STREAM_CHANGE_EVENT, +#define SCTP_STREAM_CHANGE_EVENT SCTP_STREAM_CHANGE_EVENT };/* Notification error codes used to fill up the error fields in some
net/sctp/ulpevent.c +28 -0
@@ -911,6 +911,34 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(return event; } +struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event ( +const struct sctp_association *asoc,__u16 flags, +__u32 strchange_instrms,__u32 strchange_outstrms,gfp_t gfp) +{ +struct sctp_stream_change_event *schange; +struct sctp_ulpevent *event; +struct sk_buff *skb; + + event =sctp_ulpevent_new (sizeof (struct sctp_stream_change_event ), +MSG_NOTIFICATION , gfp); +if (!event) +return NULL ; + + skb =sctp_event2skb (event); + schange = (struct sctp_stream_change_event *) +skb_put (skb,sizeof (struct sctp_stream_change_event )); + + schange->strchange_type =SCTP_STREAM_CHANGE_EVENT ; + schange->strchange_flags = flags; + schange->strchange_length =sizeof (struct sctp_stream_change_event ); +sctp_ulpevent_set_owner (event, asoc); + schange->strchange_assoc_id =sctp_assoc2id (asoc); + schange->strchange_instrms = strchange_instrms; + schange->strchange_outstrms = strchange_outstrms; + +return event; +} +/* Return the notification type, assuming this is a notification * event. */
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH v2 4/7 sctp: implement receiver-side procedures for the Add Outgoing Streams Request Parameter
This patch is to add Receiver-Side Procedures for the Add Outgoing Streams Request Parameter described in section 5.2.5.
It is also to improve sctp_chunk_lookup_strreset_param, so that it can be used for processing addstrm_out request.
--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 89 +++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 86 insertions(+), 10 deletions(-)
include/net/sctp/sm.h +4 -0
@@ -297,6 +297,10 @@ struct sctp_chunk *sctp_process_strreset_tsnreq(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_addstrm_out ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */
net/sctp/sm_statefuns.c +3 -0
@@ -3875,6 +3875,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_TSN_REQUEST ) reply =sctp_process_strreset_tsnreq ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_ADD_OUT_STREAMS ) + reply =sctp_process_strreset_addstrm_out ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */
net/sctp/stream.c +79 -9
120 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH v2 5/7 sctp: implement receiver-side procedures for the Add Incoming Streams Request Parameter
This patch is to implement Receiver-Side Procedures for the Add Incoming Streams Request Parameter described in rfc6525 section 5.2.6.
It is also to fix that it shouldn't have add streams when sending addstrm in request, as the process in peer will handle it by sending a addstrm out request back.
--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 74 +++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 69 insertions(+), 12 deletions(-)
include/net/sctp/sm.h +4 -0
@@ -301,6 +301,10 @@ struct sctp_chunk *sctp_process_strreset_addstrm_out(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_addstrm_in ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */
net/sctp/sm_statefuns.c +3 -0
@@ -3878,6 +3878,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_ADD_OUT_STREAMS ) reply =sctp_process_strreset_addstrm_out ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_ADD_IN_STREAMS ) + reply =sctp_process_strreset_addstrm_in ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */
net/sctp/stream.c +62 -12
83 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH v2 6/7 sctp: implement receiver-side procedures for the Reconf Response Parameter
This patch is to implement Receiver-Side Procedures for the Re-configuration Response Parameter in rfc6525 section 5.2.7.
sctp_process_strreset_resp would process the response for any kind of reconf request, and the stream reconf is applied only when the response result is success.
--- include/net/sctp/sm.h | 4 ++ net/sctp/sm_statefuns.c | 6 +- net/sctp/stream.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 3 deletions(-)
include/net/sctp/sm.h +4 -0
@@ -305,6 +305,10 @@ struct sctp_chunk *sctp_process_strreset_addstrm_in(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_resp ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */
net/sctp/sm_statefuns.c +3 -3
@@ -3881,9 +3881,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_ADD_IN_STREAMS ) reply =sctp_process_strreset_addstrm_in ( (struct sctp_association *)asoc, param, &ev); -/* More handles for other types will be added here, by now it -* just ignores other types. -*/ +else if (param.p->type =SCTP_PARAM_RESET_RESPONSE ) + reply =sctp_process_strreset_resp ( + (struct sctp_association *)asoc, param, &ev);if (ev) sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
net/sctp/stream.c +154 -0
157 lines not on this page · raw message
Signature · 1 line
2.1.0
Xin Long
maintainerPATCH v2 7/7 sctp: add get and set sockopt for reconf_enable
This patchset is to add SCTP_RECONFIG_SUPPORTED sockopt, it would set and get asoc reconf_enable value when asoc_id is set, or it would set and get ep reconf_enalbe value if asoc_id is 0.
It is also to add sysctl interface for users to set the default value for reconf_enable.
After this patch, stream reconf will work.
--- include/uapi/linux/sctp.h | 1 + net/sctp/socket.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++ net/sctp/sysctl.c | 7 ++++ 3 files changed, 89 insertions(+)
include/uapi/linux/sctp.h +1 -0
@@ -115,6 +115,7 @@ typedef __s32 sctp_assoc_t;#define SCTP_PR_SUPPORTED 113#define SCTP_DEFAULT_PRINFO 114#define SCTP_PR_ASSOC_STATUS 115 +#define SCTP_RECONFIG_SUPPORTED 117#define SCTP_ENABLE_STREAM_RESET 118#define SCTP_RESET_STREAMS 119#define SCTP_RESET_ASSOC 120
net/sctp/socket.c +81 -0
105 lines not on this page · raw message
net/sctp/sysctl.c +7 -0
@@ -275,6 +275,13 @@ static struct ctl_table sctp_net_table[] = { .proc_handler = proc_dointvec, }, { + .procname = "reconf_enable", + .data = &init_net.sctp.reconf_enable, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + { .procname = "auth_enable", .data = &init_net.sctp.auth_enable, .maxlen = sizeof(int),
Signature · 1 line
2.1.0
Marcelo Ricardo Leitner
maintainerRe: [PATCHv2 net-next 2/7] sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter
In reply to Xin LongQuoted 60 lines · Xin Long
This patch is to implement Receiver-Side Procedures for the SSN/TSN Reset Request Parameter described in rfc6525 section 6.2.4.
The process is kind of complicate, it's wonth having some comments from section 6.2.4 in the codes.
Signed-off-by Xin Long <[email protected]>--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)include/net/sctp/sm.h +4
-0@@ -293,6 +293,10 @@ struct sctp_chunk *sctp_process_strreset_inreq(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */ net/sctp/sm_statefuns.c +3
-0@@ -3872,6 +3872,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_IN_REQUEST ) reply =sctp_process_strreset_inreq ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_TSN_REQUEST ) + reply =sctp_process_strreset_tsnreq ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */ net/sctp/stream.c +10
-0@@ -477,3 +477,82 @@ struct sctp_chunk *sctp_process_strreset_inreq(return chunk; } + +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp) +{ +__u32 init_tsn =0 , next_tsn =0 , max_tsn_seen; +struct sctp_strreset_tsnreq *tsnreq = param.v; +struct sctp_stream *stream = asoc->stream; +__u32 result =SCTP_STRRESET_DENIED ;
net/sctp/stream.c struct sctp_chunk *sctp_process_strreset_inreq( · line 499
Quoted 10 lines
net/sctp/stream.c +10
-0+__u32 request_seq; +__u16 i; + + request_seq =ntohl (tsnreq->request_seq); +if (request_seq > asoc->strreset_inseq) { + result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }else if (request_seq = asoc->strreset_inseq) { + asoc->strreset_inseq++; + }
I guess I already asked this, but.. why request_seq < asoc->strreset_inseq is allowed?
Quoted 67 lines
net/sctp/stream.c +59
-0+ +if (!(asoc->strreset_enable &SCTP_ENABLE_RESET_ASSOC_REQ )) + goto out; + +if (asoc->strreset_outstanding) { + result =SCTP_STRRESET_ERR_IN_PROGRESS ; + goto out; + } + +/* G3: The same processing as though a SACK chunk with no gap report +* and a cumulative TSN ACK of the Sender's Next TSN minus 1 were +* received MUST be performed. +*/ + max_tsn_seen =sctp_tsnmap_get_max_tsn_seen (&asoc->peer.tsn_map); +sctp_ulpq_reasm_flushtsn (&asoc->ulpq, max_tsn_seen); +sctp_ulpq_abort_pd (&asoc->ulpq,GFP_ATOMIC ); + +/* G1: Compute an appropriate value for the Receiver's Next TSN -- the +* TSN that the peer should use to send the next DATA chunk. The +* value SHOULD be the smallest TSN not acknowledged by the +* receiver of the request plus 2^31. +*/ + init_tsn =sctp_tsnmap_get_ctsn (&asoc->peer.tsn_map) + (1 <<31 ); +sctp_tsnmap_init (&asoc->peer.tsn_map,SCTP_TSN_MAP_INITIAL , + init_tsn,GFP_ATOMIC ); + +/* G4: The same processing as though a FWD-TSN chunk (as defined in +* [RFC3758]) with all streams affected and a new cumulative TSN +* ACK of the Receiver's Next TSN minus 1 were received MUST be +* performed. +*/ +sctp_outq_free (&asoc->outqueue); + +/* G2: Compute an appropriate value for the local endpoint's next TSN, +* i.e., the next TSN assigned by the receiver of the SSN/TSN reset +* chunk. The value SHOULD be the highest TSN sent by the receiver +* of the request plus 1. +*/ + next_tsn = asoc->next_tsn; + asoc->ctsn_ack_point = next_tsn -1 ; + asoc->adv_peer_ack_point = asoc->ctsn_ack_point; + +/* G5: The next expected and outgoing SSNs MUST be reset to 0 for all +* incoming and outgoing streams. +*/ +for (i =0 ; i < stream->outcnt; i++) + stream->out[i].ssn =0 ; +for (i =0 ; i < stream->incnt; i++) + stream->in[i].ssn =0 ; + + result =SCTP_STRRESET_PERFORMED ; + + *evp =sctp_ulpevent_make_assoc_reset_event (asoc,0 , init_tsn, + next_tsn,GFP_ATOMIC ); + +out: +return sctp_make_strreset_tsnresp (asoc, result, request_seq, + next_tsn, init_tsn); +}Signature · 6 lines
2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Xin Long
maintainerRe: [PATCHv2 net-next 2/7] sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter
Quoted 66 lines · Marcelo Ricardo Leitner
Quoted 65 lines · Xin Long
This patch is to implement Receiver-Side Procedures for the SSN/TSN Reset Request Parameter described in rfc6525 section 6.2.4.
The process is kind of complicate, it's wonth having some comments from section 6.2.4 in the codes.
Signed-off-by Xin Long <[email protected]>--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)include/net/sctp/sm.h +4
-0@@ -293,6 +293,10 @@ struct sctp_chunk *sctp_process_strreset_inreq(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */ net/sctp/sm_statefuns.c +3
-0@@ -3872,6 +3872,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_IN_REQUEST ) reply =sctp_process_strreset_inreq ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_TSN_REQUEST ) + reply =sctp_process_strreset_tsnreq ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */ net/sctp/stream.c +15
-0@@ -477,3 +477,82 @@ struct sctp_chunk *sctp_process_strreset_inreq(return chunk; } + +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp) +{ +__u32 init_tsn =0 , next_tsn =0 , max_tsn_seen; +struct sctp_strreset_tsnreq *tsnreq = param.v; +struct sctp_stream *stream = asoc->stream; +__u32 result =SCTP_STRRESET_DENIED ; +__u32 request_seq; +__u16 i; + + request_seq =ntohl (tsnreq->request_seq); +if (request_seq > asoc->strreset_inseq) {
Quoted 8 lines
net/sctp/stream.c struct sctp_chunk *sctp_process_strreset_inreq( · line 499
Quoted 5 lines
net/sctp/stream.c +5
-0+ result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }else if (request_seq = asoc->strreset_inseq) { + asoc->strreset_inseq++; + }I guess I already asked this, but.. why
request_seq<asoc->strreset_inseqis allowed?
we can not just ignore or response with ERR.
rfc6525#section-5.2.1:
... If the received RE-CONFIG chunk contains at least
one request and based on the analysis of the Re-configuration Request Sequence Numbers this is the last received RE-CONFIG chunk (i.e., a retransmission), the same RE-CONFIG chunk MUST to be sent back in response, as it was earlier.
Quoted 68 lines
Quoted 68 lines
net/sctp/stream.c +59
-1+ +if (!(asoc->strreset_enable &SCTP_ENABLE_RESET_ASSOC_REQ )) + goto out; + +if (asoc->strreset_outstanding) { + result =SCTP_STRRESET_ERR_IN_PROGRESS ; + goto out; + } + +/* G3: The same processing as though a SACK chunk with no gap report +* and a cumulative TSN ACK of the Sender's Next TSN minus 1 were +* received MUST be performed. +*/ + max_tsn_seen =sctp_tsnmap_get_max_tsn_seen (&asoc->peer.tsn_map); +sctp_ulpq_reasm_flushtsn (&asoc->ulpq, max_tsn_seen); +sctp_ulpq_abort_pd (&asoc->ulpq,GFP_ATOMIC ); + +/* G1: Compute an appropriate value for the Receiver's Next TSN -- the +* TSN that the peer should use to send the next DATA chunk. The +* value SHOULD be the smallest TSN not acknowledged by the +* receiver of the request plus 2^31. +*/ + init_tsn =sctp_tsnmap_get_ctsn (&asoc->peer.tsn_map) + (1 <<31 ); +sctp_tsnmap_init (&asoc->peer.tsn_map,SCTP_TSN_MAP_INITIAL , + init_tsn,GFP_ATOMIC ); + +/* G4: The same processing as though a FWD-TSN chunk (as defined in +* [RFC3758]) with all streams affected and a new cumulative TSN +* ACK of the Receiver's Next TSN minus 1 were received MUST be +* performed. +*/ +sctp_outq_free (&asoc->outqueue); + +/* G2: Compute an appropriate value for the local endpoint's next TSN, +* i.e., the next TSN assigned by the receiver of the SSN/TSN reset +* chunk. The value SHOULD be the highest TSN sent by the receiver +* of the request plus 1. +*/ + next_tsn = asoc->next_tsn; + asoc->ctsn_ack_point = next_tsn -1 ; + asoc->adv_peer_ack_point = asoc->ctsn_ack_point; + +/* G5: The next expected and outgoing SSNs MUST be reset to 0 for all +* incoming and outgoing streams. +*/ +for (i =0 ; i < stream->outcnt; i++) + stream->out[i].ssn =0 ; +for (i =0 ; i < stream->incnt; i++) + stream->in[i].ssn =0 ; + + result =SCTP_STRRESET_PERFORMED ; + + *evp =sctp_ulpevent_make_assoc_reset_event (asoc,0 , init_tsn, + next_tsn,GFP_ATOMIC ); + +out: +return sctp_make_strreset_tsnresp (asoc, result, request_seq, + next_tsn, init_tsn); +} --2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Marcelo Ricardo Leitner
maintainerRe: [PATCHv2 net-next 2/7] sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter
Quoted 76 lines · Xin Long
Quoted 66 lines · Marcelo Ricardo Leitner
Quoted 65 lines · Xin Long
This patch is to implement Receiver-Side Procedures for the SSN/TSN Reset Request Parameter described in rfc6525 section 6.2.4.
The process is kind of complicate, it's wonth having some comments from section 6.2.4 in the codes.
Signed-off-by Xin Long <[email protected]>--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)include/net/sctp/sm.h +4
-0@@ -293,6 +293,10 @@ struct sctp_chunk *sctp_process_strreset_inreq(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */ net/sctp/sm_statefuns.c +3
-0@@ -3872,6 +3872,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_IN_REQUEST ) reply =sctp_process_strreset_inreq ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_TSN_REQUEST ) + reply =sctp_process_strreset_tsnreq ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */ net/sctp/stream.c +15
-0@@ -477,3 +477,82 @@ struct sctp_chunk *sctp_process_strreset_inreq(return chunk; } + +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp) +{ +__u32 init_tsn =0 , next_tsn =0 , max_tsn_seen; +struct sctp_strreset_tsnreq *tsnreq = param.v; +struct sctp_stream *stream = asoc->stream; +__u32 result =SCTP_STRRESET_DENIED ; +__u32 request_seq; +__u16 i; + + request_seq =ntohl (tsnreq->request_seq); +if (request_seq > asoc->strreset_inseq) {Quoted 8 lines
net/sctp/stream.c struct sctp_chunk *sctp_process_strreset_inreq( · line 499
Quoted 5 lines
net/sctp/stream.c +5
-0+ result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }else if (request_seq = asoc->strreset_inseq) { + asoc->strreset_inseq++; + }I guess I already asked this, but.. why
request_seq<asoc->strreset_inseqis allowed?
Quoted 6 lines
we can not just ignore or response with ERR.
rfc6525#section-5.2.1:... If the received RE-CONFIG chunk contains at least
one request and based on the analysis of the Re-configuration Request Sequence Numbers this is the last received RE-CONFIG chunk (i.e., a
^^^^^^^^^^^^^
Quoted 2 lines
retransmission), the same RE-CONFIG chunk MUST to be sent back in response, as it was earlier.
That means we should only re-process that *last* reconf request, and not just any old one. My understanding is that we need something like:
+ } else if (request_seq < asoc->strreset_inseq-1) {
+ result = SCTP_STRRESET_ERR_BAD_SEQNO;
+ goto out;
+ }
And then this makes it evident that we have to handle request_seq as serial numbers (like TSNs are handled).
Quoted 75 lines
Quoted 65 lines
Quoted 65 lines
net/sctp/stream.c +59
-1+ +if (!(asoc->strreset_enable &SCTP_ENABLE_RESET_ASSOC_REQ )) + goto out; + +if (asoc->strreset_outstanding) { + result =SCTP_STRRESET_ERR_IN_PROGRESS ; + goto out; + } + +/* G3: The same processing as though a SACK chunk with no gap report +* and a cumulative TSN ACK of the Sender's Next TSN minus 1 were +* received MUST be performed. +*/ + max_tsn_seen =sctp_tsnmap_get_max_tsn_seen (&asoc->peer.tsn_map); +sctp_ulpq_reasm_flushtsn (&asoc->ulpq, max_tsn_seen); +sctp_ulpq_abort_pd (&asoc->ulpq,GFP_ATOMIC ); + +/* G1: Compute an appropriate value for the Receiver's Next TSN -- the +* TSN that the peer should use to send the next DATA chunk. The +* value SHOULD be the smallest TSN not acknowledged by the +* receiver of the request plus 2^31. +*/ + init_tsn =sctp_tsnmap_get_ctsn (&asoc->peer.tsn_map) + (1 <<31 ); +sctp_tsnmap_init (&asoc->peer.tsn_map,SCTP_TSN_MAP_INITIAL , + init_tsn,GFP_ATOMIC ); + +/* G4: The same processing as though a FWD-TSN chunk (as defined in +* [RFC3758]) with all streams affected and a new cumulative TSN +* ACK of the Receiver's Next TSN minus 1 were received MUST be +* performed. +*/ +sctp_outq_free (&asoc->outqueue); + +/* G2: Compute an appropriate value for the local endpoint's next TSN, +* i.e., the next TSN assigned by the receiver of the SSN/TSN reset +* chunk. The value SHOULD be the highest TSN sent by the receiver +* of the request plus 1. +*/ + next_tsn = asoc->next_tsn; + asoc->ctsn_ack_point = next_tsn -1 ; + asoc->adv_peer_ack_point = asoc->ctsn_ack_point; + +/* G5: The next expected and outgoing SSNs MUST be reset to 0 for all +* incoming and outgoing streams. +*/ +for (i =0 ; i < stream->outcnt; i++) + stream->out[i].ssn =0 ; +for (i =0 ; i < stream->incnt; i++) + stream->in[i].ssn =0 ; + + result =SCTP_STRRESET_PERFORMED ; + + *evp =sctp_ulpevent_make_assoc_reset_event (asoc,0 , init_tsn, + next_tsn,GFP_ATOMIC ); + +out: +return sctp_make_strreset_tsnresp (asoc, result, request_seq, + next_tsn, init_tsn); +} --2.1.0
Quoted 5 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Xin Long
maintainerRe: [PATCHv2 net-next 2/7] sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter
Quoted 94 lines · Marcelo Ricardo Leitner
Quoted 76 lines · Xin Long
Quoted 66 lines · Marcelo Ricardo Leitner
Quoted 65 lines · Xin Long
This patch is to implement Receiver-Side Procedures for the SSN/TSN Reset Request Parameter described in rfc6525 section 6.2.4.
The process is kind of complicate, it's wonth having some comments from section 6.2.4 in the codes.
Signed-off-by Xin Long <[email protected]>--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)include/net/sctp/sm.h +4
-0@@ -293,6 +293,10 @@ struct sctp_chunk *sctp_process_strreset_inreq(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */ net/sctp/sm_statefuns.c +3
-0@@ -3872,6 +3872,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_IN_REQUEST ) reply =sctp_process_strreset_inreq ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_TSN_REQUEST ) + reply =sctp_process_strreset_tsnreq ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */ net/sctp/stream.c +15
-0@@ -477,3 +477,82 @@ struct sctp_chunk *sctp_process_strreset_inreq(return chunk; } + +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp) +{ +__u32 init_tsn =0 , next_tsn =0 , max_tsn_seen; +struct sctp_strreset_tsnreq *tsnreq = param.v; +struct sctp_stream *stream = asoc->stream; +__u32 result =SCTP_STRRESET_DENIED ; +__u32 request_seq; +__u16 i; + + request_seq =ntohl (tsnreq->request_seq); +if (request_seq > asoc->strreset_inseq) {Quoted 8 lines
net/sctp/stream.c struct sctp_chunk *sctp_process_strreset_inreq( · line 499
Quoted 5 lines
net/sctp/stream.c +5
-0+ result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }else if (request_seq = asoc->strreset_inseq) { + asoc->strreset_inseq++; + }I guess I already asked this, but.. why
request_seq<asoc->strreset_inseqis allowed?Quoted 6 lines
we can not just ignore or response with ERR.
rfc6525#section-5.2.1:... If the received RE-CONFIG chunk contains at least
one request and based on the analysis of the Re-configuration Request Sequence Numbers this is the last received RE-CONFIG chunk (i.e., a^^^^^^^^^^^^^Quoted 2 lines
retransmission), the same RE-CONFIG chunk MUST to be sent back in response, as it was earlier.
That means we should only re-process that *last* reconf request, and not just any old one. My understanding is that we need something like:
net/sctp/stream.c +4
-0+ }else if (request_seq < asoc->strreset_inseq-1 ) { + result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }
Quoted 2 lines
And then this makes it evident that we have to handle
request_seqas serial numbers (like TSNs are handled).
Got you.
Here is actually also a replay attack. If a duplicate request happens:
In sender side, If the request is not yet acked, it will just process the response as usual. If It's acked already, It will drop the duplicate response as no matched asoc->strreset_chunk any more. It's safe.
But in receiver side. It will process stream/asoc again when receiving a duplicate request. If receiver side has processed some data chunks and tsn/ssn have been increased before this. we shouldn't process this request, but only send back a response with the original result. The problem is that we didn't save the result of last request.
Quoted 77 lines
Quoted 77 lines
Quoted 67 lines
Quoted 67 lines
net/sctp/stream.c +59
-1+ +if (!(asoc->strreset_enable &SCTP_ENABLE_RESET_ASSOC_REQ )) + goto out; + +if (asoc->strreset_outstanding) { + result =SCTP_STRRESET_ERR_IN_PROGRESS ; + goto out; + } + +/* G3: The same processing as though a SACK chunk with no gap report +* and a cumulative TSN ACK of the Sender's Next TSN minus 1 were +* received MUST be performed. +*/ + max_tsn_seen =sctp_tsnmap_get_max_tsn_seen (&asoc->peer.tsn_map); +sctp_ulpq_reasm_flushtsn (&asoc->ulpq, max_tsn_seen); +sctp_ulpq_abort_pd (&asoc->ulpq,GFP_ATOMIC ); + +/* G1: Compute an appropriate value for the Receiver's Next TSN -- the +* TSN that the peer should use to send the next DATA chunk. The +* value SHOULD be the smallest TSN not acknowledged by the +* receiver of the request plus 2^31. +*/ + init_tsn =sctp_tsnmap_get_ctsn (&asoc->peer.tsn_map) + (1 <<31 ); +sctp_tsnmap_init (&asoc->peer.tsn_map,SCTP_TSN_MAP_INITIAL , + init_tsn,GFP_ATOMIC ); + +/* G4: The same processing as though a FWD-TSN chunk (as defined in +* [RFC3758]) with all streams affected and a new cumulative TSN +* ACK of the Receiver's Next TSN minus 1 were received MUST be +* performed. +*/ +sctp_outq_free (&asoc->outqueue); + +/* G2: Compute an appropriate value for the local endpoint's next TSN, +* i.e., the next TSN assigned by the receiver of the SSN/TSN reset +* chunk. The value SHOULD be the highest TSN sent by the receiver +* of the request plus 1. +*/ + next_tsn = asoc->next_tsn; + asoc->ctsn_ack_point = next_tsn -1 ; + asoc->adv_peer_ack_point = asoc->ctsn_ack_point; + +/* G5: The next expected and outgoing SSNs MUST be reset to 0 for all +* incoming and outgoing streams. +*/ +for (i =0 ; i < stream->outcnt; i++) + stream->out[i].ssn =0 ; +for (i =0 ; i < stream->incnt; i++) + stream->in[i].ssn =0 ; + + result =SCTP_STRRESET_PERFORMED ; + + *evp =sctp_ulpevent_make_assoc_reset_event (asoc,0 , init_tsn, + next_tsn,GFP_ATOMIC ); + +out: +return sctp_make_strreset_tsnresp (asoc, result, request_seq, + next_tsn, init_tsn); +} --2.1.0
Quoted 5 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Marcelo Ricardo Leitner
maintainerRe: [PATCHv2 net-next 2/7] sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter
Quoted 96 lines · Xin Long
Quoted 94 lines · Marcelo Ricardo Leitner
Quoted 76 lines · Xin Long
Quoted 66 lines · Marcelo Ricardo Leitner
Quoted 65 lines · Xin Long
This patch is to implement Receiver-Side Procedures for the SSN/TSN Reset Request Parameter described in rfc6525 section 6.2.4.
The process is kind of complicate, it's wonth having some comments from section 6.2.4 in the codes.
Signed-off-by Xin Long <[email protected]>--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)include/net/sctp/sm.h +4
-0@@ -293,6 +293,10 @@ struct sctp_chunk *sctp_process_strreset_inreq(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */ net/sctp/sm_statefuns.c +3
-0@@ -3872,6 +3872,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_IN_REQUEST ) reply =sctp_process_strreset_inreq ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_TSN_REQUEST ) + reply =sctp_process_strreset_tsnreq ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */ net/sctp/stream.c +15
-0@@ -477,3 +477,82 @@ struct sctp_chunk *sctp_process_strreset_inreq(return chunk; } + +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp) +{ +__u32 init_tsn =0 , next_tsn =0 , max_tsn_seen; +struct sctp_strreset_tsnreq *tsnreq = param.v; +struct sctp_stream *stream = asoc->stream; +__u32 result =SCTP_STRRESET_DENIED ; +__u32 request_seq; +__u16 i; + + request_seq =ntohl (tsnreq->request_seq); +if (request_seq > asoc->strreset_inseq) {Quoted 8 lines
net/sctp/stream.c struct sctp_chunk *sctp_process_strreset_inreq( · line 499
Quoted 5 lines
net/sctp/stream.c +5
-0+ result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }else if (request_seq = asoc->strreset_inseq) { + asoc->strreset_inseq++; + }I guess I already asked this, but.. why
request_seq<asoc->strreset_inseqis allowed?Quoted 6 lines
we can not just ignore or response with ERR.
rfc6525#section-5.2.1:... If the received RE-CONFIG chunk contains at least
one request and based on the analysis of the Re-configuration Request Sequence Numbers this is the last received RE-CONFIG chunk (i.e., a^^^^^^^^^^^^^Quoted 2 lines
retransmission), the same RE-CONFIG chunk MUST to be sent back in response, as it was earlier.
That means we should only re-process that *last* reconf request, and not just any old one. My understanding is that we need something like:
net/sctp/stream.c +4
-0+ }else if (request_seq < asoc->strreset_inseq-1 ) { + result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }
Quoted 5 lines
Quoted 2 lines
And then this makes it evident that we have to handle
request_seqas serial numbers (like TSNs are handled).Got you.
Here is actually also a replay attack. If a duplicate request happens:
Yep.
Quoted 10 lines
In sender side, If the request is not yet acked, it will just process the response as usual. If It's acked already, It will drop the duplicate response as no matched
asoc->strreset_chunkany more. It's safe.But in receiver side. It will process stream/asoc again when receiving a duplicate request. If receiver side has processed some data chunks and tsn/ssn have been increased before this. we shouldn't process this request, but only send back a response with the original result. The problem is that we didn't save the result of last request.
Sender will stop sending DATA while the reset is happening. We probably can use the "first DATA" as a trigger to then free the response chunk in receiver, or the next request (as it can't have 2 requests at the same, issuing the 2nd one means it got the ack for the previous one), whichever happens first.
Quoted 84 lines
Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
net/sctp/stream.c +59
-1+ +if (!(asoc->strreset_enable &SCTP_ENABLE_RESET_ASSOC_REQ )) + goto out; + +if (asoc->strreset_outstanding) { + result =SCTP_STRRESET_ERR_IN_PROGRESS ; + goto out; + } + +/* G3: The same processing as though a SACK chunk with no gap report +* and a cumulative TSN ACK of the Sender's Next TSN minus 1 were +* received MUST be performed. +*/ + max_tsn_seen =sctp_tsnmap_get_max_tsn_seen (&asoc->peer.tsn_map); +sctp_ulpq_reasm_flushtsn (&asoc->ulpq, max_tsn_seen); +sctp_ulpq_abort_pd (&asoc->ulpq,GFP_ATOMIC ); + +/* G1: Compute an appropriate value for the Receiver's Next TSN -- the +* TSN that the peer should use to send the next DATA chunk. The +* value SHOULD be the smallest TSN not acknowledged by the +* receiver of the request plus 2^31. +*/ + init_tsn =sctp_tsnmap_get_ctsn (&asoc->peer.tsn_map) + (1 <<31 ); +sctp_tsnmap_init (&asoc->peer.tsn_map,SCTP_TSN_MAP_INITIAL , + init_tsn,GFP_ATOMIC ); + +/* G4: The same processing as though a FWD-TSN chunk (as defined in +* [RFC3758]) with all streams affected and a new cumulative TSN +* ACK of the Receiver's Next TSN minus 1 were received MUST be +* performed. +*/ +sctp_outq_free (&asoc->outqueue); + +/* G2: Compute an appropriate value for the local endpoint's next TSN, +* i.e., the next TSN assigned by the receiver of the SSN/TSN reset +* chunk. The value SHOULD be the highest TSN sent by the receiver +* of the request plus 1. +*/ + next_tsn = asoc->next_tsn; + asoc->ctsn_ack_point = next_tsn -1 ; + asoc->adv_peer_ack_point = asoc->ctsn_ack_point; + +/* G5: The next expected and outgoing SSNs MUST be reset to 0 for all +* incoming and outgoing streams. +*/ +for (i =0 ; i < stream->outcnt; i++) + stream->out[i].ssn =0 ; +for (i =0 ; i < stream->incnt; i++) + stream->in[i].ssn =0 ; + + result =SCTP_STRRESET_PERFORMED ; + + *evp =sctp_ulpevent_make_assoc_reset_event (asoc,0 , init_tsn, + next_tsn,GFP_ATOMIC ); + +out: +return sctp_make_strreset_tsnresp (asoc, result, request_seq, + next_tsn, init_tsn); +} --2.1.0
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Xin Long
maintainerRe: [PATCHv2 net-next 2/7] sctp: implement receiver-side procedures for the SSN/TSN Reset Request Parameter
Quoted 116 lines · Marcelo Ricardo Leitner
Quoted 96 lines · Xin Long
Quoted 94 lines · Marcelo Ricardo Leitner
Quoted 76 lines · Xin Long
Quoted 66 lines · Marcelo Ricardo Leitner
Quoted 65 lines · Xin Long
This patch is to implement Receiver-Side Procedures for the SSN/TSN Reset Request Parameter described in rfc6525 section 6.2.4.
The process is kind of complicate, it's wonth having some comments from section 6.2.4 in the codes.
Signed-off-by Xin Long <[email protected]>--- include/net/sctp/sm.h | 4 +++ net/sctp/sm_statefuns.c | 3 ++ net/sctp/stream.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)include/net/sctp/sm.h +4
-0@@ -293,6 +293,10 @@ struct sctp_chunk *sctp_process_strreset_inreq(struct sctp_association *asoc, union sctp_params param, struct sctp_ulpevent **evp); +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp);/* Prototypes for statetable processing. */ net/sctp/sm_statefuns.c +3
-0@@ -3872,6 +3872,9 @@ sctp_disposition_t sctp_sf_do_reconf(struct net *net,else if (param.p->type =SCTP_PARAM_RESET_IN_REQUEST ) reply =sctp_process_strreset_inreq ( (struct sctp_association *)asoc, param, &ev); +else if (param.p->type =SCTP_PARAM_RESET_TSN_REQUEST ) + reply =sctp_process_strreset_tsnreq ( + (struct sctp_association *)asoc, param, &ev);/* More handles for other types will be added here, by now it * just ignores other types. */ net/sctp/stream.c +15
-0@@ -477,3 +477,82 @@ struct sctp_chunk *sctp_process_strreset_inreq(return chunk; } + +struct sctp_chunk *sctp_process_strreset_tsnreq ( +struct sctp_association *asoc, +union sctp_params param, +struct sctp_ulpevent **evp) +{ +__u32 init_tsn =0 , next_tsn =0 , max_tsn_seen; +struct sctp_strreset_tsnreq *tsnreq = param.v; +struct sctp_stream *stream = asoc->stream; +__u32 result =SCTP_STRRESET_DENIED ; +__u32 request_seq; +__u16 i; + + request_seq =ntohl (tsnreq->request_seq); +if (request_seq > asoc->strreset_inseq) {Quoted 8 lines
net/sctp/stream.c struct sctp_chunk *sctp_process_strreset_inreq( · line 499
Quoted 5 lines
net/sctp/stream.c +5
-0+ result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }else if (request_seq = asoc->strreset_inseq) { + asoc->strreset_inseq++; + }I guess I already asked this, but.. why
request_seq<asoc->strreset_inseqis allowed?Quoted 6 lines
we can not just ignore or response with ERR.
rfc6525#section-5.2.1:... If the received RE-CONFIG chunk contains at least
one request and based on the analysis of the Re-configuration Request Sequence Numbers this is the last received RE-CONFIG chunk (i.e., a^^^^^^^^^^^^^Quoted 2 lines
retransmission), the same RE-CONFIG chunk MUST to be sent back in response, as it was earlier.
That means we should only re-process that *last* reconf request, and not just any old one. My understanding is that we need something like:
net/sctp/stream.c +4
-0+ }else if (request_seq < asoc->strreset_inseq-1 ) { + result =SCTP_STRRESET_ERR_BAD_SEQNO ; + goto out; + }Quoted 5 lines
Quoted 2 lines
And then this makes it evident that we have to handle
request_seqas serial numbers (like TSNs are handled).Got you.
Here is actually also a replay attack. If a duplicate request happens:
Yep.
Quoted 10 lines
In sender side, If the request is not yet acked, it will just process the response as usual. If It's acked already, It will drop the duplicate response as no matched
asoc->strreset_chunkany more. It's safe.But in receiver side. It will process stream/asoc again when receiving a duplicate request. If receiver side has processed some data chunks and tsn/ssn have been increased before this. we shouldn't process this request, but only send back a response with the original result. The problem is that we didn't save the result of last request.
Quoted 5 lines
Sender will stop sending DATA while the reset is happening. We probably can use the "first DATA" as a trigger to then free the response chunk in receiver, or the next request (as it can't have 2 requests at the same, issuing the 2nd one means it got the ack for the previous one), whichever happens first.
for the next request, just check (request_seq = asoc->strreset_inseq-1) as you said above.
as for the "first DATA", maybe check (the right instreams' ssn = 0) (this issue not only exists on this patch (resetassoc),
but also on addstrm/resetstream).
Thanks.
Quoted 85 lines
Quoted 85 lines
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
net/sctp/stream.c +59
-1+ +if (!(asoc->strreset_enable &SCTP_ENABLE_RESET_ASSOC_REQ )) + goto out; + +if (asoc->strreset_outstanding) { + result =SCTP_STRRESET_ERR_IN_PROGRESS ; + goto out; + } + +/* G3: The same processing as though a SACK chunk with no gap report +* and a cumulative TSN ACK of the Sender's Next TSN minus 1 were +* received MUST be performed. +*/ + max_tsn_seen =sctp_tsnmap_get_max_tsn_seen (&asoc->peer.tsn_map); +sctp_ulpq_reasm_flushtsn (&asoc->ulpq, max_tsn_seen); +sctp_ulpq_abort_pd (&asoc->ulpq,GFP_ATOMIC ); + +/* G1: Compute an appropriate value for the Receiver's Next TSN -- the +* TSN that the peer should use to send the next DATA chunk. The +* value SHOULD be the smallest TSN not acknowledged by the +* receiver of the request plus 2^31. +*/ + init_tsn =sctp_tsnmap_get_ctsn (&asoc->peer.tsn_map) + (1 <<31 ); +sctp_tsnmap_init (&asoc->peer.tsn_map,SCTP_TSN_MAP_INITIAL , + init_tsn,GFP_ATOMIC ); + +/* G4: The same processing as though a FWD-TSN chunk (as defined in +* [RFC3758]) with all streams affected and a new cumulative TSN +* ACK of the Receiver's Next TSN minus 1 were received MUST be +* performed. +*/ +sctp_outq_free (&asoc->outqueue); + +/* G2: Compute an appropriate value for the local endpoint's next TSN, +* i.e., the next TSN assigned by the receiver of the SSN/TSN reset +* chunk. The value SHOULD be the highest TSN sent by the receiver +* of the request plus 1. +*/ + next_tsn = asoc->next_tsn; + asoc->ctsn_ack_point = next_tsn -1 ; + asoc->adv_peer_ack_point = asoc->ctsn_ack_point; + +/* G5: The next expected and outgoing SSNs MUST be reset to 0 for all +* incoming and outgoing streams. +*/ +for (i =0 ; i < stream->outcnt; i++) + stream->out[i].ssn =0 ; +for (i =0 ; i < stream->incnt; i++) + stream->in[i].ssn =0 ; + + result =SCTP_STRRESET_PERFORMED ; + + *evp =sctp_ulpevent_make_assoc_reset_event (asoc,0 , init_tsn, + next_tsn,GFP_ATOMIC ); + +out: +return sctp_make_strreset_tsnresp (asoc, result, request_seq, + next_tsn, init_tsn); +} --2.1.0
Quoted 10 lines
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Xin Long
maintainerQuoted 10 lines · Xin Long
Patch 2/7, 4/7, 5/7, 6/7 are to implement the process of asoc reset request, add streams requests and all kinds of responses.
Patch 1/7 and 3/7 are ahead of 2/7 and 4/7 to add two event notification for asoc reset and add streams.
Patch 7/7 is the last patch for implementing rfc6525 sctp stream reconf to add sysctl and sockopt interface for users to enable sctp stream reconf.
After this patchset, sctp stream reconf will be able to work as rfc6525.
Attachments are the scripts I used to do tests for all patchsets, including the scripts on bsd side when doing some interactivity tests with bsd.
David Miller
maintainerFrom: Xin Long <[email protected]>
Date: Fri, 10 Mar 2017 12:11:05 +0800
Quoted 11 lines
Patch 2/7, 4/7, 5/7, 6/7 are to implement the process of asoc reset request, add streams requests and all kinds of responses.
Patch 1/7 and 3/7 are ahead of 2/7 and 4/7 to add two event notification for asoc reset and add streams.
Patch 7/7 is the last patch for implementing rfc6525 sctp stream reconf to add sysctl and sockopt interface for users to enable sctp stream reconf.
After this patchset, sctp stream reconf will be able to work as rfc6525.
Quoted 10 lines
v1->v2:
- put these into a smaller group.
- rename the titles of the commits and improve some changelogs.
- improvesctp_chunk_lookup_strreset_paramand reuse it in patch 4/7.
- process addstrm outreq as the ack of in addstrm inreq ifstrreset_chunkis not NULL in patch 4/7.
- remove the stream alloc when sending addstrm inreq, and the process in peer will response it by sending a addstrm out request back in patch 5/7.
- adjust the process of addstrm in resp to fit in the codes that only alloc streams through addstrm outreq in patch 6/7.
Series applied, thanks.