hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/net/sctp/diag.c
....@@ -1,25 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* SCTP kernel implementation
23 * (C) Copyright Red Hat Inc. 2017
34 *
45 * This file is part of the SCTP kernel implementation
56 *
67 * These functions implement sctp diag support.
7
- *
8
- * This SCTP implementation is free software;
9
- * you can redistribute it and/or modify it under the terms of
10
- * the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2, or (at your option)
12
- * any later version.
13
- *
14
- * This SCTP implementation is distributed in the hope that it
15
- * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16
- * ************************
17
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
- * See the GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with GNU CC; see the file COPYING. If not, see
22
- * <http://www.gnu.org/licenses/>.
238 *
249 * Please send any bug reports or fixes you make to the
2510 * email addresched(es):
....@@ -76,10 +61,6 @@
7661 r->idiag_timer = SCTP_EVENT_TIMEOUT_T3_RTX;
7762 r->idiag_retrans = asoc->rtx_data_chunks;
7863 r->idiag_expires = jiffies_to_msecs(t3_rtx->expires - jiffies);
79
- } else {
80
- r->idiag_timer = 0;
81
- r->idiag_retrans = 0;
82
- r->idiag_expires = 0;
8364 }
8465 }
8566
....@@ -159,13 +140,14 @@
159140 r = nlmsg_data(nlh);
160141 BUG_ON(!sk_fullsock(sk));
161142
143
+ r->idiag_timer = 0;
144
+ r->idiag_retrans = 0;
145
+ r->idiag_expires = 0;
162146 if (asoc) {
163147 inet_diag_msg_sctpasoc_fill(r, sk, asoc);
164148 } else {
165149 inet_diag_msg_common_fill(r, sk);
166150 r->idiag_state = sk->sk_state;
167
- r->idiag_timer = 0;
168
- r->idiag_retrans = 0;
169151 }
170152
171153 if (inet_diag_msg_attrs_fill(sk, skb, r, ext, user_ns, net_admin))
....@@ -190,7 +172,7 @@
190172 mem[SK_MEMINFO_FWD_ALLOC] = sk->sk_forward_alloc;
191173 mem[SK_MEMINFO_WMEM_QUEUED] = sk->sk_wmem_queued;
192174 mem[SK_MEMINFO_OPTMEM] = atomic_read(&sk->sk_omem_alloc);
193
- mem[SK_MEMINFO_BACKLOG] = sk->sk_backlog.len;
175
+ mem[SK_MEMINFO_BACKLOG] = READ_ONCE(sk->sk_backlog.len);
194176 mem[SK_MEMINFO_DROPS] = atomic_read(&sk->sk_drops);
195177
196178 if (nla_put(skb, INET_DIAG_SKMEMINFO, sizeof(mem), &mem) < 0)
....@@ -436,18 +418,19 @@
436418 r->idiag_rqueue = atomic_read(&infox->asoc->rmem_alloc);
437419 r->idiag_wqueue = infox->asoc->sndbuf_used;
438420 } else {
439
- r->idiag_rqueue = sk->sk_ack_backlog;
440
- r->idiag_wqueue = sk->sk_max_ack_backlog;
421
+ r->idiag_rqueue = READ_ONCE(sk->sk_ack_backlog);
422
+ r->idiag_wqueue = READ_ONCE(sk->sk_max_ack_backlog);
441423 }
442424 if (infox->sctpinfo)
443425 sctp_get_sctp_info(sk, infox->asoc, infox->sctpinfo);
444426 }
445427
446
-static int sctp_diag_dump_one(struct sk_buff *in_skb,
447
- const struct nlmsghdr *nlh,
428
+static int sctp_diag_dump_one(struct netlink_callback *cb,
448429 const struct inet_diag_req_v2 *req)
449430 {
431
+ struct sk_buff *in_skb = cb->skb;
450432 struct net *net = sock_net(in_skb->sk);
433
+ const struct nlmsghdr *nlh = cb->nlh;
451434 union sctp_addr laddr, paddr;
452435 struct sctp_comm_param commp = {
453436 .skb = in_skb,
....@@ -481,7 +464,7 @@
481464 }
482465
483466 static void sctp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
484
- const struct inet_diag_req_v2 *r, struct nlattr *bc)
467
+ const struct inet_diag_req_v2 *r)
485468 {
486469 u32 idiag_states = r->idiag_states;
487470 struct net *net = sock_net(skb->sk);