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
10 * $Id: af_inet6.c,v 1.66 2002/02/01 22:01:04 davem Exp $
13 * piggy, Karl Knutson : Socket protocol table
14 * Hideaki YOSHIFUJI : sin6_scope_id support
15 * Arnaldo Melo : check proc_net_create return, cleanups
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version
20 * 2 of the License, or (at your option) any later version.
24 #include <linux/module.h>
25 #include <linux/capability.h>
26 #include <linux/errno.h>
27 #include <linux/types.h>
28 #include <linux/socket.h>
30 #include <linux/kernel.h>
31 #include <linux/sched.h>
32 #include <linux/timer.h>
33 #include <linux/string.h>
34 #include <linux/sockios.h>
35 #include <linux/net.h>
36 #include <linux/fcntl.h>
38 #include <linux/interrupt.h>
39 #include <linux/proc_fs.h>
40 #include <linux/stat.h>
41 #include <linux/init.h>
42 #include <linux/vs_context.h>
44 #include <linux/inet.h>
45 #include <linux/netdevice.h>
46 #include <linux/icmpv6.h>
47 #include <linux/smp_lock.h>
48 #include <linux/netfilter_ipv6.h>
53 #include <net/udplite.h>
56 #include <net/protocol.h>
57 #include <net/inet_common.h>
58 #include <net/transp_v6.h>
59 #include <net/ip6_route.h>
60 #include <net/addrconf.h>
61 #ifdef CONFIG_IPV6_TUNNEL
62 #include <net/ip6_tunnel.h>
64 #ifdef CONFIG_IPV6_MIP6
68 #include <asm/uaccess.h>
69 #include <asm/system.h>
71 MODULE_AUTHOR("Cast of dozens");
72 MODULE_DESCRIPTION("IPv6 protocol stack for Linux");
73 MODULE_LICENSE("GPL");
75 int sysctl_ipv6_bindv6only __read_mostly;
77 /* The inetsw table contains everything that inet_create needs to
80 static struct list_head inetsw6[SOCK_MAX];
81 static DEFINE_SPINLOCK(inetsw6_lock);
83 static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
85 const int offset = sk->sk_prot->obj_size - sizeof(struct ipv6_pinfo);
87 return (struct ipv6_pinfo *)(((u8 *)sk) + offset);
90 static int inet6_create(struct socket *sock, int protocol)
92 struct inet_sock *inet;
93 struct ipv6_pinfo *np;
96 struct inet_protosw *answer;
97 struct proto *answer_prot;
98 unsigned char answer_flags;
100 int try_loading_module = 0;
103 /* Look for the requested type/protocol pair. */
106 err = -ESOCKTNOSUPPORT;
108 list_for_each_rcu(p, &inetsw6[sock->type]) {
109 answer = list_entry(p, struct inet_protosw, list);
111 /* Check the non-wild match. */
112 if (protocol == answer->protocol) {
113 if (protocol != IPPROTO_IP)
116 /* Check for the two wild cases. */
117 if (IPPROTO_IP == protocol) {
118 protocol = answer->protocol;
121 if (IPPROTO_IP == answer->protocol)
124 err = -EPROTONOSUPPORT;
129 if (try_loading_module < 2) {
132 * Be more specific, e.g. net-pf-10-proto-132-type-1
133 * (net-pf-PF_INET6-proto-IPPROTO_SCTP-type-SOCK_STREAM)
135 if (++try_loading_module == 1)
136 request_module("net-pf-%d-proto-%d-type-%d",
137 PF_INET6, protocol, sock->type);
139 * Fall back to generic, e.g. net-pf-10-proto-132
140 * (net-pf-PF_INET6-proto-IPPROTO_SCTP)
143 request_module("net-pf-%d-proto-%d",
145 goto lookup_protocol;
151 if ((protocol == IPPROTO_ICMPV6) && vx_ccaps(VXC_RAW_ICMP))
153 if (answer->capability > 0 && !capable(answer->capability))
156 sock->ops = answer->ops;
157 answer_prot = answer->prot;
158 answer_no_check = answer->no_check;
159 answer_flags = answer->flags;
162 BUG_TRAP(answer_prot->slab != NULL);
165 sk = sk_alloc(PF_INET6, GFP_KERNEL, answer_prot, 1);
169 sock_init_data(sock, sk);
172 sk->sk_no_check = answer_no_check;
173 if (INET_PROTOSW_REUSE & answer_flags)
177 inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;
179 if (SOCK_RAW == sock->type) {
180 inet->num = protocol;
181 if (IPPROTO_RAW == protocol)
185 sk->sk_destruct = inet_sock_destruct;
186 sk->sk_family = PF_INET6;
187 sk->sk_protocol = protocol;
189 sk->sk_backlog_rcv = answer->prot->backlog_rcv;
191 inet_sk(sk)->pinet6 = np = inet6_sk_generic(sk);
195 np->pmtudisc = IPV6_PMTUDISC_WANT;
196 np->ipv6only = sysctl_ipv6_bindv6only;
198 /* Init the ipv4 part of the socket since we can have sockets
199 * using v6 API for ipv4.
206 inet->mc_list = NULL;
208 if (ipv4_config.no_pmtu_disc)
209 inet->pmtudisc = IP_PMTUDISC_DONT;
211 inet->pmtudisc = IP_PMTUDISC_WANT;
213 * Increment only the relevant sk_prot->socks debug field, this changes
214 * the previous behaviour of incrementing both the equivalent to
215 * answer->prot->socks (inet6_sock_nr) and inet_sock_nr.
217 * This allows better debug granularity as we'll know exactly how many
218 * UDPv6, TCPv6, etc socks were allocated, not the sum of all IPv6
219 * transport protocol socks. -acme
221 sk_refcnt_debug_inc(sk);
224 /* It assumes that any protocol which allows
225 * the user to assign a number at socket
226 * creation time automatically shares.
228 inet->sport = htons(inet->num);
229 sk->sk_prot->hash(sk);
231 if (sk->sk_prot->init) {
232 err = sk->sk_prot->init(sk);
234 sk_common_release(sk);
239 vxdprintk(VXD_CBIT(net, 4), "inet6_create(%p, %d): %d",
240 sock, protocol, err);
248 /* bind for INET6 API */
249 int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
251 struct sockaddr_in6 *addr=(struct sockaddr_in6 *)uaddr;
252 struct sock *sk = sock->sk;
253 struct inet_sock *inet = inet_sk(sk);
254 struct ipv6_pinfo *np = inet6_sk(sk);
260 /* If the socket has its own bind function then use it. */
261 if (sk->sk_prot->bind)
262 return sk->sk_prot->bind(sk, uaddr, addr_len);
264 if (addr_len < SIN6_LEN_RFC2133)
266 addr_type = ipv6_addr_type(&addr->sin6_addr);
267 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
270 snum = ntohs(addr->sin6_port);
271 if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
276 /* Check these errors (active socket, double bind). */
277 if (sk->sk_state != TCP_CLOSE || inet->num) {
282 /* Check if the address belongs to the host. */
283 if (addr_type == IPV6_ADDR_MAPPED) {
284 v4addr = addr->sin6_addr.s6_addr32[3];
285 if (inet_addr_type(v4addr) != RTN_LOCAL) {
286 err = -EADDRNOTAVAIL;
290 if (addr_type != IPV6_ADDR_ANY) {
291 struct net_device *dev = NULL;
293 if (addr_type & IPV6_ADDR_LINKLOCAL) {
294 if (addr_len >= sizeof(struct sockaddr_in6) &&
295 addr->sin6_scope_id) {
296 /* Override any existing binding, if another one
297 * is supplied by user.
299 sk->sk_bound_dev_if = addr->sin6_scope_id;
302 /* Binding to link-local address requires an interface */
303 if (!sk->sk_bound_dev_if) {
307 dev = dev_get_by_index(sk->sk_bound_dev_if);
314 /* VServer: Only accept if we have the address available */
315 if (sk->sk_nx_info && !addr6_in_nx_info(sk->sk_nx_info, &addr->sin6_addr)) {
316 vxdprintk(VXD_CBIT(net, 3), "inet6_bind(" NIP6_FMT ", %d): EADDRNOTAVAIL",
317 NIP6(addr->sin6_addr), sk->sk_nx_info->nx_id);
318 err = -EADDRNOTAVAIL;
323 vxdprintk(VXD_CBIT(net, 3), "inet6_bind(" NIP6_FMT ", %d): PASS",
324 NIP6(addr->sin6_addr), sk->sk_nx_info ? sk->sk_nx_info->nx_id : 0);
326 /* ipv4 addr of the socket is invalid. Only the
327 * unspecified and mapped address have a v4 equivalent.
329 v4addr = LOOPBACK4_IPV6;
330 if (!(addr_type & IPV6_ADDR_MULTICAST)) {
331 if (!ipv6_chk_addr(&addr->sin6_addr, dev, 0)) {
334 err = -EADDRNOTAVAIL;
343 inet->rcv_saddr = v4addr;
344 inet->saddr = v4addr;
346 ipv6_addr_copy(&np->rcv_saddr, &addr->sin6_addr);
348 if (!(addr_type & IPV6_ADDR_MULTICAST))
349 ipv6_addr_copy(&np->saddr, &addr->sin6_addr);
351 /* Make sure we are allowed to bind here. */
352 if (sk->sk_prot->get_port(sk, snum)) {
353 inet_reset_saddr(sk);
358 if (addr_type != IPV6_ADDR_ANY)
359 sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
361 sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
362 inet->sport = htons(inet->num);
370 int inet6_release(struct socket *sock)
372 struct sock *sk = sock->sk;
378 ipv6_sock_mc_close(sk);
381 ipv6_sock_ac_close(sk);
383 return inet_release(sock);
386 int inet6_destroy_sock(struct sock *sk)
388 struct ipv6_pinfo *np = inet6_sk(sk);
390 struct ipv6_txoptions *opt;
392 /* Release rx options */
394 if ((skb = xchg(&np->pktoptions, NULL)) != NULL)
397 /* Free flowlabels */
398 fl6_free_socklist(sk);
400 /* Free tx options */
402 if ((opt = xchg(&np->opt, NULL)) != NULL)
403 sock_kfree_s(sk, opt, opt->tot_len);
408 EXPORT_SYMBOL_GPL(inet6_destroy_sock);
411 * This does both peername and sockname.
414 int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
415 int *uaddr_len, int peer)
417 struct sockaddr_in6 *sin=(struct sockaddr_in6 *)uaddr;
418 struct sock *sk = sock->sk;
419 struct inet_sock *inet = inet_sk(sk);
420 struct ipv6_pinfo *np = inet6_sk(sk);
422 sin->sin6_family = AF_INET6;
423 sin->sin6_flowinfo = 0;
424 sin->sin6_scope_id = 0;
428 if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
431 sin->sin6_port = inet->dport;
432 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
434 sin->sin6_flowinfo = np->flow_label;
436 if (ipv6_addr_any(&np->rcv_saddr))
437 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
439 ipv6_addr_copy(&sin->sin6_addr, &np->rcv_saddr);
441 sin->sin6_port = inet->sport;
443 if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
444 sin->sin6_scope_id = sk->sk_bound_dev_if;
445 *uaddr_len = sizeof(*sin);
449 int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
451 struct sock *sk = sock->sk;
456 return sock_get_timestamp(sk, (struct timeval __user *)arg);
461 return(ipv6_route_ioctl(cmd,(void __user *)arg));
464 return addrconf_add_ifaddr((void __user *) arg);
466 return addrconf_del_ifaddr((void __user *) arg);
468 return addrconf_set_dstaddr((void __user *) arg);
470 if (!sk->sk_prot->ioctl)
472 return sk->sk_prot->ioctl(sk, cmd, arg);
478 const struct proto_ops inet6_stream_ops = {
480 .owner = THIS_MODULE,
481 .release = inet6_release,
483 .connect = inet_stream_connect, /* ok */
484 .socketpair = sock_no_socketpair, /* a do nothing */
485 .accept = inet_accept, /* ok */
486 .getname = inet6_getname,
487 .poll = tcp_poll, /* ok */
488 .ioctl = inet6_ioctl, /* must change */
489 .listen = inet_listen, /* ok */
490 .shutdown = inet_shutdown, /* ok */
491 .setsockopt = sock_common_setsockopt, /* ok */
492 .getsockopt = sock_common_getsockopt, /* ok */
493 .sendmsg = inet_sendmsg, /* ok */
494 .recvmsg = sock_common_recvmsg, /* ok */
495 .mmap = sock_no_mmap,
496 .sendpage = tcp_sendpage,
498 .compat_setsockopt = compat_sock_common_setsockopt,
499 .compat_getsockopt = compat_sock_common_getsockopt,
503 const struct proto_ops inet6_dgram_ops = {
505 .owner = THIS_MODULE,
506 .release = inet6_release,
508 .connect = inet_dgram_connect, /* ok */
509 .socketpair = sock_no_socketpair, /* a do nothing */
510 .accept = sock_no_accept, /* a do nothing */
511 .getname = inet6_getname,
512 .poll = udp_poll, /* ok */
513 .ioctl = inet6_ioctl, /* must change */
514 .listen = sock_no_listen, /* ok */
515 .shutdown = inet_shutdown, /* ok */
516 .setsockopt = sock_common_setsockopt, /* ok */
517 .getsockopt = sock_common_getsockopt, /* ok */
518 .sendmsg = inet_sendmsg, /* ok */
519 .recvmsg = sock_common_recvmsg, /* ok */
520 .mmap = sock_no_mmap,
521 .sendpage = sock_no_sendpage,
523 .compat_setsockopt = compat_sock_common_setsockopt,
524 .compat_getsockopt = compat_sock_common_getsockopt,
528 static struct net_proto_family inet6_family_ops = {
530 .create = inet6_create,
531 .owner = THIS_MODULE,
534 /* Same as inet6_dgram_ops, sans udp_poll. */
535 static const struct proto_ops inet6_sockraw_ops = {
537 .owner = THIS_MODULE,
538 .release = inet6_release,
540 .connect = inet_dgram_connect, /* ok */
541 .socketpair = sock_no_socketpair, /* a do nothing */
542 .accept = sock_no_accept, /* a do nothing */
543 .getname = inet6_getname,
544 .poll = datagram_poll, /* ok */
545 .ioctl = inet6_ioctl, /* must change */
546 .listen = sock_no_listen, /* ok */
547 .shutdown = inet_shutdown, /* ok */
548 .setsockopt = sock_common_setsockopt, /* ok */
549 .getsockopt = sock_common_getsockopt, /* ok */
550 .sendmsg = inet_sendmsg, /* ok */
551 .recvmsg = sock_common_recvmsg, /* ok */
552 .mmap = sock_no_mmap,
553 .sendpage = sock_no_sendpage,
555 .compat_setsockopt = compat_sock_common_setsockopt,
556 .compat_getsockopt = compat_sock_common_getsockopt,
560 static struct inet_protosw rawv6_protosw = {
562 .protocol = IPPROTO_IP, /* wild card */
564 .ops = &inet6_sockraw_ops,
565 .capability = CAP_NET_RAW,
566 .no_check = UDP_CSUM_DEFAULT,
567 .flags = INET_PROTOSW_REUSE,
571 inet6_register_protosw(struct inet_protosw *p)
573 struct list_head *lh;
574 struct inet_protosw *answer;
575 int protocol = p->protocol;
576 struct list_head *last_perm;
578 spin_lock_bh(&inetsw6_lock);
580 if (p->type >= SOCK_MAX)
583 /* If we are trying to override a permanent protocol, bail. */
585 last_perm = &inetsw6[p->type];
586 list_for_each(lh, &inetsw6[p->type]) {
587 answer = list_entry(lh, struct inet_protosw, list);
589 /* Check only the non-wild match. */
590 if (INET_PROTOSW_PERMANENT & answer->flags) {
591 if (protocol == answer->protocol)
601 /* Add the new entry after the last permanent entry if any, so that
602 * the new entry does not override a permanent entry when matched with
603 * a wild-card protocol. But it is allowed to override any existing
604 * non-permanent entry. This means that when we remove this entry, the
605 * system automatically returns to the old behavior.
607 list_add_rcu(&p->list, last_perm);
609 spin_unlock_bh(&inetsw6_lock);
613 printk(KERN_ERR "Attempt to override permanent protocol %d.\n",
619 "Ignoring attempt to register invalid socket type %d.\n",
625 inet6_unregister_protosw(struct inet_protosw *p)
627 if (INET_PROTOSW_PERMANENT & p->flags) {
629 "Attempt to unregister permanent protocol %d.\n",
632 spin_lock_bh(&inetsw6_lock);
633 list_del_rcu(&p->list);
634 spin_unlock_bh(&inetsw6_lock);
640 int inet6_sk_rebuild_header(struct sock *sk)
643 struct dst_entry *dst;
644 struct ipv6_pinfo *np = inet6_sk(sk);
646 dst = __sk_dst_check(sk, np->dst_cookie);
649 struct inet_sock *inet = inet_sk(sk);
650 struct in6_addr *final_p = NULL, final;
653 memset(&fl, 0, sizeof(fl));
654 fl.proto = sk->sk_protocol;
655 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
656 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
657 fl.fl6_flowlabel = np->flow_label;
658 fl.oif = sk->sk_bound_dev_if;
659 fl.fl_ip_dport = inet->dport;
660 fl.fl_ip_sport = inet->sport;
661 security_sk_classify_flow(sk, &fl);
663 if (np->opt && np->opt->srcrt) {
664 struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
665 ipv6_addr_copy(&final, &fl.fl6_dst);
666 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
670 err = ip6_dst_lookup(sk, &dst, &fl);
672 sk->sk_route_caps = 0;
676 ipv6_addr_copy(&fl.fl6_dst, final_p);
678 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) {
679 sk->sk_err_soft = -err;
683 __ip6_dst_store(sk, dst, NULL, NULL);
689 EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header);
691 int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
693 struct ipv6_pinfo *np = inet6_sk(sk);
694 struct inet6_skb_parm *opt = IP6CB(skb);
697 if ((opt->hop && (np->rxopt.bits.hopopts ||
698 np->rxopt.bits.ohopopts)) ||
699 ((IPV6_FLOWINFO_MASK & *(__be32*)skb->nh.raw) &&
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)))
710 EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
712 int ipv6_dev_in_nx_info6(struct net_device *dev, struct nx_info *nxi) {
715 if (nxi->nbipv6 > 0) {
716 struct inet6_dev *in_dev;
717 struct inet6_ifaddr **ifap;
718 struct inet6_ifaddr *ifa;
720 in_dev = in6_dev_get(dev);
722 for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
723 ifap = &ifa->if_next) {
724 if (addr6_in_nx_info(nxi, &(ifa->addr))) {
735 EXPORT_SYMBOL_GPL(ipv6_dev_in_nx_info6);
738 snmp6_mib_init(void *ptr[2], size_t mibsize, size_t mibalign)
743 ptr[0] = __alloc_percpu(mibsize);
747 ptr[1] = __alloc_percpu(mibsize);
761 snmp6_mib_free(void *ptr[2])
767 ptr[0] = ptr[1] = NULL;
770 static int __init init_ipv6_mibs(void)
772 if (snmp6_mib_init((void **)ipv6_statistics, sizeof (struct ipstats_mib),
773 __alignof__(struct ipstats_mib)) < 0)
775 if (snmp6_mib_init((void **)icmpv6_statistics, sizeof (struct icmpv6_mib),
776 __alignof__(struct icmpv6_mib)) < 0)
778 if (snmp6_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib),
779 __alignof__(struct udp_mib)) < 0)
781 if (snmp6_mib_init((void **)udplite_stats_in6, sizeof (struct udp_mib),
782 __alignof__(struct udp_mib)) < 0)
783 goto err_udplite_mib;
787 snmp6_mib_free((void **)udp_stats_in6);
789 snmp6_mib_free((void **)icmpv6_statistics);
791 snmp6_mib_free((void **)ipv6_statistics);
797 static void cleanup_ipv6_mibs(void)
799 snmp6_mib_free((void **)ipv6_statistics);
800 snmp6_mib_free((void **)icmpv6_statistics);
801 snmp6_mib_free((void **)udp_stats_in6);
802 snmp6_mib_free((void **)udplite_stats_in6);
805 #ifdef CONFIG_IPV6_MODULE
806 static void vc_net_register_init(void)
808 struct nx_ipv6_mod mymod = {
809 .dev_in_nx_info6 = ipv6_dev_in_nx_info6,
812 vc_net_register_ipv6(&mymod);
816 static int __init inet6_init(void)
818 struct sk_buff *dummy_skb;
822 BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > sizeof(dummy_skb->cb));
825 #if 0 /* FIXME --RR */
826 if (!mod_member_present(&__this_module, can_unload))
829 __this_module.can_unload = &ipv6_unload;
833 err = proto_register(&tcpv6_prot, 1);
837 err = proto_register(&udpv6_prot, 1);
839 goto out_unregister_tcp_proto;
841 err = proto_register(&udplitev6_prot, 1);
843 goto out_unregister_udp_proto;
845 err = proto_register(&rawv6_prot, 1);
847 goto out_unregister_udplite_proto;
850 /* Register the socket-side information for inet6_create. */
851 for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
854 /* We MUST register RAW sockets before we create the ICMP6,
855 * IGMP6, or NDISC control sockets.
857 inet6_register_protosw(&rawv6_protosw);
859 /* Register the family here so that the init calls below will
860 * be able to create sockets. (?? is this dangerous ??)
862 err = sock_register(&inet6_family_ops);
864 goto out_unregister_raw_proto;
866 /* Initialise ipv6 mibs */
867 err = init_ipv6_mibs();
869 goto out_unregister_sock;
872 * ipngwg API draft makes clear that the correct semantics
873 * for TCP and UDP is to consider one TCP and UDP instance
874 * in a host availiable by both INET and INET6 APIs and
875 * able to communicate via both network protocols.
879 ipv6_sysctl_register();
881 err = icmpv6_init(&inet6_family_ops);
884 err = ndisc_init(&inet6_family_ops);
887 err = igmp6_init(&inet6_family_ops);
890 err = ipv6_netfilter_init();
893 /* Create /proc/foo6 entries. */
894 #ifdef CONFIG_PROC_FS
896 if (raw6_proc_init())
898 if (tcp6_proc_init())
900 if (udp6_proc_init())
902 if (udplite6_proc_init())
903 goto proc_udplite6_fail;
904 if (ipv6_misc_proc_init())
905 goto proc_misc6_fail;
908 goto proc_anycast6_fail;
913 ip6_flowlabel_init();
914 err = addrconf_init();
918 /* Init v6 extension headers. */
923 #ifdef CONFIG_IPV6_MIP6
927 /* Init v6 transport protocols. */
934 #ifdef CONFIG_IPV6_MODULE
935 vc_net_register_init();
943 ip6_flowlabel_cleanup();
945 #ifdef CONFIG_PROC_FS
950 ipv6_misc_proc_exit();
952 udplite6_proc_exit();
961 ipv6_netfilter_fini();
970 ipv6_sysctl_unregister();
974 sock_unregister(PF_INET6);
975 out_unregister_raw_proto:
976 proto_unregister(&rawv6_prot);
977 out_unregister_udplite_proto:
978 proto_unregister(&udplitev6_prot);
979 out_unregister_udp_proto:
980 proto_unregister(&udpv6_prot);
981 out_unregister_tcp_proto:
982 proto_unregister(&tcpv6_prot);
985 module_init(inet6_init);
987 static void __exit inet6_exit(void)
989 /* First of all disallow new sockets creation. */
990 sock_unregister(PF_INET6);
991 #ifdef CONFIG_IPV6_MODULE
992 vc_net_unregister_ipv6();
994 #ifdef CONFIG_PROC_FS
997 ipv6_misc_proc_exit();
999 udplite6_proc_exit();
1003 #ifdef CONFIG_IPV6_MIP6
1006 /* Cleanup code parts. */
1007 ip6_flowlabel_cleanup();
1009 ip6_route_cleanup();
1010 ipv6_packet_cleanup();
1012 ipv6_netfilter_fini();
1015 #ifdef CONFIG_SYSCTL
1016 ipv6_sysctl_unregister();
1018 cleanup_ipv6_mibs();
1019 proto_unregister(&rawv6_prot);
1020 proto_unregister(&udpv6_prot);
1021 proto_unregister(&tcpv6_prot);
1023 module_exit(inet6_exit);
1025 MODULE_ALIAS_NETPROTO(PF_INET6);