Commit 8f13399d authored by Xin Long's avatar Xin Long Committed by David S. Miller

sctp: shrink stream outq only when new outcnt < old outcnt

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: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2f2a7ffa
...@@ -22,17 +22,11 @@ ...@@ -22,17 +22,11 @@
#include <net/sctp/sm.h> #include <net/sctp/sm.h>
#include <net/sctp/stream_sched.h> #include <net/sctp/stream_sched.h>
/* Migrates chunks from stream queues to new stream queues if needed, static void sctp_stream_shrink_out(struct sctp_stream *stream, __u16 outcnt)
* 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)
{ {
struct sctp_association *asoc; struct sctp_association *asoc;
struct sctp_chunk *ch, *temp; struct sctp_chunk *ch, *temp;
struct sctp_outq *outq; struct sctp_outq *outq;
int i;
asoc = container_of(stream, struct sctp_association, stream); asoc = container_of(stream, struct sctp_association, stream);
outq = &asoc->outqueue; outq = &asoc->outqueue;
...@@ -56,6 +50,19 @@ static void sctp_stream_outq_migrate(struct sctp_stream *stream, ...@@ -56,6 +50,19 @@ static void sctp_stream_outq_migrate(struct sctp_stream *stream,
sctp_chunk_free(ch); 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) { if (new) {
/* Here we actually move the old ext stuff into the new /* Here we actually move the old ext stuff into the new
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment