hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/sctp/outqueue.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* SCTP kernel implementation
23 * (C) Copyright IBM Corp. 2001, 2004
34 * Copyright (c) 1999-2000 Cisco, Inc.
....@@ -8,22 +9,6 @@
89 *
910 * These functions implement the sctp_outq class. The outqueue handles
1011 * bundling and queueing of outgoing SCTP chunks.
11
- *
12
- * This SCTP implementation is free software;
13
- * you can redistribute it and/or modify it under the terms of
14
- * the GNU General Public License as published by
15
- * the Free Software Foundation; either version 2, or (at your option)
16
- * any later version.
17
- *
18
- * This SCTP implementation is distributed in the hope that it
19
- * will be useful, but WITHOUT ANY WARRANTY; without even the implied
20
- * ************************
21
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22
- * See the GNU General Public License for more details.
23
- *
24
- * You should have received a copy of the GNU General Public License
25
- * along with GNU CC; see the file COPYING. If not, see
26
- * <http://www.gnu.org/licenses/>.
2712 *
2813 * Please send any bug reports or fixes you make to the
2914 * email address(es):
....@@ -213,7 +198,7 @@
213198 INIT_LIST_HEAD(&q->retransmit);
214199 INIT_LIST_HEAD(&q->sacked);
215200 INIT_LIST_HEAD(&q->abandoned);
216
- sctp_sched_set_sched(asoc, SCTP_SS_DEFAULT);
201
+ sctp_sched_set_sched(asoc, sctp_sk(asoc->base.sk)->default_ss);
217202 }
218203
219204 /* Free the outqueue structure and any related pending chunks.
....@@ -295,7 +280,7 @@
295280 /* Put a new chunk in an sctp_outq. */
296281 void sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk, gfp_t gfp)
297282 {
298
- struct net *net = sock_net(q->asoc->base.sk);
283
+ struct net *net = q->asoc->base.net;
299284
300285 pr_debug("%s: outq:%p, chunk:%p[%s]\n", __func__, q, chunk,
301286 chunk && chunk->chunk_hdr ?
....@@ -386,9 +371,7 @@
386371 asoc->outqueue.outstanding_bytes -= sctp_data_size(chk);
387372 }
388373
389
- msg_len -= SCTP_DATA_SNDSIZE(chk) +
390
- sizeof(struct sk_buff) +
391
- sizeof(struct sctp_chunk);
374
+ msg_len -= chk->skb->truesize + sizeof(struct sctp_chunk);
392375 if (msg_len <= 0)
393376 break;
394377 }
....@@ -401,6 +384,7 @@
401384 {
402385 struct sctp_outq *q = &asoc->outqueue;
403386 struct sctp_chunk *chk, *temp;
387
+ struct sctp_stream_out *sout;
404388
405389 q->sched->unsched_all(&asoc->stream);
406390
....@@ -415,16 +399,16 @@
415399 sctp_sched_dequeue_common(q, chk);
416400 asoc->sent_cnt_removable--;
417401 asoc->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
418
- if (chk->sinfo.sinfo_stream < asoc->stream.outcnt) {
419
- struct sctp_stream_out *streamout =
420
- SCTP_SO(&asoc->stream, chk->sinfo.sinfo_stream);
421402
422
- streamout->ext->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
423
- }
403
+ sout = SCTP_SO(&asoc->stream, chk->sinfo.sinfo_stream);
404
+ sout->ext->abandoned_unsent[SCTP_PR_INDEX(PRIO)]++;
424405
425
- msg_len -= SCTP_DATA_SNDSIZE(chk) +
426
- sizeof(struct sk_buff) +
427
- sizeof(struct sctp_chunk);
406
+ /* clear out_curr if all frag chunks are pruned */
407
+ if (asoc->stream.out_curr == sout &&
408
+ list_is_last(&chk->frag_list, &chk->msg->chunks))
409
+ asoc->stream.out_curr = NULL;
410
+
411
+ msg_len -= chk->skb->truesize + sizeof(struct sctp_chunk);
428412 sctp_chunk_free(chk);
429413 if (msg_len <= 0)
430414 break;
....@@ -553,7 +537,7 @@
553537 void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
554538 enum sctp_retransmit_reason reason)
555539 {
556
- struct net *net = sock_net(q->asoc->base.sk);
540
+ struct net *net = q->asoc->base.net;
557541
558542 switch (reason) {
559543 case SCTP_RTXR_T3_RTX:
....@@ -931,7 +915,7 @@
931915 case SCTP_CID_ABORT:
932916 if (sctp_test_T_bit(chunk))
933917 ctx->packet->vtag = ctx->asoc->c.my_vtag;
934
- /* fallthru */
918
+ fallthrough;
935919
936920 /* The following chunks are "response" chunks, i.e.
937921 * they are generated in response to something we
....@@ -946,7 +930,7 @@
946930 case SCTP_CID_ECN_CWR:
947931 case SCTP_CID_ASCONF_ACK:
948932 one_packet = 1;
949
- /* Fall through */
933
+ fallthrough;
950934
951935 case SCTP_CID_SACK:
952936 case SCTP_CID_HEARTBEAT:
....@@ -1049,7 +1033,7 @@
10491033 if (!ctx->packet || !ctx->packet->has_cookie_echo)
10501034 return;
10511035
1052
- /* fall through */
1036
+ fallthrough;
10531037 case SCTP_STATE_ESTABLISHED:
10541038 case SCTP_STATE_SHUTDOWN_PENDING:
10551039 case SCTP_STATE_SHUTDOWN_RECEIVED:
....@@ -1259,8 +1243,9 @@
12591243 transport_list = &asoc->peer.transport_addr_list;
12601244
12611245 /* SCTP path tracepoint for congestion control debugging. */
1262
- list_for_each_entry(transport, transport_list, transports) {
1263
- trace_sctp_probe_path(transport, asoc);
1246
+ if (trace_sctp_probe_path_enabled()) {
1247
+ list_for_each_entry(transport, transport_list, transports)
1248
+ trace_sctp_probe_path(transport, asoc);
12641249 }
12651250
12661251 sack_ctsn = ntohl(sack->cum_tsn_ack);
....@@ -1909,6 +1894,6 @@
19091894
19101895 if (ftsn_chunk) {
19111896 list_add_tail(&ftsn_chunk->list, &q->control_chunk_list);
1912
- SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_OUTCTRLCHUNKS);
1897
+ SCTP_INC_STATS(asoc->base.net, SCTP_MIB_OUTCTRLCHUNKS);
19131898 }
19141899 }