.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* SCTP kernel implementation |
---|
2 | 3 | * (C) Copyright IBM Corp. 2001, 2004 |
---|
3 | 4 | * Copyright (c) 1999-2000 Cisco, Inc. |
---|
.. | .. |
---|
8 | 9 | * |
---|
9 | 10 | * These functions implement the sctp_outq class. The outqueue handles |
---|
10 | 11 | * 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/>. |
---|
27 | 12 | * |
---|
28 | 13 | * Please send any bug reports or fixes you make to the |
---|
29 | 14 | * email address(es): |
---|
.. | .. |
---|
213 | 198 | INIT_LIST_HEAD(&q->retransmit); |
---|
214 | 199 | INIT_LIST_HEAD(&q->sacked); |
---|
215 | 200 | 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); |
---|
217 | 202 | } |
---|
218 | 203 | |
---|
219 | 204 | /* Free the outqueue structure and any related pending chunks. |
---|
.. | .. |
---|
295 | 280 | /* Put a new chunk in an sctp_outq. */ |
---|
296 | 281 | void sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk, gfp_t gfp) |
---|
297 | 282 | { |
---|
298 | | - struct net *net = sock_net(q->asoc->base.sk); |
---|
| 283 | + struct net *net = q->asoc->base.net; |
---|
299 | 284 | |
---|
300 | 285 | pr_debug("%s: outq:%p, chunk:%p[%s]\n", __func__, q, chunk, |
---|
301 | 286 | chunk && chunk->chunk_hdr ? |
---|
.. | .. |
---|
386 | 371 | asoc->outqueue.outstanding_bytes -= sctp_data_size(chk); |
---|
387 | 372 | } |
---|
388 | 373 | |
---|
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); |
---|
392 | 375 | if (msg_len <= 0) |
---|
393 | 376 | break; |
---|
394 | 377 | } |
---|
.. | .. |
---|
401 | 384 | { |
---|
402 | 385 | struct sctp_outq *q = &asoc->outqueue; |
---|
403 | 386 | struct sctp_chunk *chk, *temp; |
---|
| 387 | + struct sctp_stream_out *sout; |
---|
404 | 388 | |
---|
405 | 389 | q->sched->unsched_all(&asoc->stream); |
---|
406 | 390 | |
---|
.. | .. |
---|
415 | 399 | sctp_sched_dequeue_common(q, chk); |
---|
416 | 400 | asoc->sent_cnt_removable--; |
---|
417 | 401 | 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); |
---|
421 | 402 | |
---|
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)]++; |
---|
424 | 405 | |
---|
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); |
---|
428 | 412 | sctp_chunk_free(chk); |
---|
429 | 413 | if (msg_len <= 0) |
---|
430 | 414 | break; |
---|
.. | .. |
---|
553 | 537 | void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport, |
---|
554 | 538 | enum sctp_retransmit_reason reason) |
---|
555 | 539 | { |
---|
556 | | - struct net *net = sock_net(q->asoc->base.sk); |
---|
| 540 | + struct net *net = q->asoc->base.net; |
---|
557 | 541 | |
---|
558 | 542 | switch (reason) { |
---|
559 | 543 | case SCTP_RTXR_T3_RTX: |
---|
.. | .. |
---|
931 | 915 | case SCTP_CID_ABORT: |
---|
932 | 916 | if (sctp_test_T_bit(chunk)) |
---|
933 | 917 | ctx->packet->vtag = ctx->asoc->c.my_vtag; |
---|
934 | | - /* fallthru */ |
---|
| 918 | + fallthrough; |
---|
935 | 919 | |
---|
936 | 920 | /* The following chunks are "response" chunks, i.e. |
---|
937 | 921 | * they are generated in response to something we |
---|
.. | .. |
---|
946 | 930 | case SCTP_CID_ECN_CWR: |
---|
947 | 931 | case SCTP_CID_ASCONF_ACK: |
---|
948 | 932 | one_packet = 1; |
---|
949 | | - /* Fall through */ |
---|
| 933 | + fallthrough; |
---|
950 | 934 | |
---|
951 | 935 | case SCTP_CID_SACK: |
---|
952 | 936 | case SCTP_CID_HEARTBEAT: |
---|
.. | .. |
---|
1049 | 1033 | if (!ctx->packet || !ctx->packet->has_cookie_echo) |
---|
1050 | 1034 | return; |
---|
1051 | 1035 | |
---|
1052 | | - /* fall through */ |
---|
| 1036 | + fallthrough; |
---|
1053 | 1037 | case SCTP_STATE_ESTABLISHED: |
---|
1054 | 1038 | case SCTP_STATE_SHUTDOWN_PENDING: |
---|
1055 | 1039 | case SCTP_STATE_SHUTDOWN_RECEIVED: |
---|
.. | .. |
---|
1259 | 1243 | transport_list = &asoc->peer.transport_addr_list; |
---|
1260 | 1244 | |
---|
1261 | 1245 | /* 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); |
---|
1264 | 1249 | } |
---|
1265 | 1250 | |
---|
1266 | 1251 | sack_ctsn = ntohl(sack->cum_tsn_ack); |
---|
.. | .. |
---|
1909 | 1894 | |
---|
1910 | 1895 | if (ftsn_chunk) { |
---|
1911 | 1896 | 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); |
---|
1913 | 1898 | } |
---|
1914 | 1899 | } |
---|