Skip to contentSkip to conversation

sctp: implement receiver side procedures for the Stream

PATCH In review Wei Yongjun 1 participant 1 message Mar 9, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/6 sctp: implement receiver side procedures for the Stream

STREAM-RESET Extension Section 4.2.1:

Upon reception of a Stream Reset Chunk each parameter within it should be processed. If some parameters have to be sent back, they MUST all be put into one STREAM RESET chunk. If the received STREAM RESET chunk contains at least one request parameter, a SACK chunk MUST be sent back and MAY be bundled with the STREAM RESET chunk. If the received STREAM RESET chunk contains at least one request and based on the analysis of the Stream Reset Request Sequence Numbers this is the last received STREAM RESET chunk, the same STREAM RESET chunk has to be sent back in response as earlier.

---
 include/net/sctp/constants.h |    5 +-
 include/net/sctp/sm.h        |    3 +
 include/net/sctp/structs.h   |    9 +
 include/net/sctp/ulpevent.h  |    3 +
 net/sctp/associola.c         |    4 +
 net/sctp/sm_make_chunk.c     |  595 ++++++++++++++++++++++++++++++++++++++++++
 net/sctp/sm_statefuns.c      |  128 +++++++++
 net/sctp/sm_statetable.c     |   33 +++
 net/sctp/ssnmap.c            |   20 ++
 net/sctp/ulpevent.c          |   27 ++
 10 files changed, 826 insertions(+), 1 deletions(-)
include/net/sctp/constants.h +4 -1
index 85337c2..8568d31 100644
@@ -71,10 +71,13 @@ enum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM };
 
 #define SCTP_NUM_AUTH_CHUNK_TYPES	1
 
+#define SCTP_NUM_STRRST_CHUNK_TYPES	1
+
 #define SCTP_NUM_CHUNK_TYPES		(SCTP_NUM_BASE_CHUNK_TYPES + \
 					 SCTP_NUM_ADDIP_CHUNK_TYPES +\
 					 SCTP_NUM_PRSCTP_CHUNK_TYPES +\
-					 SCTP_NUM_AUTH_CHUNK_TYPES)
+					 SCTP_NUM_AUTH_CHUNK_TYPES +\
+					 SCTP_NUM_STRRST_CHUNK_TYPES)
 
 /* These are the different flavours of event.  */
 typedef enum {
include/net/sctp/sm.h +3 -0
index 4f40111..0883c4b 100644
@@ -146,6 +146,7 @@ sctp_state_fn_t sctp_sf_do_9_2_reshutack;
 sctp_state_fn_t sctp_sf_eat_fwd_tsn;
 sctp_state_fn_t sctp_sf_eat_fwd_tsn_fast;
 sctp_state_fn_t sctp_sf_eat_auth;
+sctp_state_fn_t sctp_sf_do_stream_reset;
 
 /* Prototypes for primitive event state functions.  */
 sctp_state_fn_t sctp_sf_do_prm_asoc;
@@ -267,6 +268,8 @@ struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc);
 struct sctp_chunk *sctp_make_stream_reset(struct sctp_association *asoc,
 					  __u16 flags, __u16 nstreams,
 					  __u16 *streamlist);
+struct sctp_chunk *sctp_process_stream_reset(struct sctp_association *asoc,
+					     struct sctp_chunk *strrst);
 
 void sctp_chunk_assign_tsn(struct sctp_chunk *);
 void sctp_chunk_assign_ssn(struct sctp_chunk *);
include/net/sctp/structs.h +9 -0
index a16d35c..f6d02af 100644
@@ -462,6 +462,11 @@ union sctp_params {
 	struct sctp_chunks_param *chunks;
 	struct sctp_hmac_algo_param *hmac_algo;
 	struct sctp_addip_param *addip;
+	struct sctp_reset_out_req *rstout;
+	struct sctp_reset_in_req *rstin;
+	struct sctp_reset_tsn_req *rsttsn;
+	struct sctp_reset_tsn_res *rstres;
+	struct sctp_add_stream *rstadd;
 };
 
 /* RFC 2960.  Section 3.3.5 Heartbeat.
@@ -505,6 +510,8 @@ struct sctp_ssnmap {
 
 struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
 				    gfp_t gfp);
+struct sctp_ssnmap *sctp_ssnmap_resize(struct sctp_ssnmap *map,
+				       __u16 in, __u16 out, gfp_t gfp);
 void sctp_ssnmap_free(struct sctp_ssnmap *map);
 void sctp_ssnmap_clear(struct sctp_ssnmap *map);
 
@@ -1925,6 +1932,8 @@ struct sctp_association {
 
 	/* Cache the STREAM-RESET chunk last send */
 	struct sctp_chunk *strrst_last_stream_reset;
+	/* Cache the lsat two respone result it send */
+	struct sctp_chunk *strrst_last_reset_response;
 
 	/* Need to send an ECNE Chunk? */
 	char need_ecne;
include/net/sctp/ulpevent.h +3 -0
index 7ea12e8..5596cae 100644
@@ -132,6 +132,9 @@ struct sctp_ulpevent *sctp_ulpevent_make_authkey(
 	const struct sctp_association *asoc, __u16 key_id,
 	__u32 indication, gfp_t gfp);
 
+struct sctp_ulpevent *sctp_ulpevent_make_stream_reset(
+	const struct sctp_association *asoc, __u16 flags, gfp_t gfp);
+
 void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
 	struct msghdr *);
 __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
net/sctp/associola.c +4 -0
index a2e585d..495929a 100644
@@ -450,6 +450,10 @@ void sctp_association_free(struct sctp_association *asoc)
 	if (asoc->addip_last_asconf)
 		sctp_chunk_free(asoc->addip_last_asconf);
 
+	/* Free any cached STREAM-RESET response chunk*/
+	if (asoc->strrst_last_reset_response)
+		sctp_chunk_free(asoc->strrst_last_reset_response);
+
 	/* Free any cached STREAM-RESET chunk. */
 	if (asoc->strrst_last_stream_reset)
 		sctp_chunk_free(asoc->strrst_last_stream_reset);
net/sctp/sm_make_chunk.c +595 -0

604 lines not on this page · raw message

net/sctp/sm_statefuns.c +128 -0

134 lines not on this page · raw message

net/sctp/sm_statetable.c +33 -0
index 40c9472..b86157d 100644
@@ -551,6 +551,34 @@ static const sctp_sm_table_entry_t auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TY
 	TYPE_SCTP_AUTH,
 }; /*state_fn_t auth_chunk_event_table[][] */
 
+#define TYPE_SCTP_STREAM_RESET { \
+	/* SCTP_STATE_EMPTY */ \
+	TYPE_SCTP_FUNC(sctp_sf_ootb), \
+	/* SCTP_STATE_CLOSED */ \
+	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
+	/* SCTP_STATE_COOKIE_WAIT */ \
+	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
+	/* SCTP_STATE_COOKIE_ECHOED */ \
+	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
+	/* SCTP_STATE_ESTABLISHED */ \
+	TYPE_SCTP_FUNC(sctp_sf_do_stream_reset), \
+	/* SCTP_STATE_SHUTDOWN_PENDING */ \
+	TYPE_SCTP_FUNC(sctp_sf_do_stream_reset), \
+	/* SCTP_STATE_SHUTDOWN_SENT */ \
+	TYPE_SCTP_FUNC(sctp_sf_do_stream_reset), \
+	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
+	TYPE_SCTP_FUNC(sctp_sf_do_stream_reset), \
+	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
+	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
+} /* TYPE_SCTP_STREAM_RESET */
+
+/* The primary index for this table is the chunk type.
+ * The secondary index for this table is the state.
+ */
+static const sctp_sm_table_entry_t stream_reset_chunk_event_table[SCTP_NUM_STRRST_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
+	TYPE_SCTP_STREAM_RESET,
+}; /*state_fn_t stream_reset_chunk_event_table[][] */
+
 static const sctp_sm_table_entry_t
 chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
 	/* SCTP_STATE_EMPTY */
@@ -1053,5 +1081,10 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid,
 			return &auth_chunk_event_table[0][state];
 	}
 
+	if (sctp_strrst_enable) {
+		if (cid = SCTP_CID_STREAM_RESET)
+			return &stream_reset_chunk_event_table[0][state];
+	}
+
 	return &chunk_event_table_unknown[state];
 }
net/sctp/ssnmap.c +20 -0
index 737d330..01abf90 100644
@@ -107,6 +107,26 @@ static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
 	return map;
 }
 
+/* Resize the ssnmap to new length. */
+struct sctp_ssnmap *sctp_ssnmap_resize(struct sctp_ssnmap *map,
+					__u16 in, __u16 out, gfp_t gfp)
+{
+	struct sctp_ssnmap *new;
+
+	new = sctp_ssnmap_new(in, out, gfp);
+	if (!new)
+		return NULL;
+
+	memcpy(new->in.ssn, map->in.ssn,
+	       (in > map->in.len) ? map->in.len : in);
+	memcpy(new->out.ssn, map->out.ssn,
+	       (out > map->out.len) ? map->out.len : out);
+
+	sctp_ssnmap_free(map);
+
+	return new;
+}
+
 /* Clear out the ssnmap streams.  */
 void sctp_ssnmap_clear(struct sctp_ssnmap *map)
 {
net/sctp/ulpevent.c +27 -0
index 5f186ca..4a7cc61 100644
@@ -862,6 +862,33 @@ fail:
 }
 
 
+struct sctp_ulpevent *sctp_ulpevent_make_stream_reset(
+	const struct sctp_association *asoc, __u16 flags, gfp_t gfp)
+{
+	struct sctp_ulpevent *event;
+	struct sctp_stream_reset_event *rst;
+	struct sk_buff *skb;
+	__u32 length = sizeof(struct sctp_stream_reset_event);
+
+	event = sctp_ulpevent_new(length, MSG_NOTIFICATION, gfp);
+	if (!event)
+		goto fail;
+
+	skb = sctp_event2skb(event);
+	rst = (struct sctp_stream_reset_event *)skb_put(skb, length);
+
+	rst->strrst_type = SCTP_STREAM_RESET_EVENT;
+	rst->strrst_flags = flags;
+	rst->strrst_length = length;
+
+	sctp_ulpevent_set_owner(event, asoc);
+	rst->strrst_assoc_id = sctp_assoc2id(asoc);
+
+	return event;
+fail:
+	return NULL;
+}
+
 /* Return the notification type, assuming this is a notification
  * event.
  */
Signature · 1 line
1.5.3.8