Skip to content

Commit 7a090b0

Browse files
lxindavem330
authored andcommitted
sctp: add stream reconf primitive
This patch is to add a primitive based on sctp primitive frame for sending stream reconf request. It works as the other primitives, and create a SCTP_CMD_REPLY command to send the request chunk out. sctp_primitive_RECONF would be the api to send a reconf request chunk. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7b9438d commit 7a090b0

File tree

6 files changed

+41
-1
lines changed

6 files changed

+41
-1
lines changed

include/net/sctp/constants.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ typedef enum {
114114
SCTP_PRIMITIVE_SEND,
115115
SCTP_PRIMITIVE_REQUESTHEARTBEAT,
116116
SCTP_PRIMITIVE_ASCONF,
117+
SCTP_PRIMITIVE_RECONF,
117118
} sctp_event_primitive_t;
118119

119-
#define SCTP_EVENT_PRIMITIVE_MAX SCTP_PRIMITIVE_ASCONF
120+
#define SCTP_EVENT_PRIMITIVE_MAX SCTP_PRIMITIVE_RECONF
120121
#define SCTP_NUM_PRIMITIVE_TYPES (SCTP_EVENT_PRIMITIVE_MAX + 1)
121122

122123
/* We define here a utility type for manipulating subtypes.

include/net/sctp/sctp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ int sctp_primitive_ABORT(struct net *, struct sctp_association *, void *arg);
141141
int sctp_primitive_SEND(struct net *, struct sctp_association *, void *arg);
142142
int sctp_primitive_REQUESTHEARTBEAT(struct net *, struct sctp_association *, void *arg);
143143
int sctp_primitive_ASCONF(struct net *, struct sctp_association *, void *arg);
144+
int sctp_primitive_RECONF(struct net *net, struct sctp_association *asoc,
145+
void *arg);
144146

145147
/*
146148
* sctp/input.c

include/net/sctp/sm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ sctp_state_fn_t sctp_sf_error_shutdown;
157157
sctp_state_fn_t sctp_sf_ignore_primitive;
158158
sctp_state_fn_t sctp_sf_do_prm_requestheartbeat;
159159
sctp_state_fn_t sctp_sf_do_prm_asconf;
160+
sctp_state_fn_t sctp_sf_do_prm_reconf;
160161

161162
/* Prototypes for other event state functions. */
162163
sctp_state_fn_t sctp_sf_do_no_pending_tsn;

net/sctp/primitive.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,6 @@ DECLARE_PRIMITIVE(REQUESTHEARTBEAT);
211211
*/
212212

213213
DECLARE_PRIMITIVE(ASCONF);
214+
215+
/* RE-CONFIG 5.1 */
216+
DECLARE_PRIMITIVE(RECONF);

net/sctp/sm_statefuns.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5185,6 +5185,19 @@ sctp_disposition_t sctp_sf_do_prm_asconf(struct net *net,
51855185
return SCTP_DISPOSITION_CONSUME;
51865186
}
51875187

5188+
/* RE-CONFIG Section 5.1 RECONF Chunk Procedures */
5189+
sctp_disposition_t sctp_sf_do_prm_reconf(struct net *net,
5190+
const struct sctp_endpoint *ep,
5191+
const struct sctp_association *asoc,
5192+
const sctp_subtype_t type,
5193+
void *arg, sctp_cmd_seq_t *commands)
5194+
{
5195+
struct sctp_chunk *chunk = arg;
5196+
5197+
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(chunk));
5198+
return SCTP_DISPOSITION_CONSUME;
5199+
}
5200+
51885201
/*
51895202
* Ignore the primitive event
51905203
*

net/sctp/sm_statetable.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,25 @@ chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
643643
TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
644644
} /* TYPE_SCTP_PRIMITIVE_ASCONF */
645645

646+
#define TYPE_SCTP_PRIMITIVE_RECONF { \
647+
/* SCTP_STATE_CLOSED */ \
648+
TYPE_SCTP_FUNC(sctp_sf_error_closed), \
649+
/* SCTP_STATE_COOKIE_WAIT */ \
650+
TYPE_SCTP_FUNC(sctp_sf_error_closed), \
651+
/* SCTP_STATE_COOKIE_ECHOED */ \
652+
TYPE_SCTP_FUNC(sctp_sf_error_closed), \
653+
/* SCTP_STATE_ESTABLISHED */ \
654+
TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
655+
/* SCTP_STATE_SHUTDOWN_PENDING */ \
656+
TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
657+
/* SCTP_STATE_SHUTDOWN_SENT */ \
658+
TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
659+
/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
660+
TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
661+
/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
662+
TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
663+
} /* TYPE_SCTP_PRIMITIVE_RECONF */
664+
646665
/* The primary index for this table is the primitive type.
647666
* The secondary index for this table is the state.
648667
*/
@@ -653,6 +672,7 @@ static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPE
653672
TYPE_SCTP_PRIMITIVE_SEND,
654673
TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
655674
TYPE_SCTP_PRIMITIVE_ASCONF,
675+
TYPE_SCTP_PRIMITIVE_RECONF,
656676
};
657677

658678
#define TYPE_SCTP_OTHER_NO_PENDING_TSN { \

0 commit comments

Comments
 (0)