af_inet6.c 30 KB

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