* [PATCH net 0/2] sctp: shrink stream outq in the right place @ 2020-07-22 15:52 Xin Long 2020-07-22 15:52 ` [PATCH net 1/2] sctp: shrink stream outq only when new outcnt < old outcnt Xin Long ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Xin Long @ 2020-07-22 15:52 UTC (permalink / raw) To: network dev, linux-sctp; +Cc: davem, Marcelo Ricardo Leitner, Neil Horman Patch 1 is an improvement, and Patch 2 is a bug fix. Xin Long (2): sctp: shrink stream outq only when new outcnt < old outcnt sctp: shrink stream outq when fails to do addstream reconf net/sctp/stream.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) -- 2.1.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/2] sctp: shrink stream outq only when new outcnt < old outcnt 2020-07-22 15:52 [PATCH net 0/2] sctp: shrink stream outq in the right place Xin Long @ 2020-07-22 15:52 ` Xin Long 2020-07-22 15:52 ` [PATCH net 2/2] sctp: shrink stream outq when fails to do addstream reconf Xin Long 2020-07-22 20:46 ` [PATCH net 0/2] sctp: shrink stream outq in the right place Marcelo Ricardo Leitner 2020-07-23 1:05 ` David Miller 2 siblings, 1 reply; 5+ messages in thread From: Xin Long @ 2020-07-22 15:52 UTC (permalink / raw) To: network dev, linux-sctp; +Cc: davem, Marcelo Ricardo Leitner, Neil Horman It's not necessary to go list_for_each for outq->out_chunk_list when new outcnt >= old outcnt, as no chunk with higher sid than new (outcnt - 1) exists in the outqueue. While at it, also move the list_for_each code in a new function sctp_stream_shrink_out(), which will be used in the next patch. Signed-off-by: Xin Long <lucien.xin@gmail.com> --- net/sctp/stream.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/net/sctp/stream.c b/net/sctp/stream.c index 67f7e71..4f87693 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -22,17 +22,11 @@ #include <net/sctp/sm.h> #include <net/sctp/stream_sched.h> -/* Migrates chunks from stream queues to new stream queues if needed, - * but not across associations. Also, removes those chunks to streams - * higher than the new max. - */ -static void sctp_stream_outq_migrate(struct sctp_stream *stream, - struct sctp_stream *new, __u16 outcnt) +static void sctp_stream_shrink_out(struct sctp_stream *stream, __u16 outcnt) { struct sctp_association *asoc; struct sctp_chunk *ch, *temp; struct sctp_outq *outq; - int i; asoc = container_of(stream, struct sctp_association, stream); outq = &asoc->outqueue; @@ -56,6 +50,19 @@ static void sctp_stream_outq_migrate(struct sctp_stream *stream, sctp_chunk_free(ch); } +} + +/* Migrates chunks from stream queues to new stream queues if needed, + * but not across associations. Also, removes those chunks to streams + * higher than the new max. + */ +static void sctp_stream_outq_migrate(struct sctp_stream *stream, + struct sctp_stream *new, __u16 outcnt) +{ + int i; + + if (stream->outcnt > outcnt) + sctp_stream_shrink_out(stream, outcnt); if (new) { /* Here we actually move the old ext stuff into the new -- 2.1.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/2] sctp: shrink stream outq when fails to do addstream reconf 2020-07-22 15:52 ` [PATCH net 1/2] sctp: shrink stream outq only when new outcnt < old outcnt Xin Long @ 2020-07-22 15:52 ` Xin Long 0 siblings, 0 replies; 5+ messages in thread From: Xin Long @ 2020-07-22 15:52 UTC (permalink / raw) To: network dev, linux-sctp; +Cc: davem, Marcelo Ricardo Leitner, Neil Horman When adding a stream with stream reconf, the new stream firstly is in CLOSED state but new out chunks can still be enqueued. Then once gets the confirmation from the peer, the state will change to OPEN. However, if the peer denies, it needs to roll back the stream. But when doing that, it only sets the stream outcnt back, and the chunks already in the new stream don't get purged. It caused these chunks can still be dequeued in sctp_outq_dequeue_data(). As its stream is still in CLOSE, the chunk will be enqueued to the head again by sctp_outq_head_data(). This chunk will never be sent out, and the chunks after it can never be dequeued. The assoc will be 'hung' in a dead loop of sending this chunk. To fix it, this patch is to purge these chunks already in the new stream by calling sctp_stream_shrink_out() when failing to do the addstream reconf. Fixes: 11ae76e67a17 ("sctp: implement receiver-side procedures for the Reconf Response Parameter") Reported-by: Ying Xu <yinxu@redhat.com> Signed-off-by: Xin Long <lucien.xin@gmail.com> --- net/sctp/stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/sctp/stream.c b/net/sctp/stream.c index 4f87693..bda2536 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -1044,11 +1044,13 @@ struct sctp_chunk *sctp_process_strreset_resp( nums = ntohs(addstrm->number_of_streams); number = stream->outcnt - nums; - if (result = SCTP_STRRESET_PERFORMED) + if (result = SCTP_STRRESET_PERFORMED) { for (i = number; i < stream->outcnt; i++) SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN; - else + } else { + sctp_stream_shrink_out(stream, number); stream->outcnt = number; + } *evp = sctp_ulpevent_make_stream_change_event(asoc, flags, 0, nums, GFP_ATOMIC); -- 2.1.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/2] sctp: shrink stream outq in the right place 2020-07-22 15:52 [PATCH net 0/2] sctp: shrink stream outq in the right place Xin Long 2020-07-22 15:52 ` [PATCH net 1/2] sctp: shrink stream outq only when new outcnt < old outcnt Xin Long @ 2020-07-22 20:46 ` Marcelo Ricardo Leitner 2020-07-23 1:05 ` David Miller 2 siblings, 0 replies; 5+ messages in thread From: Marcelo Ricardo Leitner @ 2020-07-22 20:46 UTC (permalink / raw) To: Xin Long; +Cc: network dev, linux-sctp, davem, Neil Horman On Wed, Jul 22, 2020 at 11:52:10PM +0800, Xin Long wrote: > Patch 1 is an improvement, and Patch 2 is a bug fix. > > Xin Long (2): > sctp: shrink stream outq only when new outcnt < old outcnt > sctp: shrink stream outq when fails to do addstream reconf Nice changelogs, thanks. Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/2] sctp: shrink stream outq in the right place 2020-07-22 15:52 [PATCH net 0/2] sctp: shrink stream outq in the right place Xin Long 2020-07-22 15:52 ` [PATCH net 1/2] sctp: shrink stream outq only when new outcnt < old outcnt Xin Long 2020-07-22 20:46 ` [PATCH net 0/2] sctp: shrink stream outq in the right place Marcelo Ricardo Leitner @ 2020-07-23 1:05 ` David Miller 2 siblings, 0 replies; 5+ messages in thread From: David Miller @ 2020-07-23 1:05 UTC (permalink / raw) To: lucien.xin; +Cc: netdev, linux-sctp, marcelo.leitner, nhorman From: Xin Long <lucien.xin@gmail.com> Date: Wed, 22 Jul 2020 23:52:10 +0800 > Patch 1 is an improvement, and Patch 2 is a bug fix. Series applied, and queued up for -stable, thank you. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-23 1:05 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-07-22 15:52 [PATCH net 0/2] sctp: shrink stream outq in the right place Xin Long 2020-07-22 15:52 ` [PATCH net 1/2] sctp: shrink stream outq only when new outcnt < old outcnt Xin Long 2020-07-22 15:52 ` [PATCH net 2/2] sctp: shrink stream outq when fails to do addstream reconf Xin Long 2020-07-22 20:46 ` [PATCH net 0/2] sctp: shrink stream outq in the right place Marcelo Ricardo Leitner 2020-07-23 1:05 ` David Miller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).