Skip to content

Commit 8f13399

Browse files
lxindavem330
authored andcommitted
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: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2f2a7ff commit 8f13399

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

net/sctp/stream.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,11 @@
2222
#include <net/sctp/sm.h>
2323
#include <net/sctp/stream_sched.h>
2424

25-
/* Migrates chunks from stream queues to new stream queues if needed,
26-
* but not across associations. Also, removes those chunks to streams
27-
* higher than the new max.
28-
*/
29-
static void sctp_stream_outq_migrate(struct sctp_stream *stream,
30-
struct sctp_stream *new, __u16 outcnt)
25+
static void sctp_stream_shrink_out(struct sctp_stream *stream, __u16 outcnt)
3126
{
3227
struct sctp_association *asoc;
3328
struct sctp_chunk *ch, *temp;
3429
struct sctp_outq *outq;
35-
int i;
3630

3731
asoc = container_of(stream, struct sctp_association, stream);
3832
outq = &asoc->outqueue;
@@ -56,6 +50,19 @@ static void sctp_stream_outq_migrate(struct sctp_stream *stream,
5650

5751
sctp_chunk_free(ch);
5852
}
53+
}
54+
55+
/* Migrates chunks from stream queues to new stream queues if needed,
56+
* but not across associations. Also, removes those chunks to streams
57+
* higher than the new max.
58+
*/
59+
static void sctp_stream_outq_migrate(struct sctp_stream *stream,
60+
struct sctp_stream *new, __u16 outcnt)
61+
{
62+
int i;
63+
64+
if (stream->outcnt > outcnt)
65+
sctp_stream_shrink_out(stream, outcnt);
5966

6067
if (new) {
6168
/* Here we actually move the old ext stuff into the new

0 commit comments

Comments
 (0)