Skip to content

Commit 107e242

Browse files
lxindavem330
authored andcommitted
sctp: update mid instead of ssn when doing stream and asoc reset
When using idata and doing stream and asoc reset, setting ssn with 0 could only clear the 1st 16 bits of mid. So to make this work for both data and idata, it sets mid with 0 instead of ssn, and also mid_uo for unordered idata also need to be cleared, as said in section 2.3.2 of RFC8260. Signed-off-by: Xin Long <[email protected]> Acked-by: Marcelo R. Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ef4775e commit 107e242

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

net/sctp/stream.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,13 @@ void sctp_stream_clear(struct sctp_stream *stream)
216216
{
217217
int i;
218218

219-
for (i = 0; i < stream->outcnt; i++)
220-
stream->out[i].ssn = 0;
219+
for (i = 0; i < stream->outcnt; i++) {
220+
stream->out[i].mid = 0;
221+
stream->out[i].mid_uo = 0;
222+
}
221223

222224
for (i = 0; i < stream->incnt; i++)
223-
stream->in[i].ssn = 0;
225+
stream->in[i].mid = 0;
224226
}
225227

226228
void sctp_stream_update(struct sctp_stream *stream, struct sctp_stream *new)
@@ -607,10 +609,10 @@ struct sctp_chunk *sctp_process_strreset_outreq(
607609
}
608610

609611
for (i = 0; i < nums; i++)
610-
stream->in[ntohs(str_p[i])].ssn = 0;
612+
stream->in[ntohs(str_p[i])].mid = 0;
611613
} else {
612614
for (i = 0; i < stream->incnt; i++)
613-
stream->in[i].ssn = 0;
615+
stream->in[i].mid = 0;
614616
}
615617

616618
result = SCTP_STRRESET_PERFORMED;
@@ -783,10 +785,12 @@ struct sctp_chunk *sctp_process_strreset_tsnreq(
783785
/* G5: The next expected and outgoing SSNs MUST be reset to 0 for all
784786
* incoming and outgoing streams.
785787
*/
786-
for (i = 0; i < stream->outcnt; i++)
787-
stream->out[i].ssn = 0;
788+
for (i = 0; i < stream->outcnt; i++) {
789+
stream->out[i].mid = 0;
790+
stream->out[i].mid_uo = 0;
791+
}
788792
for (i = 0; i < stream->incnt; i++)
789-
stream->in[i].ssn = 0;
793+
stream->in[i].mid = 0;
790794

791795
result = SCTP_STRRESET_PERFORMED;
792796

@@ -976,11 +980,15 @@ struct sctp_chunk *sctp_process_strreset_resp(
976980

977981
if (result == SCTP_STRRESET_PERFORMED) {
978982
if (nums) {
979-
for (i = 0; i < nums; i++)
980-
stream->out[ntohs(str_p[i])].ssn = 0;
983+
for (i = 0; i < nums; i++) {
984+
stream->out[ntohs(str_p[i])].mid = 0;
985+
stream->out[ntohs(str_p[i])].mid_uo = 0;
986+
}
981987
} else {
982-
for (i = 0; i < stream->outcnt; i++)
983-
stream->out[i].ssn = 0;
988+
for (i = 0; i < stream->outcnt; i++) {
989+
stream->out[i].mid = 0;
990+
stream->out[i].mid_uo = 0;
991+
}
984992
}
985993

986994
flags = SCTP_STREAM_RESET_OUTGOING_SSN;
@@ -1041,10 +1049,12 @@ struct sctp_chunk *sctp_process_strreset_resp(
10411049
asoc->ctsn_ack_point = asoc->next_tsn - 1;
10421050
asoc->adv_peer_ack_point = asoc->ctsn_ack_point;
10431051

1044-
for (i = 0; i < stream->outcnt; i++)
1045-
stream->out[i].ssn = 0;
1052+
for (i = 0; i < stream->outcnt; i++) {
1053+
stream->out[i].mid = 0;
1054+
stream->out[i].mid_uo = 0;
1055+
}
10461056
for (i = 0; i < stream->incnt; i++)
1047-
stream->in[i].ssn = 0;
1057+
stream->in[i].mid = 0;
10481058
}
10491059

10501060
for (i = 0; i < stream->outcnt; i++)

0 commit comments

Comments
 (0)