hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/net/ipv4/udp_diag.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * udp_diag.c Module for monitoring UDP transport protocols sockets.
34 *
45 * Authors: Pavel Emelyanov, <xemul@parallels.com>
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License
8
- * as published by the Free Software Foundation; either version
9
- * 2 of the License, or (at your option) any later version.
106 */
117
128
....@@ -25,16 +21,15 @@
2521 if (!inet_diag_bc_sk(bc, sk))
2622 return 0;
2723
28
- return inet_sk_diag_fill(sk, NULL, skb, req,
29
- sk_user_ns(NETLINK_CB(cb->skb).sk),
30
- NETLINK_CB(cb->skb).portid,
31
- cb->nlh->nlmsg_seq, NLM_F_MULTI, cb->nlh, net_admin);
24
+ return inet_sk_diag_fill(sk, NULL, skb, cb, req, NLM_F_MULTI,
25
+ net_admin);
3226 }
3327
34
-static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb,
35
- const struct nlmsghdr *nlh,
28
+static int udp_dump_one(struct udp_table *tbl,
29
+ struct netlink_callback *cb,
3630 const struct inet_diag_req_v2 *req)
3731 {
32
+ struct sk_buff *in_skb = cb->skb;
3833 int err = -EINVAL;
3934 struct sock *sk = NULL;
4035 struct sk_buff *rep;
....@@ -42,6 +37,7 @@
4237
4338 rcu_read_lock();
4439 if (req->sdiag_family == AF_INET)
40
+ /* src and dst are swapped for historical reasons */
4541 sk = __udp4_lib_lookup(net,
4642 req->id.idiag_src[0], req->id.idiag_sport,
4743 req->id.idiag_dst[0], req->id.idiag_dport,
....@@ -74,11 +70,8 @@
7470 if (!rep)
7571 goto out;
7672
77
- err = inet_sk_diag_fill(sk, NULL, rep, req,
78
- sk_user_ns(NETLINK_CB(in_skb).sk),
79
- NETLINK_CB(in_skb).portid,
80
- nlh->nlmsg_seq, 0, nlh,
81
- netlink_net_capable(in_skb, CAP_NET_ADMIN));
73
+ err = inet_sk_diag_fill(sk, NULL, rep, cb, req, 0,
74
+ netlink_net_capable(in_skb, CAP_NET_ADMIN));
8275 if (err < 0) {
8376 WARN_ON(err == -EMSGSIZE);
8477 kfree_skb(rep);
....@@ -97,12 +90,16 @@
9790
9891 static void udp_dump(struct udp_table *table, struct sk_buff *skb,
9992 struct netlink_callback *cb,
100
- const struct inet_diag_req_v2 *r, struct nlattr *bc)
93
+ const struct inet_diag_req_v2 *r)
10194 {
10295 bool net_admin = netlink_net_capable(cb->skb, CAP_NET_ADMIN);
10396 struct net *net = sock_net(skb->sk);
97
+ struct inet_diag_dump_data *cb_data;
10498 int num, s_num, slot, s_slot;
99
+ struct nlattr *bc;
105100
101
+ cb_data = cb->data;
102
+ bc = cb_data->inet_diag_nla_bc;
106103 s_slot = cb->args[0];
107104 num = s_num = cb->args[1];
108105
....@@ -150,15 +147,15 @@
150147 }
151148
152149 static void udp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
153
- const struct inet_diag_req_v2 *r, struct nlattr *bc)
150
+ const struct inet_diag_req_v2 *r)
154151 {
155
- udp_dump(&udp_table, skb, cb, r, bc);
152
+ udp_dump(&udp_table, skb, cb, r);
156153 }
157154
158
-static int udp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
155
+static int udp_diag_dump_one(struct netlink_callback *cb,
159156 const struct inet_diag_req_v2 *req)
160157 {
161
- return udp_dump_one(&udp_table, in_skb, nlh, req);
158
+ return udp_dump_one(&udp_table, cb, req);
162159 }
163160
164161 static void udp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
....@@ -253,16 +250,15 @@
253250 };
254251
255252 static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
256
- const struct inet_diag_req_v2 *r,
257
- struct nlattr *bc)
253
+ const struct inet_diag_req_v2 *r)
258254 {
259
- udp_dump(&udplite_table, skb, cb, r, bc);
255
+ udp_dump(&udplite_table, skb, cb, r);
260256 }
261257
262
-static int udplite_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
258
+static int udplite_diag_dump_one(struct netlink_callback *cb,
263259 const struct inet_diag_req_v2 *req)
264260 {
265
- return udp_dump_one(&udplite_table, in_skb, nlh, req);
261
+ return udp_dump_one(&udplite_table, cb, req);
266262 }
267263
268264 static const struct inet_diag_handler udplite_diag_handler = {