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.
22 #include <linux/module.h>
23 #include <linux/capability.h>
24 #include <linux/errno.h>
25 #include <linux/types.h>
26 #include <linux/socket.h>
28 #include <linux/kernel.h>
29 #include <linux/timer.h>
30 #include <linux/string.h>
31 #include <linux/sockios.h>
32 #include <linux/net.h>
33 #include <linux/fcntl.h>
35 #include <linux/interrupt.h>
36 #include <linux/proc_fs.h>
37 #include <linux/stat.h>
38 #include <linux/init.h>
40 #include <linux/inet.h>
41 #include <linux/netdevice.h>
42 #include <linux/icmpv6.h>
43 #include <linux/netfilter_ipv6.h>
48 #include <net/udplite.h>
51 #include <net/protocol.h>
52 #include <net/inet_common.h>
53 #include <net/transp_v6.h>
54 #include <net/ip6_route.h>
55 #include <net/addrconf.h>
56 #ifdef CONFIG_IPV6_TUNNEL
57 #include <net/ip6_tunnel.h>
60 #include <asm/uaccess.h>
61 #include <asm/system.h>
62 #include <linux/mroute6.h>
64 MODULE_AUTHOR("Cast of dozens");
65 MODULE_DESCRIPTION("IPv6 protocol stack for Linux");
66 MODULE_LICENSE("GPL");
68 /* The inetsw6 table contains everything that inet6_create needs to
71 static struct list_head inetsw6[SOCK_MAX];
72 static DEFINE_SPINLOCK(inetsw6_lock);
74 static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
76 const int offset = sk->sk_prot->obj_size - sizeof(struct ipv6_pinfo);
78 return (struct ipv6_pinfo *)(((u8 *)sk) + offset);
81 static int inet6_create(struct net *net, struct socket *sock, int protocol)
83 struct inet_sock *inet;
84 struct ipv6_pinfo *np;
87 struct inet_protosw *answer;
88 struct proto *answer_prot;
89 unsigned char answer_flags;
91 int try_loading_module = 0;
94 if (sock->type != SOCK_RAW &&
95 sock->type != SOCK_DGRAM &&
99 /* Look for the requested type/protocol pair. */
102 err = -ESOCKTNOSUPPORT;
104 list_for_each_rcu(p, &inetsw6[sock->type]) {
105 answer = list_entry(p, struct inet_protosw, list);
107 /* Check the non-wild match. */
108 if (protocol == answer->protocol) {
109 if (protocol != IPPROTO_IP)
112 /* Check for the two wild cases. */
113 if (IPPROTO_IP == protocol) {
114 protocol = answer->protocol;
117 if (IPPROTO_IP == answer->protocol)
120 err = -EPROTONOSUPPORT;
125 if (try_loading_module < 2) {
128 * Be more specific, e.g. net-pf-10-proto-132-type-1
129 * (net-pf-PF_INET6-proto-IPPROTO_SCTP-type-SOCK_STREAM)
131 if (++try_loading_module == 1)
132 request_module("net-pf-%d-proto-%d-type-%d",
133 PF_INET6, protocol, sock->type);
135 * Fall back to generic, e.g. net-pf-10-proto-132
136 * (net-pf-PF_INET6-proto-IPPROTO_SCTP)
139 request_module("net-pf-%d-proto-%d",
141 goto lookup_protocol;
147 if (answer->capability > 0 && !capable(answer->capability))
150 sock->ops = answer->ops;
151 answer_prot = answer->prot;
152 answer_no_check = answer->no_check;
153 answer_flags = answer->flags;
156 BUG_TRAP(answer_prot->slab != NULL);
159 sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot);
163 sock_init_data(sock, sk);
166 sk->sk_no_check = answer_no_check;
167 if (INET_PROTOSW_REUSE & answer_flags)
171 inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;
173 if (SOCK_RAW == sock->type) {
174 inet->num = protocol;
175 if (IPPROTO_RAW == protocol)
179 sk->sk_destruct = inet_sock_destruct;
180 sk->sk_family = PF_INET6;
181 sk->sk_protocol = protocol;
183 sk->sk_backlog_rcv = answer->prot->backlog_rcv;
185 inet_sk(sk)->pinet6 = np = inet6_sk_generic(sk);
189 np->pmtudisc = IPV6_PMTUDISC_WANT;
190 np->ipv6only = net->ipv6.sysctl.bindv6only;
192 /* Init the ipv4 part of the socket since we can have sockets
193 * using v6 API for ipv4.
200 inet->mc_list = NULL;
202 if (ipv4_config.no_pmtu_disc)
203 inet->pmtudisc = IP_PMTUDISC_DONT;
205 inet->pmtudisc = IP_PMTUDISC_WANT;
207 * Increment only the relevant sk_prot->socks debug field, this changes
208 * the previous behaviour of incrementing both the equivalent to
209 * answer->prot->socks (inet6_sock_nr) and inet_sock_nr.
211 * This allows better debug granularity as we'll know exactly how many
212 * UDPv6, TCPv6, etc socks were allocated, not the sum of all IPv6
213 * transport protocol socks. -acme
215 sk_refcnt_debug_inc(sk);
218 /* It assumes that any protocol which allows
219 * the user to assign a number at socket
220 * creation time automatically shares.
222 inet->sport = htons(inet->num);
223 sk->sk_prot->hash(sk);
225 if (sk->sk_prot->init) {
226 err = sk->sk_prot->init(sk);
228 sk_common_release(sk);
240 /* bind for INET6 API */
241 int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
243 struct sockaddr_in6 *addr=(struct sockaddr_in6 *)uaddr;
244 struct sock *sk = sock->sk;
245 struct inet_sock *inet = inet_sk(sk);
246 struct ipv6_pinfo *np = inet6_sk(sk);
247 struct net *net = sock_net(sk);
253 /* If the socket has its own bind function then use it. */
254 if (sk->sk_prot->bind)
255 return sk->sk_prot->bind(sk, uaddr, addr_len);
257 if (addr_len < SIN6_LEN_RFC2133)
259 addr_type = ipv6_addr_type(&addr->sin6_addr);
260 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
263 snum = ntohs(addr->sin6_port);
264 if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
269 /* Check these errors (active socket, double bind). */
270 if (sk->sk_state != TCP_CLOSE || inet->num) {
275 /* Check if the address belongs to the host. */
276 if (addr_type == IPV6_ADDR_MAPPED) {
277 v4addr = addr->sin6_addr.s6_addr32[3];
278 if (inet_addr_type(net, v4addr) != RTN_LOCAL) {
279 err = -EADDRNOTAVAIL;
283 if (addr_type != IPV6_ADDR_ANY) {
284 struct net_device *dev = NULL;
286 if (addr_type & IPV6_ADDR_LINKLOCAL) {
287 if (addr_len >= sizeof(struct sockaddr_in6) &&
288 addr->sin6_scope_id) {
289 /* Override any existing binding, if another one
290 * is supplied by user.
292 sk->sk_bound_dev_if = addr->sin6_scope_id;
295 /* Binding to link-local address requires an interface */
296 if (!sk->sk_bound_dev_if) {
300 dev = dev_get_by_index(net, sk->sk_bound_dev_if);
307 /* ipv4 addr of the socket is invalid. Only the
308 * unspecified and mapped address have a v4 equivalent.
310 v4addr = LOOPBACK4_IPV6;
311 if (!(addr_type & IPV6_ADDR_MULTICAST)) {
312 if (!ipv6_chk_addr(net, &addr->sin6_addr,
316 err = -EADDRNOTAVAIL;
325 inet->rcv_saddr = v4addr;
326 inet->saddr = v4addr;
328 ipv6_addr_copy(&np->rcv_saddr, &addr->sin6_addr);
330 if (!(addr_type & IPV6_ADDR_MULTICAST))
331 ipv6_addr_copy(&np->saddr, &addr->sin6_addr);
333 /* Make sure we are allowed to bind here. */
334 if (sk->sk_prot->get_port(sk, snum)) {
335 inet_reset_saddr(sk);
340 if (addr_type != IPV6_ADDR_ANY)
341 sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
343 sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
344 inet->sport = htons(inet->num);
352 EXPORT_SYMBOL(inet6_bind);
354 int inet6_release(struct socket *sock)
356 struct sock *sk = sock->sk;
362 ipv6_sock_mc_close(sk);
365 ipv6_sock_ac_close(sk);
367 return inet_release(sock);
370 EXPORT_SYMBOL(inet6_release);
372 void inet6_destroy_sock(struct sock *sk)
374 struct ipv6_pinfo *np = inet6_sk(sk);
376 struct ipv6_txoptions *opt;
378 /* Release rx options */
380 if ((skb = xchg(&np->pktoptions, NULL)) != NULL)
383 /* Free flowlabels */
384 fl6_free_socklist(sk);
386 /* Free tx options */
388 if ((opt = xchg(&np->opt, NULL)) != NULL)
389 sock_kfree_s(sk, opt, opt->tot_len);
392 EXPORT_SYMBOL_GPL(inet6_destroy_sock);
395 * This does both peername and sockname.
398 int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
399 int *uaddr_len, int peer)
401 struct sockaddr_in6 *sin=(struct sockaddr_in6 *)uaddr;
402 struct sock *sk = sock->sk;
403 struct inet_sock *inet = inet_sk(sk);
404 struct ipv6_pinfo *np = inet6_sk(sk);
406 sin->sin6_family = AF_INET6;
407 sin->sin6_flowinfo = 0;
408 sin->sin6_scope_id = 0;
412 if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
415 sin->sin6_port = inet->dport;
416 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
418 sin->sin6_flowinfo = np->flow_label;
420 if (ipv6_addr_any(&np->rcv_saddr))
421 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
423 ipv6_addr_copy(&sin->sin6_addr, &np->rcv_saddr);
425 sin->sin6_port = inet->sport;
427 if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
428 sin->sin6_scope_id = sk->sk_bound_dev_if;
429 *uaddr_len = sizeof(*sin);
433 EXPORT_SYMBOL(inet6_getname);
435 int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
437 struct sock *sk = sock->sk;
438 struct net *net = sock_net(sk);
443 return sock_get_timestamp(sk, (struct timeval __user *)arg);
446 return sock_get_timestampns(sk, (struct timespec __user *)arg);
451 return(ipv6_route_ioctl(net, cmd, (void __user *)arg));
454 return addrconf_add_ifaddr(net, (void __user *) arg);
456 return addrconf_del_ifaddr(net, (void __user *) arg);
458 return addrconf_set_dstaddr(net, (void __user *) arg);
460 if (!sk->sk_prot->ioctl)
462 return sk->sk_prot->ioctl(sk, cmd, arg);
468 EXPORT_SYMBOL(inet6_ioctl);
470 const struct proto_ops inet6_stream_ops = {
472 .owner = THIS_MODULE,
473 .release = inet6_release,
475 .connect = inet_stream_connect, /* ok */
476 .socketpair = sock_no_socketpair, /* a do nothing */
477 .accept = inet_accept, /* ok */
478 .getname = inet6_getname,
479 .poll = tcp_poll, /* ok */
480 .ioctl = inet6_ioctl, /* must change */
481 .listen = inet_listen, /* ok */
482 .shutdown = inet_shutdown, /* ok */
483 .setsockopt = sock_common_setsockopt, /* ok */
484 .getsockopt = sock_common_getsockopt, /* ok */
485 .sendmsg = tcp_sendmsg, /* ok */
486 .recvmsg = sock_common_recvmsg, /* ok */
487 .mmap = sock_no_mmap,
488 .sendpage = tcp_sendpage,
489 .splice_read = tcp_splice_read,
491 .compat_setsockopt = compat_sock_common_setsockopt,
492 .compat_getsockopt = compat_sock_common_getsockopt,
496 const struct proto_ops inet6_dgram_ops = {
498 .owner = THIS_MODULE,
499 .release = inet6_release,
501 .connect = inet_dgram_connect, /* ok */
502 .socketpair = sock_no_socketpair, /* a do nothing */
503 .accept = sock_no_accept, /* a do nothing */
504 .getname = inet6_getname,
505 .poll = udp_poll, /* ok */
506 .ioctl = inet6_ioctl, /* must change */
507 .listen = sock_no_listen, /* ok */
508 .shutdown = inet_shutdown, /* ok */
509 .setsockopt = sock_common_setsockopt, /* ok */
510 .getsockopt = sock_common_getsockopt, /* ok */
511 .sendmsg = inet_sendmsg, /* ok */
512 .recvmsg = sock_common_recvmsg, /* ok */
513 .mmap = sock_no_mmap,
514 .sendpage = sock_no_sendpage,
516 .compat_setsockopt = compat_sock_common_setsockopt,
517 .compat_getsockopt = compat_sock_common_getsockopt,
521 static struct net_proto_family inet6_family_ops = {
523 .create = inet6_create,
524 .owner = THIS_MODULE,
527 int inet6_register_protosw(struct inet_protosw *p)
529 struct list_head *lh;
530 struct inet_protosw *answer;
531 struct list_head *last_perm;
532 int protocol = p->protocol;
535 spin_lock_bh(&inetsw6_lock);
538 if (p->type >= SOCK_MAX)
541 /* If we are trying to override a permanent protocol, bail. */
544 last_perm = &inetsw6[p->type];
545 list_for_each(lh, &inetsw6[p->type]) {
546 answer = list_entry(lh, struct inet_protosw, list);
548 /* Check only the non-wild match. */
549 if (INET_PROTOSW_PERMANENT & answer->flags) {
550 if (protocol == answer->protocol)
560 /* Add the new entry after the last permanent entry if any, so that
561 * the new entry does not override a permanent entry when matched with
562 * a wild-card protocol. But it is allowed to override any existing
563 * non-permanent entry. This means that when we remove this entry, the
564 * system automatically returns to the old behavior.
566 list_add_rcu(&p->list, last_perm);
569 spin_unlock_bh(&inetsw6_lock);
573 printk(KERN_ERR "Attempt to override permanent protocol %d.\n",
579 "Ignoring attempt to register invalid socket type %d.\n",
584 EXPORT_SYMBOL(inet6_register_protosw);
587 inet6_unregister_protosw(struct inet_protosw *p)
589 if (INET_PROTOSW_PERMANENT & p->flags) {
591 "Attempt to unregister permanent protocol %d.\n",
594 spin_lock_bh(&inetsw6_lock);
595 list_del_rcu(&p->list);
596 spin_unlock_bh(&inetsw6_lock);
602 EXPORT_SYMBOL(inet6_unregister_protosw);
604 int inet6_sk_rebuild_header(struct sock *sk)
607 struct dst_entry *dst;
608 struct ipv6_pinfo *np = inet6_sk(sk);
610 dst = __sk_dst_check(sk, np->dst_cookie);
613 struct inet_sock *inet = inet_sk(sk);
614 struct in6_addr *final_p = NULL, final;
617 memset(&fl, 0, sizeof(fl));
618 fl.proto = sk->sk_protocol;
619 ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
620 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
621 fl.fl6_flowlabel = np->flow_label;
622 fl.oif = sk->sk_bound_dev_if;
623 fl.fl_ip_dport = inet->dport;
624 fl.fl_ip_sport = inet->sport;
625 security_sk_classify_flow(sk, &fl);
627 if (np->opt && np->opt->srcrt) {
628 struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
629 ipv6_addr_copy(&final, &fl.fl6_dst);
630 ipv6_addr_copy(&fl.fl6_dst, rt0->addr);
634 err = ip6_dst_lookup(sk, &dst, &fl);
636 sk->sk_route_caps = 0;
640 ipv6_addr_copy(&fl.fl6_dst, final_p);
642 if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) {
643 sk->sk_err_soft = -err;
647 __ip6_dst_store(sk, dst, NULL, NULL);
653 EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header);
655 int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
657 struct ipv6_pinfo *np = inet6_sk(sk);
658 struct inet6_skb_parm *opt = IP6CB(skb);
661 if ((opt->hop && (np->rxopt.bits.hopopts ||
662 np->rxopt.bits.ohopopts)) ||
663 ((IPV6_FLOWINFO_MASK &
664 *(__be32 *)skb_network_header(skb)) &&
665 np->rxopt.bits.rxflow) ||
666 (opt->srcrt && (np->rxopt.bits.srcrt ||
667 np->rxopt.bits.osrcrt)) ||
668 ((opt->dst1 || opt->dst0) &&
669 (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts)))
675 EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
677 static struct inet6_protocol *ipv6_gso_pull_exthdrs(struct sk_buff *skb,
680 struct inet6_protocol *ops = NULL;
683 struct ipv6_opt_hdr *opth;
686 if (proto != NEXTHDR_HOP) {
687 ops = rcu_dereference(inet6_protos[proto]);
692 if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
696 if (unlikely(!pskb_may_pull(skb, 8)))
699 opth = (void *)skb->data;
700 len = ipv6_optlen(opth);
702 if (unlikely(!pskb_may_pull(skb, len)))
705 proto = opth->nexthdr;
706 __skb_pull(skb, len);
712 static int ipv6_gso_send_check(struct sk_buff *skb)
714 struct ipv6hdr *ipv6h;
715 struct inet6_protocol *ops;
718 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
721 ipv6h = ipv6_hdr(skb);
722 __skb_pull(skb, sizeof(*ipv6h));
723 err = -EPROTONOSUPPORT;
726 ops = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
727 if (likely(ops && ops->gso_send_check)) {
728 skb_reset_transport_header(skb);
729 err = ops->gso_send_check(skb);
737 static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features)
739 struct sk_buff *segs = ERR_PTR(-EINVAL);
740 struct ipv6hdr *ipv6h;
741 struct inet6_protocol *ops;
743 if (!(features & NETIF_F_V6_CSUM))
744 features &= ~NETIF_F_SG;
746 if (unlikely(skb_shinfo(skb)->gso_type &
754 if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
757 ipv6h = ipv6_hdr(skb);
758 __skb_pull(skb, sizeof(*ipv6h));
759 segs = ERR_PTR(-EPROTONOSUPPORT);
762 ops = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
763 if (likely(ops && ops->gso_segment)) {
764 skb_reset_transport_header(skb);
765 segs = ops->gso_segment(skb, features);
769 if (unlikely(IS_ERR(segs)))
772 for (skb = segs; skb; skb = skb->next) {
773 ipv6h = ipv6_hdr(skb);
774 ipv6h->payload_len = htons(skb->len - skb->mac_len -
782 static struct packet_type ipv6_packet_type = {
783 .type = __constant_htons(ETH_P_IPV6),
785 .gso_send_check = ipv6_gso_send_check,
786 .gso_segment = ipv6_gso_segment,
789 static int __init ipv6_packet_init(void)
791 dev_add_pack(&ipv6_packet_type);
795 static void ipv6_packet_cleanup(void)
797 dev_remove_pack(&ipv6_packet_type);
800 static int __init init_ipv6_mibs(void)
802 if (snmp_mib_init((void **)ipv6_statistics,
803 sizeof(struct ipstats_mib)) < 0)
805 if (snmp_mib_init((void **)icmpv6_statistics,
806 sizeof(struct icmpv6_mib)) < 0)
808 if (snmp_mib_init((void **)icmpv6msg_statistics,
809 sizeof(struct icmpv6msg_mib)) < 0)
810 goto err_icmpmsg_mib;
811 if (snmp_mib_init((void **)udp_stats_in6, sizeof (struct udp_mib)) < 0)
813 if (snmp_mib_init((void **)udplite_stats_in6,
814 sizeof (struct udp_mib)) < 0)
815 goto err_udplite_mib;
819 snmp_mib_free((void **)udp_stats_in6);
821 snmp_mib_free((void **)icmpv6msg_statistics);
823 snmp_mib_free((void **)icmpv6_statistics);
825 snmp_mib_free((void **)ipv6_statistics);
831 static void cleanup_ipv6_mibs(void)
833 snmp_mib_free((void **)ipv6_statistics);
834 snmp_mib_free((void **)icmpv6_statistics);
835 snmp_mib_free((void **)icmpv6msg_statistics);
836 snmp_mib_free((void **)udp_stats_in6);
837 snmp_mib_free((void **)udplite_stats_in6);
840 static int inet6_net_init(struct net *net)
844 net->ipv6.sysctl.bindv6only = 0;
845 net->ipv6.sysctl.flush_delay = 0;
846 net->ipv6.sysctl.ip6_rt_max_size = 4096;
847 net->ipv6.sysctl.ip6_rt_gc_min_interval = HZ / 2;
848 net->ipv6.sysctl.ip6_rt_gc_timeout = 60*HZ;
849 net->ipv6.sysctl.ip6_rt_gc_interval = 30*HZ;
850 net->ipv6.sysctl.ip6_rt_gc_elasticity = 9;
851 net->ipv6.sysctl.ip6_rt_mtu_expires = 10*60*HZ;
852 net->ipv6.sysctl.ip6_rt_min_advmss = IPV6_MIN_MTU - 20 - 40;
853 net->ipv6.sysctl.icmpv6_time = 1*HZ;
855 #ifdef CONFIG_PROC_FS
856 err = udp6_proc_init(net);
859 err = tcp6_proc_init(net);
862 err = ac6_proc_init(net);
869 #ifdef CONFIG_PROC_FS
878 static void inet6_net_exit(struct net *net)
880 #ifdef CONFIG_PROC_FS
887 static struct pernet_operations inet6_net_ops = {
888 .init = inet6_net_init,
889 .exit = inet6_net_exit,
892 static int __init inet6_init(void)
894 struct sk_buff *dummy_skb;
898 BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > sizeof(dummy_skb->cb));
900 err = proto_register(&tcpv6_prot, 1);
904 err = proto_register(&udpv6_prot, 1);
906 goto out_unregister_tcp_proto;
908 err = proto_register(&udplitev6_prot, 1);
910 goto out_unregister_udp_proto;
912 err = proto_register(&rawv6_prot, 1);
914 goto out_unregister_udplite_proto;
917 /* Register the socket-side information for inet6_create. */
918 for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
921 /* We MUST register RAW sockets before we create the ICMP6,
922 * IGMP6, or NDISC control sockets.
926 goto out_unregister_raw_proto;
928 /* Register the family here so that the init calls below will
929 * be able to create sockets. (?? is this dangerous ??)
931 err = sock_register(&inet6_family_ops);
933 goto out_sock_register_fail;
935 /* Initialise ipv6 mibs */
936 err = init_ipv6_mibs();
938 goto out_unregister_sock;
941 * ipngwg API draft makes clear that the correct semantics
942 * for TCP and UDP is to consider one TCP and UDP instance
943 * in a host availiable by both INET and INET6 APIs and
944 * able to communicate via both network protocols.
947 err = register_pernet_subsys(&inet6_net_ops);
949 goto register_pernet_fail;
962 err = ipv6_netfilter_init();
965 /* Create /proc/foo6 entries. */
966 #ifdef CONFIG_PROC_FS
968 if (raw6_proc_init())
970 if (udplite6_proc_init())
971 goto proc_udplite6_fail;
972 if (ipv6_misc_proc_init())
973 goto proc_misc6_fail;
977 err = ip6_route_init();
980 err = ip6_flowlabel_init();
982 goto ip6_flowlabel_fail;
983 err = addrconf_init();
987 /* Init v6 extension headers. */
988 err = ipv6_exthdrs_init();
990 goto ipv6_exthdrs_fail;
992 err = ipv6_frag_init();
996 /* Init v6 transport protocols. */
1001 err = udplitev6_init();
1003 goto udplitev6_fail;
1009 err = ipv6_packet_init();
1011 goto ipv6_packet_fail;
1013 #ifdef CONFIG_SYSCTL
1014 err = ipv6_sysctl_register();
1021 #ifdef CONFIG_SYSCTL
1023 ipv6_packet_cleanup();
1034 ipv6_exthdrs_exit();
1038 ip6_flowlabel_cleanup();
1040 ip6_route_cleanup();
1042 #ifdef CONFIG_PROC_FS
1045 ipv6_misc_proc_exit();
1047 udplite6_proc_exit();
1052 ipv6_netfilter_fini();
1062 unregister_pernet_subsys(&inet6_net_ops);
1063 register_pernet_fail:
1064 cleanup_ipv6_mibs();
1065 out_unregister_sock:
1066 sock_unregister(PF_INET6);
1067 rtnl_unregister_all(PF_INET6);
1068 out_sock_register_fail:
1070 out_unregister_raw_proto:
1071 proto_unregister(&rawv6_prot);
1072 out_unregister_udplite_proto:
1073 proto_unregister(&udplitev6_prot);
1074 out_unregister_udp_proto:
1075 proto_unregister(&udpv6_prot);
1076 out_unregister_tcp_proto:
1077 proto_unregister(&tcpv6_prot);
1080 module_init(inet6_init);
1082 static void __exit inet6_exit(void)
1084 /* First of all disallow new sockets creation. */
1085 sock_unregister(PF_INET6);
1086 /* Disallow any further netlink messages */
1087 rtnl_unregister_all(PF_INET6);
1089 #ifdef CONFIG_SYSCTL
1090 ipv6_sysctl_unregister();
1096 /* Cleanup code parts. */
1097 ipv6_packet_cleanup();
1099 ipv6_exthdrs_exit();
1101 ip6_flowlabel_cleanup();
1102 ip6_route_cleanup();
1103 #ifdef CONFIG_PROC_FS
1105 /* Cleanup code parts. */
1107 ipv6_misc_proc_exit();
1108 udplite6_proc_exit();
1111 ipv6_netfilter_fini();
1118 unregister_pernet_subsys(&inet6_net_ops);
1119 cleanup_ipv6_mibs();
1120 proto_unregister(&rawv6_prot);
1121 proto_unregister(&udplitev6_prot);
1122 proto_unregister(&udpv6_prot);
1123 proto_unregister(&tcpv6_prot);
1125 module_exit(inet6_exit);
1127 MODULE_ALIAS_NETPROTO(PF_INET6);