af_inet6.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  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. #define pr_fmt(fmt) "IPv6: " fmt
  21. #include <linux/module.h>
  22. #include <linux/capability.h>
  23. #include <linux/errno.h>
  24. #include <linux/types.h>
  25. #include <linux/socket.h>
  26. #include <linux/in.h>
  27. #include <linux/kernel.h>
  28. #include <linux/timer.h>
  29. #include <linux/string.h>
  30. #include <linux/sockios.h>
  31. #include <linux/net.h>
  32. #include <linux/fcntl.h>
  33. #include <linux/mm.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/proc_fs.h>
  36. #include <linux/stat.h>
  37. #include <linux/init.h>
  38. #include <linux/slab.h>
  39. #include <linux/inet.h>
  40. #include <linux/netdevice.h>
  41. #include <linux/icmpv6.h>
  42. #include <linux/netfilter_ipv6.h>
  43. #include <net/ip.h>
  44. #include <net/ipv6.h>
  45. #include <net/udp.h>
  46. #include <net/udplite.h>
  47. #include <net/tcp.h>
  48. #include <net/ipip.h>
  49. #include <net/protocol.h>
  50. #include <net/inet_common.h>
  51. #include <net/route.h>
  52. #include <net/transp_v6.h>
  53. #include <net/ip6_route.h>
  54. #include <net/addrconf.h>
  55. #ifdef CONFIG_IPV6_TUNNEL
  56. #include <net/ip6_tunnel.h>
  57. #endif
  58. #include <asm/uaccess.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;
  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 = SK_CAN_REUSE;
  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. skb = xchg(&np->pktoptions, NULL);
  360. if (skb != NULL)
  361. kfree_skb(skb);
  362. skb = xchg(&np->rxpmtu, NULL);
  363. if (skb != NULL)
  364. kfree_skb(skb);
  365. /* Free flowlabels */
  366. fl6_free_socklist(sk);
  367. /* Free tx options */
  368. opt = xchg(&np->opt, NULL);
  369. if (opt != NULL)
  370. sock_kfree_s(sk, opt, opt->tot_len);
  371. }
  372. EXPORT_SYMBOL_GPL(inet6_destroy_sock);
  373. /*
  374. * This does both peername and sockname.
  375. */
  376. int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
  377. int *uaddr_len, int peer)
  378. {
  379. struct sockaddr_in6 *sin = (struct sockaddr_in6 *)uaddr;
  380. struct sock *sk = sock->sk;
  381. struct inet_sock *inet = inet_sk(sk);
  382. struct ipv6_pinfo *np = inet6_sk(sk);
  383. sin->sin6_family = AF_INET6;
  384. sin->sin6_flowinfo = 0;
  385. sin->sin6_scope_id = 0;
  386. if (peer) {
  387. if (!inet->inet_dport)
  388. return -ENOTCONN;
  389. if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
  390. peer == 1)
  391. return -ENOTCONN;
  392. sin->sin6_port = inet->inet_dport;
  393. sin->sin6_addr = np->daddr;
  394. if (np->sndflow)
  395. sin->sin6_flowinfo = np->flow_label;
  396. } else {
  397. if (ipv6_addr_any(&np->rcv_saddr))
  398. sin->sin6_addr = np->saddr;
  399. else
  400. sin->sin6_addr = np->rcv_saddr;
  401. sin->sin6_port = inet->inet_sport;
  402. }
  403. if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
  404. sin->sin6_scope_id = sk->sk_bound_dev_if;
  405. *uaddr_len = sizeof(*sin);
  406. return 0;
  407. }
  408. EXPORT_SYMBOL(inet6_getname);
  409. int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
  410. {
  411. struct sock *sk = sock->sk;
  412. struct net *net = sock_net(sk);
  413. switch (cmd) {
  414. case SIOCGSTAMP:
  415. return sock_get_timestamp(sk, (struct timeval __user *)arg);
  416. case SIOCGSTAMPNS:
  417. return sock_get_timestampns(sk, (struct timespec __user *)arg);
  418. case SIOCADDRT:
  419. case SIOCDELRT:
  420. return ipv6_route_ioctl(net, cmd, (void __user *)arg);
  421. case SIOCSIFADDR:
  422. return addrconf_add_ifaddr(net, (void __user *) arg);
  423. case SIOCDIFADDR:
  424. return addrconf_del_ifaddr(net, (void __user *) arg);
  425. case SIOCSIFDSTADDR:
  426. return addrconf_set_dstaddr(net, (void __user *) arg);
  427. default:
  428. if (!sk->sk_prot->ioctl)
  429. return -ENOIOCTLCMD;
  430. return sk->sk_prot->ioctl(sk, cmd, arg);
  431. }
  432. /*NOTREACHED*/
  433. return 0;
  434. }
  435. EXPORT_SYMBOL(inet6_ioctl);
  436. const struct proto_ops inet6_stream_ops = {
  437. .family = PF_INET6,
  438. .owner = THIS_MODULE,
  439. .release = inet6_release,
  440. .bind = inet6_bind,
  441. .connect = inet_stream_connect, /* ok */
  442. .socketpair = sock_no_socketpair, /* a do nothing */
  443. .accept = inet_accept, /* ok */
  444. .getname = inet6_getname,
  445. .poll = tcp_poll, /* ok */
  446. .ioctl = inet6_ioctl, /* must change */
  447. .listen = inet_listen, /* ok */
  448. .shutdown = inet_shutdown, /* ok */
  449. .setsockopt = sock_common_setsockopt, /* ok */
  450. .getsockopt = sock_common_getsockopt, /* ok */
  451. .sendmsg = inet_sendmsg, /* ok */
  452. .recvmsg = inet_recvmsg, /* ok */
  453. .mmap = sock_no_mmap,
  454. .sendpage = inet_sendpage,
  455. .splice_read = tcp_splice_read,
  456. #ifdef CONFIG_COMPAT
  457. .compat_setsockopt = compat_sock_common_setsockopt,
  458. .compat_getsockopt = compat_sock_common_getsockopt,
  459. #endif
  460. };
  461. const struct proto_ops inet6_dgram_ops = {
  462. .family = PF_INET6,
  463. .owner = THIS_MODULE,
  464. .release = inet6_release,
  465. .bind = inet6_bind,
  466. .connect = inet_dgram_connect, /* ok */
  467. .socketpair = sock_no_socketpair, /* a do nothing */
  468. .accept = sock_no_accept, /* a do nothing */
  469. .getname = inet6_getname,
  470. .poll = udp_poll, /* ok */
  471. .ioctl = inet6_ioctl, /* must change */
  472. .listen = sock_no_listen, /* ok */
  473. .shutdown = inet_shutdown, /* ok */
  474. .setsockopt = sock_common_setsockopt, /* ok */
  475. .getsockopt = sock_common_getsockopt, /* ok */
  476. .sendmsg = inet_sendmsg, /* ok */
  477. .recvmsg = inet_recvmsg, /* ok */
  478. .mmap = sock_no_mmap,
  479. .sendpage = sock_no_sendpage,
  480. #ifdef CONFIG_COMPAT
  481. .compat_setsockopt = compat_sock_common_setsockopt,
  482. .compat_getsockopt = compat_sock_common_getsockopt,
  483. #endif
  484. };
  485. static const struct net_proto_family inet6_family_ops = {
  486. .family = PF_INET6,
  487. .create = inet6_create,
  488. .owner = THIS_MODULE,
  489. };
  490. int inet6_register_protosw(struct inet_protosw *p)
  491. {
  492. struct list_head *lh;
  493. struct inet_protosw *answer;
  494. struct list_head *last_perm;
  495. int protocol = p->protocol;
  496. int ret;
  497. spin_lock_bh(&inetsw6_lock);
  498. ret = -EINVAL;
  499. if (p->type >= SOCK_MAX)
  500. goto out_illegal;
  501. /* If we are trying to override a permanent protocol, bail. */
  502. answer = NULL;
  503. ret = -EPERM;
  504. last_perm = &inetsw6[p->type];
  505. list_for_each(lh, &inetsw6[p->type]) {
  506. answer = list_entry(lh, struct inet_protosw, list);
  507. /* Check only the non-wild match. */
  508. if (INET_PROTOSW_PERMANENT & answer->flags) {
  509. if (protocol == answer->protocol)
  510. break;
  511. last_perm = lh;
  512. }
  513. answer = NULL;
  514. }
  515. if (answer)
  516. goto out_permanent;
  517. /* Add the new entry after the last permanent entry if any, so that
  518. * the new entry does not override a permanent entry when matched with
  519. * a wild-card protocol. But it is allowed to override any existing
  520. * non-permanent entry. This means that when we remove this entry, the
  521. * system automatically returns to the old behavior.
  522. */
  523. list_add_rcu(&p->list, last_perm);
  524. ret = 0;
  525. out:
  526. spin_unlock_bh(&inetsw6_lock);
  527. return ret;
  528. out_permanent:
  529. pr_err("Attempt to override permanent protocol %d\n", protocol);
  530. goto out;
  531. out_illegal:
  532. pr_err("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. pr_err("Attempt to unregister permanent protocol %d\n",
  542. p->protocol);
  543. } else {
  544. spin_lock_bh(&inetsw6_lock);
  545. list_del_rcu(&p->list);
  546. spin_unlock_bh(&inetsw6_lock);
  547. synchronize_net();
  548. }
  549. }
  550. EXPORT_SYMBOL(inet6_unregister_protosw);
  551. int inet6_sk_rebuild_header(struct sock *sk)
  552. {
  553. struct ipv6_pinfo *np = inet6_sk(sk);
  554. struct dst_entry *dst;
  555. dst = __sk_dst_check(sk, np->dst_cookie);
  556. if (dst == NULL) {
  557. struct inet_sock *inet = inet_sk(sk);
  558. struct in6_addr *final_p, final;
  559. struct flowi6 fl6;
  560. memset(&fl6, 0, sizeof(fl6));
  561. fl6.flowi6_proto = sk->sk_protocol;
  562. fl6.daddr = np->daddr;
  563. fl6.saddr = np->saddr;
  564. fl6.flowlabel = np->flow_label;
  565. fl6.flowi6_oif = sk->sk_bound_dev_if;
  566. fl6.flowi6_mark = sk->sk_mark;
  567. fl6.fl6_dport = inet->inet_dport;
  568. fl6.fl6_sport = inet->inet_sport;
  569. security_sk_classify_flow(sk, flowi6_to_flowi(&fl6));
  570. final_p = fl6_update_dst(&fl6, np->opt, &final);
  571. dst = ip6_dst_lookup_flow(sk, &fl6, final_p, false);
  572. if (IS_ERR(dst)) {
  573. sk->sk_route_caps = 0;
  574. sk->sk_err_soft = -PTR_ERR(dst);
  575. return PTR_ERR(dst);
  576. }
  577. __ip6_dst_store(sk, dst, NULL, NULL);
  578. }
  579. return 0;
  580. }
  581. EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header);
  582. bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb)
  583. {
  584. const struct ipv6_pinfo *np = inet6_sk(sk);
  585. const struct inet6_skb_parm *opt = IP6CB(skb);
  586. if (np->rxopt.all) {
  587. if ((opt->hop && (np->rxopt.bits.hopopts ||
  588. np->rxopt.bits.ohopopts)) ||
  589. ((IPV6_FLOWINFO_MASK &
  590. *(__be32 *)skb_network_header(skb)) &&
  591. np->rxopt.bits.rxflow) ||
  592. (opt->srcrt && (np->rxopt.bits.srcrt ||
  593. np->rxopt.bits.osrcrt)) ||
  594. ((opt->dst1 || opt->dst0) &&
  595. (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts)))
  596. return true;
  597. }
  598. return false;
  599. }
  600. EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
  601. static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto)
  602. {
  603. const struct inet6_protocol *ops = NULL;
  604. for (;;) {
  605. struct ipv6_opt_hdr *opth;
  606. int len;
  607. if (proto != NEXTHDR_HOP) {
  608. ops = rcu_dereference(inet6_protos[proto]);
  609. if (unlikely(!ops))
  610. break;
  611. if (!(ops->flags & INET6_PROTO_GSO_EXTHDR))
  612. break;
  613. }
  614. if (unlikely(!pskb_may_pull(skb, 8)))
  615. break;
  616. opth = (void *)skb->data;
  617. len = ipv6_optlen(opth);
  618. if (unlikely(!pskb_may_pull(skb, len)))
  619. break;
  620. proto = opth->nexthdr;
  621. __skb_pull(skb, len);
  622. }
  623. return proto;
  624. }
  625. static int ipv6_gso_send_check(struct sk_buff *skb)
  626. {
  627. const struct ipv6hdr *ipv6h;
  628. const struct inet6_protocol *ops;
  629. int err = -EINVAL;
  630. if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
  631. goto out;
  632. ipv6h = ipv6_hdr(skb);
  633. __skb_pull(skb, sizeof(*ipv6h));
  634. err = -EPROTONOSUPPORT;
  635. rcu_read_lock();
  636. ops = rcu_dereference(inet6_protos[
  637. ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr)]);
  638. if (likely(ops && ops->gso_send_check)) {
  639. skb_reset_transport_header(skb);
  640. err = ops->gso_send_check(skb);
  641. }
  642. rcu_read_unlock();
  643. out:
  644. return err;
  645. }
  646. static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb,
  647. netdev_features_t features)
  648. {
  649. struct sk_buff *segs = ERR_PTR(-EINVAL);
  650. struct ipv6hdr *ipv6h;
  651. const struct inet6_protocol *ops;
  652. int proto;
  653. struct frag_hdr *fptr;
  654. unsigned int unfrag_ip6hlen;
  655. u8 *prevhdr;
  656. int offset = 0;
  657. if (!(features & NETIF_F_V6_CSUM))
  658. features &= ~NETIF_F_SG;
  659. if (unlikely(skb_shinfo(skb)->gso_type &
  660. ~(SKB_GSO_UDP |
  661. SKB_GSO_DODGY |
  662. SKB_GSO_TCP_ECN |
  663. SKB_GSO_TCPV6 |
  664. 0)))
  665. goto out;
  666. if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h))))
  667. goto out;
  668. ipv6h = ipv6_hdr(skb);
  669. __skb_pull(skb, sizeof(*ipv6h));
  670. segs = ERR_PTR(-EPROTONOSUPPORT);
  671. proto = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr);
  672. rcu_read_lock();
  673. ops = rcu_dereference(inet6_protos[proto]);
  674. if (likely(ops && ops->gso_segment)) {
  675. skb_reset_transport_header(skb);
  676. segs = ops->gso_segment(skb, features);
  677. }
  678. rcu_read_unlock();
  679. if (IS_ERR(segs))
  680. goto out;
  681. for (skb = segs; skb; skb = skb->next) {
  682. ipv6h = ipv6_hdr(skb);
  683. ipv6h->payload_len = htons(skb->len - skb->mac_len -
  684. sizeof(*ipv6h));
  685. if (proto == IPPROTO_UDP) {
  686. unfrag_ip6hlen = ip6_find_1stfragopt(skb, &prevhdr);
  687. fptr = (struct frag_hdr *)(skb_network_header(skb) +
  688. unfrag_ip6hlen);
  689. fptr->frag_off = htons(offset);
  690. if (skb->next != NULL)
  691. fptr->frag_off |= htons(IP6_MF);
  692. offset += (ntohs(ipv6h->payload_len) -
  693. sizeof(struct frag_hdr));
  694. }
  695. }
  696. out:
  697. return segs;
  698. }
  699. static struct sk_buff **ipv6_gro_receive(struct sk_buff **head,
  700. struct sk_buff *skb)
  701. {
  702. const struct inet6_protocol *ops;
  703. struct sk_buff **pp = NULL;
  704. struct sk_buff *p;
  705. struct ipv6hdr *iph;
  706. unsigned int nlen;
  707. unsigned int hlen;
  708. unsigned int off;
  709. int flush = 1;
  710. int proto;
  711. __wsum csum;
  712. off = skb_gro_offset(skb);
  713. hlen = off + sizeof(*iph);
  714. iph = skb_gro_header_fast(skb, off);
  715. if (skb_gro_header_hard(skb, hlen)) {
  716. iph = skb_gro_header_slow(skb, hlen, off);
  717. if (unlikely(!iph))
  718. goto out;
  719. }
  720. skb_gro_pull(skb, sizeof(*iph));
  721. skb_set_transport_header(skb, skb_gro_offset(skb));
  722. flush += ntohs(iph->payload_len) != skb_gro_len(skb);
  723. rcu_read_lock();
  724. proto = iph->nexthdr;
  725. ops = rcu_dereference(inet6_protos[proto]);
  726. if (!ops || !ops->gro_receive) {
  727. __pskb_pull(skb, skb_gro_offset(skb));
  728. proto = ipv6_gso_pull_exthdrs(skb, proto);
  729. skb_gro_pull(skb, -skb_transport_offset(skb));
  730. skb_reset_transport_header(skb);
  731. __skb_push(skb, skb_gro_offset(skb));
  732. ops = rcu_dereference(inet6_protos[proto]);
  733. if (!ops || !ops->gro_receive)
  734. goto out_unlock;
  735. iph = ipv6_hdr(skb);
  736. }
  737. NAPI_GRO_CB(skb)->proto = proto;
  738. flush--;
  739. nlen = skb_network_header_len(skb);
  740. for (p = *head; p; p = p->next) {
  741. const struct ipv6hdr *iph2;
  742. __be32 first_word; /* <Version:4><Traffic_Class:8><Flow_Label:20> */
  743. if (!NAPI_GRO_CB(p)->same_flow)
  744. continue;
  745. iph2 = ipv6_hdr(p);
  746. first_word = *(__be32 *)iph ^ *(__be32 *)iph2 ;
  747. /* All fields must match except length and Traffic Class. */
  748. if (nlen != skb_network_header_len(p) ||
  749. (first_word & htonl(0xF00FFFFF)) ||
  750. memcmp(&iph->nexthdr, &iph2->nexthdr,
  751. nlen - offsetof(struct ipv6hdr, nexthdr))) {
  752. NAPI_GRO_CB(p)->same_flow = 0;
  753. continue;
  754. }
  755. /* flush if Traffic Class fields are different */
  756. NAPI_GRO_CB(p)->flush |= !!(first_word & htonl(0x0FF00000));
  757. NAPI_GRO_CB(p)->flush |= flush;
  758. }
  759. NAPI_GRO_CB(skb)->flush |= flush;
  760. csum = skb->csum;
  761. skb_postpull_rcsum(skb, iph, skb_network_header_len(skb));
  762. pp = ops->gro_receive(head, skb);
  763. skb->csum = csum;
  764. out_unlock:
  765. rcu_read_unlock();
  766. out:
  767. NAPI_GRO_CB(skb)->flush |= flush;
  768. return pp;
  769. }
  770. static int ipv6_gro_complete(struct sk_buff *skb)
  771. {
  772. const struct inet6_protocol *ops;
  773. struct ipv6hdr *iph = ipv6_hdr(skb);
  774. int err = -ENOSYS;
  775. iph->payload_len = htons(skb->len - skb_network_offset(skb) -
  776. sizeof(*iph));
  777. rcu_read_lock();
  778. ops = rcu_dereference(inet6_protos[NAPI_GRO_CB(skb)->proto]);
  779. if (WARN_ON(!ops || !ops->gro_complete))
  780. goto out_unlock;
  781. err = ops->gro_complete(skb);
  782. out_unlock:
  783. rcu_read_unlock();
  784. return err;
  785. }
  786. static struct packet_type ipv6_packet_type __read_mostly = {
  787. .type = cpu_to_be16(ETH_P_IPV6),
  788. .func = ipv6_rcv,
  789. .gso_send_check = ipv6_gso_send_check,
  790. .gso_segment = ipv6_gso_segment,
  791. .gro_receive = ipv6_gro_receive,
  792. .gro_complete = ipv6_gro_complete,
  793. };
  794. static int __init ipv6_packet_init(void)
  795. {
  796. dev_add_pack(&ipv6_packet_type);
  797. return 0;
  798. }
  799. static void ipv6_packet_cleanup(void)
  800. {
  801. dev_remove_pack(&ipv6_packet_type);
  802. }
  803. static int __net_init ipv6_init_mibs(struct net *net)
  804. {
  805. if (snmp_mib_init((void __percpu **)net->mib.udp_stats_in6,
  806. sizeof(struct udp_mib),
  807. __alignof__(struct udp_mib)) < 0)
  808. return -ENOMEM;
  809. if (snmp_mib_init((void __percpu **)net->mib.udplite_stats_in6,
  810. sizeof(struct udp_mib),
  811. __alignof__(struct udp_mib)) < 0)
  812. goto err_udplite_mib;
  813. if (snmp_mib_init((void __percpu **)net->mib.ipv6_statistics,
  814. sizeof(struct ipstats_mib),
  815. __alignof__(struct ipstats_mib)) < 0)
  816. goto err_ip_mib;
  817. if (snmp_mib_init((void __percpu **)net->mib.icmpv6_statistics,
  818. sizeof(struct icmpv6_mib),
  819. __alignof__(struct icmpv6_mib)) < 0)
  820. goto err_icmp_mib;
  821. net->mib.icmpv6msg_statistics = kzalloc(sizeof(struct icmpv6msg_mib),
  822. GFP_KERNEL);
  823. if (!net->mib.icmpv6msg_statistics)
  824. goto err_icmpmsg_mib;
  825. return 0;
  826. err_icmpmsg_mib:
  827. snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics);
  828. err_icmp_mib:
  829. snmp_mib_free((void __percpu **)net->mib.ipv6_statistics);
  830. err_ip_mib:
  831. snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6);
  832. err_udplite_mib:
  833. snmp_mib_free((void __percpu **)net->mib.udp_stats_in6);
  834. return -ENOMEM;
  835. }
  836. static void ipv6_cleanup_mibs(struct net *net)
  837. {
  838. snmp_mib_free((void __percpu **)net->mib.udp_stats_in6);
  839. snmp_mib_free((void __percpu **)net->mib.udplite_stats_in6);
  840. snmp_mib_free((void __percpu **)net->mib.ipv6_statistics);
  841. snmp_mib_free((void __percpu **)net->mib.icmpv6_statistics);
  842. kfree(net->mib.icmpv6msg_statistics);
  843. }
  844. static int __net_init inet6_net_init(struct net *net)
  845. {
  846. int err = 0;
  847. net->ipv6.sysctl.bindv6only = 0;
  848. net->ipv6.sysctl.icmpv6_time = 1*HZ;
  849. err = ipv6_init_mibs(net);
  850. if (err)
  851. return err;
  852. #ifdef CONFIG_PROC_FS
  853. err = udp6_proc_init(net);
  854. if (err)
  855. goto out;
  856. err = tcp6_proc_init(net);
  857. if (err)
  858. goto proc_tcp6_fail;
  859. err = ac6_proc_init(net);
  860. if (err)
  861. goto proc_ac6_fail;
  862. #endif
  863. return err;
  864. #ifdef CONFIG_PROC_FS
  865. proc_ac6_fail:
  866. tcp6_proc_exit(net);
  867. proc_tcp6_fail:
  868. udp6_proc_exit(net);
  869. out:
  870. ipv6_cleanup_mibs(net);
  871. return err;
  872. #endif
  873. }
  874. static void __net_exit inet6_net_exit(struct net *net)
  875. {
  876. #ifdef CONFIG_PROC_FS
  877. udp6_proc_exit(net);
  878. tcp6_proc_exit(net);
  879. ac6_proc_exit(net);
  880. #endif
  881. ipv6_cleanup_mibs(net);
  882. }
  883. static struct pernet_operations inet6_net_ops = {
  884. .init = inet6_net_init,
  885. .exit = inet6_net_exit,
  886. };
  887. static int __init inet6_init(void)
  888. {
  889. struct sk_buff *dummy_skb;
  890. struct list_head *r;
  891. int err = 0;
  892. BUILD_BUG_ON(sizeof(struct inet6_skb_parm) > sizeof(dummy_skb->cb));
  893. /* Register the socket-side information for inet6_create. */
  894. for (r = &inetsw6[0]; r < &inetsw6[SOCK_MAX]; ++r)
  895. INIT_LIST_HEAD(r);
  896. if (disable_ipv6_mod) {
  897. pr_info("Loaded, but administratively disabled, reboot required to enable\n");
  898. goto out;
  899. }
  900. err = proto_register(&tcpv6_prot, 1);
  901. if (err)
  902. goto out;
  903. err = proto_register(&udpv6_prot, 1);
  904. if (err)
  905. goto out_unregister_tcp_proto;
  906. err = proto_register(&udplitev6_prot, 1);
  907. if (err)
  908. goto out_unregister_udp_proto;
  909. err = proto_register(&rawv6_prot, 1);
  910. if (err)
  911. goto out_unregister_udplite_proto;
  912. /* We MUST register RAW sockets before we create the ICMP6,
  913. * IGMP6, or NDISC control sockets.
  914. */
  915. err = rawv6_init();
  916. if (err)
  917. goto out_unregister_raw_proto;
  918. /* Register the family here so that the init calls below will
  919. * be able to create sockets. (?? is this dangerous ??)
  920. */
  921. err = sock_register(&inet6_family_ops);
  922. if (err)
  923. goto out_sock_register_fail;
  924. tcpv6_prot.sysctl_mem = init_net.ipv4.sysctl_tcp_mem;
  925. /*
  926. * ipngwg API draft makes clear that the correct semantics
  927. * for TCP and UDP is to consider one TCP and UDP instance
  928. * in a host available by both INET and INET6 APIs and
  929. * able to communicate via both network protocols.
  930. */
  931. err = register_pernet_subsys(&inet6_net_ops);
  932. if (err)
  933. goto register_pernet_fail;
  934. err = icmpv6_init();
  935. if (err)
  936. goto icmp_fail;
  937. err = ip6_mr_init();
  938. if (err)
  939. goto ipmr_fail;
  940. err = ndisc_init();
  941. if (err)
  942. goto ndisc_fail;
  943. err = igmp6_init();
  944. if (err)
  945. goto igmp_fail;
  946. err = ipv6_netfilter_init();
  947. if (err)
  948. goto netfilter_fail;
  949. /* Create /proc/foo6 entries. */
  950. #ifdef CONFIG_PROC_FS
  951. err = -ENOMEM;
  952. if (raw6_proc_init())
  953. goto proc_raw6_fail;
  954. if (udplite6_proc_init())
  955. goto proc_udplite6_fail;
  956. if (ipv6_misc_proc_init())
  957. goto proc_misc6_fail;
  958. if (if6_proc_init())
  959. goto proc_if6_fail;
  960. #endif
  961. err = ip6_route_init();
  962. if (err)
  963. goto ip6_route_fail;
  964. err = ip6_flowlabel_init();
  965. if (err)
  966. goto ip6_flowlabel_fail;
  967. err = addrconf_init();
  968. if (err)
  969. goto addrconf_fail;
  970. /* Init v6 extension headers. */
  971. err = ipv6_exthdrs_init();
  972. if (err)
  973. goto ipv6_exthdrs_fail;
  974. err = ipv6_frag_init();
  975. if (err)
  976. goto ipv6_frag_fail;
  977. /* Init v6 transport protocols. */
  978. err = udpv6_init();
  979. if (err)
  980. goto udpv6_fail;
  981. err = udplitev6_init();
  982. if (err)
  983. goto udplitev6_fail;
  984. err = tcpv6_init();
  985. if (err)
  986. goto tcpv6_fail;
  987. err = ipv6_packet_init();
  988. if (err)
  989. goto ipv6_packet_fail;
  990. #ifdef CONFIG_SYSCTL
  991. err = ipv6_sysctl_register();
  992. if (err)
  993. goto sysctl_fail;
  994. #endif
  995. out:
  996. return err;
  997. #ifdef CONFIG_SYSCTL
  998. sysctl_fail:
  999. ipv6_packet_cleanup();
  1000. #endif
  1001. ipv6_packet_fail:
  1002. tcpv6_exit();
  1003. tcpv6_fail:
  1004. udplitev6_exit();
  1005. udplitev6_fail:
  1006. udpv6_exit();
  1007. udpv6_fail:
  1008. ipv6_frag_exit();
  1009. ipv6_frag_fail:
  1010. ipv6_exthdrs_exit();
  1011. ipv6_exthdrs_fail:
  1012. addrconf_cleanup();
  1013. addrconf_fail:
  1014. ip6_flowlabel_cleanup();
  1015. ip6_flowlabel_fail:
  1016. ip6_route_cleanup();
  1017. ip6_route_fail:
  1018. #ifdef CONFIG_PROC_FS
  1019. if6_proc_exit();
  1020. proc_if6_fail:
  1021. ipv6_misc_proc_exit();
  1022. proc_misc6_fail:
  1023. udplite6_proc_exit();
  1024. proc_udplite6_fail:
  1025. raw6_proc_exit();
  1026. proc_raw6_fail:
  1027. #endif
  1028. ipv6_netfilter_fini();
  1029. netfilter_fail:
  1030. igmp6_cleanup();
  1031. igmp_fail:
  1032. ndisc_cleanup();
  1033. ndisc_fail:
  1034. ip6_mr_cleanup();
  1035. ipmr_fail:
  1036. icmpv6_cleanup();
  1037. icmp_fail:
  1038. unregister_pernet_subsys(&inet6_net_ops);
  1039. register_pernet_fail:
  1040. sock_unregister(PF_INET6);
  1041. rtnl_unregister_all(PF_INET6);
  1042. out_sock_register_fail:
  1043. rawv6_exit();
  1044. out_unregister_raw_proto:
  1045. proto_unregister(&rawv6_prot);
  1046. out_unregister_udplite_proto:
  1047. proto_unregister(&udplitev6_prot);
  1048. out_unregister_udp_proto:
  1049. proto_unregister(&udpv6_prot);
  1050. out_unregister_tcp_proto:
  1051. proto_unregister(&tcpv6_prot);
  1052. goto out;
  1053. }
  1054. module_init(inet6_init);
  1055. static void __exit inet6_exit(void)
  1056. {
  1057. if (disable_ipv6_mod)
  1058. return;
  1059. /* First of all disallow new sockets creation. */
  1060. sock_unregister(PF_INET6);
  1061. /* Disallow any further netlink messages */
  1062. rtnl_unregister_all(PF_INET6);
  1063. udpv6_exit();
  1064. udplitev6_exit();
  1065. tcpv6_exit();
  1066. /* Cleanup code parts. */
  1067. ipv6_packet_cleanup();
  1068. ipv6_frag_exit();
  1069. ipv6_exthdrs_exit();
  1070. addrconf_cleanup();
  1071. ip6_flowlabel_cleanup();
  1072. ip6_route_cleanup();
  1073. #ifdef CONFIG_PROC_FS
  1074. /* Cleanup code parts. */
  1075. if6_proc_exit();
  1076. ipv6_misc_proc_exit();
  1077. udplite6_proc_exit();
  1078. raw6_proc_exit();
  1079. #endif
  1080. ipv6_netfilter_fini();
  1081. igmp6_cleanup();
  1082. ndisc_cleanup();
  1083. ip6_mr_cleanup();
  1084. icmpv6_cleanup();
  1085. rawv6_exit();
  1086. unregister_pernet_subsys(&inet6_net_ops);
  1087. proto_unregister(&rawv6_prot);
  1088. proto_unregister(&udplitev6_prot);
  1089. proto_unregister(&udpv6_prot);
  1090. proto_unregister(&tcpv6_prot);
  1091. rcu_barrier(); /* Wait for completion of call_rcu()'s */
  1092. }
  1093. module_exit(inet6_exit);
  1094. MODULE_ALIAS_NETPROTO(PF_INET6);