stream_interleave.c (101cfc9f787d8ca22866a178f2c1684fb10f8c7a) stream_interleave.c (05364ca03cfd419caecb292fede20eb39667eaae)
1/* SCTP kernel implementation
2 * (C) Copyright Red Hat Inc. 2017
3 *
4 * This file is part of the SCTP kernel implementation
5 *
6 * These functions implement sctp stream message interleaving, mostly
7 * including I-DATA and I-FORWARD-TSN chunks process.
8 *

--- 183 unchanged lines hidden (view full) ---

192 struct sk_buff *first_frag = NULL;
193 struct sk_buff *last_frag = NULL;
194 struct sctp_ulpevent *retval;
195 struct sctp_stream_in *sin;
196 struct sk_buff *pos;
197 __u32 next_fsn = 0;
198 int is_last = 0;
199
1/* SCTP kernel implementation
2 * (C) Copyright Red Hat Inc. 2017
3 *
4 * This file is part of the SCTP kernel implementation
5 *
6 * These functions implement sctp stream message interleaving, mostly
7 * including I-DATA and I-FORWARD-TSN chunks process.
8 *

--- 183 unchanged lines hidden (view full) ---

192 struct sk_buff *first_frag = NULL;
193 struct sk_buff *last_frag = NULL;
194 struct sctp_ulpevent *retval;
195 struct sctp_stream_in *sin;
196 struct sk_buff *pos;
197 __u32 next_fsn = 0;
198 int is_last = 0;
199
200 sin = sctp_stream_in(ulpq->asoc, event->stream);
200 sin = sctp_stream_in(&ulpq->asoc->stream, event->stream);
201
202 skb_queue_walk(&ulpq->reasm, pos) {
203 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
204
205 if (cevent->stream < event->stream)
206 continue;
207
208 if (cevent->stream > event->stream ||

--- 64 unchanged lines hidden (view full) ---

273 struct sk_buff *pd_first = NULL;
274 struct sk_buff *pd_last = NULL;
275 struct sctp_stream_in *sin;
276 __u32 next_fsn = 0;
277 __u32 pd_point = 0;
278 __u32 pd_len = 0;
279 __u32 mid = 0;
280
201
202 skb_queue_walk(&ulpq->reasm, pos) {
203 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
204
205 if (cevent->stream < event->stream)
206 continue;
207
208 if (cevent->stream > event->stream ||

--- 64 unchanged lines hidden (view full) ---

273 struct sk_buff *pd_first = NULL;
274 struct sk_buff *pd_last = NULL;
275 struct sctp_stream_in *sin;
276 __u32 next_fsn = 0;
277 __u32 pd_point = 0;
278 __u32 pd_len = 0;
279 __u32 mid = 0;
280
281 sin = sctp_stream_in(ulpq->asoc, event->stream);
281 sin = sctp_stream_in(&ulpq->asoc->stream, event->stream);
282
283 skb_queue_walk(&ulpq->reasm, pos) {
284 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
285
286 if (cevent->stream < event->stream)
287 continue;
288 if (cevent->stream > event->stream)
289 break;

--- 73 unchanged lines hidden (view full) ---

363
364 if (SCTP_DATA_NOT_FRAG == (event->msg_flags & SCTP_DATA_FRAG_MASK)) {
365 event->msg_flags |= MSG_EOR;
366 return event;
367 }
368
369 sctp_intl_store_reasm(ulpq, event);
370
282
283 skb_queue_walk(&ulpq->reasm, pos) {
284 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
285
286 if (cevent->stream < event->stream)
287 continue;
288 if (cevent->stream > event->stream)
289 break;

--- 73 unchanged lines hidden (view full) ---

363
364 if (SCTP_DATA_NOT_FRAG == (event->msg_flags & SCTP_DATA_FRAG_MASK)) {
365 event->msg_flags |= MSG_EOR;
366 return event;
367 }
368
369 sctp_intl_store_reasm(ulpq, event);
370
371 sin = sctp_stream_in(ulpq->asoc, event->stream);
371 sin = sctp_stream_in(&ulpq->asoc->stream, event->stream);
372 if (sin->pd_mode && event->mid == sin->mid &&
373 event->fsn == sin->fsn)
374 retval = sctp_intl_retrieve_partial(ulpq, event);
375
376 if (!retval)
377 retval = sctp_intl_retrieve_reassembled(ulpq, event);
378
379 return retval;

--- 190 unchanged lines hidden (view full) ---

570 struct sk_buff *first_frag = NULL;
571 struct sk_buff *last_frag = NULL;
572 struct sctp_ulpevent *retval;
573 struct sctp_stream_in *sin;
574 struct sk_buff *pos;
575 __u32 next_fsn = 0;
576 int is_last = 0;
577
372 if (sin->pd_mode && event->mid == sin->mid &&
373 event->fsn == sin->fsn)
374 retval = sctp_intl_retrieve_partial(ulpq, event);
375
376 if (!retval)
377 retval = sctp_intl_retrieve_reassembled(ulpq, event);
378
379 return retval;

--- 190 unchanged lines hidden (view full) ---

570 struct sk_buff *first_frag = NULL;
571 struct sk_buff *last_frag = NULL;
572 struct sctp_ulpevent *retval;
573 struct sctp_stream_in *sin;
574 struct sk_buff *pos;
575 __u32 next_fsn = 0;
576 int is_last = 0;
577
578 sin = sctp_stream_in(ulpq->asoc, event->stream);
578 sin = sctp_stream_in(&ulpq->asoc->stream, event->stream);
579
580 skb_queue_walk(&ulpq->reasm_uo, pos) {
581 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
582
583 if (cevent->stream < event->stream)
584 continue;
585 if (cevent->stream > event->stream)
586 break;

--- 67 unchanged lines hidden (view full) ---

654 struct sk_buff *pd_first = NULL;
655 struct sk_buff *pd_last = NULL;
656 struct sctp_stream_in *sin;
657 __u32 next_fsn = 0;
658 __u32 pd_point = 0;
659 __u32 pd_len = 0;
660 __u32 mid = 0;
661
579
580 skb_queue_walk(&ulpq->reasm_uo, pos) {
581 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
582
583 if (cevent->stream < event->stream)
584 continue;
585 if (cevent->stream > event->stream)
586 break;

--- 67 unchanged lines hidden (view full) ---

654 struct sk_buff *pd_first = NULL;
655 struct sk_buff *pd_last = NULL;
656 struct sctp_stream_in *sin;
657 __u32 next_fsn = 0;
658 __u32 pd_point = 0;
659 __u32 pd_len = 0;
660 __u32 mid = 0;
661
662 sin = sctp_stream_in(ulpq->asoc, event->stream);
662 sin = sctp_stream_in(&ulpq->asoc->stream, event->stream);
663
664 skb_queue_walk(&ulpq->reasm_uo, pos) {
665 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
666
667 if (cevent->stream < event->stream)
668 continue;
669 if (cevent->stream > event->stream)
670 break;

--- 74 unchanged lines hidden (view full) ---

745
746 if (SCTP_DATA_NOT_FRAG == (event->msg_flags & SCTP_DATA_FRAG_MASK)) {
747 event->msg_flags |= MSG_EOR;
748 return event;
749 }
750
751 sctp_intl_store_reasm_uo(ulpq, event);
752
663
664 skb_queue_walk(&ulpq->reasm_uo, pos) {
665 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
666
667 if (cevent->stream < event->stream)
668 continue;
669 if (cevent->stream > event->stream)
670 break;

--- 74 unchanged lines hidden (view full) ---

745
746 if (SCTP_DATA_NOT_FRAG == (event->msg_flags & SCTP_DATA_FRAG_MASK)) {
747 event->msg_flags |= MSG_EOR;
748 return event;
749 }
750
751 sctp_intl_store_reasm_uo(ulpq, event);
752
753 sin = sctp_stream_in(ulpq->asoc, event->stream);
753 sin = sctp_stream_in(&ulpq->asoc->stream, event->stream);
754 if (sin->pd_mode_uo && event->mid == sin->mid_uo &&
755 event->fsn == sin->fsn_uo)
756 retval = sctp_intl_retrieve_partial_uo(ulpq, event);
757
758 if (!retval)
759 retval = sctp_intl_retrieve_reassembled_uo(ulpq, event);
760
761 return retval;

--- 7 unchanged lines hidden (view full) ---

769 struct sctp_ulpevent *retval;
770 struct sk_buff *pos;
771 __u32 next_fsn = 0;
772 __u16 sid = 0;
773
774 skb_queue_walk(&ulpq->reasm_uo, pos) {
775 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
776
754 if (sin->pd_mode_uo && event->mid == sin->mid_uo &&
755 event->fsn == sin->fsn_uo)
756 retval = sctp_intl_retrieve_partial_uo(ulpq, event);
757
758 if (!retval)
759 retval = sctp_intl_retrieve_reassembled_uo(ulpq, event);
760
761 return retval;

--- 7 unchanged lines hidden (view full) ---

769 struct sctp_ulpevent *retval;
770 struct sk_buff *pos;
771 __u32 next_fsn = 0;
772 __u16 sid = 0;
773
774 skb_queue_walk(&ulpq->reasm_uo, pos) {
775 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
776
777 csin = sctp_stream_in(ulpq->asoc, cevent->stream);
777 csin = sctp_stream_in(&ulpq->asoc->stream, cevent->stream);
778 if (csin->pd_mode_uo)
779 continue;
780
781 switch (cevent->msg_flags & SCTP_DATA_FRAG_MASK) {
782 case SCTP_DATA_FIRST_FRAG:
783 if (first_frag)
784 goto out;
785 first_frag = pos;

--- 84 unchanged lines hidden (view full) ---

870 struct sctp_ulpevent *retval;
871 struct sk_buff *pos;
872 __u32 next_fsn = 0;
873 __u16 sid = 0;
874
875 skb_queue_walk(&ulpq->reasm, pos) {
876 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
877
778 if (csin->pd_mode_uo)
779 continue;
780
781 switch (cevent->msg_flags & SCTP_DATA_FRAG_MASK) {
782 case SCTP_DATA_FIRST_FRAG:
783 if (first_frag)
784 goto out;
785 first_frag = pos;

--- 84 unchanged lines hidden (view full) ---

870 struct sctp_ulpevent *retval;
871 struct sk_buff *pos;
872 __u32 next_fsn = 0;
873 __u16 sid = 0;
874
875 skb_queue_walk(&ulpq->reasm, pos) {
876 struct sctp_ulpevent *cevent = sctp_skb2event(pos);
877
878 csin = sctp_stream_in(ulpq->asoc, cevent->stream);
878 csin = sctp_stream_in(&ulpq->asoc->stream, cevent->stream);
879 if (csin->pd_mode)
880 continue;
881
882 switch (cevent->msg_flags & SCTP_DATA_FRAG_MASK) {
883 case SCTP_DATA_FIRST_FRAG:
884 if (first_frag)
885 goto out;
886 if (cevent->mid == csin->mid) {

--- 161 unchanged lines hidden (view full) ---

1048}
1049
1050static void sctp_intl_abort_pd(struct sctp_ulpq *ulpq, gfp_t gfp)
1051{
1052 struct sctp_stream *stream = &ulpq->asoc->stream;
1053 __u16 sid;
1054
1055 for (sid = 0; sid < stream->incnt; sid++) {
879 if (csin->pd_mode)
880 continue;
881
882 switch (cevent->msg_flags & SCTP_DATA_FRAG_MASK) {
883 case SCTP_DATA_FIRST_FRAG:
884 if (first_frag)
885 goto out;
886 if (cevent->mid == csin->mid) {

--- 161 unchanged lines hidden (view full) ---

1048}
1049
1050static void sctp_intl_abort_pd(struct sctp_ulpq *ulpq, gfp_t gfp)
1051{
1052 struct sctp_stream *stream = &ulpq->asoc->stream;
1053 __u16 sid;
1054
1055 for (sid = 0; sid < stream->incnt; sid++) {
1056 struct sctp_stream_in *sin = &stream->in[sid];
1056 struct sctp_stream_in *sin = SCTP_SI(stream, sid);
1057 __u32 mid;
1058
1059 if (sin->pd_mode_uo) {
1060 sin->pd_mode_uo = 0;
1061
1062 mid = sin->mid_uo;
1063 sctp_intl_stream_abort_pd(ulpq, sid, mid, 0x1, gfp);
1064 }

--- 177 unchanged lines hidden (view full) ---

1242 /* Walk through all the skipped SSNs */
1243 sctp_walk_fwdtsn(skip, chunk)
1244 sctp_ulpq_skip(ulpq, ntohs(skip->stream), ntohs(skip->ssn));
1245}
1246
1247static void sctp_intl_skip(struct sctp_ulpq *ulpq, __u16 sid, __u32 mid,
1248 __u8 flags)
1249{
1057 __u32 mid;
1058
1059 if (sin->pd_mode_uo) {
1060 sin->pd_mode_uo = 0;
1061
1062 mid = sin->mid_uo;
1063 sctp_intl_stream_abort_pd(ulpq, sid, mid, 0x1, gfp);
1064 }

--- 177 unchanged lines hidden (view full) ---

1242 /* Walk through all the skipped SSNs */
1243 sctp_walk_fwdtsn(skip, chunk)
1244 sctp_ulpq_skip(ulpq, ntohs(skip->stream), ntohs(skip->ssn));
1245}
1246
1247static void sctp_intl_skip(struct sctp_ulpq *ulpq, __u16 sid, __u32 mid,
1248 __u8 flags)
1249{
1250 struct sctp_stream_in *sin = sctp_stream_in(ulpq->asoc, sid);
1250 struct sctp_stream_in *sin = sctp_stream_in(&ulpq->asoc->stream, sid);
1251 struct sctp_stream *stream = &ulpq->asoc->stream;
1252
1253 if (flags & SCTP_FTSN_U_BIT) {
1254 if (sin->pd_mode_uo && MID_lt(sin->mid_uo, mid)) {
1255 sin->pd_mode_uo = 0;
1256 sctp_intl_stream_abort_pd(ulpq, sid, mid, 0x1,
1257 GFP_ATOMIC);
1258 }

--- 72 unchanged lines hidden ---
1251 struct sctp_stream *stream = &ulpq->asoc->stream;
1252
1253 if (flags & SCTP_FTSN_U_BIT) {
1254 if (sin->pd_mode_uo && MID_lt(sin->mid_uo, mid)) {
1255 sin->pd_mode_uo = 0;
1256 sctp_intl_stream_abort_pd(ulpq, sid, mid, 0x1,
1257 GFP_ATOMIC);
1258 }

--- 72 unchanged lines hidden ---