Message ID | 1342677450-21810-1-git-send-email-xufengzhang.main@gmail.com |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: <xufengzhang.main@gmail.com> 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@windriver.com> Can some SCTP experts please review this? -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Jul 19, 2012 at 01:57:30PM +0800, xufengzhang.main@gmail.com 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@windriver.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 07/19/2012 01:57 PM, xufengzhang.main@gmail.com 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@windriver.com> > --- > 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
xufeng zhang <xufeng.zhang@windriver.com> wrote: >On 07/19/2012 01:57 PM, xufengzhang.main@gmail.com 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@windriver.com> >> --- >> 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; >> >>
On 07/24/2012 10:27 AM, Vlad Yasevich wrote: > xufeng zhang<xufeng.zhang@windriver.com> wrote: > > >> On 07/19/2012 01:57 PM, xufengzhang.main@gmail.com 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@windriver.com> >>> --- >>> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
xufeng zhang <xufeng.zhang@windriver.com> wrote: >On 07/24/2012 10:27 AM, Vlad Yasevich wrote: >> xufeng zhang<xufeng.zhang@windriver.com> wrote: >> >> >>> On 07/19/2012 01:57 PM, xufengzhang.main@gmail.com 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@windriver.com> >>>> --- >>>> 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; >>>> >>>> >>>> >> >>
On 7/24/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Xufeng Zhang <xufengzhang.main@gmail.com> wrote: >On 7/24/12, Vlad Yasevich <vyasevich@gmail.com> 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
On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 7/25/12, Xufeng Zhang <xufengzhang.main@gmail.com> wrote: > On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Jul 25, 2012 at 05:22:19PM +0800, Xufeng Zhang wrote: > On 7/25/12, Xufeng Zhang <xufengzhang.main@gmail.com> wrote: > > On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 07/25/2012 05:22 AM, Xufeng Zhang wrote: > On 7/25/12, Xufeng Zhang <xufengzhang.main@gmail.com> wrote: >> On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 7/25/12, Neil Horman <nhorman@tuxdriver.com> wrote: > On Wed, Jul 25, 2012 at 05:22:19PM +0800, Xufeng Zhang wrote: >> On 7/25/12, Xufeng Zhang <xufengzhang.main@gmail.com> wrote: >> > On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Xufeng Zhang <xufengzhang.main@gmail.com> wrote: >On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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. >>>>> >>>> >> >> >>
On 7/26/12, Xufeng Zhang <xufengzhang.main@gmail.com> wrote: > On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Xufeng Zhang <xufengzhang.main@gmail.com> wrote: >On 7/26/12, Xufeng Zhang <xufengzhang.main@gmail.com> wrote: >> On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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. >>>>>> >>>>> >>> >>> >>> >>
On 7/26/12, Vlad Yasevich <vyasevich@gmail.com> wrote: > Xufeng Zhang <xufengzhang.main@gmail.com> wrote: > >>On 7/26/12, Xufeng Zhang <xufengzhang.main@gmail.com> wrote: >>> On 7/25/12, Vlad Yasevich <vyasevich@gmail.com> 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 netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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;
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@windriver.com> --- include/net/sctp/structs.h | 2 ++ net/sctp/output.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 0 deletions(-)