forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/net/dccp/ipv6.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * DCCP over IPv6
34 * Linux INET6 implementation
....@@ -5,11 +6,6 @@
56 * Based on net/dccp6/ipv6.c
67 *
78 * Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
8
- *
9
- * This program is free software; you can redistribute it and/or
10
- * modify it under the terms of the GNU General Public License
11
- * as published by the Free Software Foundation; either version
12
- * 2 of the License, or (at your option) any later version.
139 */
1410
1511 #include <linux/module.h>
....@@ -68,7 +64,7 @@
6864
6965 }
7066
71
-static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
67
+static int dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
7268 u8 type, u8 code, int offset, __be32 info)
7369 {
7470 const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
....@@ -96,16 +92,18 @@
9692 if (!sk) {
9793 __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),
9894 ICMP6_MIB_INERRORS);
99
- return;
95
+ return -ENOENT;
10096 }
10197
10298 if (sk->sk_state == DCCP_TIME_WAIT) {
10399 inet_twsk_put(inet_twsk(sk));
104
- return;
100
+ return 0;
105101 }
106102 seq = dccp_hdr_seq(dh);
107
- if (sk->sk_state == DCCP_NEW_SYN_RECV)
108
- return dccp_req_err(sk, seq);
103
+ if (sk->sk_state == DCCP_NEW_SYN_RECV) {
104
+ dccp_req_err(sk, seq);
105
+ return 0;
106
+ }
109107
110108 bh_lock_sock(sk);
111109 if (sock_owned_by_user(sk))
....@@ -183,6 +181,7 @@
183181 out:
184182 bh_unlock_sock(sk);
185183 sock_put(sk);
184
+ return 0;
186185 }
187186
188187
....@@ -204,7 +203,7 @@
204203 fl6.flowi6_oif = ireq->ir_iif;
205204 fl6.fl6_dport = ireq->ir_rmt_port;
206205 fl6.fl6_sport = htons(ireq->ir_num);
207
- security_req_classify_flow(req, flowi6_to_flowi(&fl6));
206
+ security_req_classify_flow(req, flowi6_to_flowi_common(&fl6));
208207
209208
210209 rcu_read_lock();
....@@ -231,7 +230,8 @@
231230 opt = ireq->ipv6_opt;
232231 if (!opt)
233232 opt = rcu_dereference(np->opt);
234
- err = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass);
233
+ err = ip6_xmit(sk, skb, &fl6, sk->sk_mark, opt, np->tclass,
234
+ sk->sk_priority);
235235 rcu_read_unlock();
236236 err = net_xmit_eval(err);
237237 }
....@@ -279,13 +279,13 @@
279279 fl6.flowi6_oif = inet6_iif(rxskb);
280280 fl6.fl6_dport = dccp_hdr(skb)->dccph_dport;
281281 fl6.fl6_sport = dccp_hdr(skb)->dccph_sport;
282
- security_skb_classify_flow(rxskb, flowi6_to_flowi(&fl6));
282
+ security_skb_classify_flow(rxskb, flowi6_to_flowi_common(&fl6));
283283
284284 /* sk = NULL, but it is safe for now. RST socket required. */
285285 dst = ip6_dst_lookup_flow(sock_net(ctl_sk), ctl_sk, &fl6, NULL);
286286 if (!IS_ERR(dst)) {
287287 skb_dst_set(skb, dst);
288
- ip6_xmit(ctl_sk, skb, &fl6, 0, NULL, 0);
288
+ ip6_xmit(ctl_sk, skb, &fl6, 0, NULL, 0, 0);
289289 DCCP_INC_STATS(DCCP_MIB_OUTSEGS);
290290 DCCP_INC_STATS(DCCP_MIB_OUTRSTS);
291291 return;
....@@ -538,7 +538,7 @@
538538 dccp_done(newsk);
539539 goto out;
540540 }
541
- *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));
541
+ *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash), NULL);
542542 /* Clone pktoptions received with SYN, if we own the req */
543543 if (*own_req && ireq->pktopts) {
544544 newnp->pktoptions = skb_clone(ireq->pktopts, GFP_ATOMIC);
....@@ -836,7 +836,7 @@
836836 if (fl6.flowlabel & IPV6_FLOWLABEL_MASK) {
837837 struct ip6_flowlabel *flowlabel;
838838 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
839
- if (flowlabel == NULL)
839
+ if (IS_ERR(flowlabel))
840840 return -EINVAL;
841841 fl6_sock_release(flowlabel);
842842 }
....@@ -912,7 +912,7 @@
912912 fl6.flowi6_oif = sk->sk_bound_dev_if;
913913 fl6.fl6_dport = usin->sin6_port;
914914 fl6.fl6_sport = inet->inet_sport;
915
- security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
915
+ security_sk_classify_flow(sk, flowi6_to_flowi_common(&fl6));
916916
917917 opt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk));
918918 final_p = fl6_update_dst(&fl6, opt, &final);
....@@ -957,6 +957,8 @@
957957
958958 late_failure:
959959 dccp_set_state(sk, DCCP_CLOSED);
960
+ if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))
961
+ inet_reset_saddr(sk);
960962 __sk_dst_reset(sk);
961963 failure:
962964 inet->inet_dport = 0;
....@@ -975,10 +977,6 @@
975977 .getsockopt = ipv6_getsockopt,
976978 .addr2sockaddr = inet6_csk_addr2sockaddr,
977979 .sockaddr_len = sizeof(struct sockaddr_in6),
978
-#ifdef CONFIG_COMPAT
979
- .compat_setsockopt = compat_ipv6_setsockopt,
980
- .compat_getsockopt = compat_ipv6_getsockopt,
981
-#endif
982980 };
983981
984982 /*
....@@ -995,10 +993,6 @@
995993 .getsockopt = ipv6_getsockopt,
996994 .addr2sockaddr = inet6_csk_addr2sockaddr,
997995 .sockaddr_len = sizeof(struct sockaddr_in6),
998
-#ifdef CONFIG_COMPAT
999
- .compat_setsockopt = compat_ipv6_setsockopt,
1000
- .compat_getsockopt = compat_ipv6_getsockopt,
1001
-#endif
1002996 };
1003997
1004998 /* NOTE: A lot of things set to zero explicitly by call to
....@@ -1054,10 +1048,6 @@
10541048 .rsk_prot = &dccp6_request_sock_ops,
10551049 .twsk_prot = &dccp6_timewait_sock_ops,
10561050 .h.hashinfo = &dccp_hashinfo,
1057
-#ifdef CONFIG_COMPAT
1058
- .compat_setsockopt = compat_dccp_setsockopt,
1059
- .compat_getsockopt = compat_dccp_getsockopt,
1060
-#endif
10611051 };
10621052
10631053 static const struct inet6_protocol dccp_v6_protocol = {
....@@ -1077,6 +1067,7 @@
10771067 .getname = inet6_getname,
10781068 .poll = dccp_poll,
10791069 .ioctl = inet6_ioctl,
1070
+ .gettstamp = sock_gettstamp,
10801071 .listen = inet_dccp_listen,
10811072 .shutdown = inet_shutdown,
10821073 .setsockopt = sock_common_setsockopt,
....@@ -1086,8 +1077,7 @@
10861077 .mmap = sock_no_mmap,
10871078 .sendpage = sock_no_sendpage,
10881079 #ifdef CONFIG_COMPAT
1089
- .compat_setsockopt = compat_sock_common_setsockopt,
1090
- .compat_getsockopt = compat_sock_common_getsockopt,
1080
+ .compat_ioctl = inet6_compat_ioctl,
10911081 #endif
10921082 };
10931083