mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Neil Horman <nhorman@tuxdriver.com>
To: xufeng zhang <xufeng.zhang@windriver.com>
Cc: xufengzhang.main@gmail.com, vyasevich@gmail.com, sri@us.ibm.com,
	davem@davemloft.net, linux-sctp@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling
Date: Tue, 24 Jul 2012 07:38:02 -0400	[thread overview]
Message-ID: <20120724113802.GA30142@hmsreliant.think-freely.org> (raw)
In-Reply-To: <500DFF5A.20203@windriver.com>

On Tue, Jul 24, 2012 at 09:50:18AM +0800, xufeng zhang wrote:
> On 07/23/2012 08:14 PM, Neil Horman wrote:
> >On Mon, Jul 23, 2012 at 10:30:34AM +0800, xufeng zhang wrote:
> >>On 07/23/2012 08:49 AM, Neil Horman wrote:
> >>>Not sure I understand how you came into this error.  If we get an invalid
> >>>stream, we issue an SCTP_REPORT_TSN side effect, followed by an SCTP_CMD_REPLY
> >>>which sends the error chunk.  The reply goes through
> >>>sctp_outq_tail->sctp_outq_chunk->sctp_outq_transmit_chunk->sctp_outq_append_chunk.
> >>>That last function checks to see if a sack is already part of the packet, and if
> >>>there isn't one, appends one, using the updated tsn map.
> >>Yes, you are right, but consider the invalid stream identifier's
> >>DATA chunk is the first
> >>DATA chunk in the association which will need SACK immediately.
> >>Here is what I thought of the scenario:
> >>     sctp_sf_eat_data_6_2()
> >>         -->sctp_eat_data()
> >>             -->sctp_make_op_error()
> >>             -->sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(err))
> >>             -->sctp_outq_tail()          /* First enqueue ERROR chunk */
> >>         -->sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_FORCE())
> >>             -->sctp_gen_sack()
> >>                 -->sctp_make_sack()
> >>                 -->sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
> >>SCTP_CHUNK(sack))
> >>                 -->sctp_outq_tail()          /* Then enqueue SACK chunk */
> >>
> >>So SACK chunk is enqueued after ERROR chunk.
> >Ah, I see.  Since the ERROR and SACK chunks are both control chunks, and since
> >we explicitly add the SACK to the control queue instead of going through the
> >bundle path in sctp_packet_append_chunk the ordering gets wrong.
> >
> >Ok, so the problem makes sense.  I think the soultion could be alot easier
> >though.  IIRC SACK chunks always live at the head of a packet, so why not just
> >special case it in sctp_outq_tail?  I.e. instead of doing a list_add_tail, in
> >the else clause of sctp_outq_tail check the chunk_hdr->type to see if its
> >SCTP_CID_SACK.  If it is, use list_add_head rather than list_add_tail.  I think
> >that will fix up both the COOKIE_ECHO and ESTABLISHED cases, won't it?  And then
> >you won't have keep track of extra state in the packet configuration.
> Yes, it's a good idea, but I think the premise is not correct:
> RFC 4960 page 57:
> "D) Upon reception of the COOKIE ECHO chunk, endpoint "Z" will reply
>    with a COOKIE ACK chunk after building a TCB and moving to the
>    ESTABLISHED state. A COOKIE ACK chunk may be bundled with any
>    pending DATA chunks (and/or SACK chunks), *but the COOKIE ACK chunk
>    MUST be the first chunk in the packet*."
> 
> So we can't put SACK chunk always at the head of the packet.
> 
Ok, Fair point, but that just changes the ordering a bit to:
COOKIE_ACK
SACK
OTHER CONTROL CHUNKS

What about something like this?  Its completely untested, and I'm sure it can be
cleaned up a bunch, but this keeps us from having to add additional state to the
packet structure.


diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index e7aa177c..eeac32f 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -300,7 +300,7 @@ void sctp_outq_free(struct sctp_outq *q)
 int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk)
 {
 	int error = 0;
-
+	struct sctp_chunk *cptr;
 	SCTP_DEBUG_PRINTK("sctp_outq_tail(%p, %p[%s])\n",
 			  q, chunk, chunk && chunk->chunk_hdr ?
 			  sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type))
@@ -344,7 +344,21 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk)
 			break;
 		}
 	} else {
-		list_add_tail(&chunk->list, &q->control_chunk_list);
+		list_del_init(&chunk->list);
+		if (chunk->chunk_hdr->type == SCTP_CID_COOKIE_ACK)
+			list_add_head(&chunk->list, &q->control_chunk_list);
+		else if (!list_empty(&q->control_chunk_list) &&
+		    chunk->chunk_hdr->type == SCTP_CID_SACK) {
+			list_for_each_entry(cptr, &q->control_chunk_list, list) {
+				if (cptr->chunk_hdr->type == SCTP_CID_COOKIE_ACK)
+					continue;
+				list_add(&chunk->list, &cptr->list);
+				break;
+			}
+		} 
+
+		if (list_empty(&chunk->list))
+			list_add_tail(&chunk->list, &q->control_chunk_list);
 		SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);
 	}
 
> 
> Thanks,
> Xufeng Zhang
> >Regards
> >Neil
> >
> >
> 

  parent reply	other threads:[~2012-07-24 11:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19  5:57 xufengzhang.main
2012-07-22 19:45 ` David Miller
2012-07-23  0:49 ` Neil Horman
2012-07-23  2:30   ` xufeng zhang
2012-07-23 12:14     ` Neil Horman
2012-07-24  1:53       ` Xufeng Zhang
     [not found]       ` <500DFF5A.20203@windriver.com>
2012-07-24 11:38         ` Neil Horman [this message]
2012-07-25  2:34           ` Xufeng Zhang
2012-07-25 11:15             ` Neil Horman
2012-07-23  5:16 ` xufeng zhang
2012-07-24  2:27   ` Vlad Yasevich
2012-07-24  3:02     ` xufeng zhang
2012-07-24 14:05       ` Vlad Yasevich
2012-07-25  2:28         ` Xufeng Zhang
2012-07-25  7:16           ` Vlad Yasevich
2012-07-25  8:05             ` Xufeng Zhang
2012-07-25  9:22               ` Xufeng Zhang
2012-07-25 11:27                 ` Neil Horman
2012-07-26  1:34                   ` Xufeng Zhang
2012-07-25 15:00                 ` Vlad Yasevich
2012-07-26  1:30                   ` Xufeng Zhang
2012-07-26  2:45                     ` Vlad Yasevich
2012-07-26  2:50                     ` Xufeng Zhang
2012-07-26  2:55                       ` Vlad Yasevich
2012-07-26  3:12                         ` Xufeng Zhang
2012-07-27 21:22                           ` Vlad Yasevich
2012-07-30  4:58                             ` Xufeng Zhang
2012-07-30  5:47                               ` Xufeng Zhang
2012-07-31  6:17                                 ` Xufeng Zhang
2012-07-31  6:51                                   ` xufeng zhang
2012-08-02 21:17                                     ` Vlad Yasevich
2012-08-03  2:24                                       ` xufeng zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120724113802.GA30142@hmsreliant.think-freely.org \
    --to=nhorman@tuxdriver.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sri@us.ibm.com \
    --cc=vyasevich@gmail.com \
    --cc=xufeng.zhang@windriver.com \
    --cc=xufengzhang.main@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®