netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] sctp: fix association hangs due to reassembly/ordering logic
@ 2013-02-26 14:36 Lee A. Roberts
  2013-02-26 14:36 ` [PATCH 1/4] sctp: fix association hangs due to off-by-one errors in sctp_tsnmap_grow() Lee A. Roberts
                   ` (10 more replies)
  0 siblings, 11 replies; 43+ messages in thread
From: Lee A. Roberts @ 2013-02-26 14:36 UTC (permalink / raw)
  To: netdev; +Cc: lee.roberts

From: "Lee A. Roberts" <lee.roberts@hp.com>

This series of patches resolves several SCTP association hangs observed during
SCTP stress testing.  Observable symptoms include communications hangs with
data being held in the association reassembly and/or lobby (ordering) queues.
Close examination of reassembly/ordering queues may show either duplicated
or missing packets.

Lee A. Roberts (4):
  sctp: fix association hangs due to off-by-one errors in
    sctp_tsnmap_grow()
  sctp: fix association hangs due to reneging packets below the
    cumulative TSN ACK point
  sctp: fix association hangs due to errors when reneging events from
    the ordering queue
  sctp: fix association hangs due to partial delivery errors

 net/sctp/tsnmap.c   |   13 ++++----
 net/sctp/ulpqueue.c |   87 +++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 78 insertions(+), 22 deletions(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 43+ messages in thread
* [PATCH 4/4] sctp: fix association hangs due to partial delivery errors
@ 2013-02-21 16:45 Roberts, Lee A.
  2013-02-21 20:25 ` Vlad Yasevich
  0 siblings, 1 reply; 43+ messages in thread
From: Roberts, Lee A. @ 2013-02-21 16:45 UTC (permalink / raw)
  To: linux-sctp@vger.kernel.org, netdev@vger.kernel.org
  Cc: linux-kernel@vger.kernel.org

From: Lee A. Roberts <lee.roberts@hp.com>

Resolve SCTP association hangs observed during SCTP stress
testing.  Observable symptoms include communications hangs
with data being held in the association reassembly and/or lobby
(ordering) queues.  Close examination of reassembly queue shows
missing packets.

In sctp_ulpq_retrieve_partial() and sctp_ulpq_retrieve_first(),
correct message reassembly logic for SCTP partial delivery.
Change logic to ensure that as much data as possible is sent
with the initial partial delivery and that following partial
deliveries contain all available data.

In sctp_ulpq_partial_delivery(), attempt partial delivery only
if the data on the head of the reassembly queue is at or before
the cumulative TSN ACK point.

In sctp_ulpq_renege(), adjust logic to enter partial delivery
only if the incoming chunk remains on the reassembly queue
after processing by sctp_ulpq_tail_data().  If the incoming
chunk has been delivered and data remains on the reassembly
queue, attempt to drain the queue.  Remove call to
sctp_tsnmap_mark(), as this is handled correctly in call to
sctp_ulpq_tail_data().

Patch applies to linux-3.8 kernel.

Signed-off-by: Lee A. Roberts <lee.roberts@hp.com>
---
 net/sctp/ulpqueue.c |   53 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 8 deletions(-)

diff -uprN -X linux-3.8-vanilla/Documentation/dontdiff linux-3.8-SCTP+3/net/sctp/ulpqueue.c linux-3.8-SCTP+4/net/sctp/ulpqueue.c
--- linux-3.8-SCTP+3/net/sctp/ulpqueue.c	2013-02-21 07:55:32.817713326 -0700
+++ linux-3.8-SCTP+4/net/sctp/ulpqueue.c	2013-02-21 08:07:41.562212475 -0700
@@ -540,14 +540,19 @@ static struct sctp_ulpevent *sctp_ulpq_r
 		ctsn = cevent->tsn;
 
 		switch (cevent->msg_flags & SCTP_DATA_FRAG_MASK) {
+		case SCTP_DATA_FIRST_FRAG:
+			if (!first_frag)
+				return NULL;
+			goto done;
 		case SCTP_DATA_MIDDLE_FRAG:
 			if (!first_frag) {
 				first_frag = pos;
 				next_tsn = ctsn + 1;
 				last_frag = pos;
-			} else if (next_tsn == ctsn)
+			} else if (next_tsn == ctsn) {
 				next_tsn++;
-			else
+				last_frag = pos;
+			} else
 				goto done;
 			break;
 		case SCTP_DATA_LAST_FRAG:
@@ -651,6 +656,14 @@ static struct sctp_ulpevent *sctp_ulpq_r
 			} else
 				goto done;
 			break;
+
+		case SCTP_DATA_LAST_FRAG:
+			if (!first_frag)
+				return NULL;
+			else
+				goto done;
+			break;
+
 		default:
 			return NULL;
 		}
@@ -1025,16 +1038,28 @@ void sctp_ulpq_partial_delivery(struct s
 	struct sctp_ulpevent *event;
 	struct sctp_association *asoc;
 	struct sctp_sock *sp;
+	__u32 ctsn;
+	struct sk_buff *skb;
 
 	asoc = ulpq->asoc;
 	sp = sctp_sk(asoc->base.sk);
 
 	/* If the association is already in Partial Delivery mode
-	 * we have noting to do.
+	 * we have nothing to do.
 	 */
 	if (ulpq->pd_mode)
 		return;
 
+	/* Data must be at or below the Cumulative TSN ACK Point to
+	 * start partial delivery.
+	 */
+	skb = skb_peek(&asoc->ulpq.reasm);
+	if (skb != NULL) {
+		ctsn = sctp_skb2event(skb)->tsn;
+		if (!TSN_lte(ctsn, sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map)))
+			return;
+	}
+
 	/* If the user enabled fragment interleave socket option,
 	 * multiple associations can enter partial delivery.
 	 * Otherwise, we can only enter partial delivery if the
@@ -1057,6 +1082,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *
 		      gfp_t gfp)
 {
 	struct sctp_association *asoc;
+	struct sk_buff *skb;
 	__u16 needed, freed;
 
 	asoc = ulpq->asoc;
@@ -1077,12 +1103,23 @@ void sctp_ulpq_renege(struct sctp_ulpq *
 	}
 	/* If able to free enough room, accept this chunk. */
 	if (chunk && (freed >= needed)) {
-		__u32 tsn;
+		__u32 tsn, ctsn;
 		tsn = ntohl(chunk->subh.data_hdr->tsn);
-		sctp_tsnmap_mark(&asoc->peer.tsn_map, tsn, chunk->transport);
-		sctp_ulpq_tail_data(ulpq, chunk, gfp);
-
-		sctp_ulpq_partial_delivery(ulpq, gfp);
+		if (sctp_ulpq_tail_data(ulpq, chunk, gfp) == 0) {
+			/*
+			 * Enter partial delivery if chunk is still on
+			 * reassembly queue; otherwise, drain the queue.
+			 */
+			skb = skb_peek(&ulpq->reasm);
+			if (skb != NULL) {
+				ctsn = sctp_skb2event(skb)->tsn;
+				if (TSN_lte(ctsn, tsn))
+					sctp_ulpq_partial_delivery(ulpq, chunk,
+						gfp);
+				else
+					sctp_ulpq_reasm_drain(ulpq);
+			}
+		}
 	}
 
 	sk_mem_reclaim(asoc->base.sk);

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2013-02-28 20:36 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-26 14:36 [PATCH 0/4] sctp: fix association hangs due to reassembly/ordering logic Lee A. Roberts
2013-02-26 14:36 ` [PATCH 1/4] sctp: fix association hangs due to off-by-one errors in sctp_tsnmap_grow() Lee A. Roberts
2013-02-27 13:52   ` Vlad Yasevich
2013-02-26 14:36 ` [PATCH 2/4] sctp: fix association hangs due to reneging packets below the cumulative TSN ACK point Lee A. Roberts
2013-02-27 13:52   ` Vlad Yasevich
2013-02-26 14:36 ` [PATCH 3/4] sctp: fix association hangs due to errors when reneging events from the ordering queue Lee A. Roberts
2013-02-27 13:53   ` Vlad Yasevich
2013-02-26 14:36 ` [PATCH 4/4] sctp: fix association hangs due to partial delivery errors Lee A. Roberts
2013-02-27  2:34   ` Vlad Yasevich
2013-02-27  4:38     ` Roberts, Lee A.
2013-02-27 13:51       ` Vlad Yasevich
2013-02-27 13:53   ` Vlad Yasevich
2013-02-26 22:37 ` [PATCH 0/4] sctp: fix association hangs due to reassembly/ordering logic David Miller
2013-02-27 12:35   ` Neil Horman
2013-02-27 16:41   ` Sridhar Samudrala
2013-02-27 17:15     ` Neil Horman
2013-02-27 18:09 ` David Miller
2013-02-27 18:55   ` Roberts, Lee A.
2013-02-27 19:09     ` David Miller
2013-02-27 18:54 ` [PATCH v2 " Lee A. Roberts
2013-02-27 19:36   ` Daniel Borkmann
2013-02-27 19:43     ` David Miller
2013-02-27 20:13   ` Vlad Yasevich
2013-02-27 20:24     ` David Miller
2013-02-27 20:49       ` Vlad Yasevich
2013-02-27 20:26     ` Roberts, Lee A.
2013-02-28 14:37   ` [PATCH v3 " Lee A. Roberts
2013-02-28 15:07     ` Vlad Yasevich
2013-02-28 20:36     ` David Miller
2013-02-28 14:37   ` [PATCH v3 1/4] sctp: fix association hangs due to off-by-one errors in sctp_tsnmap_grow() Lee A. Roberts
2013-02-28 14:37   ` [PATCH v3 2/4] sctp: fix association hangs due to reneging packets below the cumulative TSN ACK point Lee A. Roberts
2013-02-28 14:37   ` [PATCH v3 3/4] sctp: fix association hangs due to errors when reneging events from the ordering queue Lee A. Roberts
2013-02-28 14:37   ` [PATCH v3 4/4] sctp: fix association hangs due to partial delivery errors Lee A. Roberts
2013-02-27 18:54 ` [PATCH v2 1/4] sctp: fix association hangs due to off-by-one errors in sctp_tsnmap_grow() Lee A. Roberts
2013-02-28 14:31   ` Neil Horman
2013-02-27 18:54 ` [PATCH v2 2/4] sctp: fix association hangs due to reneging packets below the cumulative TSN ACK point Lee A. Roberts
2013-02-28 14:33   ` Neil Horman
2013-02-27 18:54 ` [PATCH v2 3/4] sctp: fix association hangs due to errors when reneging events from the ordering queue Lee A. Roberts
2013-02-28 14:34   ` Neil Horman
2013-02-27 18:54 ` [PATCH v2 4/4] sctp: fix association hangs due to partial delivery errors Lee A. Roberts
2013-02-28 14:34   ` Neil Horman
  -- strict thread matches above, loose matches on Subject: below --
2013-02-21 16:45 [PATCH " Roberts, Lee A.
2013-02-21 20:25 ` Vlad Yasevich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).