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)); 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 663 if (likely(!(flags & MSG_ERRQUEUE))) 664 sock_rps_record_flow(sk); 665 666 /* IPV6_ADDRFORM can change sk->sk_prot under us. */ 667 prot = READ_ONCE(sk->sk_prot); 668 return INDIRECT_CALL_2(prot->recvmsg, tcp_recvmsg, udpv6_recvmsg, 669 sk, msg, size, flags); 670 } 671 672 const struct proto_ops inet6_stream_ops = { 673 .family = PF_INET6, 674 .owner = THIS_MODULE, 675 .release = inet6_release, 676 .bind = inet6_bind, 677 .connect = inet_stream_connect, /* ok */ 678 .socketpair = sock_no_socketpair, /* a do nothing */ 679 .accept = inet_accept, /* ok */ 680 .getname = inet6_getname, 681 .poll = tcp_poll, /* ok */ 682 .ioctl = inet6_ioctl, /* must change */ 683 .gettstamp = sock_gettstamp, 684 .listen = inet_listen, /* ok */ 685 .shutdown = inet_shutdown, /* ok */ 686 .setsockopt = sock_common_setsockopt, /* ok */ 687 .getsockopt = sock_common_getsockopt, /* ok */ 688 .sendmsg = inet6_sendmsg, /* retpoline's sake */ 689 .recvmsg = inet6_recvmsg, /* retpoline's sake */ 690 #ifdef CONFIG_MMU 691 .mmap = tcp_mmap, 692 #endif 693 .splice_eof = inet_splice_eof, 694 .sendmsg_locked = tcp_sendmsg_locked, 695 .splice_read = tcp_splice_read, 696 .set_peek_off = sk_set_peek_off, 697 .read_sock = tcp_read_sock, 698 .read_skb = tcp_read_skb, 699 .peek_len = tcp_peek_len, 700 #ifdef CONFIG_COMPAT 701 .compat_ioctl = inet6_compat_ioctl, 702 #endif 703 .set_rcvlowat = tcp_set_rcvlowat, 704 }; 705 EXPORT_SYMBOL_GPL(inet6_stream_ops); 706 707 const struct proto_ops inet6_dgram_ops = { 708 .family = PF_INET6, 709 .owner = THIS_MODULE, 710 .release = inet6_release, 711 .bind = inet6_bind, 712 .connect = inet_dgram_connect, /* ok */ 713 .socketpair = sock_no_socketpair, /* a do nothing */ 714 .accept = sock_no_accept, /* a do nothing */ 715 .getname = inet6_getname, 716 .poll = udp_poll, /* ok */ 717 .ioctl = inet6_ioctl, /* must change */ 718 .gettstamp = sock_gettstamp, 719 .listen = sock_no_listen, /* ok */ 720 .shutdown = inet_shutdown, /* ok */ 721 .setsockopt = sock_common_setsockopt, /* ok */ 722 .getsockopt = sock_common_getsockopt, /* ok */ 723 .sendmsg = inet6_sendmsg, /* retpoline's sake */ 724 .recvmsg = inet6_recvmsg, /* retpoline's sake */ 725 .read_skb = udp_read_skb, 726 .mmap = sock_no_mmap, 727 .set_peek_off = udp_set_peek_off, 728 #ifdef CONFIG_COMPAT 729 .compat_ioctl = inet6_compat_ioctl, 730 #endif 731 }; 732 733 static const struct net_proto_family inet6_family_ops = { 734 .family = PF_INET6, 735 .create = inet6_create, 736 .owner = THIS_MODULE, 737 }; 738 739 int inet6_register_protosw(struct inet_protosw *p) 740 { 741 struct list_head *lh; 742 struct inet_protosw *answer; 743 struct list_head *last_perm; 744 int protocol = p->protocol; 745 int ret; 746 747 spin_lock_bh(&inetsw6_lock); 748 749 ret = -EINVAL; 750 if (p->type >= SOCK_MAX) 751 goto out_illegal; 752 753 /* If we are trying to override a permanent protocol, bail. */ 754 answer = NULL; 755 ret = -EPERM; 756 last_perm = &inetsw6[p->type]; 757 list_for_each(lh, &inetsw6[p->type]) { 758 answer = list_entry(lh, struct inet_protosw, list); 759 760 /* Check only the non-wild match. */ 761 if (INET_PROTOSW_PERMANENT & answer->flags) { 762 if (protocol == answer->protocol) 763 break; 764 last_perm = lh; 765 } 766 767 answer = NULL; 768 } 769 if (answer) 770 goto out_permanent; 771 772 /* Add the new entry after the last permanent entry if any, so that 773 * the new entry does not override a permanent entry when matched with 774 * a wild-card protocol. But it is allowed to override any existing 775 * non-permanent entry. This means that when we remove this entry, the 776 * system automatically returns to the old behavior. 777 */ 778 list_add_rcu(&p->list, last_perm); 779 ret = 0; 780 out: 781 spin_unlock_bh(&inetsw6_lock); 782 return ret; 783 784 out_permanent: 785 pr_err("Attempt to override permanent protocol %d\n", protocol); 786 goto out; 787 788 out_illegal: 789 pr_err("Ignoring attempt to register invalid socket type %d\n", 790 p->type); 791 goto out; 792 } 793 EXPORT_SYMBOL(inet6_register_protosw); 794 795 void 796 inet6_unregister_protosw(struct inet_protosw *p) 797 { 798 if (INET_PROTOSW_PERMANENT & p->flags) { 799 pr_err("Attempt to unregister permanent protocol %d\n", 800 p->protocol); 801 } else { 802 spin_lock_bh(&inetsw6_lock); 803 list_del_rcu(&p->list); 804 spin_unlock_bh(&inetsw6_lock); 805 806 synchronize_net(); 807 } 808 } 809 EXPORT_SYMBOL(inet6_unregister_protosw); 810 811 int inet6_sk_rebuild_header(struct sock *sk) 812 { 813 struct ipv6_pinfo *np = inet6_sk(sk); 814 struct inet_sock *inet = inet_sk(sk); 815 struct in6_addr *final_p; 816 struct dst_entry *dst; 817 struct flowi6 *fl6; 818 819 dst = __sk_dst_check(sk, np->dst_cookie); 820 if (dst) 821 return 0; 822 823 fl6 = &inet->cork.fl.u.ip6; 824 memset(fl6, 0, sizeof(*fl6)); 825 fl6->flowi6_proto = sk->sk_protocol; 826 fl6->daddr = sk->sk_v6_daddr; 827 fl6->saddr = np->saddr; 828 fl6->flowlabel = np->flow_label; 829 fl6->flowi6_oif = sk->sk_bound_dev_if; 830 fl6->flowi6_mark = sk->sk_mark; 831 fl6->fl6_dport = inet->inet_dport; 832 fl6->fl6_sport = inet->inet_sport; 833 fl6->flowi6_uid = sk_uid(sk); 834 security_sk_classify_flow(sk, flowi6_to_flowi_common(fl6)); 835 836 rcu_read_lock(); 837 final_p = fl6_update_dst(fl6, rcu_dereference(np->opt), &np->final); 838 rcu_read_unlock(); 839 840 dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p); 841 if (IS_ERR(dst)) { 842 sk->sk_route_caps = 0; 843 WRITE_ONCE(sk->sk_err_soft, -PTR_ERR(dst)); 844 return PTR_ERR(dst); 845 } 846 847 ip6_dst_store(sk, dst, false, false); 848 return 0; 849 } 850 851 bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb, 852 const struct inet6_skb_parm *opt) 853 { 854 const struct ipv6_pinfo *np = inet6_sk(sk); 855 856 if (np->rxopt.all) { 857 if (((opt->flags & IP6SKB_HOPBYHOP) && 858 (np->rxopt.bits.hopopts || np->rxopt.bits.ohopopts)) || 859 (ip6_flowinfo((struct ipv6hdr *) skb_network_header(skb)) && 860 np->rxopt.bits.rxflow) || 861 (opt->srcrt && (np->rxopt.bits.srcrt || 862 np->rxopt.bits.osrcrt)) || 863 ((opt->dst1 || opt->dst0) && 864 (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts))) 865 return true; 866 } 867 return false; 868 } 869 870 static struct packet_type ipv6_packet_type __read_mostly = { 871 .type = cpu_to_be16(ETH_P_IPV6), 872 .func = ipv6_rcv, 873 .list_func = ipv6_list_rcv, 874 }; 875 876 static int __init ipv6_packet_init(void) 877 { 878 dev_add_pack(&ipv6_packet_type); 879 return 0; 880 } 881 882 static void ipv6_packet_cleanup(void) 883 { 884 dev_remove_pack(&ipv6_packet_type); 885 } 886 887 static int __net_init ipv6_init_mibs(struct net *net) 888 { 889 int i; 890 891 net->mib.udp_stats_in6 = alloc_percpu(struct udp_mib); 892 if (!net->mib.udp_stats_in6) 893 return -ENOMEM; 894 net->mib.udplite_stats_in6 = alloc_percpu(struct udp_mib); 895 if (!net->mib.udplite_stats_in6) 896 goto err_udplite_mib; 897 net->mib.ipv6_statistics = alloc_percpu(struct ipstats_mib); 898 if (!net->mib.ipv6_statistics) 899 goto err_ip_mib; 900 901 for_each_possible_cpu(i) { 902 struct ipstats_mib *af_inet6_stats; 903 af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics, i); 904 u64_stats_init(&af_inet6_stats->syncp); 905 } 906 907 908 net->mib.icmpv6_statistics = alloc_percpu(struct icmpv6_mib); 909 if (!net->mib.icmpv6_statistics) 910 goto err_icmp_mib; 911 net->mib.icmpv6msg_statistics = kzalloc_obj(struct icmpv6msg_mib); 912 if (!net->mib.icmpv6msg_statistics) 913 goto err_icmpmsg_mib; 914 return 0; 915 916 err_icmpmsg_mib: 917 free_percpu(net->mib.icmpv6_statistics); 918 err_icmp_mib: 919 free_percpu(net->mib.ipv6_statistics); 920 err_ip_mib: 921 free_percpu(net->mib.udplite_stats_in6); 922 err_udplite_mib: 923 free_percpu(net->mib.udp_stats_in6); 924 return -ENOMEM; 925 } 926 927 static void ipv6_cleanup_mibs(struct net *net) 928 { 929 free_percpu(net->mib.udp_stats_in6); 930 free_percpu(net->mib.udplite_stats_in6); 931 free_percpu(net->mib.ipv6_statistics); 932 free_percpu(net->mib.icmpv6_statistics); 933 kfree(net->mib.icmpv6msg_statistics); 934 } 935 936 static int __net_init inet6_net_init(struct net *net) 937 { 938 int err = 0; 939 940 net->ipv6.sysctl.bindv6only = 0; 941 net->ipv6.sysctl.icmpv6_time = HZ / 10; 942 net->ipv6.sysctl.icmpv6_echo_ignore_all = 0; 943 net->ipv6.sysctl.icmpv6_echo_ignore_multicast = 0; 944 net->ipv6.sysctl.icmpv6_echo_ignore_anycast = 0; 945 net->ipv6.sysctl.icmpv6_error_anycast_as_unicast = 0; 946 net->ipv6.sysctl.icmpv6_errors_extension_mask = 0; 947 948 /* By default, rate limit error messages. 949 * Except for pmtu discovery, it would break it. 950 * proc_do_large_bitmap needs pointer to the bitmap. 951 */ 952 bitmap_set(net->ipv6.sysctl.icmpv6_ratemask, 0, ICMPV6_ERRMSG_MAX + 1); 953 bitmap_clear(net->ipv6.sysctl.icmpv6_ratemask, ICMPV6_PKT_TOOBIG, 1); 954 net->ipv6.sysctl.icmpv6_ratemask_ptr = net->ipv6.sysctl.icmpv6_ratemask; 955 956 net->ipv6.sysctl.flowlabel_consistency = 1; 957 net->ipv6.sysctl.auto_flowlabels = IP6_DEFAULT_AUTO_FLOW_LABELS; 958 net->ipv6.sysctl.idgen_retries = 3; 959 net->ipv6.sysctl.idgen_delay = 1 * HZ; 960 net->ipv6.sysctl.flowlabel_state_ranges = 0; 961 net->ipv6.sysctl.max_dst_opts_cnt = IP6_DEFAULT_MAX_DST_OPTS_CNT; 962 net->ipv6.sysctl.max_hbh_opts_cnt = IP6_DEFAULT_MAX_HBH_OPTS_CNT; 963 net->ipv6.sysctl.max_dst_opts_len = IP6_DEFAULT_MAX_DST_OPTS_LEN; 964 net->ipv6.sysctl.max_hbh_opts_len = IP6_DEFAULT_MAX_HBH_OPTS_LEN; 965 net->ipv6.sysctl.fib_notify_on_flag_change = 0; 966 atomic_set(&net->ipv6.fib6_sernum, 1); 967 968 net->ipv6.sysctl.ioam6_id = IOAM6_DEFAULT_ID; 969 net->ipv6.sysctl.ioam6_id_wide = IOAM6_DEFAULT_ID_WIDE; 970 971 err = ipv6_init_mibs(net); 972 if (err) 973 return err; 974 #ifdef CONFIG_PROC_FS 975 err = udp6_proc_init(net); 976 if (err) 977 goto out; 978 err = tcp6_proc_init(net); 979 if (err) 980 goto proc_tcp6_fail; 981 err = ac6_proc_init(net); 982 if (err) 983 goto proc_ac6_fail; 984 #endif 985 return err; 986 987 #ifdef CONFIG_PROC_FS 988 proc_ac6_fail: 989 tcp6_proc_exit(net); 990 proc_tcp6_fail: 991 udp6_proc_exit(net); 992 out: 993 ipv6_cleanup_mibs(net); 994 return err; 995 #endif 996 } 997 998 static void __net_exit inet6_net_exit(struct net *net) 999 { 1000 #ifdef CONFIG_PROC_FS 1001 udp6_proc_exit(net); 1002 tcp6_proc_exit(net); 1003 ac6_proc_exit(net); 1004 #endif 1005 ipv6_cleanup_mibs(net); 1006 } 1007 1008 static struct pernet_operations inet6_net_ops = { 1009 .init = inet6_net_init, 1010 .exit = inet6_net_exit, 1011 }; 1012 1013 static int ipv6_route_input(struct sk_buff *skb) 1014 { 1015 ip6_route_input(skb); 1016 return skb_dst(skb)->error; 1017 } 1018 1019 static const struct ipv6_stub ipv6_stub_impl = { 1020 .ipv6_sock_mc_join = ipv6_sock_mc_join, 1021 .ipv6_sock_mc_drop = ipv6_sock_mc_drop, 1022 .ipv6_dst_lookup_flow = ip6_dst_lookup_flow, 1023 .ipv6_route_input = ipv6_route_input, 1024 .fib6_get_table = fib6_get_table, 1025 .fib6_table_lookup = fib6_table_lookup, 1026 .fib6_lookup = fib6_lookup, 1027 .fib6_select_path = fib6_select_path, 1028 .ip6_mtu_from_fib6 = ip6_mtu_from_fib6, 1029 .fib6_nh_init = fib6_nh_init, 1030 .fib6_nh_release = fib6_nh_release, 1031 .fib6_nh_release_dsts = fib6_nh_release_dsts, 1032 .fib6_update_sernum = fib6_update_sernum_stub, 1033 .fib6_rt_update = fib6_rt_update, 1034 .ip6_del_rt = ip6_del_rt, 1035 .udpv6_encap_enable = udpv6_encap_enable, 1036 .ndisc_send_na = ndisc_send_na, 1037 #if IS_ENABLED(CONFIG_XFRM) 1038 .xfrm6_local_rxpmtu = xfrm6_local_rxpmtu, 1039 .xfrm6_udp_encap_rcv = xfrm6_udp_encap_rcv, 1040 .xfrm6_gro_udp_encap_rcv = xfrm6_gro_udp_encap_rcv, 1041 .xfrm6_rcv_encap = xfrm6_rcv_encap, 1042 #endif 1043 .nd_tbl = &nd_tbl, 1044 .ipv6_fragment = ip6_fragment, 1045 .ipv6_dev_find = ipv6_dev_find, 1046 .ip6_xmit = ip6_xmit, 1047 }; 1048 1049 static const struct ipv6_bpf_stub ipv6_bpf_stub_impl = { 1050 .inet6_bind = __inet6_bind, 1051 .udp6_lib_lookup = __udp6_lib_lookup, 1052 .ipv6_setsockopt = do_ipv6_setsockopt, 1053 .ipv6_getsockopt = do_ipv6_getsockopt, 1054 .ipv6_dev_get_saddr = ipv6_dev_get_saddr, 1055 }; 1056 1057 static int __init inet6_init(void) 1058 { 1059 struct list_head *r; 1060 int err = 0; 1061 1062 sock_skb_cb_check_size(sizeof(struct inet6_skb_parm)); 1063 1064 /* Register the socket-side information for inet6_create. */ 1065 for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r) 1066 INIT_LIST_HEAD(r); 1067 1068 raw_hashinfo_init(&raw_v6_hashinfo); 1069 1070 if (disable_ipv6_mod) { 1071 pr_info("Loaded, but administratively disabled, reboot required to enable\n"); 1072 goto out; 1073 } 1074 1075 err = proto_register(&tcpv6_prot, 1); 1076 if (err) 1077 goto out; 1078 1079 err = proto_register(&udpv6_prot, 1); 1080 if (err) 1081 goto out_unregister_tcp_proto; 1082 1083 err = proto_register(&udplitev6_prot, 1); 1084 if (err) 1085 goto out_unregister_udp_proto; 1086 1087 err = proto_register(&rawv6_prot, 1); 1088 if (err) 1089 goto out_unregister_udplite_proto; 1090 1091 err = proto_register(&pingv6_prot, 1); 1092 if (err) 1093 goto out_unregister_raw_proto; 1094 1095 /* We MUST register RAW sockets before we create the ICMP6, 1096 * IGMP6, or NDISC control sockets. 1097 */ 1098 err = rawv6_init(); 1099 if (err) 1100 goto out_unregister_ping_proto; 1101 1102 /* Register the family here so that the init calls below will 1103 * be able to create sockets. (?? is this dangerous ??) 1104 */ 1105 err = sock_register(&inet6_family_ops); 1106 if (err) 1107 goto out_sock_register_fail; 1108 1109 /* 1110 * ipngwg API draft makes clear that the correct semantics 1111 * for TCP and UDP is to consider one TCP and UDP instance 1112 * in a host available by both INET and INET6 APIs and 1113 * able to communicate via both network protocols. 1114 */ 1115 1116 err = register_pernet_subsys(&inet6_net_ops); 1117 if (err) 1118 goto register_pernet_fail; 1119 err = ip6_mr_init(); 1120 if (err) 1121 goto ipmr_fail; 1122 err = icmpv6_init(); 1123 if (err) 1124 goto icmp_fail; 1125 err = ndisc_init(); 1126 if (err) 1127 goto ndisc_fail; 1128 err = igmp6_init(); 1129 if (err) 1130 goto igmp_fail; 1131 1132 err = ipv6_netfilter_init(); 1133 if (err) 1134 goto netfilter_fail; 1135 /* Create /proc/foo6 entries. */ 1136 #ifdef CONFIG_PROC_FS 1137 err = -ENOMEM; 1138 if (raw6_proc_init()) 1139 goto proc_raw6_fail; 1140 if (udplite6_proc_init()) 1141 goto proc_udplite6_fail; 1142 if (ipv6_misc_proc_init()) 1143 goto proc_misc6_fail; 1144 if (if6_proc_init()) 1145 goto proc_if6_fail; 1146 #endif 1147 err = ip6_route_init(); 1148 if (err) 1149 goto ip6_route_fail; 1150 err = ndisc_late_init(); 1151 if (err) 1152 goto ndisc_late_fail; 1153 err = ip6_flowlabel_init(); 1154 if (err) 1155 goto ip6_flowlabel_fail; 1156 err = ipv6_anycast_init(); 1157 if (err) 1158 goto ipv6_anycast_fail; 1159 err = addrconf_init(); 1160 if (err) 1161 goto addrconf_fail; 1162 1163 /* Init v6 extension headers. */ 1164 err = ipv6_exthdrs_init(); 1165 if (err) 1166 goto ipv6_exthdrs_fail; 1167 1168 err = ipv6_frag_init(); 1169 if (err) 1170 goto ipv6_frag_fail; 1171 1172 /* Init v6 transport protocols. */ 1173 err = udpv6_init(); 1174 if (err) 1175 goto udpv6_fail; 1176 1177 err = udplitev6_init(); 1178 if (err) 1179 goto udplitev6_fail; 1180 1181 err = udpv6_offload_init(); 1182 if (err) 1183 goto udpv6_offload_fail; 1184 1185 err = tcpv6_init(); 1186 if (err) 1187 goto tcpv6_fail; 1188 1189 err = ipv6_packet_init(); 1190 if (err) 1191 goto ipv6_packet_fail; 1192 1193 err = pingv6_init(); 1194 if (err) 1195 goto pingv6_fail; 1196 1197 err = calipso_init(); 1198 if (err) 1199 goto calipso_fail; 1200 1201 err = seg6_init(); 1202 if (err) 1203 goto seg6_fail; 1204 1205 err = rpl_init(); 1206 if (err) 1207 goto rpl_fail; 1208 1209 err = ioam6_init(); 1210 if (err) 1211 goto ioam6_fail; 1212 1213 err = igmp6_late_init(); 1214 if (err) 1215 goto igmp6_late_err; 1216 1217 #ifdef CONFIG_SYSCTL 1218 err = ipv6_sysctl_register(); 1219 if (err) 1220 goto sysctl_fail; 1221 #endif 1222 1223 /* ensure that ipv6 stubs are visible only after ipv6 is ready */ 1224 wmb(); 1225 ipv6_stub = &ipv6_stub_impl; 1226 ipv6_bpf_stub = &ipv6_bpf_stub_impl; 1227 out: 1228 return err; 1229 1230 #ifdef CONFIG_SYSCTL 1231 sysctl_fail: 1232 igmp6_late_cleanup(); 1233 #endif 1234 igmp6_late_err: 1235 ioam6_exit(); 1236 ioam6_fail: 1237 rpl_exit(); 1238 rpl_fail: 1239 seg6_exit(); 1240 seg6_fail: 1241 calipso_exit(); 1242 calipso_fail: 1243 pingv6_exit(); 1244 pingv6_fail: 1245 ipv6_packet_cleanup(); 1246 ipv6_packet_fail: 1247 tcpv6_exit(); 1248 tcpv6_fail: 1249 udpv6_offload_exit(); 1250 udpv6_offload_fail: 1251 udplitev6_exit(); 1252 udplitev6_fail: 1253 udpv6_exit(); 1254 udpv6_fail: 1255 ipv6_frag_exit(); 1256 ipv6_frag_fail: 1257 ipv6_exthdrs_exit(); 1258 ipv6_exthdrs_fail: 1259 addrconf_cleanup(); 1260 addrconf_fail: 1261 ipv6_anycast_cleanup(); 1262 ipv6_anycast_fail: 1263 ip6_flowlabel_cleanup(); 1264 ip6_flowlabel_fail: 1265 ndisc_late_cleanup(); 1266 ndisc_late_fail: 1267 ip6_route_cleanup(); 1268 ip6_route_fail: 1269 #ifdef CONFIG_PROC_FS 1270 if6_proc_exit(); 1271 proc_if6_fail: 1272 ipv6_misc_proc_exit(); 1273 proc_misc6_fail: 1274 udplite6_proc_exit(); 1275 proc_udplite6_fail: 1276 raw6_proc_exit(); 1277 proc_raw6_fail: 1278 #endif 1279 ipv6_netfilter_fini(); 1280 netfilter_fail: 1281 igmp6_cleanup(); 1282 igmp_fail: 1283 ndisc_cleanup(); 1284 ndisc_fail: 1285 icmpv6_cleanup(); 1286 icmp_fail: 1287 ip6_mr_cleanup(); 1288 ipmr_fail: 1289 unregister_pernet_subsys(&inet6_net_ops); 1290 register_pernet_fail: 1291 sock_unregister(PF_INET6); 1292 rtnl_unregister_all(PF_INET6); 1293 out_sock_register_fail: 1294 rawv6_exit(); 1295 out_unregister_ping_proto: 1296 proto_unregister(&pingv6_prot); 1297 out_unregister_raw_proto: 1298 proto_unregister(&rawv6_prot); 1299 out_unregister_udplite_proto: 1300 proto_unregister(&udplitev6_prot); 1301 out_unregister_udp_proto: 1302 proto_unregister(&udpv6_prot); 1303 out_unregister_tcp_proto: 1304 proto_unregister(&tcpv6_prot); 1305 goto out; 1306 } 1307 module_init(inet6_init); 1308 1309 MODULE_ALIAS_NETPROTO(PF_INET6); 1310