af_inet6.c 30 KB

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