af_inet6.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318
  1. /*
  2. * PF_INET6 socket protocol family
  3. * Linux INET6 implementation
  4. *
  5. * Authors:
  6. * Pedro Roque <roque@di.fc.ul.pt>
  7. *
  8. * Adapted from linux/net/ipv4/af_inet.c
  9. *
  10. * Fixes:
  11. * piggy, Karl Knutson : Socket protocol table
  12. * Hideaki YOSHIFUJI : sin6_scope_id support
  13. * Arnaldo Melo : check proc_net_create return, cleanups
  14. *
  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.
  19. */
  20. #include <linux/module.h>
  21. #include <linux/capability.h>
  22. #include <linux/errno.h>
  23. #include <linux/types.h>
  24. #include <linux/socket.h>
  25. #include <linux/in.h>
  26. #include <linux/kernel.h>
  27. #include <linux/timer.h>
  28. #include <linux/string.h>
  29. #include <linux/sockios.h>
  30. #include <linux/net.h>
  31. #include <linux/fcntl.h>
  32. #include <linux/mm.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/proc_fs.h>
  35. #include <linux/stat.h>
  36. #include <linux/init.h>
  37. #include <linux/slab.h>
  38. #include <linux/inet.h>
  39. #include <linux/netdevice.h>
  40. #include <linux/icmpv6.h>
  41. #include <linux/netfilter_ipv6.h>
  42. #include <net/ip.h>
  43. #include <net/ipv6.h>
  44. #include <net/udp.h>
  45. #include <net/udplite.h>
  46. #include <net/tcp.h>
  47. #include <net/ipip.h>
  48. #include <net/protocol.h>
  49. #include <net/inet_common.h>
  50. #include <net/route.h>
  51. #include <net/transp_v6.h>
  52. #include <net/ip6_route.h>
  53. #include <net/addrconf.h>
  54. #ifdef CONFIG_IPV6_TUNNEL
  55. #include <net/ip6_tunnel.h>
  56. #endif
  57. #include <asm/uaccess.h>
  58. #include <asm/system.h>
  59. #include <linux/mroute6.h>
  60. MODULE_AUTHOR("Cast of dozens");
  61. MODULE_DESCRIPTION("IPv6 protocol stack for Linux");
  62. MODULE_LICENSE("GPL");
  63. /* The inetsw6 table contains everything that inet6_create needs to
  64. * build a new socket.
  65. */
  66. static struct list_head inetsw6[SOCK_MAX];
  67. static DEFINE_SPINLOCK(inetsw6_lock);
  68. struct ipv6_params ipv6_defaults = {
  69. .disable_ipv6 = 0,
  70. .autoconf = 1,
  71. };
  72. static int disable_ipv6_mod = 0;
  73. module_param_named(disable, disable_ipv6_mod, int, 0444);
  74. MODULE_PARM_DESC(disable, "Disable IPv6 module such that it is non-functional");
  75. module_param_named(disable_ipv6, ipv6_defaults.disable_ipv6, int, 0444);
  76. MODULE_PARM_DESC(disable_ipv6, "Disable IPv6 on all interfaces");
  77. module_param_named(autoconf, ipv6_defaults.autoconf, int, 0444);
  78. MODULE_PARM_DESC(autoconf, "Enable IPv6 address autoconfiguration on all interfaces");
  79. static __inline__ struct ipv6_pinfo *inet6_sk_generic(struct sock *sk)
  80. {
  81. const int offset = sk->sk_prot->obj_size - sizeof(struct ipv6_pinfo);
  82. return (struct ipv6_pinfo *)(((u8 *)sk) + offset);
  83. }
  84. static int inet6_create(struct net *net, struct socket *sock, int protocol,
  85. int kern)
  86. {
  87. struct inet_sock *inet;
  88. struct ipv6_pinfo *np;
  89. struct sock *sk;
  90. struct inet_protosw *answer;
  91. struct proto *answer_prot;
  92. unsigned char answer_flags;
  93. char answer_no_check;
  94. int try_loading_module = 0;
  95. int err;
  96. if (sock->type != SOCK_RAW &&
  97. sock->type != SOCK_DGRAM &&
  98. !inet_ehash_secret)
  99. build_ehash_secret();
  100. /* Look for the requested type/protocol pair. */
  101. lookup_protocol:
  102. err = -ESOCKTNOSUPPORT;
  103. rcu_read_lock();
  104. list_for_each_entry_rcu(answer, &inetsw6[sock->type], list) {
  105. err = 0;
  106. /* Check the non-wild match. */
  107. if (protocol == answer->protocol) {
  108. if (protocol != IPPROTO_IP)
  109. break;
  110. } else {
  111. /* Check for the two wild cases. */
  112. if (IPPROTO_IP == protocol) {
  113. protocol = answer->protocol;
  114. break;
  115. }
  116. if (IPPROTO_IP == answer->protocol)
  117. break;
  118. }
  119. err = -EPROTONOSUPPORT;
  120. }
  121. if (err) {
  122. if (try_loading_module < 2) {
  123. rcu_read_unlock();
  124. /*
  125. * Be more specific, e.g. net-pf-10-proto-132-type-1
  126. * (net-pf-PF_INET6-proto-IPPROTO_SCTP-type-SOCK_STREAM)
  127. */
  128. if (++try_loading_module == 1)
  129. request_module("net-pf-%d-proto-%d-type-%d",
  130. PF_INET6, protocol, sock->type);
  131. /*
  132. * Fall back to generic, e.g. net-pf-10-proto-132
  133. * (net-pf-PF_INET6-proto-IPPROTO_SCTP)
  134. */
  135. else
  136. request_module("net-pf-%d-proto-%d",
  137. PF_INET6, protocol);
  138. goto lookup_protocol;
  139. } else
  140. goto out_rcu_unlock;
  141. }
  142. err = -EPERM;
  143. if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
  144. goto out_rcu_unlock;
  145. sock->ops = answer->ops;
  146. answer_prot = answer->prot;
  147. answer_no_check = answer->no_check;
  148. answer_flags = answer->flags;
  149. rcu_read_unlock();
  150. WARN_ON(answer_prot->slab == NULL);
  151. err = -ENOBUFS;
  152. sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot);
  153. if (sk == NULL)
  154. goto out;
  155. sock_init_data(sock, sk);
  156. err = 0;
  157. sk->sk_no_check = answer_no_check;
  158. if (INET_PROTOSW_REUSE & answer_flags)
  159. sk->sk_reuse = 1;
  160. inet = inet_sk(sk);
  161. inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;
  162. if (SOCK_RAW == sock->type) {
  163. inet->inet_num = protocol;
  164. if (IPPROTO_RAW == protocol)
  165. inet->hdrincl = 1;
  166. }
  167. sk->sk_destruct = inet_sock_destruct;
  168. sk->sk_family = PF_INET6;
  169. sk->sk_protocol = protocol;
  170. sk->sk_backlog_rcv = answer->prot->backlog_rcv;
  171. inet_sk(sk)->pinet6 = np = inet6_sk_generic(sk);
  172. np->hop_limit = -1;
  173. np->mcast_hops = IPV6_DEFAULT_MCASTHOPS;
  174. np->mc_loop = 1;
  175. np->pmtudisc = IPV6_PMTUDISC_WANT;
  176. np->ipv6only = net->ipv6.sysctl.bindv6only;
  177. /* Init the ipv4 part of the socket since we can have sockets
  178. * using v6 API for ipv4.
  179. */
  180. inet->uc_ttl = -1;
  181. inet->mc_loop = 1;
  182. inet->mc_ttl = 1;
  183. inet->mc_index = 0;
  184. inet->mc_list = NULL;
  185. inet->rcv_tos = 0;
  186. if (ipv4_config.no_pmtu_disc)
  187. inet->pmtudisc = IP_PMTUDISC_DONT;
  188. else
  189. inet->pmtudisc = IP_PMTUDISC_WANT;
  190. /*
  191. * Increment only the relevant sk_prot->socks debug field, this changes
  192. * the previous behaviour of incrementing both the equivalent to
  193. * answer->prot->socks (inet6_sock_nr) and inet_sock_nr.
  194. *
  195. * This allows better debug granularity as we'll know exactly how many
  196. * UDPv6, TCPv6, etc socks were allocated, not the sum of all IPv6
  197. * transport protocol socks. -acme
  198. */
  199. sk_refcnt_debug_inc(sk);
  200. if (inet->inet_num) {
  201. /* It assumes that any protocol which allows
  202. * the user to assign a number at socket
  203. * creation time automatically shares.
  204. */
  205. inet->inet_sport = htons(inet->inet_num);
  206. sk->sk_prot->hash(sk);
  207. }
  208. if (sk->sk_prot->init) {
  209. err = sk->sk_prot->init(sk);
  210. if (err) {
  211. sk_common_release(sk);
  212. goto out;
  213. }
  214. }
  215. out:
  216. return err;
  217. out_rcu_unlock:
  218. rcu_read_unlock();
  219. goto out;
  220. }
  221. /* bind for INET6 API */
  222. int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
  223. {
  224. struct sockaddr_in6 *addr=(struct sockaddr_in6 *)uaddr;
  225. struct sock *sk = sock->sk;
  226. struct inet_sock *inet = inet_sk(sk);
  227. struct ipv6_pinfo *np = inet6_sk(sk);
  228. struct net *net = sock_net(sk);
  229. __be32 v4addr = 0;
  230. unsigned short snum;
  231. int addr_type = 0;
  232. int err = 0;
  233. /* If the socket has its own bind function then use it. */
  234. if (sk->sk_prot->bind)
  235. return sk->sk_prot->bind(sk, uaddr, addr_len);
  236. if (addr_len < SIN6_LEN_RFC2133)
  237. return -EINVAL;
  238. if (addr->sin6_family != AF_INET6)
  239. return -EAFNOSUPPORT;
  240. addr_type = ipv6_addr_type(&addr->sin6_addr);
  241. if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
  242. return -EINVAL;
  243. snum = ntohs(addr->sin6_port);
  244. if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
  245. return -EACCES;
  246. lock_sock(sk);
  247. /* Check these errors (active socket, double bind). */
  248. if (sk->sk_state != TCP_CLOSE || inet->inet_num) {
  249. err = -EINVAL;
  250. goto out;
  251. }
  252. /* Check if the address belongs to the host. */
  253. if (addr_type == IPV6_ADDR_MAPPED) {
  254. int chk_addr_ret;
  255. /* Binding to v4-mapped address on a v6-only socket
  256. * makes no sense
  257. */
  258. if (np->ipv6only) {
  259. err = -EINVAL;
  260. goto out;
  261. }
  262. /* Reproduce AF_INET checks to make the bindings consistent */
  263. v4addr = addr->sin6_addr.s6_addr32[3];
  264. chk_addr_ret = inet_addr_type(net, v4addr);
  265. if (!sysctl_ip_nonlocal_bind &&
  266. !(inet->freebind || inet->transparent) &&
  267. v4addr != htonl(INADDR_ANY) &&
  268. chk_addr_ret != RTN_LOCAL &&
  269. chk_addr_ret != RTN_MULTICAST &&
  270. chk_addr_ret != RTN_BROADCAST) {
  271. err = -EADDRNOTAVAIL;
  272. goto out;
  273. }
  274. } else {
  275. if (addr_type != IPV6_ADDR_ANY) {
  276. struct net_device *dev = NULL;
  277. rcu_read_lock();
  278. if (addr_type & IPV6_ADDR_LINKLOCAL) {
  279. if (addr_len >= sizeof(struct sockaddr_in6) &&
  280. addr->sin6_scope_id) {
  281. /* Override any existing binding, if another one
  282. * is supplied by user.
  283. */
  284. sk->sk_bound_dev_if = addr->sin6_scope_id;
  285. }
  286. /* Binding to link-local address requires an interface */
  287. if (!sk->sk_bound_dev_if) {
  288. err = -EINVAL;
  289. goto out_unlock;
  290. }
  291. dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if);
  292. if (!dev) {
  293. err = -ENODEV;
  294. goto out_unlock;
  295. }
  296. }
  297. /* ipv4 addr of the socket is invalid. Only the
  298. * unspecified and mapped address have a v4 equivalent.
  299. */
  300. v4addr = LOOPBACK4_IPV6;
  301. if (!(addr_type & IPV6_ADDR_MULTICAST)) {
  302. if (!(inet->freebind || inet->transparent) &&
  303. !ipv6_chk_addr(net, &addr->sin6_addr,
  304. dev, 0)) {
  305. err = -EADDRNOTAVAIL;
  306. goto out_unlock;
  307. }
  308. }
  309. rcu_read_unlock();
  310. }
  311. }
  312. inet->inet_rcv_saddr = v4addr;
  313. inet->inet_saddr = v4addr;
  314. np->rcv_saddr = addr->sin6_addr;
  315. if (!(addr_type & IPV6_ADDR_MULTICAST))
  316. np->saddr = addr->sin6_addr;
  317. /* Make sure we are allowed to bind here. */
  318. if (sk->sk_prot->get_port(sk, snum)) {
  319. inet_reset_saddr(sk);
  320. err = -EADDRINUSE;
  321. goto out;
  322. }
  323. if (addr_type != IPV6_ADDR_ANY) {
  324. sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
  325. if (addr_type != IPV6_ADDR_MAPPED)
  326. np->ipv6only = 1;
  327. }
  328. if (snum)
  329. sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
  330. inet->inet_sport = htons(inet->inet_num);
  331. inet->inet_dport = 0;
  332. inet->inet_daddr = 0;
  333. out:
  334. release_sock(sk);
  335. return err;
  336. out_unlock:
  337. rcu_read_unlock();
  338. goto out;
  339. }
  340. EXPORT_SYMBOL(inet6_bind);
  341. int inet6_release(struct socket *sock)
  342. {
  343. struct sock *sk = sock->sk;
  344. if (sk == NULL)
  345. return -EINVAL;
  346. /* Free mc lists */
  347. ipv6_sock_mc_close(sk);
  348. /* Free ac lists */
  349. ipv6_sock_ac_close(sk);
  350. return inet_release(sock);
  351. }
  352. EXPORT_SYMBOL(inet6_release);
  353. void inet6_destroy_sock(struct sock *sk)
  354. {
  355. struct ipv6_pinfo *np = inet6_sk(sk);
  356. struct sk_buff *skb;
  357. struct ipv6_txoptions *opt;
  358. /* Release rx options */
  359. if ((skb = xchg(&np->pktoptions, NULL)) != NULL)
  360. kfree_skb(skb);
  361. if ((skb = xchg(&np->rxpmtu, NULL)) != NULL)
  362. kfree_skb(skb);
  363. /* Free flowlabels */
  364. fl6_free_socklist(sk);
  365. /* Free tx options */
  366. if ((opt = xchg(&np->opt, NULL)) != NULL)
  367. sock_kfree_s(sk, opt, opt->tot_len);
  368. }
  369. EXPORT_SYMBOL_GPL(inet6_destroy_sock);
  370. /*
  371. * This does both peername and sockname.
  372. */
  373. int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
  374. int *uaddr_len, int peer)
  375. {
  376. struct sockaddr_in6 *sin=(struct sockaddr_in6 *)uaddr;
  377. struct sock *sk = sock->sk;
  378. struct inet_sock *inet = inet_sk(sk);
  379. struct ipv6_pinfo *np = inet6_sk(sk);
  380. sin->sin6_family = AF_INET6;
  381. sin->sin6_flowinfo = 0;
  382. sin->sin6_scope_id = 0;
  383. if (peer) {
  384. if (!inet->inet_dport)
  385. return -ENOTCONN;
  386. if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
  387. peer == 1)
  388. return -ENOTCONN;
  389. sin->sin6_port = inet->inet_dport;
  390. sin->sin6_addr = np->daddr;
  391. if (np->sndflow)
  392. sin->sin6_flowinfo = np->flow_label;
  393. } else {
  394. if (ipv6_addr_any(&np->rcv_saddr))
  395. sin->sin6_addr = np->saddr;
  396. else
  397. sin->sin6_addr = np->rcv_saddr;
  398. sin->sin6_port = inet->inet_sport;
  399. }
  400. if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
  401. sin->sin6_scope_id = sk->sk_bound_dev_if;
  402. *uaddr_len = sizeof(*sin);
  403. return 0;
  404. }
  405. EXPORT_SYMBOL(inet6_getname);
  406. int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
  407. {
  408. struct sock *sk = sock->sk;
  409. struct net *net = sock_net(sk);
  410. switch(cmd)
  411. {
  412. case SIOCGSTAMP:
  413. return sock_get_timestamp(sk, (struct timeval __user *)arg);
  414. case SIOCGSTAMPNS:
  415. return sock_get_timestampns(sk, (struct timespec __user *)arg);
  416. case SIOCADDRT:
  417. case SIOCDELRT:
  418. return ipv6_route_ioctl(net, cmd, (void __user *)arg);
  419. case SIOCSIFADDR:
  420. return addrconf_add_ifaddr(net, (void __user *) arg);
  421. case SIOCDIFADDR:
  422. return addrconf_del_ifaddr(net, (void __user *) arg);
  423. case SIOCSIFDSTADDR:
  424. return addrconf_set_dstaddr(net, (void __user *) arg);
  425. default:
  426. if (!sk->sk_prot->ioctl)
  427. return -ENOIOCTLCMD;
  428. return sk->sk_prot->ioctl(sk, cmd, arg);
  429. }
  430. /*NOTREACHED*/
  431. return 0;
  432. }
  433. EXPORT_SYMBOL(inet6_ioctl);
  434. const struct proto_ops inet6_stream_ops = {
  435. .family = PF_INET6,
  436. .owner = THIS_MODULE,
  437. .release = inet6_release,
  438. .bind = inet6_bind,
  439. .connect = inet_stream_connect, /* ok */
  440. .socketpair = sock_no_socketpair, /* a do nothing */
  441. .accept = inet_accept, /* ok */
  442. .getname = inet6_getname,
  443. .poll = tcp_poll, /* ok */
  444. .ioctl = inet6_ioctl, /* must change */
  445. .listen = inet_listen, /* ok */
  446. .shutdown = inet_shutdown, /* ok */
  447. .setsockopt = sock_common_setsockopt, /* ok */
  448. .getsockopt = sock_common_getsockopt, /* ok */
  449. .sendmsg = inet_sendmsg, /* ok */
  450. .recvmsg = inet_recvmsg, /* ok */
  451. .mmap = sock_no_mmap,
  452. .sendpage = inet_sendpage,
  453. .splice_read = tcp_splice_read,
  454. #ifdef CONFIG_COMPAT
  455. .compat_setsockopt = compat_sock_common_setsockopt,
  456. .compat_getsockopt = compat_sock_common_getsockopt,
  457. #endif
  458. };
  459. const struct proto_ops inet6_dgram_ops = {
  460. .family = PF_INET6,
  461. .owner = THIS_MODULE,
  462. .release = inet6_release,
  463. .bind = inet6_bind,
  464. .connect = inet_dgram_connect, /* ok */
  465. .socketpair = sock_no_socketpair, /* a do nothing */
  466. .accept = sock_no_accept, /* a do nothing */
  467. .getname = inet6_getname,
  468. .poll = udp_poll, /* ok */
  469. .ioctl = inet6_ioctl, /* must change */
  470. .listen = sock_no_listen, /* ok */
  471. .shutdown = inet_shutdown, /* ok */
  472. .setsockopt = sock_common_setsockopt, /* ok */
  473. .getsockopt = sock_common_getsockopt, /* ok */
  474. .sendmsg = inet_sendmsg, /* ok */
  475. .recvmsg = inet_recvmsg, /* ok */
  476. .mmap = sock_no_mmap,
  477. .sendpage = sock_no_sendpage,
  478. #ifdef CONFIG_COMPAT
  479. .compat_setsockopt = compat_sock_common_setsockopt,
  480. .compat_getsockopt = compat_sock_common_getsockopt,
  481. #endif
  482. };
  483. static const struct net_proto_family inet6_family_ops = {
  484. .family = PF_INET6,
  485. .create = inet6_create,
  486. .owner = THIS_MODULE,
  487. };
  488. int inet6_register_protosw(struct inet_protosw *p)
  489. {
  490. struct list_head *lh;
  491. struct inet_protosw *answer;
  492. struct list_head *last_perm;
  493. int protocol = p->protocol;
  494. int ret;
  495. spin_lock_bh(&inetsw6_lock);
  496. ret = -EINVAL;
  497. if (p->type >= SOCK_MAX)
  498. goto out_illegal;
  499. /* If we are trying to override a permanent protocol, bail. */
  500. answer = NULL;
  501. ret = -EPERM;
  502. last_perm = &inetsw6[p->type];
  503. list_for_each(lh, &inetsw6[p->type]) {
  504. answer = list_entry(lh, struct inet_protosw, list);
  505. /* Check only the non-wild match. */
  506. if (INET_PROTOSW_PERMANENT & answer->flags) {
  507. if (protocol == answer->protocol)
  508. break;
  509. last_perm = lh;
  510. }
  511. answer = NULL;
  512. }
  513. if (answer)
  514. goto out_permanent;
  515. /* Add the new entry after the last permanent entry if any, so that
  516. * the new entry does not override a permanent entry when matched with
  517. * a wild-card protocol. But it is allowed to override any existing
  518. * non-permanent entry. This means that when we remove this entry, the
  519. * system automatically returns to the old behavior.
  520. */
  521. list_add_rcu(&p->list, last_perm);
  522. ret = 0;
  523. out:
  524. spin_unlock_bh(&inetsw6_lock);
  525. return ret;
  526. out_permanent:
  527. printk(KERN_ERR "Attempt to override permanent protocol %d.\n",
  528. protocol);
  529. goto out;
  530. out_illegal:
  531. printk(KERN_ERR
  532. "Ignoring attempt to register invalid socket type %d.\n",
  533. p->type);
  534. goto out;
  535. }
  536. EXPORT_SYMBOL(inet6_register_protosw);
  537. void
  538. inet6_unregister_protosw(struct inet_protosw *p)
  539. {
  540. if (INET_PROTOSW_PERMANENT & p->flags) {
  541. printk(KERN_ERR
  542. "Attempt to unregister permanent protocol %d.\n",
  543. p->protocol);
  544. } else {
  545. spin_lock_bh(&inetsw6_lock);
  546. list_del_rcu(&p->list);
  547. spin_unlock_bh(&inetsw6_lock);
  548. synchronize_net();
  549. }
  550. }
  551. EXPORT_SYMBOL(inet6_unregister_protosw);
  552. int inet6_sk_rebuild_header(struct sock *sk)
  553. {
  554. struct ipv6_pinfo *np = inet6_sk(sk);
  555. struct dst_entry *dst;
  556. dst = __sk_dst_check(sk, np->dst_cookie);
  557. if (dst == NULL) {
  558. struct inet_sock *inet = inet_sk(sk);
  559. struct in6_addr *final_p, final;
  560. struct flowi6 fl6;
  561. memset(&fl6, 0, sizeof(fl6));
  562. fl6.flowi6_proto = sk->sk_protocol;
  563. fl6.daddr = np->daddr;
  564. fl6.saddr = np->saddr;
  565. fl6.flowlabel = np->flow_label;
  566. fl6.flowi6_oif = sk->sk_bound_dev_if;
  567. fl6.flowi6_mark = sk->sk_mark;
  568. fl6.fl6_dport = inet->inet_dport;
  569. fl6.fl6_sport = inet->inet_sport;
  570. security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
  571. final_p = fl6_update_dst(&fl6, np->opt, &final);
  572. dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
  573. if (IS_ERR(dst)) {
  574. sk->sk_route_caps = 0;
  575. sk->sk_err_soft = -PTR_ERR(dst);
  576. return PTR_ERR(dst);
  577. }
  578. __ip6_dst_store(sk, dst, NULL, NULL);
  579. }
  580. return 0;
  581. }
  582. EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header);
  583. int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
  584. {
  585. struct ipv6_pinfo *np = inet6_sk(sk);
  586. struct inet6_skb_parm *opt = IP6CB(skb);
  587. if (np->rxopt.all) {
  588. if ((opt->hop && (np->rxopt.bits.hopopts ||
  589. np->rxopt.bits.ohopopts)) ||
  590. ((IPV6_FLOWINFO_MASK &
  591. *(__be32 *)skb_network_header(skb)) &&
  592. np->rxopt.bits.rxflow) ||
  593. (opt->srcrt && (np->rxopt.bits.srcrt ||
  594. np->rxopt.bits.osrcrt)) ||
  595. ((opt->dst1 || opt->dst0) &&
  596. (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts)))
  597. return 1;
  598. }
  599. return 0;
  600. }
  601. EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
  602. static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto)
  603. {
  604. const struct inet6_protocol *ops = NULL;
  605. for (;;) {
  606. struct ipv6_opt_hdr *opth;
  607. int len;
  608. if (proto != NEXTHDR_HOP) {
  609. ops = rcu_dereference(inet6_protos[proto]);
  610. if (unlikely(!ops))
  611. break;
  612. if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
  613. break;
  614. }
  615. if (unlikely(!pskb_may_pull(skb, 8)))
  616. break;
  617. opth = (void *)skb->data;
  618. len = ipv6_optlen(opth);
  619. if (unlikely(!pskb_may_pull(skb, len)))
  620. break;
  621. proto = opth->nexthdr;
  622. __skb_pull(skb, len);
  623. }
  624. return proto;
  625. }
  626. static int ipv6_gso_send_check(struct sk_buff *skb)
  627. {
  628. const struct ipv6hdr *ipv6h;
  629. const struct inet6_protocol *ops;
  630. int err = -EINVAL;
  631. if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
  632. goto out;
  633. ipv6h = ipv6_hdr(skb);
  634. __skb_pull(skb, sizeof(*ipv6h));
  635. err = -EPROTONOSUPPORT;
  636. rcu_read_lock();
  637. ops = rcu_dereference(inet6_protos[
  638. ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr)]);
  639. if (likely(ops && ops->gso_send_check)) {
  640. skb_reset_transport_header(skb);
  641. err = ops->gso_send_check(skb);
  642. }
  643. rcu_read_unlock();
  644. out:
  645. return err;
  646. }
  647. static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
  648. netdev_features_t features)
  649. {
  650. struct sk_buff *segs = ERR_PTR(-EINVAL);
  651. struct ipv6hdr *ipv6h;
  652. const struct inet6_protocol *ops;
  653. int proto;
  654. struct frag_hdr *fptr;
  655. unsigned int unfrag_ip6hlen;
  656. u8 *prevhdr;
  657. int offset = 0;
  658. if (!(features & NETIF_F_V6_CSUM))
  659. features &= ~NETIF_F_SG;
  660. if (unlikely(skb_shinfo(skb)->gso_type &
  661. ~(SKB_GSO_UDP |
  662. SKB_GSO_DODGY |
  663. SKB_GSO_TCP_ECN |
  664. SKB_GSO_TCPV6 |
  665. 0)))
  666. goto out;
  667. if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
  668. goto out;
  669. ipv6h = ipv6_hdr(skb);
  670. __skb_pull(skb, sizeof(*ipv6h));
  671. segs = ERR_PTR(-EPROTONOSUPPORT);
  672. proto = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
  673. rcu_read_lock();
  674. ops = rcu_dereference(inet6_protos[proto]);
  675. if (likely(ops && ops->gso_segment)) {
  676. skb_reset_transport_header(skb);
  677. segs = ops->gso_segment(skb, features);
  678. }
  679. rcu_read_unlock();
  680. if (IS_ERR(segs))
  681. goto out;
  682. for (skb = segs; skb; skb = skb->next) {
  683. ipv6h = ipv6_hdr(skb);
  684. ipv6h->payload_len = htons(skb->len - skb->mac_len -
  685. sizeof(*ipv6h));
  686. if (proto == IPPROTO_UDP) {
  687. unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr);
  688. fptr = (struct frag_hdr *)(skb_network_header(skb) +
  689. unfrag_ip6hlen);
  690. fptr->frag_off = htons(offset);
  691. if (skb->next != NULL)
  692. fptr->frag_off |= htons(IP6_MF);
  693. offset += (ntohs(ipv6h->payload_len) -
  694. sizeof(struct frag_hdr));
  695. }
  696. }
  697. out:
  698. return segs;
  699. }
  700. struct ipv6_gro_cb {
  701. struct napi_gro_cb napi;
  702. int proto;
  703. };
  704. #define IPV6_GRO_CB(skb) ((struct ipv6_gro_cb *)(skb)->cb)
  705. static struct sk_buff **ipv6_gro_receive(struct sk_buff **head,
  706. struct sk_buff *skb)
  707. {
  708. const struct inet6_protocol *ops;
  709. struct sk_buff **pp = NULL;
  710. struct sk_buff *p;
  711. struct ipv6hdr *iph;
  712. unsigned int nlen;
  713. unsigned int hlen;
  714. unsigned int off;
  715. int flush = 1;
  716. int proto;
  717. __wsum csum;
  718. off = skb_gro_offset(skb);
  719. hlen = off + sizeof(*iph);
  720. iph = skb_gro_header_fast(skb, off);
  721. if (skb_gro_header_hard(skb, hlen)) {
  722. iph = skb_gro_header_slow(skb, hlen, off);
  723. if (unlikely(!iph))
  724. goto out;
  725. }
  726. skb_gro_pull(skb, sizeof(*iph));
  727. skb_set_transport_header(skb, skb_gro_offset(skb));
  728. flush += ntohs(iph->payload_len) != skb_gro_len(skb);
  729. rcu_read_lock();
  730. proto = iph->nexthdr;
  731. ops = rcu_dereference(inet6_protos[proto]);
  732. if (!ops || !ops->gro_receive) {
  733. __pskb_pull(skb, skb_gro_offset(skb));
  734. proto = ipv6_gso_pull_exthdrs(skb, proto);
  735. skb_gro_pull(skb, -skb_transport_offset(skb));
  736. skb_reset_transport_header(skb);
  737. __skb_push(skb, skb_gro_offset(skb));
  738. ops = rcu_dereference(inet6_protos[proto]);
  739. if (!ops || !ops->gro_receive)
  740. goto out_unlock;
  741. iph = ipv6_hdr(skb);
  742. }
  743. IPV6_GRO_CB(skb)->proto = proto;
  744. flush--;
  745. nlen = skb_network_header_len(skb);
  746. for (p = *head; p; p = p->next) {
  747. struct ipv6hdr *iph2;
  748. if (!NAPI_GRO_CB(p)->same_flow)
  749. continue;
  750. iph2 = ipv6_hdr(p);
  751. /* All fields must match except length. */
  752. if (nlen != skb_network_header_len(p) ||
  753. memcmp(iph, iph2, offsetof(struct ipv6hdr, payload_len)) ||
  754. memcmp(&iph->nexthdr, &iph2->nexthdr,
  755. nlen - offsetof(struct ipv6hdr, nexthdr))) {
  756. NAPI_GRO_CB(p)->same_flow = 0;
  757. continue;
  758. }
  759. NAPI_GRO_CB(p)->flush |= flush;
  760. }
  761. NAPI_GRO_CB(skb)->flush |= flush;
  762. csum = skb->csum;
  763. skb_postpull_rcsum(skb, iph, skb_network_header_len(skb));
  764. pp = ops->gro_receive(head, skb);
  765. skb->csum = csum;
  766. out_unlock:
  767. rcu_read_unlock();
  768. out:
  769. NAPI_GRO_CB(skb)->flush |= flush;
  770. return pp;
  771. }
  772. static int ipv6_gro_complete(struct sk_buff *skb)
  773. {
  774. const struct inet6_protocol *ops;
  775. struct ipv6hdr *iph = ipv6_hdr(skb);
  776. int err = -ENOSYS;
  777. iph->payload_len = htons(skb->len - skb_network_offset(skb) -
  778. sizeof(*iph));
  779. rcu_read_lock();
  780. ops = rcu_dereference(inet6_protos[IPV6_GRO_CB(skb)->proto]);
  781. if (WARN_ON(!ops || !ops->gro_complete))
  782. goto out_unlock;
  783. err = ops->gro_complete(skb);
  784. out_unlock:
  785. rcu_read_unlock();
  786. return err;
  787. }
  788. static struct packet_type ipv6_packet_type __read_mostly = {
  789. .type = cpu_to_be16(ETH_P_IPV6),
  790. .func = ipv6_rcv,
  791. .gso_send_check = ipv6_gso_send_check,
  792. .gso_segment = ipv6_gso_segment,
  793. .gro_receive = ipv6_gro_receive,
  794. .gro_complete = ipv6_gro_complete,
  795. };
  796. static int __init ipv6_packet_init(void)
  797. {
  798. dev_add_pack(&ipv6_packet_type);
  799. return 0;
  800. }
  801. static void ipv6_packet_cleanup(void)
  802. {
  803. dev_remove_pack(&ipv6_packet_type);
  804. }
  805. static int __net_init ipv6_init_mibs(struct net *net)
  806. {
  807. if (snmp_mib_init((void __percpu **)net->mib.udp_stats_in6,
  808. sizeof(struct udp_mib),
  809. __alignof__(struct udp_mib)) < 0)
  810. return -ENOMEM;
  811. if (snmp_mib_init((void __percpu **)net->mib.udplite_stats_in6,
  812. sizeof(struct udp_mib),
  813. __alignof__(struct udp_mib)) < 0)
  814. goto err_udplite_mib;
  815. if (snmp_mib_init((void __percpu **)net->mib.ipv6_statistics,
  816. sizeof(struct ipstats_mib),
  817. __alignof__(struct ipstats_mib)) < 0)
  818. goto err_ip_mib;
  819. if (snmp_mib_init((void __percpu **)net->mib.icmpv6_statistics,
  820. sizeof(struct icmpv6_mib),
  821. __alignof__(struct icmpv6_mib)) < 0)
  822. goto err_icmp_mib;
  823. net->mib.icmpv6msg_statistics = kzalloc(sizeof(struct icmpv6msg_mib),
  824. GFP_KERNEL);
  825. if (!net->mib.icmpv6msg_statistics)
  826. goto err_icmpmsg_mib;
  827. return 0;
  828. err_icmpmsg_mib:
  829. snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics);
  830. err_icmp_mib:
  831. snmp_mib_free((void __percpu **)net->mib.ipv6_statistics);
  832. err_ip_mib:
  833. snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6);
  834. err_udplite_mib:
  835. snmp_mib_free((void __percpu **)net->mib.udp_stats_in6);
  836. return -ENOMEM;
  837. }
  838. static void ipv6_cleanup_mibs(struct net *net)
  839. {
  840. snmp_mib_free((void __percpu **)net->mib.udp_stats_in6);
  841. snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6);
  842. snmp_mib_free((void __percpu **)net->mib.ipv6_statistics);
  843. snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics);
  844. kfree(net->mib.icmpv6msg_statistics);
  845. }
  846. static int __net_init inet6_net_init(struct net *net)
  847. {
  848. int err = 0;
  849. net->ipv6.sysctl.bindv6only = 0;
  850. net->ipv6.sysctl.icmpv6_time = 1*HZ;
  851. err = ipv6_init_mibs(net);
  852. if (err)
  853. return err;
  854. #ifdef CONFIG_PROC_FS
  855. err = udp6_proc_init(net);
  856. if (err)
  857. goto out;
  858. err = tcp6_proc_init(net);
  859. if (err)
  860. goto proc_tcp6_fail;
  861. err = ac6_proc_init(net);
  862. if (err)
  863. goto proc_ac6_fail;
  864. #endif
  865. return err;
  866. #ifdef CONFIG_PROC_FS
  867. proc_ac6_fail:
  868. tcp6_proc_exit(net);
  869. proc_tcp6_fail:
  870. udp6_proc_exit(net);
  871. out:
  872. ipv6_cleanup_mibs(net);
  873. return err;
  874. #endif
  875. }
  876. static void __net_exit inet6_net_exit(struct net *net)
  877. {
  878. #ifdef CONFIG_PROC_FS
  879. udp6_proc_exit(net);
  880. tcp6_proc_exit(net);
  881. ac6_proc_exit(net);
  882. #endif
  883. ipv6_cleanup_mibs(net);
  884. }
  885. static struct pernet_operations inet6_net_ops = {
  886. .init = inet6_net_init,
  887. .exit = inet6_net_exit,
  888. };
  889. static int __init inet6_init(void)
  890. {
  891. struct sk_buff *dummy_skb;
  892. struct list_head *r;
  893. int err = 0;
  894. BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > sizeof(dummy_skb->cb));
  895. /* Register the socket-side information for inet6_create. */
  896. for(r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
  897. INIT_LIST_HEAD(r);
  898. if (disable_ipv6_mod) {
  899. printk(KERN_INFO
  900. "IPv6: Loaded, but administratively disabled, "
  901. "reboot required to enable\n");
  902. goto out;
  903. }
  904. err = proto_register(&tcpv6_prot, 1);
  905. if (err)
  906. goto out;
  907. err = proto_register(&udpv6_prot, 1);
  908. if (err)
  909. goto out_unregister_tcp_proto;
  910. err = proto_register(&udplitev6_prot, 1);
  911. if (err)
  912. goto out_unregister_udp_proto;
  913. err = proto_register(&rawv6_prot, 1);
  914. if (err)
  915. goto out_unregister_udplite_proto;
  916. /* We MUST register RAW sockets before we create the ICMP6,
  917. * IGMP6, or NDISC control sockets.
  918. */
  919. err = rawv6_init();
  920. if (err)
  921. goto out_unregister_raw_proto;
  922. /* Register the family here so that the init calls below will
  923. * be able to create sockets. (?? is this dangerous ??)
  924. */
  925. err = sock_register(&inet6_family_ops);
  926. if (err)
  927. goto out_sock_register_fail;
  928. #ifdef CONFIG_SYSCTL
  929. err = ipv6_static_sysctl_register();
  930. if (err)
  931. goto static_sysctl_fail;
  932. #endif
  933. tcpv6_prot.sysctl_mem = init_net.ipv4.sysctl_tcp_mem;
  934. /*
  935. * ipngwg API draft makes clear that the correct semantics
  936. * for TCP and UDP is to consider one TCP and UDP instance
  937. * in a host available by both INET and INET6 APIs and
  938. * able to communicate via both network protocols.
  939. */
  940. err = register_pernet_subsys(&inet6_net_ops);
  941. if (err)
  942. goto register_pernet_fail;
  943. err = icmpv6_init();
  944. if (err)
  945. goto icmp_fail;
  946. err = ip6_mr_init();
  947. if (err)
  948. goto ipmr_fail;
  949. err = ndisc_init();
  950. if (err)
  951. goto ndisc_fail;
  952. err = igmp6_init();
  953. if (err)
  954. goto igmp_fail;
  955. err = ipv6_netfilter_init();
  956. if (err)
  957. goto netfilter_fail;
  958. /* Create /proc/foo6 entries. */
  959. #ifdef CONFIG_PROC_FS
  960. err = -ENOMEM;
  961. if (raw6_proc_init())
  962. goto proc_raw6_fail;
  963. if (udplite6_proc_init())
  964. goto proc_udplite6_fail;
  965. if (ipv6_misc_proc_init())
  966. goto proc_misc6_fail;
  967. if (if6_proc_init())
  968. goto proc_if6_fail;
  969. #endif
  970. err = ip6_route_init();
  971. if (err)
  972. goto ip6_route_fail;
  973. err = ip6_flowlabel_init();
  974. if (err)
  975. goto ip6_flowlabel_fail;
  976. err = addrconf_init();
  977. if (err)
  978. goto addrconf_fail;
  979. /* Init v6 extension headers. */
  980. err = ipv6_exthdrs_init();
  981. if (err)
  982. goto ipv6_exthdrs_fail;
  983. err = ipv6_frag_init();
  984. if (err)
  985. goto ipv6_frag_fail;
  986. /* Init v6 transport protocols. */
  987. err = udpv6_init();
  988. if (err)
  989. goto udpv6_fail;
  990. err = udplitev6_init();
  991. if (err)
  992. goto udplitev6_fail;
  993. err = tcpv6_init();
  994. if (err)
  995. goto tcpv6_fail;
  996. err = ipv6_packet_init();
  997. if (err)
  998. goto ipv6_packet_fail;
  999. #ifdef CONFIG_SYSCTL
  1000. err = ipv6_sysctl_register();
  1001. if (err)
  1002. goto sysctl_fail;
  1003. #endif
  1004. out:
  1005. return err;
  1006. #ifdef CONFIG_SYSCTL
  1007. sysctl_fail:
  1008. ipv6_packet_cleanup();
  1009. #endif
  1010. ipv6_packet_fail:
  1011. tcpv6_exit();
  1012. tcpv6_fail:
  1013. udplitev6_exit();
  1014. udplitev6_fail:
  1015. udpv6_exit();
  1016. udpv6_fail:
  1017. ipv6_frag_exit();
  1018. ipv6_frag_fail:
  1019. ipv6_exthdrs_exit();
  1020. ipv6_exthdrs_fail:
  1021. addrconf_cleanup();
  1022. addrconf_fail:
  1023. ip6_flowlabel_cleanup();
  1024. ip6_flowlabel_fail:
  1025. ip6_route_cleanup();
  1026. ip6_route_fail:
  1027. #ifdef CONFIG_PROC_FS
  1028. if6_proc_exit();
  1029. proc_if6_fail:
  1030. ipv6_misc_proc_exit();
  1031. proc_misc6_fail:
  1032. udplite6_proc_exit();
  1033. proc_udplite6_fail:
  1034. raw6_proc_exit();
  1035. proc_raw6_fail:
  1036. #endif
  1037. ipv6_netfilter_fini();
  1038. netfilter_fail:
  1039. igmp6_cleanup();
  1040. igmp_fail:
  1041. ndisc_cleanup();
  1042. ndisc_fail:
  1043. ip6_mr_cleanup();
  1044. ipmr_fail:
  1045. icmpv6_cleanup();
  1046. icmp_fail:
  1047. unregister_pernet_subsys(&inet6_net_ops);
  1048. register_pernet_fail:
  1049. #ifdef CONFIG_SYSCTL
  1050. ipv6_static_sysctl_unregister();
  1051. static_sysctl_fail:
  1052. #endif
  1053. sock_unregister(PF_INET6);
  1054. rtnl_unregister_all(PF_INET6);
  1055. out_sock_register_fail:
  1056. rawv6_exit();
  1057. out_unregister_raw_proto:
  1058. proto_unregister(&rawv6_prot);
  1059. out_unregister_udplite_proto:
  1060. proto_unregister(&udplitev6_prot);
  1061. out_unregister_udp_proto:
  1062. proto_unregister(&udpv6_prot);
  1063. out_unregister_tcp_proto:
  1064. proto_unregister(&tcpv6_prot);
  1065. goto out;
  1066. }
  1067. module_init(inet6_init);
  1068. static void __exit inet6_exit(void)
  1069. {
  1070. if (disable_ipv6_mod)
  1071. return;
  1072. /* First of all disallow new sockets creation. */
  1073. sock_unregister(PF_INET6);
  1074. /* Disallow any further netlink messages */
  1075. rtnl_unregister_all(PF_INET6);
  1076. #ifdef CONFIG_SYSCTL
  1077. ipv6_sysctl_unregister();
  1078. #endif
  1079. udpv6_exit();
  1080. udplitev6_exit();
  1081. tcpv6_exit();
  1082. /* Cleanup code parts. */
  1083. ipv6_packet_cleanup();
  1084. ipv6_frag_exit();
  1085. ipv6_exthdrs_exit();
  1086. addrconf_cleanup();
  1087. ip6_flowlabel_cleanup();
  1088. ip6_route_cleanup();
  1089. #ifdef CONFIG_PROC_FS
  1090. /* Cleanup code parts. */
  1091. if6_proc_exit();
  1092. ipv6_misc_proc_exit();
  1093. udplite6_proc_exit();
  1094. raw6_proc_exit();
  1095. #endif
  1096. ipv6_netfilter_fini();
  1097. igmp6_cleanup();
  1098. ndisc_cleanup();
  1099. ip6_mr_cleanup();
  1100. icmpv6_cleanup();
  1101. rawv6_exit();
  1102. unregister_pernet_subsys(&inet6_net_ops);
  1103. #ifdef CONFIG_SYSCTL
  1104. ipv6_static_sysctl_unregister();
  1105. #endif
  1106. proto_unregister(&rawv6_prot);
  1107. proto_unregister(&udplitev6_prot);
  1108. proto_unregister(&udpv6_prot);
  1109. proto_unregister(&tcpv6_prot);
  1110. rcu_barrier(); /* Wait for completion of call_rcu()'s */
  1111. }
  1112. module_exit(inet6_exit);
  1113. MODULE_ALIAS_NETPROTO(PF_INET6);