1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * PF_INET6 socket protocol family 4 * Linux INET6 implementation 5 * 6 * Authors: 7 * Pedro Roque <roque@di.fc.ul.pt> 8 * 9 * Adapted from linux/net/ipv4/af_inet.c 10 * 11 * Fixes: 12 * piggy, Karl Knutson : Socket protocol table 13 * Hideaki YOSHIFUJI : sin6_scope_id support 14 * Arnaldo Melo : check proc_net_create return, cleanups 15 */ 16 17 #define pr_fmt(fmt) "IPv6: " fmt 18 19 #include <linux/module.h> 20 #include <linux/capability.h> 21 #include <linux/errno.h> 22 #include <linux/types.h> 23 #include <linux/socket.h> 24 #include <linux/in.h> 25 #include <linux/kernel.h> 26 #include <linux/timer.h> 27 #include <linux/string.h> 28 #include <linux/sockios.h> 29 #include <linux/net.h> 30 #include <linux/fcntl.h> 31 #include <linux/mm.h> 32 #include <linux/interrupt.h> 33 #include <linux/proc_fs.h> 34 #include <linux/stat.h> 35 #include <linux/init.h> 36 #include <linux/slab.h> 37 38 #include <linux/inet.h> 39 #include <linux/netdevice.h> 40 #include <linux/icmpv6.h> 41 #include <linux/netfilter_ipv6.h> 42 43 #include <net/ip.h> 44 #include <net/ipv6.h> 45 #include <net/udp.h> 46 #include <net/udplite.h> 47 #include <net/tcp.h> 48 #include <net/ping.h> 49 #include <net/protocol.h> 50 #include <net/inet_common.h> 51 #include <net/route.h> 52 #include <net/transp_v6.h> 53 #include <net/ip6_route.h> 54 #include <net/addrconf.h> 55 #include <net/ipv6_stubs.h> 56 #include <net/ndisc.h> 57 #ifdef CONFIG_IPV6_TUNNEL 58 #include <net/ip6_tunnel.h> 59 #endif 60 #include <net/calipso.h> 61 #include <net/seg6.h> 62 #include <net/rpl.h> 63 #include <net/compat.h> 64 #include <net/xfrm.h> 65 #include <net/ioam6.h> 66 #include <net/rawv6.h> 67 #include <net/rps.h> 68 69 #include <linux/uaccess.h> 70 #include <linux/mroute6.h> 71 72 #include "ip6_offload.h" 73 74 MODULE_AUTHOR("Cast of dozens"); 75 MODULE_DESCRIPTION("IPv6 protocol stack for Linux"); 76 MODULE_LICENSE("GPL"); 77 78 /* The inetsw6 table contains everything that inet6_create needs to 79 * build a new socket. 80 */ 81 static struct list_head inetsw6[SOCK_MAX]; 82 static DEFINE_SPINLOCK(inetsw6_lock); 83 84 struct ipv6_params ipv6_defaults = { 85 .disable_ipv6 = 0, 86 .autoconf = 1, 87 }; 88 89 module_param_named(disable, disable_ipv6_mod, int, 0444); 90 MODULE_PARM_DESC(disable, "Disable IPv6 module such that it is non-functional"); 91 92 module_param_named(disable_ipv6, ipv6_defaults.disable_ipv6, int, 0444); 93 MODULE_PARM_DESC(disable_ipv6, "Disable IPv6 on all interfaces"); 94 95 module_param_named(autoconf, ipv6_defaults.autoconf, int, 0444); 96 MODULE_PARM_DESC(autoconf, "Enable IPv6 address autoconfiguration on all interfaces"); 97 98 static struct ipv6_pinfo *inet6_sk_generic(struct sock *sk) 99 { 100 const int offset = sk->sk_prot->ipv6_pinfo_offset; 101 102 return (struct ipv6_pinfo *)(((u8 *)sk) + offset); 103 } 104 105 void inet6_sock_destruct(struct sock *sk) 106 { 107 inet6_cleanup_sock(sk); 108 inet_sock_destruct(sk); 109 } 110 EXPORT_SYMBOL_GPL(inet6_sock_destruct); 111 112 static int inet6_create(struct net *net, struct socket *sock, int protocol, 113 int kern) 114 { 115 struct inet_sock *inet; 116 struct ipv6_pinfo *np; 117 struct sock *sk; 118 struct inet_protosw *answer; 119 struct proto *answer_prot; 120 unsigned char answer_flags; 121 int try_loading_module = 0; 122 int err; 123 124 if (protocol < 0 || protocol >= IPPROTO_MAX) 125 return -EINVAL; 126 127 /* Look for the requested type/protocol pair. */ 128 lookup_protocol: 129 err = -ESOCKTNOSUPPORT; 130 rcu_read_lock(); 131 list_for_each_entry_rcu(answer, &inetsw6[sock->type], list) { 132 133 err = 0; 134 /* Check the non-wild match. */ 135 if (protocol == answer->protocol) { 136 if (protocol != IPPROTO_IP) 137 break; 138 } else { 139 /* Check for the two wild cases. */ 140 if (IPPROTO_IP == protocol) { 141 protocol = answer->protocol; 142 break; 143 } 144 if (IPPROTO_IP == answer->protocol) 145 break; 146 } 147 err = -EPROTONOSUPPORT; 148 } 149 150 if (err) { 151 if (try_loading_module < 2) { 152 rcu_read_unlock(); 153 /* 154 * Be more specific, e.g. net-pf-10-proto-132-type-1 155 * (net-pf-PF_INET6-proto-IPPROTO_SCTP-type-SOCK_STREAM) 156 */ 157 if (++try_loading_module == 1) 158 request_module("net-pf-%d-proto-%d-type-%d", 159 PF_INET6, protocol, sock->type); 160 /* 161 * Fall back to generic, e.g. net-pf-10-proto-132 162 * (net-pf-PF_INET6-proto-IPPROTO_SCTP) 163 */ 164 else 165 request_module("net-pf-%d-proto-%d", 166 PF_INET6, protocol); 167 goto lookup_protocol; 168 } else 169 goto out_rcu_unlock; 170 } 171 172 err = -EPERM; 173 if (sock->type == SOCK_RAW && !kern && 174 !ns_capable(net->user_ns, CAP_NET_RAW)) 175 goto out_rcu_unlock; 176 177 sock->ops = answer->ops; 178 answer_prot = answer->prot; 179 answer_flags = answer->flags; 180 rcu_read_unlock(); 181 182 WARN_ON(!answer_prot->slab); 183 184 err = -ENOBUFS; 185 sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot, kern); 186 if (!sk) 187 goto out; 188 189 sock_init_data(sock, sk); 190 191 err = 0; 192 if (INET_PROTOSW_REUSE & answer_flags) 193 sk->sk_reuse = SK_CAN_REUSE; 194 195 if (INET_PROTOSW_ICSK & answer_flags) 196 inet_init_csk_locks(sk); 197 198 inet = inet_sk(sk); 199 inet_assign_bit(IS_ICSK, sk, INET_PROTOSW_ICSK & answer_flags); 200 201 if (SOCK_RAW == sock->type) { 202 inet->inet_num = protocol; 203 if (IPPROTO_RAW == protocol) 204 inet_set_bit(HDRINCL, sk); 205 } 206 207 sk->sk_destruct = inet6_sock_destruct; 208 sk->sk_family = PF_INET6; 209 sk->sk_protocol = protocol; 210 211 sk->sk_backlog_rcv = answer->prot->backlog_rcv; 212 213 inet_sk(sk)->pinet6 = np = inet6_sk_generic(sk); 214 np->hop_limit = -1; 215 np->mcast_hops = IPV6_DEFAULT_MCASTHOPS; 216 inet6_set_bit(MC6_LOOP, sk); 217 inet6_set_bit(MC6_ALL, sk); 218 np->pmtudisc = IPV6_PMTUDISC_WANT; 219 inet6_assign_bit(REPFLOW, sk, READ_ONCE(net->ipv6.sysctl.flowlabel_reflect) & 220 FLOWLABEL_REFLECT_ESTABLISHED); 221 sk->sk_ipv6only = net->ipv6.sysctl.bindv6only; 222 sk->sk_txrehash = READ_ONCE(net->core.sysctl_txrehash); 223 224 /* Init the ipv4 part of the socket since we can have sockets 225 * using v6 API for ipv4. 226 */ 227 inet->uc_ttl = -1; 228 229 inet_set_bit(MC_LOOP, sk); 230 inet->mc_ttl = 1; 231 inet->mc_index = 0; 232 RCU_INIT_POINTER(inet->mc_list, NULL); 233 inet->rcv_tos = 0; 234 235 if (READ_ONCE(net->ipv4.sysctl_ip_no_pmtu_disc)) 236 inet->pmtudisc = IP_PMTUDISC_DONT; 237 else 238 inet->pmtudisc = IP_PMTUDISC_WANT; 239 240 if (inet->inet_num) { 241 /* It assumes that any protocol which allows 242 * the user to assign a number at socket 243 * creation time automatically shares. 244 */ 245 inet->inet_sport = htons(inet->inet_num); 246 err = sk->sk_prot->hash(sk); 247 if (err) 248 goto out_sk_release; 249 } 250 if (sk->sk_prot->init) { 251 err = sk->sk_prot->init(sk); 252 if (err) 253 goto out_sk_release; 254 } 255 256 if (!kern) { 257 err = BPF_CGROUP_RUN_PROG_INET_SOCK(sk); 258 if (err) 259 goto out_sk_release; 260 } 261 out: 262 return err; 263 out_rcu_unlock: 264 rcu_read_unlock(); 265 goto out; 266 out_sk_release: 267 sk_common_release(sk); 268 sock->sk = NULL; 269 goto out; 270 } 271 272 static int __inet6_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len, 273 u32 flags) 274 { 275 struct sockaddr_in6 *addr = (struct sockaddr_in6 *)uaddr; 276 struct inet_sock *inet = inet_sk(sk); 277 struct ipv6_pinfo *np = inet6_sk(sk); 278 struct net *net = sock_net(sk); 279 __be32 v4addr = 0; 280 unsigned short snum; 281 bool saved_ipv6only; 282 int addr_type = 0; 283 int err = 0; 284 285 if (addr->sin6_family != AF_INET6) 286 return -EAFNOSUPPORT; 287 288 addr_type = ipv6_addr_type(&addr->sin6_addr); 289 if ((addr_type & IPV6_ADDR_MULTICAST) && sk->sk_type == SOCK_STREAM) 290 return -EINVAL; 291 292 snum = ntohs(addr->sin6_port); 293 if (!(flags & BIND_NO_CAP_NET_BIND_SERVICE) && 294 snum && inet_port_requires_bind_service(net, snum) && 295 !ns_capable(net->user_ns, CAP_NET_BIND_SERVICE)) 296 return -EACCES; 297 298 if (flags & BIND_WITH_LOCK) 299 lock_sock(sk); 300 301 /* Check these errors (active socket, double bind). */ 302 if (sk->sk_state != TCP_CLOSE || inet->inet_num) { 303 err = -EINVAL; 304 goto out; 305 } 306 307 /* Check if the address belongs to the host. */ 308 if (addr_type == IPV6_ADDR_MAPPED) { 309 struct net_device *dev = NULL; 310 int chk_addr_ret; 311 312 /* Binding to v4-mapped address on a v6-only socket 313 * makes no sense 314 */ 315 if (ipv6_only_sock(sk)) { 316 err = -EINVAL; 317 goto out; 318 } 319 320 rcu_read_lock(); 321 if (sk->sk_bound_dev_if) { 322 dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if); 323 if (!dev) { 324 err = -ENODEV; 325 goto out_unlock; 326 } 327 } 328 329 /* Reproduce AF_INET checks to make the bindings consistent */ 330 v4addr = addr->sin6_addr.s6_addr32[3]; 331 chk_addr_ret = inet_addr_type_dev_table(net, dev, v4addr); 332 rcu_read_unlock(); 333 334 if (!inet_addr_valid_or_nonlocal(net, inet, v4addr, 335 chk_addr_ret)) { 336 err = -EADDRNOTAVAIL; 337 goto out; 338 } 339 } else { 340 if (addr_type != IPV6_ADDR_ANY) { 341 struct net_device *dev = NULL; 342 343 rcu_read_lock(); 344 if (__ipv6_addr_needs_scope_id(addr_type)) { 345 if (addr_len >= sizeof(struct sockaddr_in6) && 346 addr->sin6_scope_id) { 347 /* Override any existing binding, if another one 348 * is supplied by user. 349 */ 350 sk->sk_bound_dev_if = addr->sin6_scope_id; 351 } 352 353 /* Binding to link-local address requires an interface */ 354 if (!sk->sk_bound_dev_if) { 355 err = -EINVAL; 356 goto out_unlock; 357 } 358 } 359 360 if (sk->sk_bound_dev_if) { 361 dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if); 362 if (!dev) { 363 err = -ENODEV; 364 goto out_unlock; 365 } 366 } 367 368 /* ipv4 addr of the socket is invalid. Only the 369 * unspecified and mapped address have a v4 equivalent. 370 */ 371 v4addr = LOOPBACK4_IPV6; 372 if (!(addr_type & IPV6_ADDR_MULTICAST)) { 373 if (!ipv6_can_nonlocal_bind(net, inet) && 374 !ipv6_chk_addr(net, &addr->sin6_addr, 375 dev, 0)) { 376 err = -EADDRNOTAVAIL; 377 goto out_unlock; 378 } 379 } 380 rcu_read_unlock(); 381 } 382 } 383 384 inet->inet_rcv_saddr = v4addr; 385 inet->inet_saddr = v4addr; 386 387 sk->sk_v6_rcv_saddr = addr->sin6_addr; 388 389 if (!(addr_type & IPV6_ADDR_MULTICAST)) 390 np->saddr = addr->sin6_addr; 391 392 saved_ipv6only = sk->sk_ipv6only; 393 if (addr_type != IPV6_ADDR_ANY && addr_type != IPV6_ADDR_MAPPED) 394 sk->sk_ipv6only = 1; 395 396 /* Make sure we are allowed to bind here. */ 397 if (snum || !(inet_test_bit(BIND_ADDRESS_NO_PORT, sk) || 398 (flags & BIND_FORCE_ADDRESS_NO_PORT))) { 399 err = sk->sk_prot->get_port(sk, snum); 400 if (err) { 401 sk->sk_ipv6only = saved_ipv6only; 402 inet_reset_saddr(sk); 403 goto out; 404 } 405 if (!(flags & BIND_FROM_BPF)) { 406 err = BPF_CGROUP_RUN_PROG_INET6_POST_BIND(sk); 407 if (err) { 408 sk->sk_ipv6only = saved_ipv6only; 409 inet_reset_saddr(sk); 410 if (sk->sk_prot->put_port) 411 sk->sk_prot->put_port(sk); 412 goto out; 413 } 414 } 415 } 416 417 if (addr_type != IPV6_ADDR_ANY) 418 sk->sk_userlocks |= SOCK_BINDADDR_LOCK; 419 if (snum) 420 sk->sk_userlocks |= SOCK_BINDPORT_LOCK; 421 inet->inet_sport = htons(inet->inet_num); 422 inet->inet_dport = 0; 423 inet->inet_daddr = 0; 424 out: 425 if (flags & BIND_WITH_LOCK) 426 release_sock(sk); 427 return err; 428 out_unlock: 429 rcu_read_unlock(); 430 goto out; 431 } 432 433 int inet6_bind_sk(struct sock *sk, struct sockaddr_unsized *uaddr, int addr_len) 434 { 435 u32 flags = BIND_WITH_LOCK; 436 const struct proto *prot; 437 int err = 0; 438 439 /* IPV6_ADDRFORM can change sk->sk_prot under us. */ 440 prot = READ_ONCE(sk->sk_prot); 441 /* If the socket has its own bind function then use it. */ 442 if (prot->bind) 443 return prot->bind(sk, uaddr, addr_len); 444 445 if (addr_len < SIN6_LEN_RFC2133) 446 return -EINVAL; 447 448 /* BPF prog is run before any checks are done so that if the prog 449 * changes context in a wrong way it will be caught. 450 */ 451 err = BPF_CGROUP_RUN_PROG_INET_BIND_LOCK(sk, uaddr, &addr_len, 452 CGROUP_INET6_BIND, &flags); 453 if (err) 454 return err; 455 456 return __inet6_bind(sk, uaddr, addr_len, flags); 457 } 458 459 /* bind for INET6 API */ 460 int inet6_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int addr_len) 461 { 462 return inet6_bind_sk(sock->sk, uaddr, addr_len); 463 } 464 EXPORT_SYMBOL(inet6_bind); 465 466 int inet6_release(struct socket *sock) 467 { 468 struct sock *sk = sock->sk; 469 470 if (!sk) 471 return -EINVAL; 472 473 /* Free mc lists */ 474 ipv6_sock_mc_close(sk); 475 476 /* Free ac lists */ 477 ipv6_sock_ac_close(sk); 478 479 return inet_release(sock); 480 } 481 EXPORT_SYMBOL(inet6_release); 482 483 void inet6_cleanup_sock(struct sock *sk) 484 { 485 struct ipv6_pinfo *np = inet6_sk(sk); 486 struct sk_buff *skb; 487 struct ipv6_txoptions *opt; 488 489 /* Release rx options */ 490 491 skb = xchg(&np->pktoptions, NULL); 492 kfree_skb(skb); 493 494 skb = xchg(&np->rxpmtu, NULL); 495 kfree_skb(skb); 496 497 /* Free flowlabels */ 498 fl6_free_socklist(sk); 499 500 /* Free tx options */ 501 502 opt = unrcu_pointer(xchg(&np->opt, NULL)); 503 if (opt) { 504 atomic_sub(opt->tot_len, &sk->sk_omem_alloc); 505 txopt_put(opt); 506 } 507 } 508 EXPORT_SYMBOL_GPL(inet6_cleanup_sock); 509 510 /* 511 * This does both peername and sockname. 512 */ 513 int inet6_getname(struct socket *sock, struct sockaddr *uaddr, 514 int peer) 515 { 516 struct sockaddr_in6 *sin = (struct sockaddr_in6 *)uaddr; 517 int sin_addr_len = sizeof(*sin); 518 struct sock *sk = sock->sk; 519 struct inet_sock *inet = inet_sk(sk); 520 struct ipv6_pinfo *np = inet6_sk(sk); 521 522 sin->sin6_family = AF_INET6; 523 sin->sin6_flowinfo = 0; 524 sin->sin6_scope_id = 0; 525 lock_sock(sk); 526 if (peer) { 527 if (!inet->inet_dport || 528 (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) && 529 peer == 1)) { 530 release_sock(sk); 531 return -ENOTCONN; 532 } 533 sin->sin6_port = inet->inet_dport; 534 sin->sin6_addr = sk->sk_v6_daddr; 535 if (inet6_test_bit(SNDFLOW, sk)) 536 sin->sin6_flowinfo = np->flow_label; 537 BPF_CGROUP_RUN_SA_PROG(sk, (struct sockaddr *)sin, &sin_addr_len, 538 CGROUP_INET6_GETPEERNAME); 539 } else { 540 if (ipv6_addr_any(&sk->sk_v6_rcv_saddr)) 541 sin->sin6_addr = np->saddr; 542 else 543 sin->sin6_addr = sk->sk_v6_rcv_saddr; 544 sin->sin6_port = inet->inet_sport; 545 BPF_CGROUP_RUN_SA_PROG(sk, (struct sockaddr *)sin, &sin_addr_len, 546 CGROUP_INET6_GETSOCKNAME); 547 } 548 sin->sin6_scope_id = ipv6_iface_scope_id(&sin->sin6_addr, 549 sk->sk_bound_dev_if); 550 release_sock(sk); 551 return sin_addr_len; 552 } 553 EXPORT_SYMBOL(inet6_getname); 554 555 int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 556 { 557 void __user *argp = (void __user *)arg; 558 struct sock *sk = sock->sk; 559 struct net *net = sock_net(sk); 560 const struct proto *prot; 561 562 switch (cmd) { 563 case SIOCADDRT: 564 case SIOCDELRT: { 565 struct in6_rtmsg rtmsg; 566 567 if (copy_from_user(&rtmsg, argp, sizeof(rtmsg))) 568 return -EFAULT; 569 return ipv6_route_ioctl(net, cmd, &rtmsg); 570 } 571 case SIOCSIFADDR: 572 return addrconf_add_ifaddr(net, argp); 573 case SIOCDIFADDR: 574 return addrconf_del_ifaddr(net, argp); 575 case SIOCSIFDSTADDR: 576 return addrconf_set_dstaddr(net, argp); 577 default: 578 /* IPV6_ADDRFORM can change sk->sk_prot under us. */ 579 prot = READ_ONCE(sk->sk_prot); 580 if (!prot->ioctl) 581 return -ENOIOCTLCMD; 582 return sk_ioctl(sk, cmd, (void __user *)arg); 583 } 584 /*NOTREACHED*/ 585 return 0; 586 } 587 EXPORT_SYMBOL(inet6_ioctl); 588 589 #ifdef CONFIG_COMPAT 590 struct compat_in6_rtmsg { 591 struct in6_addr rtmsg_dst; 592 struct in6_addr rtmsg_src; 593 struct in6_addr rtmsg_gateway; 594 u32 rtmsg_type; 595 u16 rtmsg_dst_len; 596 u16 rtmsg_src_len; 597 u32 rtmsg_metric; 598 u32 rtmsg_info; 599 u32 rtmsg_flags; 600 s32 rtmsg_ifindex; 601 }; 602 603 static int inet6_compat_routing_ioctl(struct sock *sk, unsigned int cmd, 604 struct compat_in6_rtmsg __user *ur) 605 { 606 struct in6_rtmsg rt; 607 608 if (copy_from_user(&rt.rtmsg_dst, &ur->rtmsg_dst, 609 3 * sizeof(struct in6_addr)) || 610 get_user(rt.rtmsg_type, &ur->rtmsg_type) || 611 get_user(rt.rtmsg_dst_len, &ur->rtmsg_dst_len) || 612 get_user(rt.rtmsg_src_len, &ur->rtmsg_src_len) || 613 get_user(rt.rtmsg_metric, &ur->rtmsg_metric) || 614 get_user(rt.rtmsg_info, &ur->rtmsg_info) || 615 get_user(rt.rtmsg_flags, &ur->rtmsg_flags) || 616 get_user(rt.rtmsg_ifindex, &ur->rtmsg_ifindex)) 617 return -EFAULT; 618 619 620 return ipv6_route_ioctl(sock_net(sk), cmd, &rt); 621 } 622 623 int inet6_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 624 { 625 void __user *argp = compat_ptr(arg); 626 struct sock *sk = sock->sk; 627 628 switch (cmd) { 629 case SIOCADDRT: 630 case SIOCDELRT: 631 return inet6_compat_routing_ioctl(sk, cmd, argp); 632 default: 633 return -ENOIOCTLCMD; 634 } 635 } 636 EXPORT_SYMBOL_GPL(inet6_compat_ioctl); 637 #endif /* CONFIG_COMPAT */ 638 639 INDIRECT_CALLABLE_DECLARE(int udpv6_sendmsg(struct sock *, struct msghdr *, 640 size_t)); 641 int inet6_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) 642 { 643 struct sock *sk = sock->sk; 644 const struct proto *prot; 645 646 if (unlikely(inet_send_prepare(sk))) 647 return -EAGAIN; 648 649 /* IPV6_ADDRFORM can change sk->sk_prot under us. */ 650 prot = READ_ONCE(sk->sk_prot); 651 return INDIRECT_CALL_2(prot->sendmsg, tcp_sendmsg, udpv6_sendmsg, 652 sk, msg, size); 653 } 654 655 INDIRECT_CALLABLE_DECLARE(int udpv6_recvmsg(struct sock *, struct msghdr *, 656 size_t, int, int *)); 657 int inet6_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, 658 int flags) 659 { 660 struct sock *sk = sock->sk; 661 const struct proto *prot; 662 int addr_len = 0; 663 int err; 664 665 if (likely(!(flags & MSG_ERRQUEUE))) 666 sock_rps_record_flow(sk); 667 668 /* IPV6_ADDRFORM can change sk->sk_prot under us. */ 669 prot = READ_ONCE(sk->sk_prot); 670 err = INDIRECT_CALL_2(prot->recvmsg, tcp_recvmsg, udpv6_recvmsg, 671 sk, msg, size, flags, &addr_len); 672 if (err >= 0) 673 msg->msg_namelen = addr_len; 674 return err; 675 } 676 677 const struct proto_ops inet6_stream_ops = { 678 .family = PF_INET6, 679 .owner = THIS_MODULE, 680 .release = inet6_release, 681 .bind = inet6_bind, 682 .connect = inet_stream_connect, /* ok */ 683 .socketpair = sock_no_socketpair, /* a do nothing */ 684 .accept = inet_accept, /* ok */ 685 .getname = inet6_getname, 686 .poll = tcp_poll, /* ok */ 687 .ioctl = inet6_ioctl, /* must change */ 688 .gettstamp = sock_gettstamp, 689 .listen = inet_listen, /* ok */ 690 .shutdown = inet_shutdown, /* ok */ 691 .setsockopt = sock_common_setsockopt, /* ok */ 692 .getsockopt = sock_common_getsockopt, /* ok */ 693 .sendmsg = inet6_sendmsg, /* retpoline's sake */ 694 .recvmsg = inet6_recvmsg, /* retpoline's sake */ 695 #ifdef CONFIG_MMU 696 .mmap = tcp_mmap, 697 #endif 698 .splice_eof = inet_splice_eof, 699 .sendmsg_locked = tcp_sendmsg_locked, 700 .splice_read = tcp_splice_read, 701 .set_peek_off = sk_set_peek_off, 702 .read_sock = tcp_read_sock, 703 .read_skb = tcp_read_skb, 704 .peek_len = tcp_peek_len, 705 #ifdef CONFIG_COMPAT 706 .compat_ioctl = inet6_compat_ioctl, 707 #endif 708 .set_rcvlowat = tcp_set_rcvlowat, 709 }; 710 EXPORT_SYMBOL_GPL(inet6_stream_ops); 711 712 const struct proto_ops inet6_dgram_ops = { 713 .family = PF_INET6, 714 .owner = THIS_MODULE, 715 .release = inet6_release, 716 .bind = inet6_bind, 717 .connect = inet_dgram_connect, /* ok */ 718 .socketpair = sock_no_socketpair, /* a do nothing */ 719 .accept = sock_no_accept, /* a do nothing */ 720 .getname = inet6_getname, 721 .poll = udp_poll, /* ok */ 722 .ioctl = inet6_ioctl, /* must change */ 723 .gettstamp = sock_gettstamp, 724 .listen = sock_no_listen, /* ok */ 725 .shutdown = inet_shutdown, /* ok */ 726 .setsockopt = sock_common_setsockopt, /* ok */ 727 .getsockopt = sock_common_getsockopt, /* ok */ 728 .sendmsg = inet6_sendmsg, /* retpoline's sake */ 729 .recvmsg = inet6_recvmsg, /* retpoline's sake */ 730 .read_skb = udp_read_skb, 731 .mmap = sock_no_mmap, 732 .set_peek_off = udp_set_peek_off, 733 #ifdef CONFIG_COMPAT 734 .compat_ioctl = inet6_compat_ioctl, 735 #endif 736 }; 737 738 static const struct net_proto_family inet6_family_ops = { 739 .family = PF_INET6, 740 .create = inet6_create, 741 .owner = THIS_MODULE, 742 }; 743 744 int inet6_register_protosw(struct inet_protosw *p) 745 { 746 struct list_head *lh; 747 struct inet_protosw *answer; 748 struct list_head *last_perm; 749 int protocol = p->protocol; 750 int ret; 751 752 spin_lock_bh(&inetsw6_lock); 753 754 ret = -EINVAL; 755 if (p->type >= SOCK_MAX) 756 goto out_illegal; 757 758 /* If we are trying to override a permanent protocol, bail. */ 759 answer = NULL; 760 ret = -EPERM; 761 last_perm = &inetsw6[p->type]; 762 list_for_each(lh, &inetsw6[p->type]) { 763 answer = list_entry(lh, struct inet_protosw, list); 764 765 /* Check only the non-wild match. */ 766 if (INET_PROTOSW_PERMANENT & answer->flags) { 767 if (protocol == answer->protocol) 768 break; 769 last_perm = lh; 770 } 771 772 answer = NULL; 773 } 774 if (answer) 775 goto out_permanent; 776 777 /* Add the new entry after the last permanent entry if any, so that 778 * the new entry does not override a permanent entry when matched with 779 * a wild-card protocol. But it is allowed to override any existing 780 * non-permanent entry. This means that when we remove this entry, the 781 * system automatically returns to the old behavior. 782 */ 783 list_add_rcu(&p->list, last_perm); 784 ret = 0; 785 out: 786 spin_unlock_bh(&inetsw6_lock); 787 return ret; 788 789 out_permanent: 790 pr_err("Attempt to override permanent protocol %d\n", protocol); 791 goto out; 792 793 out_illegal: 794 pr_err("Ignoring attempt to register invalid socket type %d\n", 795 p->type); 796 goto out; 797 } 798 EXPORT_SYMBOL(inet6_register_protosw); 799 800 void 801 inet6_unregister_protosw(struct inet_protosw *p) 802 { 803 if (INET_PROTOSW_PERMANENT & p->flags) { 804 pr_err("Attempt to unregister permanent protocol %d\n", 805 p->protocol); 806 } else { 807 spin_lock_bh(&inetsw6_lock); 808 list_del_rcu(&p->list); 809 spin_unlock_bh(&inetsw6_lock); 810 811 synchronize_net(); 812 } 813 } 814 EXPORT_SYMBOL(inet6_unregister_protosw); 815 816 int inet6_sk_rebuild_header(struct sock *sk) 817 { 818 struct ipv6_pinfo *np = inet6_sk(sk); 819 struct inet_sock *inet = inet_sk(sk); 820 struct in6_addr *final_p; 821 struct dst_entry *dst; 822 struct flowi6 *fl6; 823 824 dst = __sk_dst_check(sk, np->dst_cookie); 825 if (dst) 826 return 0; 827 828 fl6 = &inet->cork.fl.u.ip6; 829 memset(fl6, 0, sizeof(*fl6)); 830 fl6->flowi6_proto = sk->sk_protocol; 831 fl6->daddr = sk->sk_v6_daddr; 832 fl6->saddr = np->saddr; 833 fl6->flowlabel = np->flow_label; 834 fl6->flowi6_oif = sk->sk_bound_dev_if; 835 fl6->flowi6_mark = sk->sk_mark; 836 fl6->fl6_dport = inet->inet_dport; 837 fl6->fl6_sport = inet->inet_sport; 838 fl6->flowi6_uid = sk_uid(sk); 839 security_sk_classify_flow(sk, flowi6_to_flowi_common(fl6)); 840 841 rcu_read_lock(); 842 final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &np->final); 843 rcu_read_unlock(); 844 845 dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p); 846 if (IS_ERR(dst)) { 847 sk->sk_route_caps = 0; 848 WRITE_ONCE(sk->sk_err_soft, -PTR_ERR(dst)); 849 return PTR_ERR(dst); 850 } 851 852 ip6_dst_store(sk, dst, false, false); 853 return 0; 854 } 855 856 bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb, 857 const struct inet6_skb_parm *opt) 858 { 859 const struct ipv6_pinfo *np = inet6_sk(sk); 860 861 if (np->rxopt.all) { 862 if (((opt->flags & IP6SKB_HOPBYHOP) && 863 (np->rxopt.bits.hopopts || np->rxopt.bits.ohopopts)) || 864 (ip6_flowinfo((struct ipv6hdr *) skb_network_header(skb)) && 865 np->rxopt.bits.rxflow) || 866 (opt->srcrt && (np->rxopt.bits.srcrt || 867 np->rxopt.bits.osrcrt)) || 868 ((opt->dst1 || opt->dst0) && 869 (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts))) 870 return true; 871 } 872 return false; 873 } 874 875 static struct packet_type ipv6_packet_type __read_mostly = { 876 .type = cpu_to_be16(ETH_P_IPV6), 877 .func = ipv6_rcv, 878 .list_func = ipv6_list_rcv, 879 }; 880 881 static int __init ipv6_packet_init(void) 882 { 883 dev_add_pack(&ipv6_packet_type); 884 return 0; 885 } 886 887 static void ipv6_packet_cleanup(void) 888 { 889 dev_remove_pack(&ipv6_packet_type); 890 } 891 892 static int __net_init ipv6_init_mibs(struct net *net) 893 { 894 int i; 895 896 net->mib.udp_stats_in6 = alloc_percpu(struct udp_mib); 897 if (!net->mib.udp_stats_in6) 898 return -ENOMEM; 899 net->mib.udplite_stats_in6 = alloc_percpu(struct udp_mib); 900 if (!net->mib.udplite_stats_in6) 901 goto err_udplite_mib; 902 net->mib.ipv6_statistics = alloc_percpu(struct ipstats_mib); 903 if (!net->mib.ipv6_statistics) 904 goto err_ip_mib; 905 906 for_each_possible_cpu(i) { 907 struct ipstats_mib *af_inet6_stats; 908 af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics, i); 909 u64_stats_init(&af_inet6_stats->syncp); 910 } 911 912 913 net->mib.icmpv6_statistics = alloc_percpu(struct icmpv6_mib); 914 if (!net->mib.icmpv6_statistics) 915 goto err_icmp_mib; 916 net->mib.icmpv6msg_statistics = kzalloc_obj(struct icmpv6msg_mib); 917 if (!net->mib.icmpv6msg_statistics) 918 goto err_icmpmsg_mib; 919 return 0; 920 921 err_icmpmsg_mib: 922 free_percpu(net->mib.icmpv6_statistics); 923 err_icmp_mib: 924 free_percpu(net->mib.ipv6_statistics); 925 err_ip_mib: 926 free_percpu(net->mib.udplite_stats_in6); 927 err_udplite_mib: 928 free_percpu(net->mib.udp_stats_in6); 929 return -ENOMEM; 930 } 931 932 static void ipv6_cleanup_mibs(struct net *net) 933 { 934 free_percpu(net->mib.udp_stats_in6); 935 free_percpu(net->mib.udplite_stats_in6); 936 free_percpu(net->mib.ipv6_statistics); 937 free_percpu(net->mib.icmpv6_statistics); 938 kfree(net->mib.icmpv6msg_statistics); 939 } 940 941 static int __net_init inet6_net_init(struct net *net) 942 { 943 int err = 0; 944 945 net->ipv6.sysctl.bindv6only = 0; 946 net->ipv6.sysctl.icmpv6_time = HZ / 10; 947 net->ipv6.sysctl.icmpv6_echo_ignore_all = 0; 948 net->ipv6.sysctl.icmpv6_echo_ignore_multicast = 0; 949 net->ipv6.sysctl.icmpv6_echo_ignore_anycast = 0; 950 net->ipv6.sysctl.icmpv6_error_anycast_as_unicast = 0; 951 net->ipv6.sysctl.icmpv6_errors_extension_mask = 0; 952 953 /* By default, rate limit error messages. 954 * Except for pmtu discovery, it would break it. 955 * proc_do_large_bitmap needs pointer to the bitmap. 956 */ 957 bitmap_set(net->ipv6.sysctl.icmpv6_ratemask, 0, ICMPV6_ERRMSG_MAX + 1); 958 bitmap_clear(net->ipv6.sysctl.icmpv6_ratemask, ICMPV6_PKT_TOOBIG, 1); 959 net->ipv6.sysctl.icmpv6_ratemask_ptr = net->ipv6.sysctl.icmpv6_ratemask; 960 961 net->ipv6.sysctl.flowlabel_consistency = 1; 962 net->ipv6.sysctl.auto_flowlabels = IP6_DEFAULT_AUTO_FLOW_LABELS; 963 net->ipv6.sysctl.idgen_retries = 3; 964 net->ipv6.sysctl.idgen_delay = 1 * HZ; 965 net->ipv6.sysctl.flowlabel_state_ranges = 0; 966 net->ipv6.sysctl.max_dst_opts_cnt = IP6_DEFAULT_MAX_DST_OPTS_CNT; 967 net->ipv6.sysctl.max_hbh_opts_cnt = IP6_DEFAULT_MAX_HBH_OPTS_CNT; 968 net->ipv6.sysctl.max_dst_opts_len = IP6_DEFAULT_MAX_DST_OPTS_LEN; 969 net->ipv6.sysctl.max_hbh_opts_len = IP6_DEFAULT_MAX_HBH_OPTS_LEN; 970 net->ipv6.sysctl.fib_notify_on_flag_change = 0; 971 atomic_set(&net->ipv6.fib6_sernum, 1); 972 973 net->ipv6.sysctl.ioam6_id = IOAM6_DEFAULT_ID; 974 net->ipv6.sysctl.ioam6_id_wide = IOAM6_DEFAULT_ID_WIDE; 975 976 err = ipv6_init_mibs(net); 977 if (err) 978 return err; 979 #ifdef CONFIG_PROC_FS 980 err = udp6_proc_init(net); 981 if (err) 982 goto out; 983 err = tcp6_proc_init(net); 984 if (err) 985 goto proc_tcp6_fail; 986 err = ac6_proc_init(net); 987 if (err) 988 goto proc_ac6_fail; 989 #endif 990 return err; 991 992 #ifdef CONFIG_PROC_FS 993 proc_ac6_fail: 994 tcp6_proc_exit(net); 995 proc_tcp6_fail: 996 udp6_proc_exit(net); 997 out: 998 ipv6_cleanup_mibs(net); 999 return err; 1000 #endif 1001 } 1002 1003 static void __net_exit inet6_net_exit(struct net *net) 1004 { 1005 #ifdef CONFIG_PROC_FS 1006 udp6_proc_exit(net); 1007 tcp6_proc_exit(net); 1008 ac6_proc_exit(net); 1009 #endif 1010 ipv6_cleanup_mibs(net); 1011 } 1012 1013 static struct pernet_operations inet6_net_ops = { 1014 .init = inet6_net_init, 1015 .exit = inet6_net_exit, 1016 }; 1017 1018 static int ipv6_route_input(struct sk_buff *skb) 1019 { 1020 ip6_route_input(skb); 1021 return skb_dst(skb)->error; 1022 } 1023 1024 static const struct ipv6_stub ipv6_stub_impl = { 1025 .ipv6_sock_mc_join = ipv6_sock_mc_join, 1026 .ipv6_sock_mc_drop = ipv6_sock_mc_drop, 1027 .ipv6_dst_lookup_flow = ip6_dst_lookup_flow, 1028 .ipv6_route_input = ipv6_route_input, 1029 .fib6_get_table = fib6_get_table, 1030 .fib6_table_lookup = fib6_table_lookup, 1031 .fib6_lookup = fib6_lookup, 1032 .fib6_select_path = fib6_select_path, 1033 .ip6_mtu_from_fib6 = ip6_mtu_from_fib6, 1034 .fib6_nh_init = fib6_nh_init, 1035 .fib6_nh_release = fib6_nh_release, 1036 .fib6_nh_release_dsts = fib6_nh_release_dsts, 1037 .fib6_update_sernum = fib6_update_sernum_stub, 1038 .fib6_rt_update = fib6_rt_update, 1039 .ip6_del_rt = ip6_del_rt, 1040 .udpv6_encap_enable = udpv6_encap_enable, 1041 .ndisc_send_na = ndisc_send_na, 1042 #if IS_ENABLED(CONFIG_XFRM) 1043 .xfrm6_local_rxpmtu = xfrm6_local_rxpmtu, 1044 .xfrm6_udp_encap_rcv = xfrm6_udp_encap_rcv, 1045 .xfrm6_gro_udp_encap_rcv = xfrm6_gro_udp_encap_rcv, 1046 .xfrm6_rcv_encap = xfrm6_rcv_encap, 1047 #endif 1048 .nd_tbl = &nd_tbl, 1049 .ipv6_fragment = ip6_fragment, 1050 .ipv6_dev_find = ipv6_dev_find, 1051 .ip6_xmit = ip6_xmit, 1052 }; 1053 1054 static const struct ipv6_bpf_stub ipv6_bpf_stub_impl = { 1055 .inet6_bind = __inet6_bind, 1056 .udp6_lib_lookup = __udp6_lib_lookup, 1057 .ipv6_setsockopt = do_ipv6_setsockopt, 1058 .ipv6_getsockopt = do_ipv6_getsockopt, 1059 .ipv6_dev_get_saddr = ipv6_dev_get_saddr, 1060 }; 1061 1062 static int __init inet6_init(void) 1063 { 1064 struct list_head *r; 1065 int err = 0; 1066 1067 sock_skb_cb_check_size(sizeof(struct inet6_skb_parm)); 1068 1069 /* Register the socket-side information for inet6_create. */ 1070 for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r) 1071 INIT_LIST_HEAD(r); 1072 1073 raw_hashinfo_init(&raw_v6_hashinfo); 1074 1075 if (disable_ipv6_mod) { 1076 pr_info("Loaded, but administratively disabled, reboot required to enable\n"); 1077 goto out; 1078 } 1079 1080 err = proto_register(&tcpv6_prot, 1); 1081 if (err) 1082 goto out; 1083 1084 err = proto_register(&udpv6_prot, 1); 1085 if (err) 1086 goto out_unregister_tcp_proto; 1087 1088 err = proto_register(&udplitev6_prot, 1); 1089 if (err) 1090 goto out_unregister_udp_proto; 1091 1092 err = proto_register(&rawv6_prot, 1); 1093 if (err) 1094 goto out_unregister_udplite_proto; 1095 1096 err = proto_register(&pingv6_prot, 1); 1097 if (err) 1098 goto out_unregister_raw_proto; 1099 1100 /* We MUST register RAW sockets before we create the ICMP6, 1101 * IGMP6, or NDISC control sockets. 1102 */ 1103 err = rawv6_init(); 1104 if (err) 1105 goto out_unregister_ping_proto; 1106 1107 /* Register the family here so that the init calls below will 1108 * be able to create sockets. (?? is this dangerous ??) 1109 */ 1110 err = sock_register(&inet6_family_ops); 1111 if (err) 1112 goto out_sock_register_fail; 1113 1114 /* 1115 * ipngwg API draft makes clear that the correct semantics 1116 * for TCP and UDP is to consider one TCP and UDP instance 1117 * in a host available by both INET and INET6 APIs and 1118 * able to communicate via both network protocols. 1119 */ 1120 1121 err = register_pernet_subsys(&inet6_net_ops); 1122 if (err) 1123 goto register_pernet_fail; 1124 err = ip6_mr_init(); 1125 if (err) 1126 goto ipmr_fail; 1127 err = icmpv6_init(); 1128 if (err) 1129 goto icmp_fail; 1130 err = ndisc_init(); 1131 if (err) 1132 goto ndisc_fail; 1133 err = igmp6_init(); 1134 if (err) 1135 goto igmp_fail; 1136 1137 err = ipv6_netfilter_init(); 1138 if (err) 1139 goto netfilter_fail; 1140 /* Create /proc/foo6 entries. */ 1141 #ifdef CONFIG_PROC_FS 1142 err = -ENOMEM; 1143 if (raw6_proc_init()) 1144 goto proc_raw6_fail; 1145 if (udplite6_proc_init()) 1146 goto proc_udplite6_fail; 1147 if (ipv6_misc_proc_init()) 1148 goto proc_misc6_fail; 1149 if (if6_proc_init()) 1150 goto proc_if6_fail; 1151 #endif 1152 err = ip6_route_init(); 1153 if (err) 1154 goto ip6_route_fail; 1155 err = ndisc_late_init(); 1156 if (err) 1157 goto ndisc_late_fail; 1158 err = ip6_flowlabel_init(); 1159 if (err) 1160 goto ip6_flowlabel_fail; 1161 err = ipv6_anycast_init(); 1162 if (err) 1163 goto ipv6_anycast_fail; 1164 err = addrconf_init(); 1165 if (err) 1166 goto addrconf_fail; 1167 1168 /* Init v6 extension headers. */ 1169 err = ipv6_exthdrs_init(); 1170 if (err) 1171 goto ipv6_exthdrs_fail; 1172 1173 err = ipv6_frag_init(); 1174 if (err) 1175 goto ipv6_frag_fail; 1176 1177 /* Init v6 transport protocols. */ 1178 err = udpv6_init(); 1179 if (err) 1180 goto udpv6_fail; 1181 1182 err = udplitev6_init(); 1183 if (err) 1184 goto udplitev6_fail; 1185 1186 err = udpv6_offload_init(); 1187 if (err) 1188 goto udpv6_offload_fail; 1189 1190 err = tcpv6_init(); 1191 if (err) 1192 goto tcpv6_fail; 1193 1194 err = ipv6_packet_init(); 1195 if (err) 1196 goto ipv6_packet_fail; 1197 1198 err = pingv6_init(); 1199 if (err) 1200 goto pingv6_fail; 1201 1202 err = calipso_init(); 1203 if (err) 1204 goto calipso_fail; 1205 1206 err = seg6_init(); 1207 if (err) 1208 goto seg6_fail; 1209 1210 err = rpl_init(); 1211 if (err) 1212 goto rpl_fail; 1213 1214 err = ioam6_init(); 1215 if (err) 1216 goto ioam6_fail; 1217 1218 err = igmp6_late_init(); 1219 if (err) 1220 goto igmp6_late_err; 1221 1222 #ifdef CONFIG_SYSCTL 1223 err = ipv6_sysctl_register(); 1224 if (err) 1225 goto sysctl_fail; 1226 #endif 1227 1228 /* ensure that ipv6 stubs are visible only after ipv6 is ready */ 1229 wmb(); 1230 ipv6_stub = &ipv6_stub_impl; 1231 ipv6_bpf_stub = &ipv6_bpf_stub_impl; 1232 out: 1233 return err; 1234 1235 #ifdef CONFIG_SYSCTL 1236 sysctl_fail: 1237 igmp6_late_cleanup(); 1238 #endif 1239 igmp6_late_err: 1240 ioam6_exit(); 1241 ioam6_fail: 1242 rpl_exit(); 1243 rpl_fail: 1244 seg6_exit(); 1245 seg6_fail: 1246 calipso_exit(); 1247 calipso_fail: 1248 pingv6_exit(); 1249 pingv6_fail: 1250 ipv6_packet_cleanup(); 1251 ipv6_packet_fail: 1252 tcpv6_exit(); 1253 tcpv6_fail: 1254 udpv6_offload_exit(); 1255 udpv6_offload_fail: 1256 udplitev6_exit(); 1257 udplitev6_fail: 1258 udpv6_exit(); 1259 udpv6_fail: 1260 ipv6_frag_exit(); 1261 ipv6_frag_fail: 1262 ipv6_exthdrs_exit(); 1263 ipv6_exthdrs_fail: 1264 addrconf_cleanup(); 1265 addrconf_fail: 1266 ipv6_anycast_cleanup(); 1267 ipv6_anycast_fail: 1268 ip6_flowlabel_cleanup(); 1269 ip6_flowlabel_fail: 1270 ndisc_late_cleanup(); 1271 ndisc_late_fail: 1272 ip6_route_cleanup(); 1273 ip6_route_fail: 1274 #ifdef CONFIG_PROC_FS 1275 if6_proc_exit(); 1276 proc_if6_fail: 1277 ipv6_misc_proc_exit(); 1278 proc_misc6_fail: 1279 udplite6_proc_exit(); 1280 proc_udplite6_fail: 1281 raw6_proc_exit(); 1282 proc_raw6_fail: 1283 #endif 1284 ipv6_netfilter_fini(); 1285 netfilter_fail: 1286 igmp6_cleanup(); 1287 igmp_fail: 1288 ndisc_cleanup(); 1289 ndisc_fail: 1290 icmpv6_cleanup(); 1291 icmp_fail: 1292 ip6_mr_cleanup(); 1293 ipmr_fail: 1294 unregister_pernet_subsys(&inet6_net_ops); 1295 register_pernet_fail: 1296 sock_unregister(PF_INET6); 1297 rtnl_unregister_all(PF_INET6); 1298 out_sock_register_fail: 1299 rawv6_exit(); 1300 out_unregister_ping_proto: 1301 proto_unregister(&pingv6_prot); 1302 out_unregister_raw_proto: 1303 proto_unregister(&rawv6_prot); 1304 out_unregister_udplite_proto: 1305 proto_unregister(&udplitev6_prot); 1306 out_unregister_udp_proto: 1307 proto_unregister(&udpv6_prot); 1308 out_unregister_tcp_proto: 1309 proto_unregister(&tcpv6_prot); 1310 goto out; 1311 } 1312 module_init(inet6_init); 1313 1314 MODULE_ALIAS_NETPROTO(PF_INET6); 1315