hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/ipv6/tcp_ipv6.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * TCP over IPv6
34 * Linux INET6 implementation
....@@ -16,11 +17,6 @@
1617 * Alexey Kuznetsov allow both IPv4 and IPv6 sockets to bind
1718 * a single port at the same time.
1819 * YOSHIFUJI Hideaki @USAGI: convert /proc/net/tcp6 to seq_file.
19
- *
20
- * This program is free software; you can redistribute it and/or
21
- * modify it under the terms of the GNU General Public License
22
- * as published by the Free Software Foundation; either version
23
- * 2 of the License, or (at your option) any later version.
2420 */
2521
2622 #include <linux/bottom_half.h>
....@@ -43,6 +39,7 @@
4339 #include <linux/ipv6.h>
4440 #include <linux/icmpv6.h>
4541 #include <linux/random.h>
42
+#include <linux/indirect_call_wrapper.h>
4643
4744 #include <net/tcp.h>
4845 #include <net/ndisc.h>
....@@ -78,17 +75,30 @@
7875 static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb);
7976
8077 static const struct inet_connection_sock_af_ops ipv6_mapped;
81
-static const struct inet_connection_sock_af_ops ipv6_specific;
78
+const struct inet_connection_sock_af_ops ipv6_specific;
8279 #ifdef CONFIG_TCP_MD5SIG
8380 static const struct tcp_sock_af_ops tcp_sock_ipv6_specific;
8481 static const struct tcp_sock_af_ops tcp_sock_ipv6_mapped_specific;
8582 #else
8683 static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(const struct sock *sk,
87
- const struct in6_addr *addr)
84
+ const struct in6_addr *addr,
85
+ int l3index)
8886 {
8987 return NULL;
9088 }
9189 #endif
90
+
91
+/* Helper returning the inet6 address from a given tcp socket.
92
+ * It can be used in TCP stack instead of inet6_sk(sk).
93
+ * This avoids a dereference and allow compiler optimizations.
94
+ * It is a specialized version of inet6_sk_generic().
95
+ */
96
+static struct ipv6_pinfo *tcp_inet6_sk(const struct sock *sk)
97
+{
98
+ unsigned int offset = sizeof(struct tcp6_sock) - sizeof(struct ipv6_pinfo);
99
+
100
+ return (struct ipv6_pinfo *)(((u8 *)sk) + offset);
101
+}
92102
93103 static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
94104 {
....@@ -97,9 +107,9 @@
97107 if (dst && dst_hold_safe(dst)) {
98108 const struct rt6_info *rt = (const struct rt6_info *)dst;
99109
100
- sk->sk_rx_dst = dst;
110
+ rcu_assign_pointer(sk->sk_rx_dst, dst);
101111 inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
102
- inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);
112
+ tcp_inet6_sk(sk)->rx_dst_cookie = rt6_get_cookie(rt);
103113 }
104114 }
105115
....@@ -138,7 +148,7 @@
138148 struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr;
139149 struct inet_sock *inet = inet_sk(sk);
140150 struct inet_connection_sock *icsk = inet_csk(sk);
141
- struct ipv6_pinfo *np = inet6_sk(sk);
151
+ struct ipv6_pinfo *np = tcp_inet6_sk(sk);
142152 struct tcp_sock *tp = tcp_sk(sk);
143153 struct in6_addr *saddr = NULL, *final_p, final;
144154 struct ipv6_txoptions *opt;
....@@ -162,7 +172,7 @@
162172 if (fl6.flowlabel&IPV6_FLOWLABEL_MASK) {
163173 struct ip6_flowlabel *flowlabel;
164174 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
165
- if (!flowlabel)
175
+ if (IS_ERR(flowlabel))
166176 return -EINVAL;
167177 fl6_sock_release(flowlabel);
168178 }
....@@ -220,8 +230,6 @@
220230 u32 exthdrlen = icsk->icsk_ext_hdr_len;
221231 struct sockaddr_in sin;
222232
223
- SOCK_DEBUG(sk, "connect: ipv4 mapped\n");
224
-
225233 if (__ipv6_only_sock(sk))
226234 return -ENETUNREACH;
227235
....@@ -230,6 +238,8 @@
230238 sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
231239
232240 icsk->icsk_af_ops = &ipv6_mapped;
241
+ if (sk_is_mptcp(sk))
242
+ mptcpv6_handle_mapped(sk, true);
233243 sk->sk_backlog_rcv = tcp_v4_do_rcv;
234244 #ifdef CONFIG_TCP_MD5SIG
235245 tp->af_specific = &tcp_sock_ipv6_mapped_specific;
....@@ -240,6 +250,8 @@
240250 if (err) {
241251 icsk->icsk_ext_hdr_len = exthdrlen;
242252 icsk->icsk_af_ops = &ipv6_specific;
253
+ if (sk_is_mptcp(sk))
254
+ mptcpv6_handle_mapped(sk, false);
243255 sk->sk_backlog_rcv = tcp_v6_do_rcv;
244256 #ifdef CONFIG_TCP_MD5SIG
245257 tp->af_specific = &tcp_sock_ipv6_specific;
....@@ -257,6 +269,7 @@
257269 fl6.flowi6_proto = IPPROTO_TCP;
258270 fl6.daddr = sk->sk_v6_daddr;
259271 fl6.saddr = saddr ? *saddr : np->saddr;
272
+ fl6.flowlabel = ip6_make_flowinfo(np->tclass, np->flow_label);
260273 fl6.flowi6_oif = sk->sk_bound_dev_if;
261274 fl6.flowi6_mark = sk->sk_mark;
262275 fl6.fl6_dport = usin->sin6_port;
....@@ -266,7 +279,7 @@
266279 opt = rcu_dereference_protected(np->opt, lockdep_sock_is_held(sk));
267280 final_p = fl6_update_dst(&fl6, opt, &final);
268281
269
- security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
282
+ security_sk_classify_flow(sk, flowi6_to_flowi_common(&fl6));
270283
271284 dst = ip6_dst_lookup_flow(sock_net(sk), sk, &fl6, final_p);
272285 if (IS_ERR(dst)) {
....@@ -327,6 +340,8 @@
327340
328341 late_failure:
329342 tcp_set_state(sk, TCP_CLOSE);
343
+ if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))
344
+ inet_reset_saddr(sk);
330345 failure:
331346 inet->inet_dport = 0;
332347 sk->sk_route_caps = 0;
....@@ -359,7 +374,7 @@
359374 }
360375 }
361376
362
-static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
377
+static int tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
363378 u8 type, u8 code, int offset, __be32 info)
364379 {
365380 const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data;
....@@ -381,17 +396,19 @@
381396 if (!sk) {
382397 __ICMP6_INC_STATS(net, __in6_dev_get(skb->dev),
383398 ICMP6_MIB_INERRORS);
384
- return;
399
+ return -ENOENT;
385400 }
386401
387402 if (sk->sk_state == TCP_TIME_WAIT) {
388403 inet_twsk_put(inet_twsk(sk));
389
- return;
404
+ return 0;
390405 }
391406 seq = ntohl(th->seq);
392407 fatal = icmpv6_err_convert(type, code, &err);
393
- if (sk->sk_state == TCP_NEW_SYN_RECV)
394
- return tcp_req_err(sk, seq, fatal);
408
+ if (sk->sk_state == TCP_NEW_SYN_RECV) {
409
+ tcp_req_err(sk, seq, fatal);
410
+ return 0;
411
+ }
395412
396413 bh_lock_sock(sk);
397414 if (sock_owned_by_user(sk) && type != ICMPV6_PKT_TOOBIG)
....@@ -400,14 +417,14 @@
400417 if (sk->sk_state == TCP_CLOSE)
401418 goto out;
402419
403
- if (ipv6_hdr(skb)->hop_limit < inet6_sk(sk)->min_hopcount) {
420
+ if (ipv6_hdr(skb)->hop_limit < tcp_inet6_sk(sk)->min_hopcount) {
404421 __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);
405422 goto out;
406423 }
407424
408425 tp = tcp_sk(sk);
409426 /* XXX (TFO) - tp->snd_una should be ISN (tcp_create_openreq_child() */
410
- fastopen = tp->fastopen_rsk;
427
+ fastopen = rcu_dereference(tp->fastopen_rsk);
411428 snd_una = fastopen ? tcp_rsk(fastopen)->snt_isn : tp->snd_una;
412429 if (sk->sk_state != TCP_LISTEN &&
413430 !between(seq, snd_una, tp->snd_nxt)) {
....@@ -415,7 +432,7 @@
415432 goto out;
416433 }
417434
418
- np = inet6_sk(sk);
435
+ np = tcp_inet6_sk(sk);
419436
420437 if (type == NDISC_REDIRECT) {
421438 if (!sock_owned_by_user(sk)) {
....@@ -459,10 +476,12 @@
459476 case TCP_SYN_SENT:
460477 case TCP_SYN_RECV:
461478 /* Only in fast or simultaneous open. If a fast open socket is
462
- * is already accepted it is treated as a connected one below.
479
+ * already accepted it is treated as a connected one below.
463480 */
464481 if (fastopen && !fastopen->sk)
465482 break;
483
+
484
+ ipv6_icmp_error(sk, skb, err, th->dest, ntohl(info), (u8 *)th);
466485
467486 if (!sock_owned_by_user(sk)) {
468487 sk->sk_err = err;
....@@ -472,6 +491,15 @@
472491 } else
473492 sk->sk_err_soft = err;
474493 goto out;
494
+ case TCP_LISTEN:
495
+ break;
496
+ default:
497
+ /* check if this ICMP message allows revert of backoff.
498
+ * (see RFC 6069)
499
+ */
500
+ if (!fastopen && type == ICMPV6_DEST_UNREACH &&
501
+ code == ICMPV6_NOROUTE)
502
+ tcp_ld_RTO_revert(sk, seq);
475503 }
476504
477505 if (!sock_owned_by_user(sk) && np->recverr) {
....@@ -483,6 +511,7 @@
483511 out:
484512 bh_unlock_sock(sk);
485513 sock_put(sk);
514
+ return 0;
486515 }
487516
488517
....@@ -490,21 +519,23 @@
490519 struct flowi *fl,
491520 struct request_sock *req,
492521 struct tcp_fastopen_cookie *foc,
493
- enum tcp_synack_type synack_type)
522
+ enum tcp_synack_type synack_type,
523
+ struct sk_buff *syn_skb)
494524 {
495525 struct inet_request_sock *ireq = inet_rsk(req);
496
- struct ipv6_pinfo *np = inet6_sk(sk);
526
+ struct ipv6_pinfo *np = tcp_inet6_sk(sk);
497527 struct ipv6_txoptions *opt;
498528 struct flowi6 *fl6 = &fl->u.ip6;
499529 struct sk_buff *skb;
500530 int err = -ENOMEM;
531
+ u8 tclass;
501532
502533 /* First, grab a route. */
503534 if (!dst && (dst = inet6_csk_route_req(sk, fl6, req,
504535 IPPROTO_TCP)) == NULL)
505536 goto done;
506537
507
- skb = tcp_make_synack(sk, dst, req, foc, synack_type);
538
+ skb = tcp_make_synack(sk, dst, req, foc, synack_type, syn_skb);
508539
509540 if (skb) {
510541 __tcp_v6_send_check(skb, &ireq->ir_v6_loc_addr,
....@@ -514,12 +545,21 @@
514545 if (np->repflow && ireq->pktopts)
515546 fl6->flowlabel = ip6_flowlabel(ipv6_hdr(ireq->pktopts));
516547
548
+ tclass = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reflect_tos) ?
549
+ (tcp_rsk(req)->syn_tos & ~INET_ECN_MASK) |
550
+ (np->tclass & INET_ECN_MASK) :
551
+ np->tclass;
552
+
553
+ if (!INET_ECN_is_capable(tclass) &&
554
+ tcp_bpf_ca_needs_ecn((struct sock *)req))
555
+ tclass |= INET_ECN_ECT_0;
556
+
517557 rcu_read_lock();
518558 opt = ireq->ipv6_opt;
519559 if (!opt)
520560 opt = rcu_dereference(np->opt);
521561 err = ip6_xmit(sk, skb, fl6, skb->mark ? : sk->sk_mark, opt,
522
- np->tclass);
562
+ tclass, sk->sk_priority);
523563 rcu_read_unlock();
524564 err = net_xmit_eval(err);
525565 }
....@@ -537,28 +577,36 @@
537577
538578 #ifdef CONFIG_TCP_MD5SIG
539579 static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(const struct sock *sk,
540
- const struct in6_addr *addr)
580
+ const struct in6_addr *addr,
581
+ int l3index)
541582 {
542
- return tcp_md5_do_lookup(sk, (union tcp_md5_addr *)addr, AF_INET6);
583
+ return tcp_md5_do_lookup(sk, l3index,
584
+ (union tcp_md5_addr *)addr, AF_INET6);
543585 }
544586
545587 static struct tcp_md5sig_key *tcp_v6_md5_lookup(const struct sock *sk,
546588 const struct sock *addr_sk)
547589 {
548
- return tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr);
590
+ int l3index;
591
+
592
+ l3index = l3mdev_master_ifindex_by_index(sock_net(sk),
593
+ addr_sk->sk_bound_dev_if);
594
+ return tcp_v6_md5_do_lookup(sk, &addr_sk->sk_v6_daddr,
595
+ l3index);
549596 }
550597
551598 static int tcp_v6_parse_md5_keys(struct sock *sk, int optname,
552
- char __user *optval, int optlen)
599
+ sockptr_t optval, int optlen)
553600 {
554601 struct tcp_md5sig cmd;
555602 struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&cmd.tcpm_addr;
603
+ int l3index = 0;
556604 u8 prefixlen;
557605
558606 if (optlen < sizeof(cmd))
559607 return -EINVAL;
560608
561
- if (copy_from_user(&cmd, optval, sizeof(cmd)))
609
+ if (copy_from_sockptr(&cmd, optval, sizeof(cmd)))
562610 return -EFAULT;
563611
564612 if (sin6->sin6_family != AF_INET6)
....@@ -574,12 +622,30 @@
574622 prefixlen = ipv6_addr_v4mapped(&sin6->sin6_addr) ? 32 : 128;
575623 }
576624
625
+ if (optname == TCP_MD5SIG_EXT &&
626
+ cmd.tcpm_flags & TCP_MD5SIG_FLAG_IFINDEX) {
627
+ struct net_device *dev;
628
+
629
+ rcu_read_lock();
630
+ dev = dev_get_by_index_rcu(sock_net(sk), cmd.tcpm_ifindex);
631
+ if (dev && netif_is_l3_master(dev))
632
+ l3index = dev->ifindex;
633
+ rcu_read_unlock();
634
+
635
+ /* ok to reference set/not set outside of rcu;
636
+ * right now device MUST be an L3 master
637
+ */
638
+ if (!dev || !l3index)
639
+ return -EINVAL;
640
+ }
641
+
577642 if (!cmd.tcpm_keylen) {
578643 if (ipv6_addr_v4mapped(&sin6->sin6_addr))
579644 return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3],
580
- AF_INET, prefixlen);
645
+ AF_INET, prefixlen,
646
+ l3index);
581647 return tcp_md5_do_del(sk, (union tcp_md5_addr *)&sin6->sin6_addr,
582
- AF_INET6, prefixlen);
648
+ AF_INET6, prefixlen, l3index);
583649 }
584650
585651 if (cmd.tcpm_keylen > TCP_MD5SIG_MAXKEYLEN)
....@@ -587,12 +653,13 @@
587653
588654 if (ipv6_addr_v4mapped(&sin6->sin6_addr))
589655 return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr.s6_addr32[3],
590
- AF_INET, prefixlen, cmd.tcpm_key,
591
- cmd.tcpm_keylen, GFP_KERNEL);
656
+ AF_INET, prefixlen, l3index,
657
+ cmd.tcpm_key, cmd.tcpm_keylen,
658
+ GFP_KERNEL);
592659
593660 return tcp_md5_do_add(sk, (union tcp_md5_addr *)&sin6->sin6_addr,
594
- AF_INET6, prefixlen, cmd.tcpm_key,
595
- cmd.tcpm_keylen, GFP_KERNEL);
661
+ AF_INET6, prefixlen, l3index,
662
+ cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
596663 }
597664
598665 static int tcp_v6_md5_hash_headers(struct tcp_md5sig_pool *hp,
....@@ -703,17 +770,23 @@
703770 #endif
704771
705772 static bool tcp_v6_inbound_md5_hash(const struct sock *sk,
706
- const struct sk_buff *skb)
773
+ const struct sk_buff *skb,
774
+ int dif, int sdif)
707775 {
708776 #ifdef CONFIG_TCP_MD5SIG
709777 const __u8 *hash_location = NULL;
710778 struct tcp_md5sig_key *hash_expected;
711779 const struct ipv6hdr *ip6h = ipv6_hdr(skb);
712780 const struct tcphdr *th = tcp_hdr(skb);
713
- int genhash;
781
+ int genhash, l3index;
714782 u8 newhash[16];
715783
716
- hash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr);
784
+ /* sdif set, means packet ingressed via a device
785
+ * in an L3 domain and dif is set to the l3mdev
786
+ */
787
+ l3index = sdif ? dif : 0;
788
+
789
+ hash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr, l3index);
717790 hash_location = tcp_parse_md5sig_option(th);
718791
719792 /* We've parsed the options - do we have a hash? */
....@@ -737,10 +810,10 @@
737810
738811 if (genhash || memcmp(hash_location, newhash, 16) != 0) {
739812 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPMD5FAILURE);
740
- net_info_ratelimited("MD5 Hash %s for [%pI6c]:%u->[%pI6c]:%u\n",
813
+ net_info_ratelimited("MD5 Hash %s for [%pI6c]:%u->[%pI6c]:%u L3 index %d\n",
741814 genhash ? "failed" : "mismatch",
742815 &ip6h->saddr, ntohs(th->source),
743
- &ip6h->daddr, ntohs(th->dest));
816
+ &ip6h->daddr, ntohs(th->dest), l3index);
744817 return true;
745818 }
746819 #endif
....@@ -751,14 +824,15 @@
751824 const struct sock *sk_listener,
752825 struct sk_buff *skb)
753826 {
827
+ bool l3_slave = ipv6_l3mdev_skb(TCP_SKB_CB(skb)->header.h6.flags);
754828 struct inet_request_sock *ireq = inet_rsk(req);
755
- const struct ipv6_pinfo *np = inet6_sk(sk_listener);
829
+ const struct ipv6_pinfo *np = tcp_inet6_sk(sk_listener);
756830
757831 ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
758832 ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
759833
760834 /* So that link locals have meaning */
761
- if (!sk_listener->sk_bound_dev_if &&
835
+ if ((!sk_listener->sk_bound_dev_if || l3_slave) &&
762836 ipv6_addr_type(&ireq->ir_v6_rmt_addr) & IPV6_ADDR_LINKLOCAL)
763837 ireq->ir_iif = tcp_v6_iif(skb);
764838
....@@ -789,7 +863,7 @@
789863 .syn_ack_timeout = tcp_syn_ack_timeout,
790864 };
791865
792
-static const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = {
866
+const struct tcp_request_sock_ops tcp_request_sock_ipv6_ops = {
793867 .mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) -
794868 sizeof(struct ipv6hdr),
795869 #ifdef CONFIG_TCP_MD5SIG
....@@ -809,7 +883,7 @@
809883 static void tcp_v6_send_response(const struct sock *sk, struct sk_buff *skb, u32 seq,
810884 u32 ack, u32 win, u32 tsval, u32 tsecr,
811885 int oif, struct tcp_md5sig_key *key, int rst,
812
- u8 tclass, __be32 label)
886
+ u8 tclass, __be32 label, u32 priority)
813887 {
814888 const struct tcphdr *th = tcp_hdr(skb);
815889 struct tcphdr *t1;
....@@ -889,14 +963,22 @@
889963 fl6.flowi6_oif = oif;
890964 }
891965
892
- if (sk)
893
- mark = (sk->sk_state == TCP_TIME_WAIT) ?
894
- inet_twsk(sk)->tw_mark : sk->sk_mark;
966
+ if (sk) {
967
+ if (sk->sk_state == TCP_TIME_WAIT) {
968
+ mark = inet_twsk(sk)->tw_mark;
969
+ /* autoflowlabel relies on buff->hash */
970
+ skb_set_hash(buff, inet_twsk(sk)->tw_txhash,
971
+ PKT_HASH_TYPE_L4);
972
+ } else {
973
+ mark = sk->sk_mark;
974
+ }
975
+ buff->tstamp = tcp_transmit_time(sk);
976
+ }
895977 fl6.flowi6_mark = IP6_REPLY_MARK(net, skb->mark) ?: mark;
896978 fl6.fl6_dport = t1->dest;
897979 fl6.fl6_sport = t1->source;
898980 fl6.flowi6_uid = sock_net_uid(net, sk && sk_fullsock(sk) ? sk : NULL);
899
- security_skb_classify_flow(skb, flowi6_to_flowi(&fl6));
981
+ security_skb_classify_flow(skb, flowi6_to_flowi_common(&fl6));
900982
901983 /* Pass a socket to ip6_dst_lookup either it is for RST
902984 * Underlying function will use this to retrieve the network
....@@ -905,7 +987,8 @@
905987 dst = ip6_dst_lookup_flow(sock_net(ctl_sk), ctl_sk, &fl6, NULL);
906988 if (!IS_ERR(dst)) {
907989 skb_dst_set(buff, dst);
908
- ip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL, tclass);
990
+ ip6_xmit(ctl_sk, buff, &fl6, fl6.flowi6_mark, NULL,
991
+ tclass & ~INET_ECN_MASK, priority);
909992 TCP_INC_STATS(net, TCP_MIB_OUTSEGS);
910993 if (rst)
911994 TCP_INC_STATS(net, TCP_MIB_OUTRSTS);
....@@ -918,15 +1001,18 @@
9181001 static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb)
9191002 {
9201003 const struct tcphdr *th = tcp_hdr(skb);
1004
+ struct ipv6hdr *ipv6h = ipv6_hdr(skb);
9211005 u32 seq = 0, ack_seq = 0;
9221006 struct tcp_md5sig_key *key = NULL;
9231007 #ifdef CONFIG_TCP_MD5SIG
9241008 const __u8 *hash_location = NULL;
925
- struct ipv6hdr *ipv6h = ipv6_hdr(skb);
9261009 unsigned char newhash[16];
9271010 int genhash;
9281011 struct sock *sk1 = NULL;
9291012 #endif
1013
+ __be32 label = 0;
1014
+ u32 priority = 0;
1015
+ struct net *net;
9301016 int oif = 0;
9311017
9321018 if (th->rst)
....@@ -938,12 +1024,23 @@
9381024 if (!sk && !ipv6_unicast_destination(skb))
9391025 return;
9401026
1027
+ net = sk ? sock_net(sk) : dev_net(skb_dst(skb)->dev);
9411028 #ifdef CONFIG_TCP_MD5SIG
9421029 rcu_read_lock();
9431030 hash_location = tcp_parse_md5sig_option(th);
9441031 if (sk && sk_fullsock(sk)) {
945
- key = tcp_v6_md5_do_lookup(sk, &ipv6h->saddr);
1032
+ int l3index;
1033
+
1034
+ /* sdif set, means packet ingressed via a device
1035
+ * in an L3 domain and inet_iif is set to it.
1036
+ */
1037
+ l3index = tcp_v6_sdif(skb) ? tcp_v6_iif_l3_slave(skb) : 0;
1038
+ key = tcp_v6_md5_do_lookup(sk, &ipv6h->saddr, l3index);
9461039 } else if (hash_location) {
1040
+ int dif = tcp_v6_iif_l3_slave(skb);
1041
+ int sdif = tcp_v6_sdif(skb);
1042
+ int l3index;
1043
+
9471044 /*
9481045 * active side is lost. Try to find listening socket through
9491046 * source port, and then find md5 key through listening socket.
....@@ -951,17 +1048,20 @@
9511048 * Incoming packet is checked with md5 hash with finding key,
9521049 * no RST generated if md5 hash doesn't match.
9531050 */
954
- sk1 = inet6_lookup_listener(dev_net(skb_dst(skb)->dev),
1051
+ sk1 = inet6_lookup_listener(net,
9551052 &tcp_hashinfo, NULL, 0,
9561053 &ipv6h->saddr,
9571054 th->source, &ipv6h->daddr,
958
- ntohs(th->source),
959
- tcp_v6_iif_l3_slave(skb),
960
- tcp_v6_sdif(skb));
1055
+ ntohs(th->source), dif, sdif);
9611056 if (!sk1)
9621057 goto out;
9631058
964
- key = tcp_v6_md5_do_lookup(sk1, &ipv6h->saddr);
1059
+ /* sdif set, means packet ingressed via a device
1060
+ * in an L3 domain and dif is set to it.
1061
+ */
1062
+ l3index = tcp_v6_sdif(skb) ? dif : 0;
1063
+
1064
+ key = tcp_v6_md5_do_lookup(sk1, &ipv6h->saddr, l3index);
9651065 if (!key)
9661066 goto out;
9671067
....@@ -979,11 +1079,25 @@
9791079
9801080 if (sk) {
9811081 oif = sk->sk_bound_dev_if;
982
- if (sk_fullsock(sk))
1082
+ if (sk_fullsock(sk)) {
1083
+ const struct ipv6_pinfo *np = tcp_inet6_sk(sk);
1084
+
9831085 trace_tcp_send_reset(sk, skb);
1086
+ if (np->repflow)
1087
+ label = ip6_flowlabel(ipv6h);
1088
+ priority = sk->sk_priority;
1089
+ }
1090
+ if (sk->sk_state == TCP_TIME_WAIT) {
1091
+ label = cpu_to_be32(inet_twsk(sk)->tw_flowlabel);
1092
+ priority = inet_twsk(sk)->tw_priority;
1093
+ }
1094
+ } else {
1095
+ if (net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_TCP_RESET)
1096
+ label = ip6_flowlabel(ipv6h);
9841097 }
9851098
986
- tcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, key, 1, 0, 0);
1099
+ tcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, key, 1,
1100
+ ipv6_get_dsfield(ipv6h), label, priority);
9871101
9881102 #ifdef CONFIG_TCP_MD5SIG
9891103 out:
....@@ -994,10 +1108,10 @@
9941108 static void tcp_v6_send_ack(const struct sock *sk, struct sk_buff *skb, u32 seq,
9951109 u32 ack, u32 win, u32 tsval, u32 tsecr, int oif,
9961110 struct tcp_md5sig_key *key, u8 tclass,
997
- __be32 label)
1111
+ __be32 label, u32 priority)
9981112 {
9991113 tcp_v6_send_response(sk, skb, seq, ack, win, tsval, tsecr, oif, key, 0,
1000
- tclass, label);
1114
+ tclass, label, priority);
10011115 }
10021116
10031117 static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb)
....@@ -1009,7 +1123,7 @@
10091123 tcptw->tw_rcv_wnd >> tw->tw_rcv_wscale,
10101124 tcp_time_stamp_raw() + tcptw->tw_ts_offset,
10111125 tcptw->tw_ts_recent, tw->tw_bound_dev_if, tcp_twsk_md5_key(tcptw),
1012
- tw->tw_tclass, cpu_to_be32(tw->tw_flowlabel));
1126
+ tw->tw_tclass, cpu_to_be32(tw->tw_flowlabel), tw->tw_priority);
10131127
10141128 inet_twsk_put(tw);
10151129 }
....@@ -1017,6 +1131,10 @@
10171131 static void tcp_v6_reqsk_send_ack(const struct sock *sk, struct sk_buff *skb,
10181132 struct request_sock *req)
10191133 {
1134
+ int l3index;
1135
+
1136
+ l3index = tcp_v6_sdif(skb) ? tcp_v6_iif_l3_slave(skb) : 0;
1137
+
10201138 /* sk->sk_state == TCP_LISTEN -> for regular TCP_SYN_RECV
10211139 * sk->sk_state == TCP_SYN_RECV -> for Fast Open.
10221140 */
....@@ -1030,9 +1148,9 @@
10301148 tcp_rsk(req)->rcv_nxt,
10311149 req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale,
10321150 tcp_time_stamp_raw() + tcp_rsk(req)->ts_off,
1033
- req->ts_recent, sk->sk_bound_dev_if,
1034
- tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->saddr),
1035
- 0, 0);
1151
+ READ_ONCE(req->ts_recent), sk->sk_bound_dev_if,
1152
+ tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->saddr, l3index),
1153
+ ipv6_get_dsfield(ipv6_hdr(skb)), 0, sk->sk_priority);
10361154 }
10371155
10381156
....@@ -1045,6 +1163,21 @@
10451163 sk = cookie_v6_check(sk, skb);
10461164 #endif
10471165 return sk;
1166
+}
1167
+
1168
+u16 tcp_v6_get_syncookie(struct sock *sk, struct ipv6hdr *iph,
1169
+ struct tcphdr *th, u32 *cookie)
1170
+{
1171
+ u16 mss = 0;
1172
+#ifdef CONFIG_SYN_COOKIES
1173
+ mss = tcp_get_syncookie_mss(&tcp6_request_sock_ops,
1174
+ &tcp_request_sock_ipv6_ops, sk, th);
1175
+ if (mss) {
1176
+ *cookie = __cookie_v6_init_sequence(iph, th, &mss);
1177
+ tcp_synq_overflow(sk);
1178
+ }
1179
+#endif
1180
+ return mss;
10481181 }
10491182
10501183 static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
....@@ -1086,14 +1219,15 @@
10861219 {
10871220 struct inet_request_sock *ireq;
10881221 struct ipv6_pinfo *newnp;
1089
- const struct ipv6_pinfo *np = inet6_sk(sk);
1222
+ const struct ipv6_pinfo *np = tcp_inet6_sk(sk);
10901223 struct ipv6_txoptions *opt;
1091
- struct tcp6_sock *newtcp6sk;
10921224 struct inet_sock *newinet;
1225
+ bool found_dup_sk = false;
10931226 struct tcp_sock *newtp;
10941227 struct sock *newsk;
10951228 #ifdef CONFIG_TCP_MD5SIG
10961229 struct tcp_md5sig_key *key;
1230
+ int l3index;
10971231 #endif
10981232 struct flowi6 fl6;
10991233
....@@ -1108,11 +1242,10 @@
11081242 if (!newsk)
11091243 return NULL;
11101244
1111
- newtcp6sk = (struct tcp6_sock *)newsk;
1112
- inet_sk(newsk)->pinet6 = &newtcp6sk->inet6;
1245
+ inet_sk(newsk)->pinet6 = tcp_inet6_sk(newsk);
11131246
11141247 newinet = inet_sk(newsk);
1115
- newnp = inet6_sk(newsk);
1248
+ newnp = tcp_inet6_sk(newsk);
11161249 newtp = tcp_sk(newsk);
11171250
11181251 memcpy(newnp, np, sizeof(struct ipv6_pinfo));
....@@ -1120,6 +1253,8 @@
11201253 newnp->saddr = newsk->sk_v6_rcv_saddr;
11211254
11221255 inet_csk(newsk)->icsk_af_ops = &ipv6_mapped;
1256
+ if (sk_is_mptcp(newsk))
1257
+ mptcpv6_handle_mapped(newsk, true);
11231258 newsk->sk_backlog_rcv = tcp_v4_do_rcv;
11241259 #ifdef CONFIG_TCP_MD5SIG
11251260 newtp->af_specific = &tcp_sock_ipv6_mapped_specific;
....@@ -1176,12 +1311,11 @@
11761311 ip6_dst_store(newsk, dst, NULL, NULL);
11771312 inet6_sk_rx_dst_set(newsk, skb);
11781313
1179
- newtcp6sk = (struct tcp6_sock *)newsk;
1180
- inet_sk(newsk)->pinet6 = &newtcp6sk->inet6;
1314
+ inet_sk(newsk)->pinet6 = tcp_inet6_sk(newsk);
11811315
11821316 newtp = tcp_sk(newsk);
11831317 newinet = inet_sk(newsk);
1184
- newnp = inet6_sk(newsk);
1318
+ newnp = tcp_inet6_sk(newsk);
11851319
11861320 memcpy(newnp, np, sizeof(struct ipv6_pinfo));
11871321
....@@ -1209,6 +1343,12 @@
12091343 newnp->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(skb));
12101344 if (np->repflow)
12111345 newnp->flow_label = ip6_flowlabel(ipv6_hdr(skb));
1346
+
1347
+ /* Set ToS of the new socket based upon the value of incoming SYN.
1348
+ * ECT bits are set later in tcp_init_transfer().
1349
+ */
1350
+ if (READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_reflect_tos))
1351
+ newnp->tclass = tcp_rsk(req)->syn_tos & ~INET_ECN_MASK;
12121352
12131353 /* Clone native IPv6 options from listening socket (if any)
12141354
....@@ -1239,8 +1379,10 @@
12391379 newinet->inet_rcv_saddr = LOOPBACK4_IPV6;
12401380
12411381 #ifdef CONFIG_TCP_MD5SIG
1382
+ l3index = l3mdev_master_ifindex_by_index(sock_net(sk), ireq->ir_iif);
1383
+
12421384 /* Copy over the MD5 key from the original socket */
1243
- key = tcp_v6_md5_do_lookup(sk, &newsk->sk_v6_daddr);
1385
+ key = tcp_v6_md5_do_lookup(sk, &newsk->sk_v6_daddr, l3index);
12441386 if (key) {
12451387 /* We're using one, so create a matching key
12461388 * on the newsk structure. If we fail to get
....@@ -1248,7 +1390,7 @@
12481390 * across. Shucks.
12491391 */
12501392 tcp_md5_do_add(newsk, (union tcp_md5_addr *)&newsk->sk_v6_daddr,
1251
- AF_INET6, 128, key->key, key->keylen,
1393
+ AF_INET6, 128, l3index, key->key, key->keylen,
12521394 sk_gfp_mask(sk, GFP_ATOMIC));
12531395 }
12541396 #endif
....@@ -1258,20 +1400,27 @@
12581400 tcp_done(newsk);
12591401 goto out;
12601402 }
1261
- *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash));
1403
+ *own_req = inet_ehash_nolisten(newsk, req_to_sk(req_unhash),
1404
+ &found_dup_sk);
12621405 if (*own_req) {
12631406 tcp_move_syn(newtp, req);
12641407
12651408 /* Clone pktoptions received with SYN, if we own the req */
12661409 if (ireq->pktopts) {
1267
- newnp->pktoptions = skb_clone(ireq->pktopts,
1268
- sk_gfp_mask(sk, GFP_ATOMIC));
1410
+ newnp->pktoptions = skb_clone_and_charge_r(ireq->pktopts, newsk);
12691411 consume_skb(ireq->pktopts);
12701412 ireq->pktopts = NULL;
1271
- if (newnp->pktoptions) {
1413
+ if (newnp->pktoptions)
12721414 tcp_v6_restore_cb(newnp->pktoptions);
1273
- skb_set_owner_r(newnp->pktoptions, newsk);
1274
- }
1415
+ }
1416
+ } else {
1417
+ if (!req_unhash && found_dup_sk) {
1418
+ /* This code path should only be executed in the
1419
+ * syncookie case only
1420
+ */
1421
+ bh_unlock_sock(newsk);
1422
+ sock_put(newsk);
1423
+ newsk = NULL;
12751424 }
12761425 }
12771426
....@@ -1296,9 +1445,9 @@
12961445 */
12971446 static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
12981447 {
1299
- struct ipv6_pinfo *np = inet6_sk(sk);
1300
- struct tcp_sock *tp;
1448
+ struct ipv6_pinfo *np = tcp_inet6_sk(sk);
13011449 struct sk_buff *opt_skb = NULL;
1450
+ struct tcp_sock *tp;
13021451
13031452 /* Imagine: socket is IPv6. IPv4 packet arrives,
13041453 goes to IPv4 receive handler and backlogged.
....@@ -1330,18 +1479,21 @@
13301479 --ANK (980728)
13311480 */
13321481 if (np->rxopt.all)
1333
- opt_skb = skb_clone(skb, sk_gfp_mask(sk, GFP_ATOMIC));
1482
+ opt_skb = skb_clone_and_charge_r(skb, sk);
13341483
13351484 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
1336
- struct dst_entry *dst = sk->sk_rx_dst;
1485
+ struct dst_entry *dst;
1486
+
1487
+ dst = rcu_dereference_protected(sk->sk_rx_dst,
1488
+ lockdep_sock_is_held(sk));
13371489
13381490 sock_rps_save_rxhash(sk, skb);
13391491 sk_mark_napi_id(sk, skb);
13401492 if (dst) {
13411493 if (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif ||
13421494 dst->ops->check(dst, np->rx_dst_cookie) == NULL) {
1495
+ RCU_INIT_POINTER(sk->sk_rx_dst, NULL);
13431496 dst_release(dst);
1344
- sk->sk_rx_dst = NULL;
13451497 }
13461498 }
13471499
....@@ -1409,7 +1561,6 @@
14091561 if (np->repflow)
14101562 np->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb));
14111563 if (ipv6_opt_accepted(sk, opt_skb, &TCP_SKB_CB(opt_skb)->header.h6)) {
1412
- skb_set_owner_r(opt_skb, sk);
14131564 tcp_v6_restore_cb(opt_skb);
14141565 opt_skb = xchg(&np->pktoptions, opt_skb);
14151566 } else {
....@@ -1446,9 +1597,11 @@
14461597 skb->tstamp || skb_hwtstamps(skb)->hwtstamp;
14471598 }
14481599
1449
-static int tcp_v6_rcv(struct sk_buff *skb)
1600
+INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
14501601 {
1602
+ struct sk_buff *skb_to_free;
14511603 int sdif = inet6_sdif(skb);
1604
+ int dif = inet6_iif(skb);
14521605 const struct tcphdr *th;
14531606 const struct ipv6hdr *hdr;
14541607 bool refcounted;
....@@ -1497,7 +1650,7 @@
14971650 struct sock *nsk;
14981651
14991652 sk = req->rsk_listener;
1500
- if (tcp_v6_inbound_md5_hash(sk, skb)) {
1653
+ if (tcp_v6_inbound_md5_hash(sk, skb, dif, sdif)) {
15011654 sk_drops_add(sk, skb);
15021655 reqsk_put(req);
15031656 goto discard_it;
....@@ -1544,7 +1697,7 @@
15441697 return 0;
15451698 }
15461699 }
1547
- if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
1700
+ if (hdr->hop_limit < tcp_inet6_sk(sk)->min_hopcount) {
15481701 __NET_INC_STATS(net, LINUX_MIB_TCPMINTTLDROP);
15491702 goto discard_and_relse;
15501703 }
....@@ -1552,7 +1705,7 @@
15521705 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb))
15531706 goto discard_and_relse;
15541707
1555
- if (tcp_v6_inbound_md5_hash(sk, skb))
1708
+ if (tcp_v6_inbound_md5_hash(sk, skb, dif, sdif))
15561709 goto discard_and_relse;
15571710
15581711 if (tcp_filter(sk, skb))
....@@ -1574,12 +1727,17 @@
15741727 tcp_segs_in(tcp_sk(sk), skb);
15751728 ret = 0;
15761729 if (!sock_owned_by_user(sk)) {
1730
+ skb_to_free = sk->sk_rx_skb_cache;
1731
+ sk->sk_rx_skb_cache = NULL;
15771732 ret = tcp_v6_do_rcv(sk, skb);
1578
- } else if (tcp_add_backlog(sk, skb)) {
1579
- goto discard_and_relse;
1733
+ } else {
1734
+ if (tcp_add_backlog(sk, skb))
1735
+ goto discard_and_relse;
1736
+ skb_to_free = NULL;
15801737 }
15811738 bh_unlock_sock(sk);
1582
-
1739
+ if (skb_to_free)
1740
+ __kfree_skb(skb_to_free);
15831741 put_and_return:
15841742 if (refcounted)
15851743 sock_put(sk);
....@@ -1645,7 +1803,7 @@
16451803 }
16461804 }
16471805 /* to ACK */
1648
- /* fall through */
1806
+ fallthrough;
16491807 case TCP_TW_ACK:
16501808 tcp_v6_timewait_ack(sk, skb);
16511809 break;
....@@ -1659,7 +1817,7 @@
16591817 goto discard_it;
16601818 }
16611819
1662
-static void tcp_v6_early_demux(struct sk_buff *skb)
1820
+void tcp_v6_early_demux(struct sk_buff *skb)
16631821 {
16641822 const struct ipv6hdr *hdr;
16651823 const struct tcphdr *th;
....@@ -1686,10 +1844,10 @@
16861844 skb->sk = sk;
16871845 skb->destructor = sock_edemux;
16881846 if (sk_fullsock(sk)) {
1689
- struct dst_entry *dst = READ_ONCE(sk->sk_rx_dst);
1847
+ struct dst_entry *dst = rcu_dereference(sk->sk_rx_dst);
16901848
16911849 if (dst)
1692
- dst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie);
1850
+ dst = dst_check(dst, tcp_inet6_sk(sk)->rx_dst_cookie);
16931851 if (dst &&
16941852 inet_sk(sk)->rx_dst_ifindex == skb->skb_iif)
16951853 skb_dst_set_noref(skb, dst);
....@@ -1703,7 +1861,14 @@
17031861 .twsk_destructor = tcp_twsk_destructor,
17041862 };
17051863
1706
-static const struct inet_connection_sock_af_ops ipv6_specific = {
1864
+INDIRECT_CALLABLE_SCOPE void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb)
1865
+{
1866
+ struct ipv6_pinfo *np = inet6_sk(sk);
1867
+
1868
+ __tcp_v6_send_check(skb, &np->saddr, &sk->sk_v6_daddr);
1869
+}
1870
+
1871
+const struct inet_connection_sock_af_ops ipv6_specific = {
17071872 .queue_xmit = inet6_csk_xmit,
17081873 .send_check = tcp_v6_send_check,
17091874 .rebuild_header = inet6_sk_rebuild_header,
....@@ -1716,10 +1881,6 @@
17161881 .getsockopt = ipv6_getsockopt,
17171882 .addr2sockaddr = inet6_csk_addr2sockaddr,
17181883 .sockaddr_len = sizeof(struct sockaddr_in6),
1719
-#ifdef CONFIG_COMPAT
1720
- .compat_setsockopt = compat_ipv6_setsockopt,
1721
- .compat_getsockopt = compat_ipv6_getsockopt,
1722
-#endif
17231884 .mtu_reduced = tcp_v6_mtu_reduced,
17241885 };
17251886
....@@ -1746,10 +1907,6 @@
17461907 .getsockopt = ipv6_getsockopt,
17471908 .addr2sockaddr = inet6_csk_addr2sockaddr,
17481909 .sockaddr_len = sizeof(struct sockaddr_in6),
1749
-#ifdef CONFIG_COMPAT
1750
- .compat_setsockopt = compat_ipv6_setsockopt,
1751
- .compat_getsockopt = compat_ipv6_getsockopt,
1752
-#endif
17531910 .mtu_reduced = tcp_v4_mtu_reduced,
17541911 };
17551912
....@@ -1777,12 +1934,6 @@
17771934 #endif
17781935
17791936 return 0;
1780
-}
1781
-
1782
-static void tcp_v6_destroy_sock(struct sock *sk)
1783
-{
1784
- tcp_v4_destroy_sock(sk);
1785
- inet6_destroy_sock(sk);
17861937 }
17871938
17881939 #ifdef CONFIG_PROC_FS
....@@ -1855,7 +2006,7 @@
18552006
18562007 state = inet_sk_state_load(sp);
18572008 if (state == TCP_LISTEN)
1858
- rx_queue = sp->sk_ack_backlog;
2009
+ rx_queue = READ_ONCE(sp->sk_ack_backlog);
18592010 else
18602011 /* Because we don't lock the socket,
18612012 * we might find a transient negative value.
....@@ -1883,7 +2034,7 @@
18832034 refcount_read(&sp->sk_refcnt), sp,
18842035 jiffies_to_clock_t(icsk->icsk_rto),
18852036 jiffies_to_clock_t(icsk->icsk_ack.ato),
1886
- (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,
2037
+ (icsk->icsk_ack.quick << 1) | inet_csk_in_pingpong_mode(sp),
18872038 tp->snd_cwnd,
18882039 state == TCP_LISTEN ?
18892040 fastopenq->max_qlen :
....@@ -1977,7 +2128,7 @@
19772128 .accept = inet_csk_accept,
19782129 .ioctl = tcp_ioctl,
19792130 .init = tcp_v6_init_sock,
1980
- .destroy = tcp_v6_destroy_sock,
2131
+ .destroy = tcp_v4_destroy_sock,
19812132 .shutdown = tcp_shutdown,
19822133 .setsockopt = tcp_setsockopt,
19832134 .getsockopt = tcp_getsockopt,
....@@ -2007,19 +2158,11 @@
20072158 .rsk_prot = &tcp6_request_sock_ops,
20082159 .h.hashinfo = &tcp_hashinfo,
20092160 .no_autobind = true,
2010
-#ifdef CONFIG_COMPAT
2011
- .compat_setsockopt = compat_tcp_setsockopt,
2012
- .compat_getsockopt = compat_tcp_getsockopt,
2013
-#endif
20142161 .diag_destroy = tcp_abort,
20152162 };
2163
+EXPORT_SYMBOL_GPL(tcpv6_prot);
20162164
2017
-/* thinking of making this const? Don't.
2018
- * early_demux can change based on sysctl.
2019
- */
2020
-static struct inet6_protocol tcpv6_protocol = {
2021
- .early_demux = tcp_v6_early_demux,
2022
- .early_demux_handler = tcp_v6_early_demux,
2165
+static const struct inet6_protocol tcpv6_protocol = {
20232166 .handler = tcp_v6_rcv,
20242167 .err_handler = tcp_v6_err,
20252168 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
....@@ -2072,9 +2215,16 @@
20722215 ret = register_pernet_subsys(&tcpv6_net_ops);
20732216 if (ret)
20742217 goto out_tcpv6_protosw;
2218
+
2219
+ ret = mptcpv6_init();
2220
+ if (ret)
2221
+ goto out_tcpv6_pernet_subsys;
2222
+
20752223 out:
20762224 return ret;
20772225
2226
+out_tcpv6_pernet_subsys:
2227
+ unregister_pernet_subsys(&tcpv6_net_ops);
20782228 out_tcpv6_protosw:
20792229 inet6_unregister_protosw(&tcpv6_protosw);
20802230 out_tcpv6_protocol: