Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling

 

 

First page Previous page 1 2 Next page Last page  View All Linux kernel RSS feed   Index | Next | Previous | View Threaded


xufengzhang.main at gmail

Jul 18, 2012, 10:57 PM

Post #1 of 32 (161 views)
Permalink
[PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling

When "Invalid Stream Identifier" ERROR happens after process the
received DATA chunks, this ERROR chunk is enqueued into outqueue
before SACK chunk, so when bundling ERROR chunk with SACK chunk,
the ERROR chunk is always placed first in the packet because of
the chunk's position in the outqueue.
This violates sctp specification:
RFC 4960 6.5. Stream Identifier and Stream Sequence Number
...The endpoint may bundle the ERROR chunk in the same
packet as the SACK as long as the ERROR follows the SACK.
So we must place SACK first when bundling "Invalid Stream Identifier"
ERROR and SACK in one packet.
Although we can do that by enqueue SACK chunk into outqueue before
ERROR chunk, it will violate the side-effect interpreter processing.
It's easy to do this job when dequeue chunks from the outqueue,
by this way, we introduce a flag 'has_isi_err' which indicate
whether or not the "Invalid Stream Identifier" ERROR happens.

Signed-off-by: Xufeng Zhang <xufeng.zhang [at] windriver>
---
include/net/sctp/structs.h | 2 ++
net/sctp/output.c | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 88949a9..5adf4de 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -842,6 +842,8 @@ struct sctp_packet {
has_sack:1, /* This packet contains a SACK chunk. */
has_auth:1, /* This packet contains an AUTH chunk */
has_data:1, /* This packet contains at least 1 DATA chunk */
+ has_isi_err:1, /* This packet contains a "Invalid Stream
+ * Identifier" ERROR chunk */
ipfragok:1, /* So let ip fragment this packet */
malloced:1; /* Is it malloced? */
};
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 817174e..77fb1ae 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -79,6 +79,7 @@ static void sctp_packet_reset(struct sctp_packet *packet)
packet->has_sack = 0;
packet->has_data = 0;
packet->has_auth = 0;
+ packet->has_isi_err = 0;
packet->ipfragok = 0;
packet->auth = NULL;
}
@@ -267,6 +268,7 @@ static sctp_xmit_t sctp_packet_bundle_sack(struct sctp_packet *pkt,
sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
struct sctp_chunk *chunk)
{
+ struct sctp_chunk *lchunk;
sctp_xmit_t retval = SCTP_XMIT_OK;
__u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length));

@@ -316,7 +318,31 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
packet->has_cookie_echo = 1;
break;

+ case SCTP_CID_ERROR:
+ if (chunk->subh.err_hdr->cause & SCTP_ERROR_INV_STRM)
+ packet->has_isi_err = 1;
+ break;
+
case SCTP_CID_SACK:
+ /* RFC 4960
+ * 6.5 Stream Identifier and Stream Sequence Number
+ * The endpoint may bundle the ERROR chunk in the same
+ * packet as the SACK as long as the ERROR follows the SACK.
+ */
+ if (packet->has_isi_err) {
+ if (list_is_singular(&packet->chunk_list))
+ list_add(&chunk->list, &packet->chunk_list);
+ else {
+ lchunk = list_first_entry(&packet->chunk_list,
+ struct sctp_chunk, list);
+ list_add(&chunk->list, &lchunk->list);
+ }
+ packet->size += chunk_len;
+ chunk->transport = packet->transport;
+ packet->has_sack = 1;
+ goto finish;
+ }
+
packet->has_sack = 1;
break;

--
1.7.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


davem at davemloft

Jul 22, 2012, 12:45 PM

Post #2 of 32 (150 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

From: <xufengzhang.main [at] gmail>
Date: Thu, 19 Jul 2012 13:57:30 +0800

> When "Invalid Stream Identifier" ERROR happens after process the
> received DATA chunks, this ERROR chunk is enqueued into outqueue
> before SACK chunk, so when bundling ERROR chunk with SACK chunk,
> the ERROR chunk is always placed first in the packet because of
> the chunk's position in the outqueue.
> This violates sctp specification:
> RFC 4960 6.5. Stream Identifier and Stream Sequence Number
> ...The endpoint may bundle the ERROR chunk in the same
> packet as the SACK as long as the ERROR follows the SACK.
> So we must place SACK first when bundling "Invalid Stream Identifier"
> ERROR and SACK in one packet.
> Although we can do that by enqueue SACK chunk into outqueue before
> ERROR chunk, it will violate the side-effect interpreter processing.
> It's easy to do this job when dequeue chunks from the outqueue,
> by this way, we introduce a flag 'has_isi_err' which indicate
> whether or not the "Invalid Stream Identifier" ERROR happens.
>
> Signed-off-by: Xufeng Zhang <xufeng.zhang [at] windriver>

Can some SCTP experts please review this?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


nhorman at tuxdriver

Jul 22, 2012, 5:49 PM

Post #3 of 32 (150 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On Thu, Jul 19, 2012 at 01:57:30PM +0800, xufengzhang.main [at] gmail wrote:
> When "Invalid Stream Identifier" ERROR happens after process the
> received DATA chunks, this ERROR chunk is enqueued into outqueue
> before SACK chunk, so when bundling ERROR chunk with SACK chunk,
> the ERROR chunk is always placed first in the packet because of
> the chunk's position in the outqueue.
> This violates sctp specification:
> RFC 4960 6.5. Stream Identifier and Stream Sequence Number
> ...The endpoint may bundle the ERROR chunk in the same
> packet as the SACK as long as the ERROR follows the SACK.
> So we must place SACK first when bundling "Invalid Stream Identifier"
> ERROR and SACK in one packet.
> Although we can do that by enqueue SACK chunk into outqueue before
> ERROR chunk, it will violate the side-effect interpreter processing.
> It's easy to do this job when dequeue chunks from the outqueue,
> by this way, we introduce a flag 'has_isi_err' which indicate
> whether or not the "Invalid Stream Identifier" ERROR happens.
>
> Signed-off-by: Xufeng Zhang <xufeng.zhang [at] windriver>

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. So Can you explain in
some more detail how you're getting into this situation?

Thanks!
Neil

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufeng.zhang at windriver

Jul 22, 2012, 7:30 PM

Post #4 of 32 (147 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

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.
> So Can you explain in
> some more detail how you're getting into this situation?
>
Actually it's triggered by a customer's test case, but we can also
reproduce this problem
easily by explicitly contaminating the sctp stack:
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -701,7 +701,7 @@ struct sctp_chunk *sctp_make_datafrag_empty(struct
sctp_association *asoc,
* creating the chunk.
*/
dp.tsn = 0;
- dp.stream = htons(sinfo->sinfo_stream);
+ dp.stream = htons(sinfo->sinfo_stream) + 10;
dp.ppid = sinfo->sinfo_ppid;

/* Set the flags for an unordered send. */


Then run sctp_darn application and capture the sctp packet at the same time.



Thanks,
Xufeng Zhang
> Thanks!
> Neil
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo [at] vger
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufeng.zhang at windriver

Jul 22, 2012, 10:16 PM

Post #5 of 32 (148 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 07/19/2012 01:57 PM, xufengzhang.main [at] gmail wrote:
> When "Invalid Stream Identifier" ERROR happens after process the
> received DATA chunks, this ERROR chunk is enqueued into outqueue
> before SACK chunk, so when bundling ERROR chunk with SACK chunk,
> the ERROR chunk is always placed first in the packet because of
> the chunk's position in the outqueue.
> This violates sctp specification:
> RFC 4960 6.5. Stream Identifier and Stream Sequence Number
> ...The endpoint may bundle the ERROR chunk in the same
> packet as the SACK as long as the ERROR follows the SACK.
> So we must place SACK first when bundling "Invalid Stream Identifier"
> ERROR and SACK in one packet.
> Although we can do that by enqueue SACK chunk into outqueue before
> ERROR chunk, it will violate the side-effect interpreter processing.
> It's easy to do this job when dequeue chunks from the outqueue,
> by this way, we introduce a flag 'has_isi_err' which indicate
> whether or not the "Invalid Stream Identifier" ERROR happens.
>
> Signed-off-by: Xufeng Zhang<xufeng.zhang [at] windriver>
> ---
> include/net/sctp/structs.h | 2 ++
> net/sctp/output.c | 26 ++++++++++++++++++++++++++
> 2 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
> index 88949a9..5adf4de 100644
> --- a/include/net/sctp/structs.h
> +++ b/include/net/sctp/structs.h
> @@ -842,6 +842,8 @@ struct sctp_packet {
> has_sack:1, /* This packet contains a SACK chunk. */
> has_auth:1, /* This packet contains an AUTH chunk */
> has_data:1, /* This packet contains at least 1 DATA chunk */
> + has_isi_err:1, /* This packet contains a "Invalid Stream
> + * Identifier" ERROR chunk */
> ipfragok:1, /* So let ip fragment this packet */
> malloced:1; /* Is it malloced? */
> };
> diff --git a/net/sctp/output.c b/net/sctp/output.c
> index 817174e..77fb1ae 100644
> --- a/net/sctp/output.c
> +++ b/net/sctp/output.c
> @@ -79,6 +79,7 @@ static void sctp_packet_reset(struct sctp_packet *packet)
> packet->has_sack = 0;
> packet->has_data = 0;
> packet->has_auth = 0;
> + packet->has_isi_err = 0;
> packet->ipfragok = 0;
> packet->auth = NULL;
> }
> @@ -267,6 +268,7 @@ static sctp_xmit_t sctp_packet_bundle_sack(struct sctp_packet *pkt,
> sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
> struct sctp_chunk *chunk)
> {
> + struct sctp_chunk *lchunk;
> sctp_xmit_t retval = SCTP_XMIT_OK;
> __u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length));
>
> @@ -316,7 +318,31 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
> packet->has_cookie_echo = 1;
> break;
>
> + case SCTP_CID_ERROR:
> + if (chunk->subh.err_hdr->cause& SCTP_ERROR_INV_STRM)
> + packet->has_isi_err = 1;
> + break;
> +
> case SCTP_CID_SACK:
> + /* RFC 4960
> + * 6.5 Stream Identifier and Stream Sequence Number
> + * The endpoint may bundle the ERROR chunk in the same
> + * packet as the SACK as long as the ERROR follows the SACK.
> + */
> + if (packet->has_isi_err) {
> + if (list_is_singular(&packet->chunk_list))
> + list_add(&chunk->list,&packet->chunk_list);
> + else {
> + lchunk = list_first_entry(&packet->chunk_list,
> + struct sctp_chunk, list);
> + list_add(&chunk->list,&lchunk->list);
> + }
>
And I should clarify the above judgment code.
AFAIK, there should be two cases for the bundling when invalid stream
identifier error happens:
1). COOKIE_ACK ERROR SACK
2). ERROR SACK
So I need to deal with the two cases differently.


Thanks,
Xufeng Zhang
> + packet->size += chunk_len;
> + chunk->transport = packet->transport;
> + packet->has_sack = 1;
> + goto finish;
> + }
> +
> packet->has_sack = 1;
> break;
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


nhorman at tuxdriver

Jul 23, 2012, 5:14 AM

Post #6 of 32 (144 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

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.

Regards
Neil

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 23, 2012, 6:53 PM

Post #7 of 32 (142 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/23/12, Neil Horman <nhorman [at] tuxdriver> 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.

(Please ignore the duplicate messages if you received, sorry for this!)

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.


Thanks,
Xufeng Zhang

>
> Regards
> Neil
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


vyasevich at gmail

Jul 23, 2012, 7:27 PM

Post #8 of 32 (144 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

xufeng zhang <xufeng.zhang [at] windriver> wrote:

>On 07/19/2012 01:57 PM, xufengzhang.main [at] gmail wrote:
>> When "Invalid Stream Identifier" ERROR happens after process the
>> received DATA chunks, this ERROR chunk is enqueued into outqueue
>> before SACK chunk, so when bundling ERROR chunk with SACK chunk,
>> the ERROR chunk is always placed first in the packet because of
>> the chunk's position in the outqueue.
>> This violates sctp specification:
>> RFC 4960 6.5. Stream Identifier and Stream Sequence Number
>> ...The endpoint may bundle the ERROR chunk in the same
>> packet as the SACK as long as the ERROR follows the SACK.
>> So we must place SACK first when bundling "Invalid Stream Identifier"
>> ERROR and SACK in one packet.
>> Although we can do that by enqueue SACK chunk into outqueue before
>> ERROR chunk, it will violate the side-effect interpreter processing.
>> It's easy to do this job when dequeue chunks from the outqueue,
>> by this way, we introduce a flag 'has_isi_err' which indicate
>> whether or not the "Invalid Stream Identifier" ERROR happens.
>>
>> Signed-off-by: Xufeng Zhang<xufeng.zhang [at] windriver>
>> ---
>> include/net/sctp/structs.h | 2 ++
>> net/sctp/output.c | 26 ++++++++++++++++++++++++++
>> 2 files changed, 28 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
>> index 88949a9..5adf4de 100644
>> --- a/include/net/sctp/structs.h
>> +++ b/include/net/sctp/structs.h
>> @@ -842,6 +842,8 @@ struct sctp_packet {
>> has_sack:1, /* This packet contains a SACK chunk. */
>> has_auth:1, /* This packet contains an AUTH chunk */
>> has_data:1, /* This packet contains at least 1 DATA chunk */
>> + has_isi_err:1, /* This packet contains a "Invalid Stream
>> + * Identifier" ERROR chunk */
>> ipfragok:1, /* So let ip fragment this packet */
>> malloced:1; /* Is it malloced? */
>> };
>> diff --git a/net/sctp/output.c b/net/sctp/output.c
>> index 817174e..77fb1ae 100644
>> --- a/net/sctp/output.c
>> +++ b/net/sctp/output.c
>> @@ -79,6 +79,7 @@ static void sctp_packet_reset(struct sctp_packet
>*packet)
>> packet->has_sack = 0;
>> packet->has_data = 0;
>> packet->has_auth = 0;
>> + packet->has_isi_err = 0;
>> packet->ipfragok = 0;
>> packet->auth = NULL;
>> }
>> @@ -267,6 +268,7 @@ static sctp_xmit_t sctp_packet_bundle_sack(struct
>sctp_packet *pkt,
>> sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
>> struct sctp_chunk *chunk)
>> {
>> + struct sctp_chunk *lchunk;
>> sctp_xmit_t retval = SCTP_XMIT_OK;
>> __u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length));
>>
>> @@ -316,7 +318,31 @@ sctp_xmit_t sctp_packet_append_chunk(struct
>sctp_packet *packet,
>> packet->has_cookie_echo = 1;
>> break;
>>
>> + case SCTP_CID_ERROR:
>> + if (chunk->subh.err_hdr->cause& SCTP_ERROR_INV_STRM)
>> + packet->has_isi_err = 1;
>> + break;
>> +
>> case SCTP_CID_SACK:
>> + /* RFC 4960
>> + * 6.5 Stream Identifier and Stream Sequence Number
>> + * The endpoint may bundle the ERROR chunk in the same
>> + * packet as the SACK as long as the ERROR follows the SACK.
>> + */
>> + if (packet->has_isi_err) {
>> + if (list_is_singular(&packet->chunk_list))
>> + list_add(&chunk->list,&packet->chunk_list);
>> + else {
>> + lchunk = list_first_entry(&packet->chunk_list,
>> + struct sctp_chunk, list);
>> + list_add(&chunk->list,&lchunk->list);
>> + }
>>
>And I should clarify the above judgment code.
>AFAIK, there should be two cases for the bundling when invalid stream
>identifier error happens:
>1). COOKIE_ACK ERROR SACK
>2). ERROR SACK
>So I need to deal with the two cases differently.
>

Sorry but I just don't buy that the above are the only 2 cases. What if there are addip chunks as well? What if there are some other extensions also. This code has to be generic enough to handle any condition.

- vlad

>
>Thanks,
>Xufeng Zhang
>> + packet->size += chunk_len;
>> + chunk->transport = packet->transport;
>> + packet->has_sack = 1;
>> + goto finish;
>> + }
>> +
>> packet->has_sack = 1;
>> break;
>>
>>


--
Sent from my Android phone with SkitMail. Please excuse my brevity.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufeng.zhang at windriver

Jul 23, 2012, 8:02 PM

Post #9 of 32 (146 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 07/24/2012 10:27 AM, Vlad Yasevich wrote:
> xufeng zhang<xufeng.zhang [at] windriver> wrote:
>
>
>> On 07/19/2012 01:57 PM, xufengzhang.main [at] gmail wrote:
>>
>>> When "Invalid Stream Identifier" ERROR happens after process the
>>> received DATA chunks, this ERROR chunk is enqueued into outqueue
>>> before SACK chunk, so when bundling ERROR chunk with SACK chunk,
>>> the ERROR chunk is always placed first in the packet because of
>>> the chunk's position in the outqueue.
>>> This violates sctp specification:
>>> RFC 4960 6.5. Stream Identifier and Stream Sequence Number
>>> ...The endpoint may bundle the ERROR chunk in the same
>>> packet as the SACK as long as the ERROR follows the SACK.
>>> So we must place SACK first when bundling "Invalid Stream Identifier"
>>> ERROR and SACK in one packet.
>>> Although we can do that by enqueue SACK chunk into outqueue before
>>> ERROR chunk, it will violate the side-effect interpreter processing.
>>> It's easy to do this job when dequeue chunks from the outqueue,
>>> by this way, we introduce a flag 'has_isi_err' which indicate
>>> whether or not the "Invalid Stream Identifier" ERROR happens.
>>>
>>> Signed-off-by: Xufeng Zhang<xufeng.zhang [at] windriver>
>>> ---
>>> include/net/sctp/structs.h | 2 ++
>>> net/sctp/output.c | 26 ++++++++++++++++++++++++++
>>> 2 files changed, 28 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
>>> index 88949a9..5adf4de 100644
>>> --- a/include/net/sctp/structs.h
>>> +++ b/include/net/sctp/structs.h
>>> @@ -842,6 +842,8 @@ struct sctp_packet {
>>> has_sack:1, /* This packet contains a SACK chunk. */
>>> has_auth:1, /* This packet contains an AUTH chunk */
>>> has_data:1, /* This packet contains at least 1 DATA chunk */
>>> + has_isi_err:1, /* This packet contains a "Invalid Stream
>>> + * Identifier" ERROR chunk */
>>> ipfragok:1, /* So let ip fragment this packet */
>>> malloced:1; /* Is it malloced? */
>>> };
>>> diff --git a/net/sctp/output.c b/net/sctp/output.c
>>> index 817174e..77fb1ae 100644
>>> --- a/net/sctp/output.c
>>> +++ b/net/sctp/output.c
>>> @@ -79,6 +79,7 @@ static void sctp_packet_reset(struct sctp_packet
>>>
>> *packet)
>>
>>> packet->has_sack = 0;
>>> packet->has_data = 0;
>>> packet->has_auth = 0;
>>> + packet->has_isi_err = 0;
>>> packet->ipfragok = 0;
>>> packet->auth = NULL;
>>> }
>>> @@ -267,6 +268,7 @@ static sctp_xmit_t sctp_packet_bundle_sack(struct
>>>
>> sctp_packet *pkt,
>>
>>> sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
>>> struct sctp_chunk *chunk)
>>> {
>>> + struct sctp_chunk *lchunk;
>>> sctp_xmit_t retval = SCTP_XMIT_OK;
>>> __u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length));
>>>
>>> @@ -316,7 +318,31 @@ sctp_xmit_t sctp_packet_append_chunk(struct
>>>
>> sctp_packet *packet,
>>
>>> packet->has_cookie_echo = 1;
>>> break;
>>>
>>> + case SCTP_CID_ERROR:
>>> + if (chunk->subh.err_hdr->cause& SCTP_ERROR_INV_STRM)
>>> + packet->has_isi_err = 1;
>>> + break;
>>> +
>>> case SCTP_CID_SACK:
>>> + /* RFC 4960
>>> + * 6.5 Stream Identifier and Stream Sequence Number
>>> + * The endpoint may bundle the ERROR chunk in the same
>>> + * packet as the SACK as long as the ERROR follows the SACK.
>>> + */
>>> + if (packet->has_isi_err) {
>>> + if (list_is_singular(&packet->chunk_list))
>>> + list_add(&chunk->list,&packet->chunk_list);
>>> + else {
>>> + lchunk = list_first_entry(&packet->chunk_list,
>>> + struct sctp_chunk, list);
>>> + list_add(&chunk->list,&lchunk->list);
>>> + }
>>>
>>>
>> And I should clarify the above judgment code.
>> AFAIK, there should be two cases for the bundling when invalid stream
>> identifier error happens:
>> 1). COOKIE_ACK ERROR SACK
>> 2). ERROR SACK
>> So I need to deal with the two cases differently.
>>
>>
> Sorry but I just don't buy that the above are the only 2 cases. What if there are addip chunks as well? What if there are some other extensions also. This code has to be generic enough to handle any condition.
>
Aha, you are right, this may happens.
So I think the general solution is to fix this problem in the enqueue side.
What do you think? any better suggestion!


Thanks,
Xufeng Zhang
> - vlad
>
>
>> Thanks,
>> Xufeng Zhang
>>
>>> + packet->size += chunk_len;
>>> + chunk->transport = packet->transport;
>>> + packet->has_sack = 1;
>>> + goto finish;
>>> + }
>>> +
>>> packet->has_sack = 1;
>>> break;
>>>
>>>
>>>
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


nhorman at tuxdriver

Jul 24, 2012, 4:38 AM

Post #10 of 32 (144 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

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
> >
> >
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


vyasevich at gmail

Jul 24, 2012, 7:05 AM

Post #11 of 32 (149 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

xufeng zhang <xufeng.zhang [at] windriver> wrote:

>On 07/24/2012 10:27 AM, Vlad Yasevich wrote:
>> xufeng zhang<xufeng.zhang [at] windriver> wrote:
>>
>>
>>> On 07/19/2012 01:57 PM, xufengzhang.main [at] gmail wrote:
>>>
>>>> When "Invalid Stream Identifier" ERROR happens after process the
>>>> received DATA chunks, this ERROR chunk is enqueued into outqueue
>>>> before SACK chunk, so when bundling ERROR chunk with SACK chunk,
>>>> the ERROR chunk is always placed first in the packet because of
>>>> the chunk's position in the outqueue.
>>>> This violates sctp specification:
>>>> RFC 4960 6.5. Stream Identifier and Stream Sequence Number
>>>> ...The endpoint may bundle the ERROR chunk in the same
>>>> packet as the SACK as long as the ERROR follows the SACK.
>>>> So we must place SACK first when bundling "Invalid Stream
>Identifier"
>>>> ERROR and SACK in one packet.
>>>> Although we can do that by enqueue SACK chunk into outqueue before
>>>> ERROR chunk, it will violate the side-effect interpreter
>processing.
>>>> It's easy to do this job when dequeue chunks from the outqueue,
>>>> by this way, we introduce a flag 'has_isi_err' which indicate
>>>> whether or not the "Invalid Stream Identifier" ERROR happens.
>>>>
>>>> Signed-off-by: Xufeng Zhang<xufeng.zhang [at] windriver>
>>>> ---
>>>> include/net/sctp/structs.h | 2 ++
>>>> net/sctp/output.c | 26 ++++++++++++++++++++++++++
>>>> 2 files changed, 28 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/include/net/sctp/structs.h
>b/include/net/sctp/structs.h
>>>> index 88949a9..5adf4de 100644
>>>> --- a/include/net/sctp/structs.h
>>>> +++ b/include/net/sctp/structs.h
>>>> @@ -842,6 +842,8 @@ struct sctp_packet {
>>>> has_sack:1, /* This packet contains a SACK chunk. */
>>>> has_auth:1, /* This packet contains an AUTH chunk */
>>>> has_data:1, /* This packet contains at least 1 DATA chunk
>*/
>>>> + has_isi_err:1, /* This packet contains a "Invalid Stream
>>>> + * Identifier" ERROR chunk */
>>>> ipfragok:1, /* So let ip fragment this packet */
>>>> malloced:1; /* Is it malloced? */
>>>> };
>>>> diff --git a/net/sctp/output.c b/net/sctp/output.c
>>>> index 817174e..77fb1ae 100644
>>>> --- a/net/sctp/output.c
>>>> +++ b/net/sctp/output.c
>>>> @@ -79,6 +79,7 @@ static void sctp_packet_reset(struct sctp_packet
>>>>
>>> *packet)
>>>
>>>> packet->has_sack = 0;
>>>> packet->has_data = 0;
>>>> packet->has_auth = 0;
>>>> + packet->has_isi_err = 0;
>>>> packet->ipfragok = 0;
>>>> packet->auth = NULL;
>>>> }
>>>> @@ -267,6 +268,7 @@ static sctp_xmit_t
>sctp_packet_bundle_sack(struct
>>>>
>>> sctp_packet *pkt,
>>>
>>>> sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet,
>>>> struct sctp_chunk *chunk)
>>>> {
>>>> + struct sctp_chunk *lchunk;
>>>> sctp_xmit_t retval = SCTP_XMIT_OK;
>>>> __u16 chunk_len = WORD_ROUND(ntohs(chunk->chunk_hdr->length));
>>>>
>>>> @@ -316,7 +318,31 @@ sctp_xmit_t sctp_packet_append_chunk(struct
>>>>
>>> sctp_packet *packet,
>>>
>>>> packet->has_cookie_echo = 1;
>>>> break;
>>>>
>>>> + case SCTP_CID_ERROR:
>>>> + if (chunk->subh.err_hdr->cause& SCTP_ERROR_INV_STRM)
>>>> + packet->has_isi_err = 1;
>>>> + break;
>>>> +
>>>> case SCTP_CID_SACK:
>>>> + /* RFC 4960
>>>> + * 6.5 Stream Identifier and Stream Sequence Number
>>>> + * The endpoint may bundle the ERROR chunk in the same
>>>> + * packet as the SACK as long as the ERROR follows the SACK.
>>>> + */
>>>> + if (packet->has_isi_err) {
>>>> + if (list_is_singular(&packet->chunk_list))
>>>> + list_add(&chunk->list,&packet->chunk_list);
>>>> + else {
>>>> + lchunk = list_first_entry(&packet->chunk_list,
>>>> + struct sctp_chunk, list);
>>>> + list_add(&chunk->list,&lchunk->list);
>>>> + }
>>>>
>>>>
>>> And I should clarify the above judgment code.
>>> AFAIK, there should be two cases for the bundling when invalid
>stream
>>> identifier error happens:
>>> 1). COOKIE_ACK ERROR SACK
>>> 2). ERROR SACK
>>> So I need to deal with the two cases differently.
>>>
>>>
>> Sorry but I just don't buy that the above are the only 2 cases. What
>if there are addip chunks as well? What if there are some other
>extensions also. This code has to be generic enough to handle any
>condition.
>>
>Aha, you are right, this may happens.
>So I think the general solution is to fix this problem in the enqueue
>side.
>What do you think? any better suggestion!
>

Don't have code in front of me but what if we carry the error condition to where we queue the Sack and add the error side effect then?

-vlad

>
>Thanks,
>Xufeng Zhang
>> - vlad
>>
>>
>>> Thanks,
>>> Xufeng Zhang
>>>
>>>> + packet->size += chunk_len;
>>>> + chunk->transport = packet->transport;
>>>> + packet->has_sack = 1;
>>>> + goto finish;
>>>> + }
>>>> +
>>>> packet->has_sack = 1;
>>>> break;
>>>>
>>>>
>>>>
>>
>>


--
Sent from my Android phone with SkitMail. Please excuse my brevity.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 24, 2012, 7:28 PM

Post #12 of 32 (145 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/24/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>>>> And I should clarify the above judgment code.
>>>> AFAIK, there should be two cases for the bundling when invalid
>>stream
>>>> identifier error happens:
>>>> 1). COOKIE_ACK ERROR SACK
>>>> 2). ERROR SACK
>>>> So I need to deal with the two cases differently.
>>>>
>>>>
>>> Sorry but I just don't buy that the above are the only 2 cases. What
>>if there are addip chunks as well? What if there are some other
>>extensions also. This code has to be generic enough to handle any
>>condition.
>>>
>>Aha, you are right, this may happens.
>>So I think the general solution is to fix this problem in the enqueue
>>side.
>>What do you think? any better suggestion!
>>
>
> Don't have code in front of me but what if we carry the error condition to
> where we queue the Sack and add the error side effect then?
Yes, this is the most direct way to fix this problem.
But I don't think it's the best way since we will take care of a lot
of things and
it also involves in lots of changes to side effect processing.
I prefer to Neil Horman's way for the solution since only COOKIE_ACK chunk is
allowed to place ahead of SACK chunk when bundling into one packet.
What do you think?



Thanks,
Xufeng Zhang
>
> -vlad
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 24, 2012, 7:34 PM

Post #13 of 32 (144 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/24/12, Neil Horman <nhorman [at] tuxdriver> wrote:
> 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.
Yeah! I like this modification, thank you very much for your work!
I'll try to send a V2 patch based on your changes and run some tests.


Thanks,
Xufeng Zhang
>
>
> 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
>> >
>> >
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


vyasevich at gmail

Jul 25, 2012, 12:16 AM

Post #14 of 32 (138 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

Xufeng Zhang <xufengzhang.main [at] gmail> wrote:

>On 7/24/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>>>>> And I should clarify the above judgment code.
>>>>> AFAIK, there should be two cases for the bundling when invalid
>>>stream
>>>>> identifier error happens:
>>>>> 1). COOKIE_ACK ERROR SACK
>>>>> 2). ERROR SACK
>>>>> So I need to deal with the two cases differently.
>>>>>
>>>>>
>>>> Sorry but I just don't buy that the above are the only 2 cases.
>What
>>>if there are addip chunks as well? What if there are some other
>>>extensions also. This code has to be generic enough to handle any
>>>condition.
>>>>
>>>Aha, you are right, this may happens.
>>>So I think the general solution is to fix this problem in the enqueue
>>>side.
>>>What do you think? any better suggestion!
>>>
>>
>> Don't have code in front of me but what if we carry the error
>condition to
>> where we queue the Sack and add the error side effect then?
>Yes, this is the most direct way to fix this problem.
>But I don't think it's the best way since we will take care of a lot
>of things and
>it also involves in lots of changes to side effect processing.
>I prefer to Neil Horman's way for the solution since only COOKIE_ACK
>chunk is
>allowed to place ahead of SACK chunk when bundling into one packet.
>What do you think?
>
>

Actually not true. AUTH can be before SACK. So can any addip chunks that aid in locating an association.

Now AUTH isn't a big issue since its autogenerated to the packet but ADDIP is since it could be queued up for retransmission.

There could be other extensions as well. It really needs to be done either through side effects or making error chunks go at the end of other control chunks. Need to audit the spec to see if that's ok.

-vlad
>
>Thanks,
>Xufeng Zhang
>>
>> -vlad


--
Sent from my Android phone with SkitMail. Please excuse my brevity.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 25, 2012, 1:05 AM

Post #15 of 32 (143 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>
> Actually not true. AUTH can be before SACK. So can any addip chunks that
> aid in locating an association.
>
> Now AUTH isn't a big issue since its autogenerated to the packet but ADDIP
> is since it could be queued up for retransmission.
>
> There could be other extensions as well. It really needs to be done either
> through side effects or making error chunks go at the end of other control
> chunks. Need to audit the spec to see if that's ok.
You are right, I just found SHUTDOWN chunks are also before SACK based on
your commit "[SCTP]: Fix SACK sequence during shutdown".
Maybe the only solution is to do some work on side effects just as you said.
Thanks for your explanation!



Thanks,
Xufeng Zhang
>
> -vlad
>>
>>Thanks,
>>Xufeng Zhang
>>>
>>> -vlad
>
>
> --
> Sent from my Android phone with SkitMail. Please excuse my brevity.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 25, 2012, 2:22 AM

Post #16 of 32 (135 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/25/12, Xufeng Zhang <xufengzhang.main [at] gmail> wrote:
> On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>>
>> Actually not true. AUTH can be before SACK. So can any addip chunks
>> that
>> aid in locating an association.
>>
>> Now AUTH isn't a big issue since its autogenerated to the packet but
>> ADDIP
>> is since it could be queued up for retransmission.
>>
>> There could be other extensions as well. It really needs to be done
>> either
>> through side effects or making error chunks go at the end of other
>> control
>> chunks. Need to audit the spec to see if that's ok.
> You are right, I just found SHUTDOWN chunks are also before SACK based on
> your commit "[SCTP]: Fix SACK sequence during shutdown".
> Maybe the only solution is to do some work on side effects just as you
> said.
> Thanks for your explanation!

And after take a moment to look into the relative codes, I think we
can implement it
by below way:
1). Add a flag(isi_err_needed) in the embedded struct peer of struct
struct sctp_association
just like sack_needed flag.
2). When "invalid stream identifier" ERROR happens in sctp_eat_data()
function, we just
set isi_err_needed flag and don't create ERROR chunk and also don't
insert SCTP_CMD_REPLY command.
3). In sctp_gen_sack() function, we create ERROR chunk and also insert
SCTP_CMD_REPLY command if isi_err_needed flag is set.

Is this way proper?


Thanks,
Xufeng Zhang
>
>
>
> Thanks,
> Xufeng Zhang
>>
>> -vlad
>>>
>>>Thanks,
>>>Xufeng Zhang
>>>>
>>>> -vlad
>>
>>
>> --
>> Sent from my Android phone with SkitMail. Please excuse my brevity.
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


nhorman at tuxdriver

Jul 25, 2012, 4:15 AM

Post #17 of 32 (138 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On Wed, Jul 25, 2012 at 10:34:32AM +0800, Xufeng Zhang wrote:
> On 7/24/12, Neil Horman <nhorman [at] tuxdriver> wrote:
> > 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.
> Yeah! I like this modification, thank you very much for your work!
> I'll try to send a V2 patch based on your changes and run some tests.
>
Awesome, thank you!
Neil

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


nhorman at tuxdriver

Jul 25, 2012, 4:27 AM

Post #18 of 32 (131 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On Wed, Jul 25, 2012 at 05:22:19PM +0800, Xufeng Zhang wrote:
> On 7/25/12, Xufeng Zhang <xufengzhang.main [at] gmail> wrote:
> > On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
> >>
> >> Actually not true. AUTH can be before SACK. So can any addip chunks
> >> that
> >> aid in locating an association.
> >>
> >> Now AUTH isn't a big issue since its autogenerated to the packet but
> >> ADDIP
> >> is since it could be queued up for retransmission.
> >>
> >> There could be other extensions as well. It really needs to be done
> >> either
> >> through side effects or making error chunks go at the end of other
> >> control
> >> chunks. Need to audit the spec to see if that's ok.
> > You are right, I just found SHUTDOWN chunks are also before SACK based on
> > your commit "[SCTP]: Fix SACK sequence during shutdown".
> > Maybe the only solution is to do some work on side effects just as you
> > said.
> > Thanks for your explanation!
>
> And after take a moment to look into the relative codes, I think we
> can implement it
> by below way:
> 1). Add a flag(isi_err_needed) in the embedded struct peer of struct
> struct sctp_association
> just like sack_needed flag.
> 2). When "invalid stream identifier" ERROR happens in sctp_eat_data()
> function, we just
> set isi_err_needed flag and don't create ERROR chunk and also don't
> insert SCTP_CMD_REPLY command.
> 3). In sctp_gen_sack() function, we create ERROR chunk and also insert
> SCTP_CMD_REPLY command if isi_err_needed flag is set.
>
> Is this way proper?
>
That would probably work yes. Another way might just be to do some re-ordering
in sctp_outq_flush. Before processing the control chunk list, scan it, and:
1) move all error chunks to the head of the list
2) move all sack chunks to the head of the list
3) move all shutdown chunks to the head of the list

You can do that in a single iteration of the list if you use a few on-stack
lists and list_splice

Neil

>
> Thanks,
> Xufeng Zhang
> >
> >
> >
> > Thanks,
> > Xufeng Zhang
> >>
> >> -vlad
> >>>
> >>>Thanks,
> >>>Xufeng Zhang
> >>>>
> >>>> -vlad
> >>
> >>
> >> --
> >> Sent from my Android phone with SkitMail. Please excuse my brevity.
> >>
> >
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


vyasevich at gmail

Jul 25, 2012, 8:00 AM

Post #19 of 32 (130 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 07/25/2012 05:22 AM, Xufeng Zhang wrote:
> On 7/25/12, Xufeng Zhang <xufengzhang.main [at] gmail> wrote:
>> On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>>>
>>> Actually not true. AUTH can be before SACK. So can any addip chunks
>>> that
>>> aid in locating an association.
>>>
>>> Now AUTH isn't a big issue since its autogenerated to the packet but
>>> ADDIP
>>> is since it could be queued up for retransmission.
>>>
>>> There could be other extensions as well. It really needs to be done
>>> either
>>> through side effects or making error chunks go at the end of other
>>> control
>>> chunks. Need to audit the spec to see if that's ok.
>> You are right, I just found SHUTDOWN chunks are also before SACK based on
>> your commit "[SCTP]: Fix SACK sequence during shutdown".
>> Maybe the only solution is to do some work on side effects just as you
>> said.
>> Thanks for your explanation!
>
> And after take a moment to look into the relative codes, I think we
> can implement it
> by below way:
> 1). Add a flag(isi_err_needed) in the embedded struct peer of struct
> struct sctp_association
> just like sack_needed flag.
> 2). When "invalid stream identifier" ERROR happens in sctp_eat_data()
> function, we just
> set isi_err_needed flag and don't create ERROR chunk and also don't
> insert SCTP_CMD_REPLY command.
> 3). In sctp_gen_sack() function, we create ERROR chunk and also insert
> SCTP_CMD_REPLY command if isi_err_needed flag is set.
>
> Is this way proper?
>

So, I looked at the code, and it looks very simple to do. We already
return a specific status from sctp_eat_data() when the error was
generated. All you have to do is take the code that generates the error
and adds it to the command list and give it its own small function that
you can then call if SCTP_IERROR_BAD_STREAM error was returned.

-vlad

>
> Thanks,
> Xufeng Zhang
>>
>>
>>
>> Thanks,
>> Xufeng Zhang
>>>
>>> -vlad
>>>>
>>>> Thanks,
>>>> Xufeng Zhang
>>>>>
>>>>> -vlad
>>>
>>>
>>> --
>>> Sent from my Android phone with SkitMail. Please excuse my brevity.
>>>
>>


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 25, 2012, 6:30 PM

Post #20 of 32 (126 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>> And after take a moment to look into the relative codes, I think we
>> can implement it
>> by below way:
>> 1). Add a flag(isi_err_needed) in the embedded struct peer of struct
>> struct sctp_association
>> just like sack_needed flag.
>> 2). When "invalid stream identifier" ERROR happens in sctp_eat_data()
>> function, we just
>> set isi_err_needed flag and don't create ERROR chunk and also don't
>> insert SCTP_CMD_REPLY command.
>> 3). In sctp_gen_sack() function, we create ERROR chunk and also insert
>> SCTP_CMD_REPLY command if isi_err_needed flag is set.
>>
>> Is this way proper?
>>
>
> So, I looked at the code, and it looks very simple to do. We already
> return a specific status from sctp_eat_data() when the error was
> generated. All you have to do is take the code that generates the error
> and adds it to the command list and give it its own small function that
> you can then call if SCTP_IERROR_BAD_STREAM error was returned.

No, it will still has the same problem by just doing this.
SCTP_CMD_GEN_SACK command actually don't enqueue SACK to outqueue,
sctp_gen_sack() do this things when processing SCTP_CMD_GEN_SACK command
in sctp_cmd_interpreter().
So it's not enough if we just insert SCTP_ERROR_INV_STRM command after
sctp_eat_data() return SCTP_IERROR_BAD_STREAM in sctp_sf_eat_data_6_2().



Thanks,
Xufeng Zhang

>
> -vlad
>
>>
>> Thanks,
>> Xufeng Zhang
>>>
>>>
>>>
>>> Thanks,
>>> Xufeng Zhang
>>>>
>>>> -vlad
>>>>>
>>>>> Thanks,
>>>>> Xufeng Zhang
>>>>>>
>>>>>> -vlad
>>>>
>>>>
>>>> --
>>>> Sent from my Android phone with SkitMail. Please excuse my brevity.
>>>>
>>>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 25, 2012, 6:34 PM

Post #21 of 32 (128 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/25/12, Neil Horman <nhorman [at] tuxdriver> wrote:
> On Wed, Jul 25, 2012 at 05:22:19PM +0800, Xufeng Zhang wrote:
>> On 7/25/12, Xufeng Zhang <xufengzhang.main [at] gmail> wrote:
>> > On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>> >>
>> >> Actually not true. AUTH can be before SACK. So can any addip chunks
>> >> that
>> >> aid in locating an association.
>> >>
>> >> Now AUTH isn't a big issue since its autogenerated to the packet but
>> >> ADDIP
>> >> is since it could be queued up for retransmission.
>> >>
>> >> There could be other extensions as well. It really needs to be done
>> >> either
>> >> through side effects or making error chunks go at the end of other
>> >> control
>> >> chunks. Need to audit the spec to see if that's ok.
>> > You are right, I just found SHUTDOWN chunks are also before SACK based
>> > on
>> > your commit "[SCTP]: Fix SACK sequence during shutdown".
>> > Maybe the only solution is to do some work on side effects just as you
>> > said.
>> > Thanks for your explanation!
>>
>> And after take a moment to look into the relative codes, I think we
>> can implement it
>> by below way:
>> 1). Add a flag(isi_err_needed) in the embedded struct peer of struct
>> struct sctp_association
>> just like sack_needed flag.
>> 2). When "invalid stream identifier" ERROR happens in sctp_eat_data()
>> function, we just
>> set isi_err_needed flag and don't create ERROR chunk and also don't
>> insert SCTP_CMD_REPLY command.
>> 3). In sctp_gen_sack() function, we create ERROR chunk and also insert
>> SCTP_CMD_REPLY command if isi_err_needed flag is set.
>>
>> Is this way proper?
>>
> That would probably work yes. Another way might just be to do some
> re-ordering
> in sctp_outq_flush. Before processing the control chunk list, scan it,
> and:
> 1) move all error chunks to the head of the list
> 2) move all sack chunks to the head of the list
> 3) move all shutdown chunks to the head of the list
>
> You can do that in a single iteration of the list if you use a few on-stack
> lists and list_splice

Thank you very much for your suggestion!
I'll compare it with side effects modification and make a decision.


Thanks,
Xufeng Zhang

>
> Neil
>
>>
>> Thanks,
>> Xufeng Zhang
>> >
>> >
>> >
>> > Thanks,
>> > Xufeng Zhang
>> >>
>> >> -vlad
>> >>>
>> >>>Thanks,
>> >>>Xufeng Zhang
>> >>>>
>> >>>> -vlad
>> >>
>> >>
>> >> --
>> >> Sent from my Android phone with SkitMail. Please excuse my brevity.
>> >>
>> >
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


vyasevich at gmail

Jul 25, 2012, 7:45 PM

Post #22 of 32 (130 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

Xufeng Zhang <xufengzhang.main [at] gmail> wrote:

>On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>>> And after take a moment to look into the relative codes, I think we
>>> can implement it
>>> by below way:
>>> 1). Add a flag(isi_err_needed) in the embedded struct peer of struct
>>> struct sctp_association
>>> just like sack_needed flag.
>>> 2). When "invalid stream identifier" ERROR happens in
>sctp_eat_data()
>>> function, we just
>>> set isi_err_needed flag and don't create ERROR chunk and also don't
>>> insert SCTP_CMD_REPLY command.
>>> 3). In sctp_gen_sack() function, we create ERROR chunk and also
>insert
>>> SCTP_CMD_REPLY command if isi_err_needed flag is set.
>>>
>>> Is this way proper?
>>>
>>
>> So, I looked at the code, and it looks very simple to do. We already
>> return a specific status from sctp_eat_data() when the error was
>> generated. All you have to do is take the code that generates the
>error
>> and adds it to the command list and give it its own small function
>that
>> you can then call if SCTP_IERROR_BAD_STREAM error was returned.
>
>No, it will still has the same problem by just doing this.
>SCTP_CMD_GEN_SACK command actually don't enqueue SACK to outqueue,
>sctp_gen_sack() do this things when processing SCTP_CMD_GEN_SACK
>command
>in sctp_cmd_interpreter().
>So it's not enough if we just insert SCTP_ERROR_INV_STRM command after
>sctp_eat_data() return SCTP_IERROR_BAD_STREAM in
>sctp_sf_eat_data_6_2().
>
>

All you have to do is change the order of side effect commands and the above is a guide. Ill prototype it tomorrow when I have time.

-vlad
>
>Thanks,
>Xufeng Zhang
>
>>
>> -vlad
>>
>>>
>>> Thanks,
>>> Xufeng Zhang
>>>>
>>>>
>>>>
>>>> Thanks,
>>>> Xufeng Zhang
>>>>>
>>>>> -vlad
>>>>>>
>>>>>> Thanks,
>>>>>> Xufeng Zhang
>>>>>>>
>>>>>>> -vlad
>>>>>
>>>>>
>>>>> --
>>>>> Sent from my Android phone with SkitMail. Please excuse my
>brevity.
>>>>>
>>>>
>>
>>
>>


--
Sent from my Android phone with SkitMail. Please excuse my brevity.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 25, 2012, 7:50 PM

Post #23 of 32 (127 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/26/12, Xufeng Zhang <xufengzhang.main [at] gmail> wrote:
> On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>>> And after take a moment to look into the relative codes, I think we
>>> can implement it
>>> by below way:
>>> 1). Add a flag(isi_err_needed) in the embedded struct peer of struct
>>> struct sctp_association
>>> just like sack_needed flag.
>>> 2). When "invalid stream identifier" ERROR happens in sctp_eat_data()
>>> function, we just
>>> set isi_err_needed flag and don't create ERROR chunk and also don't
>>> insert SCTP_CMD_REPLY command.
>>> 3). In sctp_gen_sack() function, we create ERROR chunk and also insert
>>> SCTP_CMD_REPLY command if isi_err_needed flag is set.
>>>
>>> Is this way proper?
>>>
>>
>> So, I looked at the code, and it looks very simple to do. We already
>> return a specific status from sctp_eat_data() when the error was
>> generated. All you have to do is take the code that generates the error
>> and adds it to the command list and give it its own small function that
>> you can then call if SCTP_IERROR_BAD_STREAM error was returned.
>
> No, it will still has the same problem by just doing this.
> SCTP_CMD_GEN_SACK command actually don't enqueue SACK to outqueue,
> sctp_gen_sack() do this things when processing SCTP_CMD_GEN_SACK command
> in sctp_cmd_interpreter().
> So it's not enough if we just insert SCTP_ERROR_INV_STRM command after
> sctp_eat_data() return SCTP_IERROR_BAD_STREAM in sctp_sf_eat_data_6_2().

Yes, I just tried this way, SACK is still bundled after ERROR chunk.
But I think my above method is also not fine if there are multiple
error DATA chunks
bundled in a packet.
Really awesome!



Thanks,
Xufeng Zhang

>
>
>
> Thanks,
> Xufeng Zhang
>
>>
>> -vlad
>>
>>>
>>> Thanks,
>>> Xufeng Zhang
>>>>
>>>>
>>>>
>>>> Thanks,
>>>> Xufeng Zhang
>>>>>
>>>>> -vlad
>>>>>>
>>>>>> Thanks,
>>>>>> Xufeng Zhang
>>>>>>>
>>>>>>> -vlad
>>>>>
>>>>>
>>>>> --
>>>>> Sent from my Android phone with SkitMail. Please excuse my brevity.
>>>>>
>>>>
>>
>>
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


vyasevich at gmail

Jul 25, 2012, 7:55 PM

Post #24 of 32 (128 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

Xufeng Zhang <xufengzhang.main [at] gmail> wrote:

>On 7/26/12, Xufeng Zhang <xufengzhang.main [at] gmail> wrote:
>> On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>>>> And after take a moment to look into the relative codes, I think we
>>>> can implement it
>>>> by below way:
>>>> 1). Add a flag(isi_err_needed) in the embedded struct peer of
>struct
>>>> struct sctp_association
>>>> just like sack_needed flag.
>>>> 2). When "invalid stream identifier" ERROR happens in
>sctp_eat_data()
>>>> function, we just
>>>> set isi_err_needed flag and don't create ERROR chunk and also don't
>>>> insert SCTP_CMD_REPLY command.
>>>> 3). In sctp_gen_sack() function, we create ERROR chunk and also
>insert
>>>> SCTP_CMD_REPLY command if isi_err_needed flag is set.
>>>>
>>>> Is this way proper?
>>>>
>>>
>>> So, I looked at the code, and it looks very simple to do. We
>already
>>> return a specific status from sctp_eat_data() when the error was
>>> generated. All you have to do is take the code that generates the
>error
>>> and adds it to the command list and give it its own small function
>that
>>> you can then call if SCTP_IERROR_BAD_STREAM error was returned.
>>
>> No, it will still has the same problem by just doing this.
>> SCTP_CMD_GEN_SACK command actually don't enqueue SACK to outqueue,
>> sctp_gen_sack() do this things when processing SCTP_CMD_GEN_SACK
>command
>> in sctp_cmd_interpreter().
>> So it's not enough if we just insert SCTP_ERROR_INV_STRM command
>after
>> sctp_eat_data() return SCTP_IERROR_BAD_STREAM in
>sctp_sf_eat_data_6_2().
>
>Yes, I just tried this way, SACK is still bundled after ERROR chunk.
>But I think my above method is also not fine if there are multiple
>error DATA chunks
>bundled in a packet.
>Really awesome!

1. Catch the error return.
2. Set flag indicating error is needed.
3. Queue sack as needed.
4. If error flag set call new function to queue error chunk.

That should fix things. Do this in all callers of sctp_eat_data.

-vlad

>
>
>Thanks,
>Xufeng Zhang
>
>>
>>
>>
>> Thanks,
>> Xufeng Zhang
>>
>>>
>>> -vlad
>>>
>>>>
>>>> Thanks,
>>>> Xufeng Zhang
>>>>>
>>>>>
>>>>>
>>>>> Thanks,
>>>>> Xufeng Zhang
>>>>>>
>>>>>> -vlad
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Xufeng Zhang
>>>>>>>>
>>>>>>>> -vlad
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent from my Android phone with SkitMail. Please excuse my
>brevity.
>>>>>>
>>>>>
>>>
>>>
>>>
>>


--
Sent from my Android phone with SkitMail. Please excuse my brevity.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xufengzhang.main at gmail

Jul 25, 2012, 8:12 PM

Post #25 of 32 (125 views)
Permalink
Re: [PATCH] sctp: Make "Invalid Stream Identifier" ERROR follows SACK when bundling [In reply to]

On 7/26/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
> Xufeng Zhang <xufengzhang.main [at] gmail> wrote:
>
>>On 7/26/12, Xufeng Zhang <xufengzhang.main [at] gmail> wrote:
>>> On 7/25/12, Vlad Yasevich <vyasevich [at] gmail> wrote:
>>>>> And after take a moment to look into the relative codes, I think we
>>>>> can implement it
>>>>> by below way:
>>>>> 1). Add a flag(isi_err_needed) in the embedded struct peer of
>>struct
>>>>> struct sctp_association
>>>>> just like sack_needed flag.
>>>>> 2). When "invalid stream identifier" ERROR happens in
>>sctp_eat_data()
>>>>> function, we just
>>>>> set isi_err_needed flag and don't create ERROR chunk and also don't
>>>>> insert SCTP_CMD_REPLY command.
>>>>> 3). In sctp_gen_sack() function, we create ERROR chunk and also
>>insert
>>>>> SCTP_CMD_REPLY command if isi_err_needed flag is set.
>>>>>
>>>>> Is this way proper?
>>>>>
>>>>
>>>> So, I looked at the code, and it looks very simple to do. We
>>already
>>>> return a specific status from sctp_eat_data() when the error was
>>>> generated. All you have to do is take the code that generates the
>>error
>>>> and adds it to the command list and give it its own small function
>>that
>>>> you can then call if SCTP_IERROR_BAD_STREAM error was returned.
>>>
>>> No, it will still has the same problem by just doing this.
>>> SCTP_CMD_GEN_SACK command actually don't enqueue SACK to outqueue,
>>> sctp_gen_sack() do this things when processing SCTP_CMD_GEN_SACK
>>command
>>> in sctp_cmd_interpreter().
>>> So it's not enough if we just insert SCTP_ERROR_INV_STRM command
>>after
>>> sctp_eat_data() return SCTP_IERROR_BAD_STREAM in
>>sctp_sf_eat_data_6_2().
>>
>>Yes, I just tried this way, SACK is still bundled after ERROR chunk.
>>But I think my above method is also not fine if there are multiple
>>error DATA chunks
>>bundled in a packet.
>>Really awesome!
>
> 1. Catch the error return.
> 2. Set flag indicating error is needed.
> 3. Queue sack as needed.
> 4. If error flag set call new function to queue error chunk.

Both step 3 and 4 need lots of changes to make it working since
SACK is ready to queue only at the end of the packet and we also
need to deal with multiple "invalid stream identifier" ERROR chunks
in a single packet.


Thanks,
Xufeng Zhang
>
> That should fix things. Do this in all callers of sctp_eat_data.
>
> -vlad
>
>>
>>
>>Thanks,
>>Xufeng Zhang
>>
>>>
>>>
>>>
>>> Thanks,
>>> Xufeng Zhang
>>>
>>>>
>>>> -vlad
>>>>
>>>>>
>>>>> Thanks,
>>>>> Xufeng Zhang
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> Xufeng Zhang
>>>>>>>
>>>>>>> -vlad
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Xufeng Zhang
>>>>>>>>>
>>>>>>>>> -vlad
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Sent from my Android phone with SkitMail. Please excuse my
>>brevity.
>>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>
>
>
> --
> Sent from my Android phone with SkitMail. Please excuse my brevity.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

First page Previous page 1 2 Next page Last page  View All Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.