1 /* SCTP kernel implementation
2 * (C) Copyright IBM Corp. 2001, 2004
3 * Copyright (c) 1999-2000 Cisco, Inc.
4 * Copyright (c) 1999-2001 Motorola, Inc.
5 * Copyright (c) 2001 Intel Corp.
7 * This file is part of the SCTP kernel implementation
9 * These functions manipulate sctp tsn mapping array.
11 * This SCTP implementation is free software;
12 * you can redistribute it and/or modify it under the terms of
13 * the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
17 * This SCTP implementation is distributed in the hope that it
18 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
19 * ************************
20 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 * See the GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GNU CC; see the file COPYING. If not, see
25 * <http://www.gnu.org/licenses/>.
27 * Please send any bug reports or fixes you make to the
29 * lksctp developers <linux-sctp@vger.kernel.org>
31 * Written or modified by:
32 * Xin Long <lucien.xin@gmail.com>
35 #include <net/sctp/sctp.h>
36 #include <net/sctp/sm.h>
38 int sctp_stream_new(struct sctp_association
*asoc
, gfp_t gfp
)
40 struct sctp_stream
*stream
;
43 stream
= kzalloc(sizeof(*stream
), gfp
);
47 stream
->outcnt
= asoc
->c
.sinit_num_ostreams
;
48 stream
->out
= kcalloc(stream
->outcnt
, sizeof(*stream
->out
), gfp
);
53 for (i
= 0; i
< stream
->outcnt
; i
++)
54 stream
->out
[i
].state
= SCTP_STREAM_OPEN
;
56 asoc
->stream
= stream
;
61 int sctp_stream_init(struct sctp_association
*asoc
, gfp_t gfp
)
63 struct sctp_stream
*stream
= asoc
->stream
;
66 /* Initial stream->out size may be very big, so free it and alloc
67 * a new one with new outcnt to save memory.
70 stream
->outcnt
= asoc
->c
.sinit_num_ostreams
;
71 stream
->out
= kcalloc(stream
->outcnt
, sizeof(*stream
->out
), gfp
);
75 for (i
= 0; i
< stream
->outcnt
; i
++)
76 stream
->out
[i
].state
= SCTP_STREAM_OPEN
;
78 stream
->incnt
= asoc
->c
.sinit_max_instreams
;
79 stream
->in
= kcalloc(stream
->incnt
, sizeof(*stream
->in
), gfp
);
94 void sctp_stream_free(struct sctp_stream
*stream
)
96 if (unlikely(!stream
))
104 void sctp_stream_clear(struct sctp_stream
*stream
)
108 for (i
= 0; i
< stream
->outcnt
; i
++)
109 stream
->out
[i
].ssn
= 0;
111 for (i
= 0; i
< stream
->incnt
; i
++)
112 stream
->in
[i
].ssn
= 0;
115 static int sctp_send_reconf(struct sctp_association
*asoc
,
116 struct sctp_chunk
*chunk
)
118 struct net
*net
= sock_net(asoc
->base
.sk
);
121 retval
= sctp_primitive_RECONF(net
, asoc
, chunk
);
123 sctp_chunk_free(chunk
);
128 int sctp_send_reset_streams(struct sctp_association
*asoc
,
129 struct sctp_reset_streams
*params
)
131 struct sctp_stream
*stream
= asoc
->stream
;
132 __u16 i
, str_nums
, *str_list
;
133 struct sctp_chunk
*chunk
;
134 int retval
= -EINVAL
;
137 if (!asoc
->peer
.reconf_capable
||
138 !(asoc
->strreset_enable
& SCTP_ENABLE_RESET_STREAM_REQ
)) {
139 retval
= -ENOPROTOOPT
;
143 if (asoc
->strreset_outstanding
) {
144 retval
= -EINPROGRESS
;
148 out
= params
->srs_flags
& SCTP_STREAM_RESET_OUTGOING
;
149 in
= params
->srs_flags
& SCTP_STREAM_RESET_INCOMING
;
153 str_nums
= params
->srs_number_streams
;
154 str_list
= params
->srs_stream_list
;
156 for (i
= 0; i
< str_nums
; i
++)
157 if (str_list
[i
] >= stream
->outcnt
)
161 for (i
= 0; i
< str_nums
; i
++)
162 if (str_list
[i
] >= stream
->incnt
)
165 for (i
= 0; i
< str_nums
; i
++)
166 str_list
[i
] = htons(str_list
[i
]);
168 chunk
= sctp_make_strreset_req(asoc
, str_nums
, str_list
, out
, in
);
170 for (i
= 0; i
< str_nums
; i
++)
171 str_list
[i
] = ntohs(str_list
[i
]);
180 for (i
= 0; i
< str_nums
; i
++)
181 stream
->out
[str_list
[i
]].state
=
184 for (i
= 0; i
< stream
->outcnt
; i
++)
185 stream
->out
[i
].state
= SCTP_STREAM_CLOSED
;
188 asoc
->strreset_chunk
= chunk
;
189 sctp_chunk_hold(asoc
->strreset_chunk
);
191 retval
= sctp_send_reconf(asoc
, chunk
);
193 sctp_chunk_put(asoc
->strreset_chunk
);
194 asoc
->strreset_chunk
= NULL
;
199 for (i
= 0; i
< str_nums
; i
++)
200 stream
->out
[str_list
[i
]].state
=
203 for (i
= 0; i
< stream
->outcnt
; i
++)
204 stream
->out
[i
].state
= SCTP_STREAM_OPEN
;
209 asoc
->strreset_outstanding
= out
+ in
;
215 int sctp_send_reset_assoc(struct sctp_association
*asoc
)
217 struct sctp_chunk
*chunk
= NULL
;
221 if (!asoc
->peer
.reconf_capable
||
222 !(asoc
->strreset_enable
& SCTP_ENABLE_RESET_ASSOC_REQ
))
225 if (asoc
->strreset_outstanding
)
228 chunk
= sctp_make_strreset_tsnreq(asoc
);
232 /* Block further xmit of data until this request is completed */
233 for (i
= 0; i
< asoc
->stream
->outcnt
; i
++)
234 asoc
->stream
->out
[i
].state
= SCTP_STREAM_CLOSED
;
236 asoc
->strreset_chunk
= chunk
;
237 sctp_chunk_hold(asoc
->strreset_chunk
);
239 retval
= sctp_send_reconf(asoc
, chunk
);
241 sctp_chunk_put(asoc
->strreset_chunk
);
242 asoc
->strreset_chunk
= NULL
;
244 for (i
= 0; i
< asoc
->stream
->outcnt
; i
++)
245 asoc
->stream
->out
[i
].state
= SCTP_STREAM_OPEN
;
250 asoc
->strreset_outstanding
= 1;
255 int sctp_send_add_streams(struct sctp_association
*asoc
,
256 struct sctp_add_streams
*params
)
258 struct sctp_stream
*stream
= asoc
->stream
;
259 struct sctp_chunk
*chunk
= NULL
;
260 int retval
= -ENOMEM
;
264 if (!asoc
->peer
.reconf_capable
||
265 !(asoc
->strreset_enable
& SCTP_ENABLE_CHANGE_ASSOC_REQ
)) {
266 retval
= -ENOPROTOOPT
;
270 if (asoc
->strreset_outstanding
) {
271 retval
= -EINPROGRESS
;
275 out
= params
->sas_outstrms
;
276 in
= params
->sas_instrms
;
277 outcnt
= stream
->outcnt
+ out
;
278 incnt
= stream
->incnt
+ in
;
279 if (outcnt
> SCTP_MAX_STREAM
|| incnt
> SCTP_MAX_STREAM
||
286 struct sctp_stream_out
*streamout
;
288 streamout
= krealloc(stream
->out
, outcnt
* sizeof(*streamout
),
293 memset(streamout
+ stream
->outcnt
, 0, out
* sizeof(*streamout
));
294 stream
->out
= streamout
;
297 chunk
= sctp_make_strreset_addstrm(asoc
, out
, in
);
301 asoc
->strreset_chunk
= chunk
;
302 sctp_chunk_hold(asoc
->strreset_chunk
);
304 retval
= sctp_send_reconf(asoc
, chunk
);
306 sctp_chunk_put(asoc
->strreset_chunk
);
307 asoc
->strreset_chunk
= NULL
;
311 stream
->incnt
= incnt
;
312 stream
->outcnt
= outcnt
;
314 asoc
->strreset_outstanding
= !!out
+ !!in
;
320 static sctp_paramhdr_t
*sctp_chunk_lookup_strreset_param(
321 struct sctp_association
*asoc
, __u32 resp_seq
,
324 struct sctp_chunk
*chunk
= asoc
->strreset_chunk
;
325 struct sctp_reconf_chunk
*hdr
;
326 union sctp_params param
;
331 hdr
= (struct sctp_reconf_chunk
*)chunk
->chunk_hdr
;
332 sctp_walk_params(param
, hdr
, params
) {
333 /* sctp_strreset_tsnreq is actually the basic structure
334 * of all stream reconf params, so it's safe to use it
335 * to access request_seq.
337 struct sctp_strreset_tsnreq
*req
= param
.v
;
339 if ((!resp_seq
|| req
->request_seq
== resp_seq
) &&
340 (!type
|| type
== req
->param_hdr
.type
))
347 struct sctp_chunk
*sctp_process_strreset_outreq(
348 struct sctp_association
*asoc
,
349 union sctp_params param
,
350 struct sctp_ulpevent
**evp
)
352 struct sctp_strreset_outreq
*outreq
= param
.v
;
353 struct sctp_stream
*stream
= asoc
->stream
;
354 __u16 i
, nums
, flags
= 0, *str_p
= NULL
;
355 __u32 result
= SCTP_STRRESET_DENIED
;
358 request_seq
= ntohl(outreq
->request_seq
);
360 if (ntohl(outreq
->send_reset_at_tsn
) >
361 sctp_tsnmap_get_ctsn(&asoc
->peer
.tsn_map
)) {
362 result
= SCTP_STRRESET_IN_PROGRESS
;
366 if (request_seq
> asoc
->strreset_inseq
) {
367 result
= SCTP_STRRESET_ERR_BAD_SEQNO
;
369 } else if (request_seq
== asoc
->strreset_inseq
) {
370 asoc
->strreset_inseq
++;
373 /* Check strreset_enable after inseq inc, as sender cannot tell
374 * the peer doesn't enable strreset after receiving response with
375 * result denied, as well as to keep consistent with bsd.
377 if (!(asoc
->strreset_enable
& SCTP_ENABLE_RESET_STREAM_REQ
))
380 if (asoc
->strreset_chunk
) {
381 if (!sctp_chunk_lookup_strreset_param(
382 asoc
, outreq
->response_seq
,
383 SCTP_PARAM_RESET_IN_REQUEST
)) {
384 /* same process with outstanding isn't 0 */
385 result
= SCTP_STRRESET_ERR_IN_PROGRESS
;
389 asoc
->strreset_outstanding
--;
390 asoc
->strreset_outseq
++;
392 if (!asoc
->strreset_outstanding
) {
393 struct sctp_transport
*t
;
395 t
= asoc
->strreset_chunk
->transport
;
396 if (del_timer(&t
->reconf_timer
))
397 sctp_transport_put(t
);
399 sctp_chunk_put(asoc
->strreset_chunk
);
400 asoc
->strreset_chunk
= NULL
;
403 flags
= SCTP_STREAM_RESET_INCOMING_SSN
;
406 nums
= (ntohs(param
.p
->length
) - sizeof(*outreq
)) / 2;
408 str_p
= outreq
->list_of_streams
;
409 for (i
= 0; i
< nums
; i
++) {
410 if (ntohs(str_p
[i
]) >= stream
->incnt
) {
411 result
= SCTP_STRRESET_ERR_WRONG_SSN
;
416 for (i
= 0; i
< nums
; i
++)
417 stream
->in
[ntohs(str_p
[i
])].ssn
= 0;
419 for (i
= 0; i
< stream
->incnt
; i
++)
420 stream
->in
[i
].ssn
= 0;
423 result
= SCTP_STRRESET_PERFORMED
;
425 *evp
= sctp_ulpevent_make_stream_reset_event(asoc
,
426 flags
| SCTP_STREAM_RESET_OUTGOING_SSN
, nums
, str_p
,
430 return sctp_make_strreset_resp(asoc
, result
, request_seq
);
433 struct sctp_chunk
*sctp_process_strreset_inreq(
434 struct sctp_association
*asoc
,
435 union sctp_params param
,
436 struct sctp_ulpevent
**evp
)
438 struct sctp_strreset_inreq
*inreq
= param
.v
;
439 struct sctp_stream
*stream
= asoc
->stream
;
440 __u32 result
= SCTP_STRRESET_DENIED
;
441 struct sctp_chunk
*chunk
= NULL
;
442 __u16 i
, nums
, *str_p
;
445 request_seq
= ntohl(inreq
->request_seq
);
446 if (request_seq
> asoc
->strreset_inseq
) {
447 result
= SCTP_STRRESET_ERR_BAD_SEQNO
;
449 } else if (request_seq
== asoc
->strreset_inseq
) {
450 asoc
->strreset_inseq
++;
453 if (!(asoc
->strreset_enable
& SCTP_ENABLE_RESET_STREAM_REQ
))
456 if (asoc
->strreset_outstanding
) {
457 result
= SCTP_STRRESET_ERR_IN_PROGRESS
;
461 nums
= (ntohs(param
.p
->length
) - sizeof(*inreq
)) / 2;
462 str_p
= inreq
->list_of_streams
;
463 for (i
= 0; i
< nums
; i
++) {
464 if (ntohs(str_p
[i
]) >= stream
->outcnt
) {
465 result
= SCTP_STRRESET_ERR_WRONG_SSN
;
470 chunk
= sctp_make_strreset_req(asoc
, nums
, str_p
, 1, 0);
475 for (i
= 0; i
< nums
; i
++)
476 stream
->out
[ntohs(str_p
[i
])].state
=
479 for (i
= 0; i
< stream
->outcnt
; i
++)
480 stream
->out
[i
].state
= SCTP_STREAM_CLOSED
;
482 asoc
->strreset_chunk
= chunk
;
483 asoc
->strreset_outstanding
= 1;
484 sctp_chunk_hold(asoc
->strreset_chunk
);
486 *evp
= sctp_ulpevent_make_stream_reset_event(asoc
,
487 SCTP_STREAM_RESET_INCOMING_SSN
, nums
, str_p
, GFP_ATOMIC
);
491 chunk
= sctp_make_strreset_resp(asoc
, result
, request_seq
);
496 struct sctp_chunk
*sctp_process_strreset_tsnreq(
497 struct sctp_association
*asoc
,
498 union sctp_params param
,
499 struct sctp_ulpevent
**evp
)
501 __u32 init_tsn
= 0, next_tsn
= 0, max_tsn_seen
;
502 struct sctp_strreset_tsnreq
*tsnreq
= param
.v
;
503 struct sctp_stream
*stream
= asoc
->stream
;
504 __u32 result
= SCTP_STRRESET_DENIED
;
508 request_seq
= ntohl(tsnreq
->request_seq
);
509 if (request_seq
> asoc
->strreset_inseq
) {
510 result
= SCTP_STRRESET_ERR_BAD_SEQNO
;
512 } else if (request_seq
== asoc
->strreset_inseq
) {
513 asoc
->strreset_inseq
++;
516 if (!(asoc
->strreset_enable
& SCTP_ENABLE_RESET_ASSOC_REQ
))
519 if (asoc
->strreset_outstanding
) {
520 result
= SCTP_STRRESET_ERR_IN_PROGRESS
;
524 /* G3: The same processing as though a SACK chunk with no gap report
525 * and a cumulative TSN ACK of the Sender's Next TSN minus 1 were
526 * received MUST be performed.
528 max_tsn_seen
= sctp_tsnmap_get_max_tsn_seen(&asoc
->peer
.tsn_map
);
529 sctp_ulpq_reasm_flushtsn(&asoc
->ulpq
, max_tsn_seen
);
530 sctp_ulpq_abort_pd(&asoc
->ulpq
, GFP_ATOMIC
);
532 /* G1: Compute an appropriate value for the Receiver's Next TSN -- the
533 * TSN that the peer should use to send the next DATA chunk. The
534 * value SHOULD be the smallest TSN not acknowledged by the
535 * receiver of the request plus 2^31.
537 init_tsn
= sctp_tsnmap_get_ctsn(&asoc
->peer
.tsn_map
) + (1 << 31);
538 sctp_tsnmap_init(&asoc
->peer
.tsn_map
, SCTP_TSN_MAP_INITIAL
,
539 init_tsn
, GFP_ATOMIC
);
541 /* G4: The same processing as though a FWD-TSN chunk (as defined in
542 * [RFC3758]) with all streams affected and a new cumulative TSN
543 * ACK of the Receiver's Next TSN minus 1 were received MUST be
546 sctp_outq_free(&asoc
->outqueue
);
548 /* G2: Compute an appropriate value for the local endpoint's next TSN,
549 * i.e., the next TSN assigned by the receiver of the SSN/TSN reset
550 * chunk. The value SHOULD be the highest TSN sent by the receiver
551 * of the request plus 1.
553 next_tsn
= asoc
->next_tsn
;
554 asoc
->ctsn_ack_point
= next_tsn
- 1;
555 asoc
->adv_peer_ack_point
= asoc
->ctsn_ack_point
;
557 /* G5: The next expected and outgoing SSNs MUST be reset to 0 for all
558 * incoming and outgoing streams.
560 for (i
= 0; i
< stream
->outcnt
; i
++)
561 stream
->out
[i
].ssn
= 0;
562 for (i
= 0; i
< stream
->incnt
; i
++)
563 stream
->in
[i
].ssn
= 0;
565 result
= SCTP_STRRESET_PERFORMED
;
567 *evp
= sctp_ulpevent_make_assoc_reset_event(asoc
, 0, init_tsn
,
568 next_tsn
, GFP_ATOMIC
);
571 return sctp_make_strreset_tsnresp(asoc
, result
, request_seq
,
575 struct sctp_chunk
*sctp_process_strreset_addstrm_out(
576 struct sctp_association
*asoc
,
577 union sctp_params param
,
578 struct sctp_ulpevent
**evp
)
580 struct sctp_strreset_addstrm
*addstrm
= param
.v
;
581 struct sctp_stream
*stream
= asoc
->stream
;
582 __u32 result
= SCTP_STRRESET_DENIED
;
583 struct sctp_stream_in
*streamin
;
584 __u32 request_seq
, incnt
;
587 request_seq
= ntohl(addstrm
->request_seq
);
588 if (request_seq
> asoc
->strreset_inseq
) {
589 result
= SCTP_STRRESET_ERR_BAD_SEQNO
;
591 } else if (request_seq
== asoc
->strreset_inseq
) {
592 asoc
->strreset_inseq
++;
595 if (!(asoc
->strreset_enable
& SCTP_ENABLE_CHANGE_ASSOC_REQ
))
598 if (asoc
->strreset_chunk
) {
599 if (!sctp_chunk_lookup_strreset_param(
600 asoc
, 0, SCTP_PARAM_RESET_ADD_IN_STREAMS
)) {
601 /* same process with outstanding isn't 0 */
602 result
= SCTP_STRRESET_ERR_IN_PROGRESS
;
606 asoc
->strreset_outstanding
--;
607 asoc
->strreset_outseq
++;
609 if (!asoc
->strreset_outstanding
) {
610 struct sctp_transport
*t
;
612 t
= asoc
->strreset_chunk
->transport
;
613 if (del_timer(&t
->reconf_timer
))
614 sctp_transport_put(t
);
616 sctp_chunk_put(asoc
->strreset_chunk
);
617 asoc
->strreset_chunk
= NULL
;
621 in
= ntohs(addstrm
->number_of_streams
);
622 incnt
= stream
->incnt
+ in
;
623 if (!in
|| incnt
> SCTP_MAX_STREAM
)
626 streamin
= krealloc(stream
->in
, incnt
* sizeof(*streamin
),
631 memset(streamin
+ stream
->incnt
, 0, in
* sizeof(*streamin
));
632 stream
->in
= streamin
;
633 stream
->incnt
= incnt
;
635 result
= SCTP_STRRESET_PERFORMED
;
637 *evp
= sctp_ulpevent_make_stream_change_event(asoc
,
638 0, ntohs(addstrm
->number_of_streams
), 0, GFP_ATOMIC
);
641 return sctp_make_strreset_resp(asoc
, result
, request_seq
);
644 struct sctp_chunk
*sctp_process_strreset_addstrm_in(
645 struct sctp_association
*asoc
,
646 union sctp_params param
,
647 struct sctp_ulpevent
**evp
)
649 struct sctp_strreset_addstrm
*addstrm
= param
.v
;
650 struct sctp_stream
*stream
= asoc
->stream
;
651 __u32 result
= SCTP_STRRESET_DENIED
;
652 struct sctp_stream_out
*streamout
;
653 struct sctp_chunk
*chunk
= NULL
;
654 __u32 request_seq
, outcnt
;
657 request_seq
= ntohl(addstrm
->request_seq
);
658 if (request_seq
> asoc
->strreset_inseq
) {
659 result
= SCTP_STRRESET_ERR_BAD_SEQNO
;
661 } else if (request_seq
== asoc
->strreset_inseq
) {
662 asoc
->strreset_inseq
++;
665 if (!(asoc
->strreset_enable
& SCTP_ENABLE_CHANGE_ASSOC_REQ
))
668 if (asoc
->strreset_outstanding
) {
669 result
= SCTP_STRRESET_ERR_IN_PROGRESS
;
673 out
= ntohs(addstrm
->number_of_streams
);
674 outcnt
= stream
->outcnt
+ out
;
675 if (!out
|| outcnt
> SCTP_MAX_STREAM
)
678 streamout
= krealloc(stream
->out
, outcnt
* sizeof(*streamout
),
683 memset(streamout
+ stream
->outcnt
, 0, out
* sizeof(*streamout
));
684 stream
->out
= streamout
;
686 chunk
= sctp_make_strreset_addstrm(asoc
, out
, 0);
690 asoc
->strreset_chunk
= chunk
;
691 asoc
->strreset_outstanding
= 1;
692 sctp_chunk_hold(asoc
->strreset_chunk
);
694 stream
->outcnt
= outcnt
;
696 *evp
= sctp_ulpevent_make_stream_change_event(asoc
,
697 0, 0, ntohs(addstrm
->number_of_streams
), GFP_ATOMIC
);
701 chunk
= sctp_make_strreset_resp(asoc
, result
, request_seq
);
706 struct sctp_chunk
*sctp_process_strreset_resp(
707 struct sctp_association
*asoc
,
708 union sctp_params param
,
709 struct sctp_ulpevent
**evp
)
711 struct sctp_strreset_resp
*resp
= param
.v
;
712 struct sctp_stream
*stream
= asoc
->stream
;
713 struct sctp_transport
*t
;
714 __u16 i
, nums
, flags
= 0;
715 sctp_paramhdr_t
*req
;
718 req
= sctp_chunk_lookup_strreset_param(asoc
, resp
->response_seq
, 0);
722 result
= ntohl(resp
->result
);
723 if (result
!= SCTP_STRRESET_PERFORMED
) {
724 /* if in progress, do nothing but retransmit */
725 if (result
== SCTP_STRRESET_IN_PROGRESS
)
727 else if (result
== SCTP_STRRESET_DENIED
)
728 flags
= SCTP_STREAM_RESET_DENIED
;
730 flags
= SCTP_STREAM_RESET_FAILED
;
733 if (req
->type
== SCTP_PARAM_RESET_OUT_REQUEST
) {
734 struct sctp_strreset_outreq
*outreq
;
737 outreq
= (struct sctp_strreset_outreq
*)req
;
738 nums
= (ntohs(outreq
->param_hdr
.length
) - sizeof(*outreq
)) / 2;
740 if (result
== SCTP_STRRESET_PERFORMED
) {
742 str_p
= outreq
->list_of_streams
;
743 for (i
= 0; i
< nums
; i
++)
744 stream
->out
[ntohs(str_p
[i
])].ssn
= 0;
746 for (i
= 0; i
< stream
->outcnt
; i
++)
747 stream
->out
[i
].ssn
= 0;
750 flags
= SCTP_STREAM_RESET_OUTGOING_SSN
;
753 for (i
= 0; i
< stream
->outcnt
; i
++)
754 stream
->out
[i
].state
= SCTP_STREAM_OPEN
;
756 *evp
= sctp_ulpevent_make_stream_reset_event(asoc
, flags
,
757 nums
, str_p
, GFP_ATOMIC
);
758 } else if (req
->type
== SCTP_PARAM_RESET_IN_REQUEST
) {
759 struct sctp_strreset_inreq
*inreq
;
762 /* if the result is performed, it's impossible for inreq */
763 if (result
== SCTP_STRRESET_PERFORMED
)
766 inreq
= (struct sctp_strreset_inreq
*)req
;
767 nums
= (ntohs(inreq
->param_hdr
.length
) - sizeof(*inreq
)) / 2;
769 str_p
= inreq
->list_of_streams
;
770 *evp
= sctp_ulpevent_make_stream_reset_event(asoc
, flags
,
771 nums
, str_p
, GFP_ATOMIC
);
772 } else if (req
->type
== SCTP_PARAM_RESET_TSN_REQUEST
) {
773 struct sctp_strreset_resptsn
*resptsn
;
776 /* check for resptsn, as sctp_verify_reconf didn't do it*/
777 if (ntohs(param
.p
->length
) != sizeof(*resptsn
))
780 resptsn
= (struct sctp_strreset_resptsn
*)resp
;
781 stsn
= ntohl(resptsn
->senders_next_tsn
);
782 rtsn
= ntohl(resptsn
->receivers_next_tsn
);
784 if (result
== SCTP_STRRESET_PERFORMED
) {
785 __u32 mtsn
= sctp_tsnmap_get_max_tsn_seen(
786 &asoc
->peer
.tsn_map
);
788 sctp_ulpq_reasm_flushtsn(&asoc
->ulpq
, mtsn
);
789 sctp_ulpq_abort_pd(&asoc
->ulpq
, GFP_ATOMIC
);
791 sctp_tsnmap_init(&asoc
->peer
.tsn_map
,
792 SCTP_TSN_MAP_INITIAL
,
795 sctp_outq_free(&asoc
->outqueue
);
797 asoc
->next_tsn
= rtsn
;
798 asoc
->ctsn_ack_point
= asoc
->next_tsn
- 1;
799 asoc
->adv_peer_ack_point
= asoc
->ctsn_ack_point
;
801 for (i
= 0; i
< stream
->outcnt
; i
++)
802 stream
->out
[i
].ssn
= 0;
803 for (i
= 0; i
< stream
->incnt
; i
++)
804 stream
->in
[i
].ssn
= 0;
807 for (i
= 0; i
< stream
->outcnt
; i
++)
808 stream
->out
[i
].state
= SCTP_STREAM_OPEN
;
810 *evp
= sctp_ulpevent_make_assoc_reset_event(asoc
, flags
,
811 stsn
, rtsn
, GFP_ATOMIC
);
812 } else if (req
->type
== SCTP_PARAM_RESET_ADD_OUT_STREAMS
) {
813 struct sctp_strreset_addstrm
*addstrm
;
816 addstrm
= (struct sctp_strreset_addstrm
*)req
;
817 nums
= ntohs(addstrm
->number_of_streams
);
818 number
= stream
->outcnt
- nums
;
820 if (result
== SCTP_STRRESET_PERFORMED
)
821 for (i
= number
; i
< stream
->outcnt
; i
++)
822 stream
->out
[i
].state
= SCTP_STREAM_OPEN
;
824 stream
->outcnt
= number
;
826 *evp
= sctp_ulpevent_make_stream_change_event(asoc
, flags
,
827 0, nums
, GFP_ATOMIC
);
828 } else if (req
->type
== SCTP_PARAM_RESET_ADD_IN_STREAMS
) {
829 struct sctp_strreset_addstrm
*addstrm
;
831 /* if the result is performed, it's impossible for addstrm in
834 if (result
== SCTP_STRRESET_PERFORMED
)
837 addstrm
= (struct sctp_strreset_addstrm
*)req
;
838 nums
= ntohs(addstrm
->number_of_streams
);
840 *evp
= sctp_ulpevent_make_stream_change_event(asoc
, flags
,
841 nums
, 0, GFP_ATOMIC
);
844 asoc
->strreset_outstanding
--;
845 asoc
->strreset_outseq
++;
847 /* remove everything for this reconf request */
848 if (!asoc
->strreset_outstanding
) {
849 t
= asoc
->strreset_chunk
->transport
;
850 if (del_timer(&t
->reconf_timer
))
851 sctp_transport_put(t
);
853 sctp_chunk_put(asoc
->strreset_chunk
);
854 asoc
->strreset_chunk
= NULL
;