2 * PF_INET6 socket protocol family
3 * Linux INET6 implementation
6 * Pedro Roque <roque@di.fc.ul.pt>
8 * Adapted from linux/net/ipv4/af_inet.c
11 * piggy, Karl Knutson : Socket protocol table
12 * Hideaki YOSHIFUJI : sin6_scope_id support
13 * Arnaldo Melo : check proc_net_create return, cleanups
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
21 #define pr_fmt(fmt) "IPv6: " fmt
23 #include <linux/module.h>
24 #include <linux/capability.h>
25 #include <linux/errno.h>
26 #include <linux/types.h>
27 #include <linux/socket.h>
29 #include <linux/kernel.h>
30 #include <linux/timer.h>
31 #include <linux/string.h>
32 #include <linux/sockios.h>
33 #include <linux/net.h>
34 #include <linux/fcntl.h>
36 #include <linux/interrupt.h>
37 #include <linux/proc_fs.h>
38 #include <linux/stat.h>
39 #include <linux/init.h>
40 #include <linux/slab.h>
42 #include <linux/inet.h>
43 #include <linux/netdevice.h>
44 #include <linux/icmpv6.h>
45 #include <linux/netfilter_ipv6.h>
50 #include <net/udplite.h>
53 #include <net/protocol.h>
54 #include <net/inet_common.h>
55 #include <net/route.h>
56 #include <net/transp_v6.h>
57 #include <net/ip6_route.h>
58 #include <net/addrconf.h>
59 #include <net/ndisc.h>
60 #ifdef CONFIG_IPV6_TUNNEL
61 #include <net/ip6_tunnel.h>
63 #include <net/calipso.h>
65 #include <asm/uaccess.h>
66 #include <linux/mroute6.h>
68 MODULE_AUTHOR("Cast of dozens");
69 MODULE_DESCRIPTION("IPv6 protocol stack for Linux");
70 MODULE_LICENSE("GPL");
72 /* The inetsw6 table contains everything that inet6_create needs to
75 static struct list_head inetsw6[SOCK_MAX];
76 static DEFINE_SPINLOCK(inetsw6_lock);
78 struct ipv6_params ipv6_defaults = {
83 static int disable_ipv6_mod;
85 module_param_named(disable, disable_ipv6_mod, int, 0444);
86 MODULE_PARM_DESC(disable, "Disable IPv6 module such that it is non-functional");
88 module_param_named(disable_ipv6, ipv6_defaults.disable_ipv6, int, 0444);
89 MODULE_PARM_DESC(disable_ipv6, "Disable IPv6 on all interfaces");
91 module_param_named(autoconf, ipv6_defaults.autoconf, int, 0444);
92 MODULE_PARM_DESC(autoconf, "Enable IPv6 address autoconfiguration on all interfaces");
94 static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
96 const int offset = sk->sk_prot->obj_size - sizeof(struct ipv6_pinfo);
98 return (struct ipv6_pinfo *)(((u8 *)sk) + offset);
101 static int inet6_create(struct net *net, struct socket *sock, int protocol,
104 struct inet_sock *inet;
105 struct ipv6_pinfo *np;
107 struct inet_protosw *answer;
108 struct proto *answer_prot;
109 unsigned char answer_flags;
110 int try_loading_module = 0;
113 if (protocol < 0 || protocol >= IPPROTO_MAX)
116 /* Look for the requested type/protocol pair. */
118 err = -ESOCKTNOSUPPORT;
120 list_for_each_entry_rcu(answer, &inetsw6[sock->type], list) {
123 /* Check the non-wild match. */
124 if (protocol == answer->protocol) {
125 if (protocol != IPPROTO_IP)
128 /* Check for the two wild cases. */
129 if (IPPROTO_IP == protocol) {
130 protocol = answer->protocol;
133 if (IPPROTO_IP == answer->protocol)
136 err = -EPROTONOSUPPORT;
140 if (try_loading_module < 2) {
143 * Be more specific, e.g. net-pf-10-proto-132-type-1
144 * (net-pf-PF_INET6-proto-IPPROTO_SCTP-type-SOCK_STREAM)
146 if (++try_loading_module == 1)
147 request_module("net-pf-%d-proto-%d-type-%d",
148 PF_INET6, protocol, sock->type);
150 * Fall back to generic, e.g. net-pf-10-proto-132
151 * (net-pf-PF_INET6-proto-IPPROTO_SCTP)
154 request_module("net-pf-%d-proto-%d",
156 goto lookup_protocol;
162 if (sock->type == SOCK_RAW && !kern &&
163 !ns_capable(net->user_ns, CAP_NET_RAW))
166 sock->ops = answer->ops;
167 answer_prot = answer->prot;
168 answer_flags = answer->flags;
171 WARN_ON(!answer_prot->slab);
174 sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot, kern);
178 sock_init_data(sock, sk);
181 if (INET_PROTOSW_REUSE & answer_flags)
182 sk->sk_reuse = SK_CAN_REUSE;
185 inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;
187 if (SOCK_RAW == sock->type) {
188 inet->inet_num = protocol;
189 if (IPPROTO_RAW == protocol)
193 sk->sk_destruct = inet_sock_destruct;
194 sk->sk_family = PF_INET6;
195 sk->sk_protocol = protocol;
197 sk->sk_backlog_rcv = answer->prot->backlog_rcv;
199 inet_sk(sk)->pinet6 = np = inet6_sk_generic(sk);
201 np->mcast_hops = IPV6_DEFAULT_MCASTHOPS;
203 np->pmtudisc = IPV6_PMTUDISC_WANT;
204 np->autoflowlabel = ip6_default_np_autolabel(sock_net(sk));
205 sk->sk_ipv6only = net->ipv6.sysctl.bindv6only;
207 /* Init the ipv4 part of the socket since we can have sockets
208 * using v6 API for ipv4.
215 inet->mc_list = NULL;
218 if (net->ipv4.sysctl_ip_no_pmtu_disc)
219 inet->pmtudisc = IP_PMTUDISC_DONT;
221 inet->pmtudisc = IP_PMTUDISC_WANT;
223 * Increment only the relevant sk_prot->socks debug field, this changes
224 * the previous behaviour of incrementing both the equivalent to
225 * answer->prot->socks (inet6_sock_nr) and inet_sock_nr.
227 * This allows better debug granularity as we'll know exactly how many
228 * UDPv6, TCPv6, etc socks were allocated, not the sum of all IPv6
229 * transport protocol socks. -acme
231 sk_refcnt_debug_inc(sk);
233 if (inet->inet_num) {
234 /* It assumes that any protocol which allows
235 * the user to assign a number at socket
236 * creation time automatically shares.
238 inet->inet_sport = htons(inet->inet_num);
239 err = sk->sk_prot->hash(sk);
241 sk_common_release(sk);
245 if (sk->sk_prot->init) {
246 err = sk->sk_prot->init(sk);
248 sk_common_release(sk);
260 /* bind for INET6 API */
261 int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
263 struct sockaddr_in6 *addr = (struct sockaddr_in6 *)uaddr;
264 struct sock *sk = sock->sk;
265 struct inet_sock *inet = inet_sk(sk);
266 struct ipv6_pinfo *np = inet6_sk(sk);
267 struct net *net = sock_net(sk);
273 /* If the socket has its own bind function then use it. */
274 if (sk->sk_prot->bind)
275 return sk->sk_prot->bind(sk, uaddr, addr_len);
277 if (addr_len < SIN6_LEN_RFC2133)
280 if (addr->sin6_family != AF_INET6)
281 return -EAFNOSUPPORT;
283 addr_type = ipv6_addr_type(&addr->sin6_addr);
284 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
287 snum = ntohs(addr->sin6_port);
288 if (snum && snum < PROT_SOCK && !ns_capable(net->user_ns, CAP_NET_BIND_SERVICE))
293 /* Check these errors (active socket, double bind). */
294 if (sk->sk_state != TCP_CLOSE || inet->inet_num) {
299 /* Check if the address belongs to the host. */
300 if (addr_type == IPV6_ADDR_MAPPED) {
303 /* Binding to v4-mapped address on a v6-only socket
306 if (sk->sk_ipv6only) {
311 /* Reproduce AF_INET checks to make the bindings consistent */
312 v4addr = addr->sin6_addr.s6_addr32[3];
313 chk_addr_ret = inet_addr_type(net, v4addr);
314 if (!net->ipv4.sysctl_ip_nonlocal_bind &&
315 !(inet->freebind || inet->transparent) &&
316 v4addr != htonl(INADDR_ANY) &&
317 chk_addr_ret != RTN_LOCAL &&
318 chk_addr_ret != RTN_MULTICAST &&
319 chk_addr_ret != RTN_BROADCAST) {
320 err = -EADDRNOTAVAIL;
324 if (addr_type != IPV6_ADDR_ANY) {
325 struct net_device *dev = NULL;
328 if (__ipv6_addr_needs_scope_id(addr_type)) {
329 if (addr_len >= sizeof(struct sockaddr_in6) &&
330 addr->sin6_scope_id) {
331 /* Override any existing binding, if another one
332 * is supplied by user.
334 sk->sk_bound_dev_if = addr->sin6_scope_id;
337 /* Binding to link-local address requires an interface */
338 if (!sk->sk_bound_dev_if) {
342 dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if);
349 /* ipv4 addr of the socket is invalid. Only the
350 * unspecified and mapped address have a v4 equivalent.
352 v4addr = LOOPBACK4_IPV6;
353 if (!(addr_type & IPV6_ADDR_MULTICAST)) {
354 if (!net->ipv6.sysctl.ip_nonlocal_bind &&
355 !(inet->freebind || inet->transparent) &&
356 !ipv6_chk_addr(net, &addr->sin6_addr,
358 err = -EADDRNOTAVAIL;
366 inet->inet_rcv_saddr = v4addr;
367 inet->inet_saddr = v4addr;
369 sk->sk_v6_rcv_saddr = addr->sin6_addr;
371 if (!(addr_type & IPV6_ADDR_MULTICAST))
372 np->saddr = addr->sin6_addr;
374 /* Make sure we are allowed to bind here. */
375 if ((snum || !inet->bind_address_no_port) &&
376 sk->sk_prot->get_port(sk, snum)) {
377 inet_reset_saddr(sk);
382 if (addr_type != IPV6_ADDR_ANY) {
383 sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
384 if (addr_type != IPV6_ADDR_MAPPED)
388 sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
389 inet->inet_sport = htons(inet->inet_num);
390 inet->inet_dport = 0;
391 inet->inet_daddr = 0;
399 EXPORT_SYMBOL(inet6_bind);
401 int inet6_release(struct socket *sock)
403 struct sock *sk = sock->sk;
409 ipv6_sock_mc_close(sk);
412 ipv6_sock_ac_close(sk);
414 return inet_release(sock);
416 EXPORT_SYMBOL(inet6_release);
418 void inet6_destroy_sock(struct sock *sk)
420 struct ipv6_pinfo *np = inet6_sk(sk);
422 struct ipv6_txoptions *opt;
424 /* Release rx options */
426 skb = xchg(&np->pktoptions, NULL);
430 skb = xchg(&np->rxpmtu, NULL);
434 /* Free flowlabels */
435 fl6_free_socklist(sk);
437 /* Free tx options */
439 opt = xchg((__force struct ipv6_txoptions **)&np->opt, NULL);
441 atomic_sub(opt->tot_len, &sk->sk_omem_alloc);
445 EXPORT_SYMBOL_GPL(inet6_destroy_sock);
448 * This does both peername and sockname.
451 int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
452 int *uaddr_len, int peer)
454 struct sockaddr_in6 *sin = (struct sockaddr_in6 *)uaddr;
455 struct sock *sk = sock->sk;
456 struct inet_sock *inet = inet_sk(sk);
457 struct ipv6_pinfo *np = inet6_sk(sk);
459 sin->sin6_family = AF_INET6;
460 sin->sin6_flowinfo = 0;
461 sin->sin6_scope_id = 0;
463 if (!inet->inet_dport)
465 if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
468 sin->sin6_port = inet->inet_dport;
469 sin->sin6_addr = sk->sk_v6_daddr;
471 sin->sin6_flowinfo = np->flow_label;
473 if (ipv6_addr_any(&sk->sk_v6_rcv_saddr))
474 sin->sin6_addr = np->saddr;
476 sin->sin6_addr = sk->sk_v6_rcv_saddr;
478 sin->sin6_port = inet->inet_sport;
480 sin->sin6_scope_id = ipv6_iface_scope_id(&sin->sin6_addr,
481 sk->sk_bound_dev_if);
482 *uaddr_len = sizeof(*sin);
485 EXPORT_SYMBOL(inet6_getname);
487 int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
489 struct sock *sk = sock->sk;
490 struct net *net = sock_net(sk);
494 return sock_get_timestamp(sk, (struct timeval __user *)arg);
497 return sock_get_timestampns(sk, (struct timespec __user *)arg);
502 return ipv6_route_ioctl(net, cmd, (void __user *)arg);
505 return addrconf_add_ifaddr(net, (void __user *) arg);
507 return addrconf_del_ifaddr(net, (void __user *) arg);
509 return addrconf_set_dstaddr(net, (void __user *) arg);
511 if (!sk->sk_prot->ioctl)
513 return sk->sk_prot->ioctl(sk, cmd, arg);
518 EXPORT_SYMBOL(inet6_ioctl);
520 const struct proto_ops inet6_stream_ops = {
522 .owner = THIS_MODULE,
523 .release = inet6_release,
525 .connect = inet_stream_connect, /* ok */
526 .socketpair = sock_no_socketpair, /* a do nothing */
527 .accept = inet_accept, /* ok */
528 .getname = inet6_getname,
529 .poll = tcp_poll, /* ok */
530 .ioctl = inet6_ioctl, /* must change */
531 .listen = inet_listen, /* ok */
532 .shutdown = inet_shutdown, /* ok */
533 .setsockopt = sock_common_setsockopt, /* ok */
534 .getsockopt = sock_common_getsockopt, /* ok */
535 .sendmsg = inet_sendmsg, /* ok */
536 .recvmsg = inet_recvmsg, /* ok */
537 .mmap = sock_no_mmap,
538 .sendpage = inet_sendpage,
539 .splice_read = tcp_splice_read,
541 .compat_setsockopt = compat_sock_common_setsockopt,
542 .compat_getsockopt = compat_sock_common_getsockopt,
546 const struct proto_ops inet6_dgram_ops = {
548 .owner = THIS_MODULE,
549 .release = inet6_release,
551 .connect = inet_dgram_connect, /* ok */
552 .socketpair = sock_no_socketpair, /* a do nothing */
553 .accept = sock_no_accept, /* a do nothing */
554 .getname = inet6_getname,
555 .poll = udp_poll, /* ok */
556 .ioctl = inet6_ioctl, /* must change */
557 .listen = sock_no_listen, /* ok */
558 .shutdown = inet_shutdown, /* ok */
559 .setsockopt = sock_common_setsockopt, /* ok */
560 .getsockopt = sock_common_getsockopt, /* ok */
561 .sendmsg = inet_sendmsg, /* ok */
562 .recvmsg = inet_recvmsg, /* ok */
563 .mmap = sock_no_mmap,
564 .sendpage = sock_no_sendpage,
566 .compat_setsockopt = compat_sock_common_setsockopt,
567 .compat_getsockopt = compat_sock_common_getsockopt,
571 static const struct net_proto_family inet6_family_ops = {
573 .create = inet6_create,
574 .owner = THIS_MODULE,
577 int inet6_register_protosw(struct inet_protosw *p)
579 struct list_head *lh;
580 struct inet_protosw *answer;
581 struct list_head *last_perm;
582 int protocol = p->protocol;
585 spin_lock_bh(&inetsw6_lock);
588 if (p->type >= SOCK_MAX)
591 /* If we are trying to override a permanent protocol, bail. */
594 last_perm = &inetsw6[p->type];
595 list_for_each(lh, &inetsw6[p->type]) {
596 answer = list_entry(lh, struct inet_protosw, list);
598 /* Check only the non-wild match. */
599 if (INET_PROTOSW_PERMANENT & answer->flags) {
600 if (protocol == answer->protocol)
610 /* Add the new entry after the last permanent entry if any, so that
611 * the new entry does not override a permanent entry when matched with
612 * a wild-card protocol. But it is allowed to override any existing
613 * non-permanent entry. This means that when we remove this entry, the
614 * system automatically returns to the old behavior.
616 list_add_rcu(&p->list, last_perm);
619 spin_unlock_bh(&inetsw6_lock);
623 pr_err("Attempt to override permanent protocol %d\n", protocol);
627 pr_err("Ignoring attempt to register invalid socket type %d\n",
631 EXPORT_SYMBOL(inet6_register_protosw);
634 inet6_unregister_protosw(struct inet_protosw *p)
636 if (INET_PROTOSW_PERMANENT & p->flags) {
637 pr_err("Attempt to unregister permanent protocol %d\n",
640 spin_lock_bh(&inetsw6_lock);
641 list_del_rcu(&p->list);
642 spin_unlock_bh(&inetsw6_lock);
647 EXPORT_SYMBOL(inet6_unregister_protosw);
649 int inet6_sk_rebuild_header(struct sock *sk)
651 struct ipv6_pinfo *np = inet6_sk(sk);
652 struct dst_entry *dst;
654 dst = __sk_dst_check(sk, np->dst_cookie);
657 struct inet_sock *inet = inet_sk(sk);
658 struct in6_addr *final_p, final;
661 memset(&fl6, 0, sizeof(fl6));
662 fl6.flowi6_proto = sk->sk_protocol;
663 fl6.daddr = sk->sk_v6_daddr;
664 fl6.saddr = np->saddr;
665 fl6.flowlabel = np->flow_label;
666 fl6.flowi6_oif = sk->sk_bound_dev_if;
667 fl6.flowi6_mark = sk->sk_mark;
668 fl6.fl6_dport = inet->inet_dport;
669 fl6.fl6_sport = inet->inet_sport;
670 security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
673 final_p = fl6_update_dst(&fl6, rcu_dereference(np->opt),
677 dst = ip6_dst_lookup_flow(sk, &fl6, final_p);
679 sk->sk_route_caps = 0;
680 sk->sk_err_soft = -PTR_ERR(dst);
684 ip6_dst_store(sk, dst, NULL, NULL);
689 EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header);
691 bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb,
692 const struct inet6_skb_parm *opt)
694 const struct ipv6_pinfo *np = inet6_sk(sk);
697 if (((opt->flags & IP6SKB_HOPBYHOP) &&
698 (np->rxopt.bits.hopopts || np->rxopt.bits.ohopopts)) ||
699 (ip6_flowinfo((struct ipv6hdr *) skb_network_header(skb)) &&
700 np->rxopt.bits.rxflow) ||
701 (opt->srcrt && (np->rxopt.bits.srcrt ||
702 np->rxopt.bits.osrcrt)) ||
703 ((opt->dst1 || opt->dst0) &&
704 (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts)))
709 EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
711 static struct packet_type ipv6_packet_type __read_mostly = {
712 .type = cpu_to_be16(ETH_P_IPV6),
716 static int __init ipv6_packet_init(void)
718 dev_add_pack(&ipv6_packet_type);
722 static void ipv6_packet_cleanup(void)
724 dev_remove_pack(&ipv6_packet_type);
727 static int __net_init ipv6_init_mibs(struct net *net)
731 net->mib.udp_stats_in6 = alloc_percpu(struct udp_mib);
732 if (!net->mib.udp_stats_in6)
734 net->mib.udplite_stats_in6 = alloc_percpu(struct udp_mib);
735 if (!net->mib.udplite_stats_in6)
736 goto err_udplite_mib;
737 net->mib.ipv6_statistics = alloc_percpu(struct ipstats_mib);
738 if (!net->mib.ipv6_statistics)
741 for_each_possible_cpu(i) {
742 struct ipstats_mib *af_inet6_stats;
743 af_inet6_stats = per_cpu_ptr(net->mib.ipv6_statistics, i);
744 u64_stats_init(&af_inet6_stats->syncp);
748 net->mib.icmpv6_statistics = alloc_percpu(struct icmpv6_mib);
749 if (!net->mib.icmpv6_statistics)
751 net->mib.icmpv6msg_statistics = kzalloc(sizeof(struct icmpv6msg_mib),
753 if (!net->mib.icmpv6msg_statistics)
754 goto err_icmpmsg_mib;
758 free_percpu(net->mib.icmpv6_statistics);
760 free_percpu(net->mib.ipv6_statistics);
762 free_percpu(net->mib.udplite_stats_in6);
764 free_percpu(net->mib.udp_stats_in6);
768 static void ipv6_cleanup_mibs(struct net *net)
770 free_percpu(net->mib.udp_stats_in6);
771 free_percpu(net->mib.udplite_stats_in6);
772 free_percpu(net->mib.ipv6_statistics);
773 free_percpu(net->mib.icmpv6_statistics);
774 kfree(net->mib.icmpv6msg_statistics);
777 static int __net_init inet6_net_init(struct net *net)
781 net->ipv6.sysctl.bindv6only = 0;
782 net->ipv6.sysctl.icmpv6_time = 1*HZ;
783 net->ipv6.sysctl.flowlabel_consistency = 1;
784 net->ipv6.sysctl.auto_flowlabels = IP6_DEFAULT_AUTO_FLOW_LABELS;
785 net->ipv6.sysctl.idgen_retries = 3;
786 net->ipv6.sysctl.idgen_delay = 1 * HZ;
787 net->ipv6.sysctl.flowlabel_state_ranges = 0;
788 atomic_set(&net->ipv6.fib6_sernum, 1);
790 err = ipv6_init_mibs(net);
793 #ifdef CONFIG_PROC_FS
794 err = udp6_proc_init(net);
797 err = tcp6_proc_init(net);
800 err = ac6_proc_init(net);
806 #ifdef CONFIG_PROC_FS
812 ipv6_cleanup_mibs(net);
817 static void __net_exit inet6_net_exit(struct net *net)
819 #ifdef CONFIG_PROC_FS
824 ipv6_cleanup_mibs(net);
827 static struct pernet_operations inet6_net_ops = {
828 .init = inet6_net_init,
829 .exit = inet6_net_exit,
832 static const struct ipv6_stub ipv6_stub_impl = {
833 .ipv6_sock_mc_join = ipv6_sock_mc_join,
834 .ipv6_sock_mc_drop = ipv6_sock_mc_drop,
835 .ipv6_dst_lookup = ip6_dst_lookup,
836 .udpv6_encap_enable = udpv6_encap_enable,
837 .ndisc_send_na = ndisc_send_na,
841 static int __init inet6_init(void)
846 sock_skb_cb_check_size(sizeof(struct inet6_skb_parm));
848 /* Register the socket-side information for inet6_create. */
849 for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
852 if (disable_ipv6_mod) {
853 pr_info("Loaded, but administratively disabled, reboot required to enable\n");
857 err = proto_register(&tcpv6_prot, 1);
861 err = proto_register(&udpv6_prot, 1);
863 goto out_unregister_tcp_proto;
865 err = proto_register(&udplitev6_prot, 1);
867 goto out_unregister_udp_proto;
869 err = proto_register(&rawv6_prot, 1);
871 goto out_unregister_udplite_proto;
873 err = proto_register(&pingv6_prot, 1);
875 goto out_unregister_ping_proto;
877 /* We MUST register RAW sockets before we create the ICMP6,
878 * IGMP6, or NDISC control sockets.
882 goto out_unregister_raw_proto;
884 /* Register the family here so that the init calls below will
885 * be able to create sockets. (?? is this dangerous ??)
887 err = sock_register(&inet6_family_ops);
889 goto out_sock_register_fail;
892 * ipngwg API draft makes clear that the correct semantics
893 * for TCP and UDP is to consider one TCP and UDP instance
894 * in a host available by both INET and INET6 APIs and
895 * able to communicate via both network protocols.
898 err = register_pernet_subsys(&inet6_net_ops);
900 goto register_pernet_fail;
914 ipv6_stub = &ipv6_stub_impl;
916 err = ipv6_netfilter_init();
919 /* Create /proc/foo6 entries. */
920 #ifdef CONFIG_PROC_FS
922 if (raw6_proc_init())
924 if (udplite6_proc_init())
925 goto proc_udplite6_fail;
926 if (ipv6_misc_proc_init())
927 goto proc_misc6_fail;
931 err = ip6_route_init();
934 err = ndisc_late_init();
936 goto ndisc_late_fail;
937 err = ip6_flowlabel_init();
939 goto ip6_flowlabel_fail;
940 err = addrconf_init();
944 /* Init v6 extension headers. */
945 err = ipv6_exthdrs_init();
947 goto ipv6_exthdrs_fail;
949 err = ipv6_frag_init();
953 /* Init v6 transport protocols. */
958 err = udplitev6_init();
966 err = ipv6_packet_init();
968 goto ipv6_packet_fail;
974 err = calipso_init();
979 err = ipv6_sysctl_register();
993 ipv6_packet_cleanup();
1003 ipv6_exthdrs_exit();
1007 ip6_flowlabel_cleanup();
1009 ndisc_late_cleanup();
1011 ip6_route_cleanup();
1013 #ifdef CONFIG_PROC_FS
1016 ipv6_misc_proc_exit();
1018 udplite6_proc_exit();
1023 ipv6_netfilter_fini();
1033 unregister_pernet_subsys(&inet6_net_ops);
1034 register_pernet_fail:
1035 sock_unregister(PF_INET6);
1036 rtnl_unregister_all(PF_INET6);
1037 out_sock_register_fail:
1039 out_unregister_ping_proto:
1040 proto_unregister(&pingv6_prot);
1041 out_unregister_raw_proto:
1042 proto_unregister(&rawv6_prot);
1043 out_unregister_udplite_proto:
1044 proto_unregister(&udplitev6_prot);
1045 out_unregister_udp_proto:
1046 proto_unregister(&udpv6_prot);
1047 out_unregister_tcp_proto:
1048 proto_unregister(&tcpv6_prot);
1051 module_init(inet6_init);
1053 MODULE_ALIAS_NETPROTO(PF_INET6);