ip6_vti.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251
  1. /*
  2. * IPv6 virtual tunneling interface
  3. *
  4. * Copyright (C) 2013 secunet Security Networks AG
  5. *
  6. * Author:
  7. * Steffen Klassert <steffen.klassert@secunet.com>
  8. *
  9. * Based on:
  10. * net/ipv6/ip6_tunnel.c
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version
  15. * 2 of the License, or (at your option) any later version.
  16. */
  17. #include <linux/module.h>
  18. #include <linux/capability.h>
  19. #include <linux/errno.h>
  20. #include <linux/types.h>
  21. #include <linux/sockios.h>
  22. #include <linux/icmp.h>
  23. #include <linux/if.h>
  24. #include <linux/in.h>
  25. #include <linux/ip.h>
  26. #include <linux/net.h>
  27. #include <linux/in6.h>
  28. #include <linux/netdevice.h>
  29. #include <linux/if_arp.h>
  30. #include <linux/icmpv6.h>
  31. #include <linux/init.h>
  32. #include <linux/route.h>
  33. #include <linux/rtnetlink.h>
  34. #include <linux/netfilter_ipv6.h>
  35. #include <linux/slab.h>
  36. #include <linux/hash.h>
  37. #include <linux/uaccess.h>
  38. #include <linux/atomic.h>
  39. #include <net/icmp.h>
  40. #include <net/ip.h>
  41. #include <net/ip_tunnels.h>
  42. #include <net/ipv6.h>
  43. #include <net/ip6_route.h>
  44. #include <net/addrconf.h>
  45. #include <net/ip6_tunnel.h>
  46. #include <net/xfrm.h>
  47. #include <net/net_namespace.h>
  48. #include <net/netns/generic.h>
  49. #include <linux/etherdevice.h>
  50. #define IP6_VTI_HASH_SIZE_SHIFT 5
  51. #define IP6_VTI_HASH_SIZE (1 << IP6_VTI_HASH_SIZE_SHIFT)
  52. static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
  53. {
  54. u32 hash = ipv6_addr_hash(addr1) ^ ipv6_addr_hash(addr2);
  55. return hash_32(hash, IP6_VTI_HASH_SIZE_SHIFT);
  56. }
  57. static int vti6_dev_init(struct net_device *dev);
  58. static void vti6_dev_setup(struct net_device *dev);
  59. static struct rtnl_link_ops vti6_link_ops __read_mostly;
  60. static unsigned int vti6_net_id __read_mostly;
  61. struct vti6_net {
  62. /* the vti6 tunnel fallback device */
  63. struct net_device *fb_tnl_dev;
  64. /* lists for storing tunnels in use */
  65. struct ip6_tnl __rcu *tnls_r_l[IP6_VTI_HASH_SIZE];
  66. struct ip6_tnl __rcu *tnls_wc[1];
  67. struct ip6_tnl __rcu **tnls[2];
  68. };
  69. #define for_each_vti6_tunnel_rcu(start) \
  70. for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))
  71. /**
  72. * vti6_tnl_lookup - fetch tunnel matching the end-point addresses
  73. * @net: network namespace
  74. * @remote: the address of the tunnel exit-point
  75. * @local: the address of the tunnel entry-point
  76. *
  77. * Return:
  78. * tunnel matching given end-points if found,
  79. * else fallback tunnel if its device is up,
  80. * else %NULL
  81. **/
  82. static struct ip6_tnl *
  83. vti6_tnl_lookup(struct net *net, const struct in6_addr *remote,
  84. const struct in6_addr *local)
  85. {
  86. unsigned int hash = HASH(remote, local);
  87. struct ip6_tnl *t;
  88. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  89. struct in6_addr any;
  90. for_each_vti6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
  91. if (ipv6_addr_equal(local, &t->parms.laddr) &&
  92. ipv6_addr_equal(remote, &t->parms.raddr) &&
  93. (t->dev->flags & IFF_UP))
  94. return t;
  95. }
  96. memset(&any, 0, sizeof(any));
  97. hash = HASH(&any, local);
  98. for_each_vti6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
  99. if (ipv6_addr_equal(local, &t->parms.laddr) &&
  100. (t->dev->flags & IFF_UP))
  101. return t;
  102. }
  103. hash = HASH(remote, &any);
  104. for_each_vti6_tunnel_rcu(ip6n->tnls_r_l[hash]) {
  105. if (ipv6_addr_equal(remote, &t->parms.raddr) &&
  106. (t->dev->flags & IFF_UP))
  107. return t;
  108. }
  109. t = rcu_dereference(ip6n->tnls_wc[0]);
  110. if (t && (t->dev->flags & IFF_UP))
  111. return t;
  112. return NULL;
  113. }
  114. /**
  115. * vti6_tnl_bucket - get head of list matching given tunnel parameters
  116. * @p: parameters containing tunnel end-points
  117. *
  118. * Description:
  119. * vti6_tnl_bucket() returns the head of the list matching the
  120. * &struct in6_addr entries laddr and raddr in @p.
  121. *
  122. * Return: head of IPv6 tunnel list
  123. **/
  124. static struct ip6_tnl __rcu **
  125. vti6_tnl_bucket(struct vti6_net *ip6n, const struct __ip6_tnl_parm *p)
  126. {
  127. const struct in6_addr *remote = &p->raddr;
  128. const struct in6_addr *local = &p->laddr;
  129. unsigned int h = 0;
  130. int prio = 0;
  131. if (!ipv6_addr_any(remote) || !ipv6_addr_any(local)) {
  132. prio = 1;
  133. h = HASH(remote, local);
  134. }
  135. return &ip6n->tnls[prio][h];
  136. }
  137. static void
  138. vti6_tnl_link(struct vti6_net *ip6n, struct ip6_tnl *t)
  139. {
  140. struct ip6_tnl __rcu **tp = vti6_tnl_bucket(ip6n, &t->parms);
  141. rcu_assign_pointer(t->next , rtnl_dereference(*tp));
  142. rcu_assign_pointer(*tp, t);
  143. }
  144. static void
  145. vti6_tnl_unlink(struct vti6_net *ip6n, struct ip6_tnl *t)
  146. {
  147. struct ip6_tnl __rcu **tp;
  148. struct ip6_tnl *iter;
  149. for (tp = vti6_tnl_bucket(ip6n, &t->parms);
  150. (iter = rtnl_dereference(*tp)) != NULL;
  151. tp = &iter->next) {
  152. if (t == iter) {
  153. rcu_assign_pointer(*tp, t->next);
  154. break;
  155. }
  156. }
  157. }
  158. static void vti6_dev_free(struct net_device *dev)
  159. {
  160. free_percpu(dev->tstats);
  161. }
  162. static int vti6_tnl_create2(struct net_device *dev)
  163. {
  164. struct ip6_tnl *t = netdev_priv(dev);
  165. struct net *net = dev_net(dev);
  166. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  167. int err;
  168. dev->rtnl_link_ops = &vti6_link_ops;
  169. err = register_netdevice(dev);
  170. if (err < 0)
  171. goto out;
  172. strcpy(t->parms.name, dev->name);
  173. dev_hold(dev);
  174. vti6_tnl_link(ip6n, t);
  175. return 0;
  176. out:
  177. return err;
  178. }
  179. static struct ip6_tnl *vti6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
  180. {
  181. struct net_device *dev;
  182. struct ip6_tnl *t;
  183. char name[IFNAMSIZ];
  184. int err;
  185. if (p->name[0]) {
  186. if (!dev_valid_name(p->name))
  187. goto failed;
  188. strlcpy(name, p->name, IFNAMSIZ);
  189. } else {
  190. sprintf(name, "ip6_vti%%d");
  191. }
  192. dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, vti6_dev_setup);
  193. if (!dev)
  194. goto failed;
  195. dev_net_set(dev, net);
  196. t = netdev_priv(dev);
  197. t->parms = *p;
  198. t->net = dev_net(dev);
  199. err = vti6_tnl_create2(dev);
  200. if (err < 0)
  201. goto failed_free;
  202. return t;
  203. failed_free:
  204. free_netdev(dev);
  205. failed:
  206. return NULL;
  207. }
  208. /**
  209. * vti6_locate - find or create tunnel matching given parameters
  210. * @net: network namespace
  211. * @p: tunnel parameters
  212. * @create: != 0 if allowed to create new tunnel if no match found
  213. *
  214. * Description:
  215. * vti6_locate() first tries to locate an existing tunnel
  216. * based on @parms. If this is unsuccessful, but @create is set a new
  217. * tunnel device is created and registered for use.
  218. *
  219. * Return:
  220. * matching tunnel or NULL
  221. **/
  222. static struct ip6_tnl *vti6_locate(struct net *net, struct __ip6_tnl_parm *p,
  223. int create)
  224. {
  225. const struct in6_addr *remote = &p->raddr;
  226. const struct in6_addr *local = &p->laddr;
  227. struct ip6_tnl __rcu **tp;
  228. struct ip6_tnl *t;
  229. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  230. for (tp = vti6_tnl_bucket(ip6n, p);
  231. (t = rtnl_dereference(*tp)) != NULL;
  232. tp = &t->next) {
  233. if (ipv6_addr_equal(local, &t->parms.laddr) &&
  234. ipv6_addr_equal(remote, &t->parms.raddr)) {
  235. if (create)
  236. return NULL;
  237. return t;
  238. }
  239. }
  240. if (!create)
  241. return NULL;
  242. return vti6_tnl_create(net, p);
  243. }
  244. /**
  245. * vti6_dev_uninit - tunnel device uninitializer
  246. * @dev: the device to be destroyed
  247. *
  248. * Description:
  249. * vti6_dev_uninit() removes tunnel from its list
  250. **/
  251. static void vti6_dev_uninit(struct net_device *dev)
  252. {
  253. struct ip6_tnl *t = netdev_priv(dev);
  254. struct vti6_net *ip6n = net_generic(t->net, vti6_net_id);
  255. if (dev == ip6n->fb_tnl_dev)
  256. RCU_INIT_POINTER(ip6n->tnls_wc[0], NULL);
  257. else
  258. vti6_tnl_unlink(ip6n, t);
  259. dev_put(dev);
  260. }
  261. static int vti6_rcv(struct sk_buff *skb)
  262. {
  263. struct ip6_tnl *t;
  264. const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
  265. rcu_read_lock();
  266. t = vti6_tnl_lookup(dev_net(skb->dev), &ipv6h->saddr, &ipv6h->daddr);
  267. if (t) {
  268. if (t->parms.proto != IPPROTO_IPV6 && t->parms.proto != 0) {
  269. rcu_read_unlock();
  270. goto discard;
  271. }
  272. if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
  273. rcu_read_unlock();
  274. return 0;
  275. }
  276. if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr)) {
  277. t->dev->stats.rx_dropped++;
  278. rcu_read_unlock();
  279. goto discard;
  280. }
  281. rcu_read_unlock();
  282. return xfrm6_rcv_tnl(skb, t);
  283. }
  284. rcu_read_unlock();
  285. return -EINVAL;
  286. discard:
  287. kfree_skb(skb);
  288. return 0;
  289. }
  290. static int vti6_rcv_cb(struct sk_buff *skb, int err)
  291. {
  292. unsigned short family;
  293. struct net_device *dev;
  294. struct pcpu_sw_netstats *tstats;
  295. struct xfrm_state *x;
  296. struct xfrm_mode *inner_mode;
  297. struct ip6_tnl *t = XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6;
  298. u32 orig_mark = skb->mark;
  299. int ret;
  300. if (!t)
  301. return 1;
  302. dev = t->dev;
  303. if (err) {
  304. dev->stats.rx_errors++;
  305. dev->stats.rx_dropped++;
  306. return 0;
  307. }
  308. x = xfrm_input_state(skb);
  309. inner_mode = x->inner_mode;
  310. if (x->sel.family == AF_UNSPEC) {
  311. inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol);
  312. if (inner_mode == NULL) {
  313. XFRM_INC_STATS(dev_net(skb->dev),
  314. LINUX_MIB_XFRMINSTATEMODEERROR);
  315. return -EINVAL;
  316. }
  317. }
  318. family = inner_mode->afinfo->family;
  319. skb->mark = be32_to_cpu(t->parms.i_key);
  320. ret = xfrm_policy_check(NULL, XFRM_POLICY_IN, skb, family);
  321. skb->mark = orig_mark;
  322. if (!ret)
  323. return -EPERM;
  324. skb_scrub_packet(skb, !net_eq(t->net, dev_net(skb->dev)));
  325. skb->dev = dev;
  326. tstats = this_cpu_ptr(dev->tstats);
  327. u64_stats_update_begin(&tstats->syncp);
  328. tstats->rx_packets++;
  329. tstats->rx_bytes += skb->len;
  330. u64_stats_update_end(&tstats->syncp);
  331. return 0;
  332. }
  333. /**
  334. * vti6_addr_conflict - compare packet addresses to tunnel's own
  335. * @t: the outgoing tunnel device
  336. * @hdr: IPv6 header from the incoming packet
  337. *
  338. * Description:
  339. * Avoid trivial tunneling loop by checking that tunnel exit-point
  340. * doesn't match source of incoming packet.
  341. *
  342. * Return:
  343. * 1 if conflict,
  344. * 0 else
  345. **/
  346. static inline bool
  347. vti6_addr_conflict(const struct ip6_tnl *t, const struct ipv6hdr *hdr)
  348. {
  349. return ipv6_addr_equal(&t->parms.raddr, &hdr->saddr);
  350. }
  351. static bool vti6_state_check(const struct xfrm_state *x,
  352. const struct in6_addr *dst,
  353. const struct in6_addr *src)
  354. {
  355. xfrm_address_t *daddr = (xfrm_address_t *)dst;
  356. xfrm_address_t *saddr = (xfrm_address_t *)src;
  357. /* if there is no transform then this tunnel is not functional.
  358. * Or if the xfrm is not mode tunnel.
  359. */
  360. if (!x || x->props.mode != XFRM_MODE_TUNNEL ||
  361. x->props.family != AF_INET6)
  362. return false;
  363. if (ipv6_addr_any(dst))
  364. return xfrm_addr_equal(saddr, &x->props.saddr, AF_INET6);
  365. if (!xfrm_state_addr_check(x, daddr, saddr, AF_INET6))
  366. return false;
  367. return true;
  368. }
  369. /**
  370. * vti6_xmit - send a packet
  371. * @skb: the outgoing socket buffer
  372. * @dev: the outgoing tunnel device
  373. * @fl: the flow informations for the xfrm_lookup
  374. **/
  375. static int
  376. vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
  377. {
  378. struct ip6_tnl *t = netdev_priv(dev);
  379. struct net_device_stats *stats = &t->dev->stats;
  380. struct dst_entry *dst = skb_dst(skb);
  381. struct net_device *tdev;
  382. struct xfrm_state *x;
  383. int pkt_len = skb->len;
  384. int err = -1;
  385. int mtu;
  386. if (!dst)
  387. goto tx_err_link_failure;
  388. dst_hold(dst);
  389. dst = xfrm_lookup(t->net, dst, fl, NULL, 0);
  390. if (IS_ERR(dst)) {
  391. err = PTR_ERR(dst);
  392. dst = NULL;
  393. goto tx_err_link_failure;
  394. }
  395. x = dst->xfrm;
  396. if (!vti6_state_check(x, &t->parms.raddr, &t->parms.laddr))
  397. goto tx_err_link_failure;
  398. if (!ip6_tnl_xmit_ctl(t, (const struct in6_addr *)&x->props.saddr,
  399. (const struct in6_addr *)&x->id.daddr))
  400. goto tx_err_link_failure;
  401. tdev = dst->dev;
  402. if (tdev == dev) {
  403. stats->collisions++;
  404. net_warn_ratelimited("%s: Local routing loop detected!\n",
  405. t->parms.name);
  406. goto tx_err_dst_release;
  407. }
  408. skb_scrub_packet(skb, !net_eq(t->net, dev_net(dev)));
  409. skb_dst_set(skb, dst);
  410. skb->dev = skb_dst(skb)->dev;
  411. mtu = dst_mtu(dst);
  412. if (!skb->ignore_df && skb->len > mtu) {
  413. skb_dst_update_pmtu(skb, mtu);
  414. if (skb->protocol == htons(ETH_P_IPV6)) {
  415. if (mtu < IPV6_MIN_MTU)
  416. mtu = IPV6_MIN_MTU;
  417. icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
  418. } else {
  419. icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
  420. htonl(mtu));
  421. }
  422. return -EMSGSIZE;
  423. }
  424. err = dst_output(t->net, skb->sk, skb);
  425. if (net_xmit_eval(err) == 0) {
  426. struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats);
  427. u64_stats_update_begin(&tstats->syncp);
  428. tstats->tx_bytes += pkt_len;
  429. tstats->tx_packets++;
  430. u64_stats_update_end(&tstats->syncp);
  431. } else {
  432. stats->tx_errors++;
  433. stats->tx_aborted_errors++;
  434. }
  435. return 0;
  436. tx_err_link_failure:
  437. stats->tx_carrier_errors++;
  438. dst_link_failure(skb);
  439. tx_err_dst_release:
  440. dst_release(dst);
  441. return err;
  442. }
  443. static netdev_tx_t
  444. vti6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
  445. {
  446. struct ip6_tnl *t = netdev_priv(dev);
  447. struct net_device_stats *stats = &t->dev->stats;
  448. struct ipv6hdr *ipv6h;
  449. struct flowi fl;
  450. int ret;
  451. memset(&fl, 0, sizeof(fl));
  452. switch (skb->protocol) {
  453. case htons(ETH_P_IPV6):
  454. ipv6h = ipv6_hdr(skb);
  455. if ((t->parms.proto != IPPROTO_IPV6 && t->parms.proto != 0) ||
  456. vti6_addr_conflict(t, ipv6h))
  457. goto tx_err;
  458. xfrm_decode_session(skb, &fl, AF_INET6);
  459. memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
  460. break;
  461. case htons(ETH_P_IP):
  462. xfrm_decode_session(skb, &fl, AF_INET);
  463. memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
  464. break;
  465. default:
  466. goto tx_err;
  467. }
  468. /* override mark with tunnel output key */
  469. fl.flowi_mark = be32_to_cpu(t->parms.o_key);
  470. ret = vti6_xmit(skb, dev, &fl);
  471. if (ret < 0)
  472. goto tx_err;
  473. return NETDEV_TX_OK;
  474. tx_err:
  475. stats->tx_errors++;
  476. stats->tx_dropped++;
  477. kfree_skb(skb);
  478. return NETDEV_TX_OK;
  479. }
  480. static int vti6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
  481. u8 type, u8 code, int offset, __be32 info)
  482. {
  483. __be32 spi;
  484. __u32 mark;
  485. struct xfrm_state *x;
  486. struct ip6_tnl *t;
  487. struct ip_esp_hdr *esph;
  488. struct ip_auth_hdr *ah;
  489. struct ip_comp_hdr *ipch;
  490. struct net *net = dev_net(skb->dev);
  491. const struct ipv6hdr *iph = (const struct ipv6hdr *)skb->data;
  492. int protocol = iph->nexthdr;
  493. t = vti6_tnl_lookup(dev_net(skb->dev), &iph->daddr, &iph->saddr);
  494. if (!t)
  495. return -1;
  496. mark = be32_to_cpu(t->parms.o_key);
  497. switch (protocol) {
  498. case IPPROTO_ESP:
  499. esph = (struct ip_esp_hdr *)(skb->data + offset);
  500. spi = esph->spi;
  501. break;
  502. case IPPROTO_AH:
  503. ah = (struct ip_auth_hdr *)(skb->data + offset);
  504. spi = ah->spi;
  505. break;
  506. case IPPROTO_COMP:
  507. ipch = (struct ip_comp_hdr *)(skb->data + offset);
  508. spi = htonl(ntohs(ipch->cpi));
  509. break;
  510. default:
  511. return 0;
  512. }
  513. if (type != ICMPV6_PKT_TOOBIG &&
  514. type != NDISC_REDIRECT)
  515. return 0;
  516. x = xfrm_state_lookup(net, mark, (const xfrm_address_t *)&iph->daddr,
  517. spi, protocol, AF_INET6);
  518. if (!x)
  519. return 0;
  520. if (type == NDISC_REDIRECT)
  521. ip6_redirect(skb, net, skb->dev->ifindex, 0,
  522. sock_net_uid(net, NULL));
  523. else
  524. ip6_update_pmtu(skb, net, info, 0, 0, sock_net_uid(net, NULL));
  525. xfrm_state_put(x);
  526. return 0;
  527. }
  528. static void vti6_link_config(struct ip6_tnl *t, bool keep_mtu)
  529. {
  530. struct net_device *dev = t->dev;
  531. struct __ip6_tnl_parm *p = &t->parms;
  532. struct net_device *tdev = NULL;
  533. int mtu;
  534. memcpy(dev->dev_addr, &p->laddr, sizeof(struct in6_addr));
  535. memcpy(dev->broadcast, &p->raddr, sizeof(struct in6_addr));
  536. p->flags &= ~(IP6_TNL_F_CAP_XMIT | IP6_TNL_F_CAP_RCV |
  537. IP6_TNL_F_CAP_PER_PACKET);
  538. p->flags |= ip6_tnl_get_cap(t, &p->laddr, &p->raddr);
  539. if (p->flags & IP6_TNL_F_CAP_XMIT && p->flags & IP6_TNL_F_CAP_RCV)
  540. dev->flags |= IFF_POINTOPOINT;
  541. else
  542. dev->flags &= ~IFF_POINTOPOINT;
  543. if (keep_mtu && dev->mtu) {
  544. dev->mtu = clamp(dev->mtu, dev->min_mtu, dev->max_mtu);
  545. return;
  546. }
  547. if (p->flags & IP6_TNL_F_CAP_XMIT) {
  548. int strict = (ipv6_addr_type(&p->raddr) &
  549. (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL));
  550. struct rt6_info *rt = rt6_lookup(t->net,
  551. &p->raddr, &p->laddr,
  552. p->link, NULL, strict);
  553. if (rt)
  554. tdev = rt->dst.dev;
  555. ip6_rt_put(rt);
  556. }
  557. if (!tdev && p->link)
  558. tdev = __dev_get_by_index(t->net, p->link);
  559. if (tdev)
  560. mtu = tdev->mtu - sizeof(struct ipv6hdr);
  561. else
  562. mtu = ETH_DATA_LEN - LL_MAX_HEADER - sizeof(struct ipv6hdr);
  563. dev->mtu = max_t(int, mtu, IPV4_MIN_MTU);
  564. }
  565. /**
  566. * vti6_tnl_change - update the tunnel parameters
  567. * @t: tunnel to be changed
  568. * @p: tunnel configuration parameters
  569. * @keep_mtu: MTU was set from userspace, don't re-compute it
  570. *
  571. * Description:
  572. * vti6_tnl_change() updates the tunnel parameters
  573. **/
  574. static int
  575. vti6_tnl_change(struct ip6_tnl *t, const struct __ip6_tnl_parm *p,
  576. bool keep_mtu)
  577. {
  578. t->parms.laddr = p->laddr;
  579. t->parms.raddr = p->raddr;
  580. t->parms.link = p->link;
  581. t->parms.i_key = p->i_key;
  582. t->parms.o_key = p->o_key;
  583. t->parms.proto = p->proto;
  584. t->parms.fwmark = p->fwmark;
  585. dst_cache_reset(&t->dst_cache);
  586. vti6_link_config(t, keep_mtu);
  587. return 0;
  588. }
  589. static int vti6_update(struct ip6_tnl *t, struct __ip6_tnl_parm *p,
  590. bool keep_mtu)
  591. {
  592. struct net *net = dev_net(t->dev);
  593. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  594. int err;
  595. vti6_tnl_unlink(ip6n, t);
  596. synchronize_net();
  597. err = vti6_tnl_change(t, p, keep_mtu);
  598. vti6_tnl_link(ip6n, t);
  599. netdev_state_change(t->dev);
  600. return err;
  601. }
  602. static void
  603. vti6_parm_from_user(struct __ip6_tnl_parm *p, const struct ip6_tnl_parm2 *u)
  604. {
  605. p->laddr = u->laddr;
  606. p->raddr = u->raddr;
  607. p->link = u->link;
  608. p->i_key = u->i_key;
  609. p->o_key = u->o_key;
  610. p->proto = u->proto;
  611. memcpy(p->name, u->name, sizeof(u->name));
  612. }
  613. static void
  614. vti6_parm_to_user(struct ip6_tnl_parm2 *u, const struct __ip6_tnl_parm *p)
  615. {
  616. u->laddr = p->laddr;
  617. u->raddr = p->raddr;
  618. u->link = p->link;
  619. u->i_key = p->i_key;
  620. u->o_key = p->o_key;
  621. if (u->i_key)
  622. u->i_flags |= GRE_KEY;
  623. if (u->o_key)
  624. u->o_flags |= GRE_KEY;
  625. u->proto = p->proto;
  626. memcpy(u->name, p->name, sizeof(u->name));
  627. }
  628. /**
  629. * vti6_ioctl - configure vti6 tunnels from userspace
  630. * @dev: virtual device associated with tunnel
  631. * @ifr: parameters passed from userspace
  632. * @cmd: command to be performed
  633. *
  634. * Description:
  635. * vti6_ioctl() is used for managing vti6 tunnels
  636. * from userspace.
  637. *
  638. * The possible commands are the following:
  639. * %SIOCGETTUNNEL: get tunnel parameters for device
  640. * %SIOCADDTUNNEL: add tunnel matching given tunnel parameters
  641. * %SIOCCHGTUNNEL: change tunnel parameters to those given
  642. * %SIOCDELTUNNEL: delete tunnel
  643. *
  644. * The fallback device "ip6_vti0", created during module
  645. * initialization, can be used for creating other tunnel devices.
  646. *
  647. * Return:
  648. * 0 on success,
  649. * %-EFAULT if unable to copy data to or from userspace,
  650. * %-EPERM if current process hasn't %CAP_NET_ADMIN set
  651. * %-EINVAL if passed tunnel parameters are invalid,
  652. * %-EEXIST if changing a tunnel's parameters would cause a conflict
  653. * %-ENODEV if attempting to change or delete a nonexisting device
  654. **/
  655. static int
  656. vti6_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  657. {
  658. int err = 0;
  659. struct ip6_tnl_parm2 p;
  660. struct __ip6_tnl_parm p1;
  661. struct ip6_tnl *t = NULL;
  662. struct net *net = dev_net(dev);
  663. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  664. switch (cmd) {
  665. case SIOCGETTUNNEL:
  666. if (dev == ip6n->fb_tnl_dev) {
  667. if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p))) {
  668. err = -EFAULT;
  669. break;
  670. }
  671. vti6_parm_from_user(&p1, &p);
  672. t = vti6_locate(net, &p1, 0);
  673. } else {
  674. memset(&p, 0, sizeof(p));
  675. }
  676. if (!t)
  677. t = netdev_priv(dev);
  678. vti6_parm_to_user(&p, &t->parms);
  679. if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))
  680. err = -EFAULT;
  681. break;
  682. case SIOCADDTUNNEL:
  683. case SIOCCHGTUNNEL:
  684. err = -EPERM;
  685. if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
  686. break;
  687. err = -EFAULT;
  688. if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
  689. break;
  690. err = -EINVAL;
  691. if (p.proto != IPPROTO_IPV6 && p.proto != 0)
  692. break;
  693. vti6_parm_from_user(&p1, &p);
  694. t = vti6_locate(net, &p1, cmd == SIOCADDTUNNEL);
  695. if (dev != ip6n->fb_tnl_dev && cmd == SIOCCHGTUNNEL) {
  696. if (t) {
  697. if (t->dev != dev) {
  698. err = -EEXIST;
  699. break;
  700. }
  701. } else
  702. t = netdev_priv(dev);
  703. err = vti6_update(t, &p1, false);
  704. }
  705. if (t) {
  706. err = 0;
  707. vti6_parm_to_user(&p, &t->parms);
  708. if (copy_to_user(ifr->ifr_ifru.ifru_data, &p, sizeof(p)))
  709. err = -EFAULT;
  710. } else
  711. err = (cmd == SIOCADDTUNNEL ? -ENOBUFS : -ENOENT);
  712. break;
  713. case SIOCDELTUNNEL:
  714. err = -EPERM;
  715. if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
  716. break;
  717. if (dev == ip6n->fb_tnl_dev) {
  718. err = -EFAULT;
  719. if (copy_from_user(&p, ifr->ifr_ifru.ifru_data, sizeof(p)))
  720. break;
  721. err = -ENOENT;
  722. vti6_parm_from_user(&p1, &p);
  723. t = vti6_locate(net, &p1, 0);
  724. if (!t)
  725. break;
  726. err = -EPERM;
  727. if (t->dev == ip6n->fb_tnl_dev)
  728. break;
  729. dev = t->dev;
  730. }
  731. err = 0;
  732. unregister_netdevice(dev);
  733. break;
  734. default:
  735. err = -EINVAL;
  736. }
  737. return err;
  738. }
  739. static const struct net_device_ops vti6_netdev_ops = {
  740. .ndo_init = vti6_dev_init,
  741. .ndo_uninit = vti6_dev_uninit,
  742. .ndo_start_xmit = vti6_tnl_xmit,
  743. .ndo_do_ioctl = vti6_ioctl,
  744. .ndo_get_stats64 = ip_tunnel_get_stats64,
  745. .ndo_get_iflink = ip6_tnl_get_iflink,
  746. };
  747. /**
  748. * vti6_dev_setup - setup virtual tunnel device
  749. * @dev: virtual device associated with tunnel
  750. *
  751. * Description:
  752. * Initialize function pointers and device parameters
  753. **/
  754. static void vti6_dev_setup(struct net_device *dev)
  755. {
  756. dev->netdev_ops = &vti6_netdev_ops;
  757. dev->needs_free_netdev = true;
  758. dev->priv_destructor = vti6_dev_free;
  759. dev->type = ARPHRD_TUNNEL6;
  760. dev->min_mtu = IPV4_MIN_MTU;
  761. dev->max_mtu = IP_MAX_MTU - sizeof(struct ipv6hdr);
  762. dev->flags |= IFF_NOARP;
  763. dev->addr_len = sizeof(struct in6_addr);
  764. netif_keep_dst(dev);
  765. /* This perm addr will be used as interface identifier by IPv6 */
  766. dev->addr_assign_type = NET_ADDR_RANDOM;
  767. eth_random_addr(dev->perm_addr);
  768. }
  769. /**
  770. * vti6_dev_init_gen - general initializer for all tunnel devices
  771. * @dev: virtual device associated with tunnel
  772. **/
  773. static inline int vti6_dev_init_gen(struct net_device *dev)
  774. {
  775. struct ip6_tnl *t = netdev_priv(dev);
  776. t->dev = dev;
  777. t->net = dev_net(dev);
  778. dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
  779. if (!dev->tstats)
  780. return -ENOMEM;
  781. return 0;
  782. }
  783. /**
  784. * vti6_dev_init - initializer for all non fallback tunnel devices
  785. * @dev: virtual device associated with tunnel
  786. **/
  787. static int vti6_dev_init(struct net_device *dev)
  788. {
  789. struct ip6_tnl *t = netdev_priv(dev);
  790. int err = vti6_dev_init_gen(dev);
  791. if (err)
  792. return err;
  793. vti6_link_config(t, true);
  794. return 0;
  795. }
  796. /**
  797. * vti6_fb_tnl_dev_init - initializer for fallback tunnel device
  798. * @dev: fallback device
  799. *
  800. * Return: 0
  801. **/
  802. static int __net_init vti6_fb_tnl_dev_init(struct net_device *dev)
  803. {
  804. struct ip6_tnl *t = netdev_priv(dev);
  805. struct net *net = dev_net(dev);
  806. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  807. t->parms.proto = IPPROTO_IPV6;
  808. dev_hold(dev);
  809. rcu_assign_pointer(ip6n->tnls_wc[0], t);
  810. return 0;
  811. }
  812. static int vti6_validate(struct nlattr *tb[], struct nlattr *data[],
  813. struct netlink_ext_ack *extack)
  814. {
  815. return 0;
  816. }
  817. static void vti6_netlink_parms(struct nlattr *data[],
  818. struct __ip6_tnl_parm *parms)
  819. {
  820. memset(parms, 0, sizeof(*parms));
  821. if (!data)
  822. return;
  823. if (data[IFLA_VTI_LINK])
  824. parms->link = nla_get_u32(data[IFLA_VTI_LINK]);
  825. if (data[IFLA_VTI_LOCAL])
  826. parms->laddr = nla_get_in6_addr(data[IFLA_VTI_LOCAL]);
  827. if (data[IFLA_VTI_REMOTE])
  828. parms->raddr = nla_get_in6_addr(data[IFLA_VTI_REMOTE]);
  829. if (data[IFLA_VTI_IKEY])
  830. parms->i_key = nla_get_be32(data[IFLA_VTI_IKEY]);
  831. if (data[IFLA_VTI_OKEY])
  832. parms->o_key = nla_get_be32(data[IFLA_VTI_OKEY]);
  833. if (data[IFLA_VTI_FWMARK])
  834. parms->fwmark = nla_get_u32(data[IFLA_VTI_FWMARK]);
  835. }
  836. static int vti6_newlink(struct net *src_net, struct net_device *dev,
  837. struct nlattr *tb[], struct nlattr *data[],
  838. struct netlink_ext_ack *extack)
  839. {
  840. struct net *net = dev_net(dev);
  841. struct ip6_tnl *nt;
  842. nt = netdev_priv(dev);
  843. vti6_netlink_parms(data, &nt->parms);
  844. nt->parms.proto = IPPROTO_IPV6;
  845. if (vti6_locate(net, &nt->parms, 0))
  846. return -EEXIST;
  847. return vti6_tnl_create2(dev);
  848. }
  849. static void vti6_dellink(struct net_device *dev, struct list_head *head)
  850. {
  851. struct net *net = dev_net(dev);
  852. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  853. if (dev != ip6n->fb_tnl_dev)
  854. unregister_netdevice_queue(dev, head);
  855. }
  856. static int vti6_changelink(struct net_device *dev, struct nlattr *tb[],
  857. struct nlattr *data[],
  858. struct netlink_ext_ack *extack)
  859. {
  860. struct ip6_tnl *t;
  861. struct __ip6_tnl_parm p;
  862. struct net *net = dev_net(dev);
  863. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  864. if (dev == ip6n->fb_tnl_dev)
  865. return -EINVAL;
  866. vti6_netlink_parms(data, &p);
  867. t = vti6_locate(net, &p, 0);
  868. if (t) {
  869. if (t->dev != dev)
  870. return -EEXIST;
  871. } else
  872. t = netdev_priv(dev);
  873. return vti6_update(t, &p, tb && tb[IFLA_MTU]);
  874. }
  875. static size_t vti6_get_size(const struct net_device *dev)
  876. {
  877. return
  878. /* IFLA_VTI_LINK */
  879. nla_total_size(4) +
  880. /* IFLA_VTI_LOCAL */
  881. nla_total_size(sizeof(struct in6_addr)) +
  882. /* IFLA_VTI_REMOTE */
  883. nla_total_size(sizeof(struct in6_addr)) +
  884. /* IFLA_VTI_IKEY */
  885. nla_total_size(4) +
  886. /* IFLA_VTI_OKEY */
  887. nla_total_size(4) +
  888. /* IFLA_VTI_FWMARK */
  889. nla_total_size(4) +
  890. 0;
  891. }
  892. static int vti6_fill_info(struct sk_buff *skb, const struct net_device *dev)
  893. {
  894. struct ip6_tnl *tunnel = netdev_priv(dev);
  895. struct __ip6_tnl_parm *parm = &tunnel->parms;
  896. if (nla_put_u32(skb, IFLA_VTI_LINK, parm->link) ||
  897. nla_put_in6_addr(skb, IFLA_VTI_LOCAL, &parm->laddr) ||
  898. nla_put_in6_addr(skb, IFLA_VTI_REMOTE, &parm->raddr) ||
  899. nla_put_be32(skb, IFLA_VTI_IKEY, parm->i_key) ||
  900. nla_put_be32(skb, IFLA_VTI_OKEY, parm->o_key) ||
  901. nla_put_u32(skb, IFLA_VTI_FWMARK, parm->fwmark))
  902. goto nla_put_failure;
  903. return 0;
  904. nla_put_failure:
  905. return -EMSGSIZE;
  906. }
  907. static const struct nla_policy vti6_policy[IFLA_VTI_MAX + 1] = {
  908. [IFLA_VTI_LINK] = { .type = NLA_U32 },
  909. [IFLA_VTI_LOCAL] = { .len = sizeof(struct in6_addr) },
  910. [IFLA_VTI_REMOTE] = { .len = sizeof(struct in6_addr) },
  911. [IFLA_VTI_IKEY] = { .type = NLA_U32 },
  912. [IFLA_VTI_OKEY] = { .type = NLA_U32 },
  913. [IFLA_VTI_FWMARK] = { .type = NLA_U32 },
  914. };
  915. static struct rtnl_link_ops vti6_link_ops __read_mostly = {
  916. .kind = "vti6",
  917. .maxtype = IFLA_VTI_MAX,
  918. .policy = vti6_policy,
  919. .priv_size = sizeof(struct ip6_tnl),
  920. .setup = vti6_dev_setup,
  921. .validate = vti6_validate,
  922. .newlink = vti6_newlink,
  923. .dellink = vti6_dellink,
  924. .changelink = vti6_changelink,
  925. .get_size = vti6_get_size,
  926. .fill_info = vti6_fill_info,
  927. .get_link_net = ip6_tnl_get_link_net,
  928. };
  929. static void __net_exit vti6_destroy_tunnels(struct vti6_net *ip6n,
  930. struct list_head *list)
  931. {
  932. int h;
  933. struct ip6_tnl *t;
  934. for (h = 0; h < IP6_VTI_HASH_SIZE; h++) {
  935. t = rtnl_dereference(ip6n->tnls_r_l[h]);
  936. while (t) {
  937. unregister_netdevice_queue(t->dev, list);
  938. t = rtnl_dereference(t->next);
  939. }
  940. }
  941. t = rtnl_dereference(ip6n->tnls_wc[0]);
  942. unregister_netdevice_queue(t->dev, list);
  943. }
  944. static int __net_init vti6_init_net(struct net *net)
  945. {
  946. struct vti6_net *ip6n = net_generic(net, vti6_net_id);
  947. struct ip6_tnl *t = NULL;
  948. int err;
  949. ip6n->tnls[0] = ip6n->tnls_wc;
  950. ip6n->tnls[1] = ip6n->tnls_r_l;
  951. err = -ENOMEM;
  952. ip6n->fb_tnl_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6_vti0",
  953. NET_NAME_UNKNOWN, vti6_dev_setup);
  954. if (!ip6n->fb_tnl_dev)
  955. goto err_alloc_dev;
  956. dev_net_set(ip6n->fb_tnl_dev, net);
  957. ip6n->fb_tnl_dev->rtnl_link_ops = &vti6_link_ops;
  958. err = vti6_fb_tnl_dev_init(ip6n->fb_tnl_dev);
  959. if (err < 0)
  960. goto err_register;
  961. err = register_netdev(ip6n->fb_tnl_dev);
  962. if (err < 0)
  963. goto err_register;
  964. t = netdev_priv(ip6n->fb_tnl_dev);
  965. strcpy(t->parms.name, ip6n->fb_tnl_dev->name);
  966. return 0;
  967. err_register:
  968. free_netdev(ip6n->fb_tnl_dev);
  969. err_alloc_dev:
  970. return err;
  971. }
  972. static void __net_exit vti6_exit_batch_net(struct list_head *net_list)
  973. {
  974. struct vti6_net *ip6n;
  975. struct net *net;
  976. LIST_HEAD(list);
  977. rtnl_lock();
  978. list_for_each_entry(net, net_list, exit_list) {
  979. ip6n = net_generic(net, vti6_net_id);
  980. vti6_destroy_tunnels(ip6n, &list);
  981. }
  982. unregister_netdevice_many(&list);
  983. rtnl_unlock();
  984. }
  985. static struct pernet_operations vti6_net_ops = {
  986. .init = vti6_init_net,
  987. .exit_batch = vti6_exit_batch_net,
  988. .id = &vti6_net_id,
  989. .size = sizeof(struct vti6_net),
  990. };
  991. static struct xfrm6_protocol vti_esp6_protocol __read_mostly = {
  992. .handler = vti6_rcv,
  993. .cb_handler = vti6_rcv_cb,
  994. .err_handler = vti6_err,
  995. .priority = 100,
  996. };
  997. static struct xfrm6_protocol vti_ah6_protocol __read_mostly = {
  998. .handler = vti6_rcv,
  999. .cb_handler = vti6_rcv_cb,
  1000. .err_handler = vti6_err,
  1001. .priority = 100,
  1002. };
  1003. static struct xfrm6_protocol vti_ipcomp6_protocol __read_mostly = {
  1004. .handler = vti6_rcv,
  1005. .cb_handler = vti6_rcv_cb,
  1006. .err_handler = vti6_err,
  1007. .priority = 100,
  1008. };
  1009. /**
  1010. * vti6_tunnel_init - register protocol and reserve needed resources
  1011. *
  1012. * Return: 0 on success
  1013. **/
  1014. static int __init vti6_tunnel_init(void)
  1015. {
  1016. const char *msg;
  1017. int err;
  1018. msg = "tunnel device";
  1019. err = register_pernet_device(&vti6_net_ops);
  1020. if (err < 0)
  1021. goto pernet_dev_failed;
  1022. msg = "tunnel protocols";
  1023. err = xfrm6_protocol_register(&vti_esp6_protocol, IPPROTO_ESP);
  1024. if (err < 0)
  1025. goto xfrm_proto_esp_failed;
  1026. err = xfrm6_protocol_register(&vti_ah6_protocol, IPPROTO_AH);
  1027. if (err < 0)
  1028. goto xfrm_proto_ah_failed;
  1029. err = xfrm6_protocol_register(&vti_ipcomp6_protocol, IPPROTO_COMP);
  1030. if (err < 0)
  1031. goto xfrm_proto_comp_failed;
  1032. msg = "netlink interface";
  1033. err = rtnl_link_register(&vti6_link_ops);
  1034. if (err < 0)
  1035. goto rtnl_link_failed;
  1036. return 0;
  1037. rtnl_link_failed:
  1038. xfrm6_protocol_deregister(&vti_ipcomp6_protocol, IPPROTO_COMP);
  1039. xfrm_proto_comp_failed:
  1040. xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH);
  1041. xfrm_proto_ah_failed:
  1042. xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP);
  1043. xfrm_proto_esp_failed:
  1044. unregister_pernet_device(&vti6_net_ops);
  1045. pernet_dev_failed:
  1046. pr_err("vti6 init: failed to register %s\n", msg);
  1047. return err;
  1048. }
  1049. /**
  1050. * vti6_tunnel_cleanup - free resources and unregister protocol
  1051. **/
  1052. static void __exit vti6_tunnel_cleanup(void)
  1053. {
  1054. rtnl_link_unregister(&vti6_link_ops);
  1055. xfrm6_protocol_deregister(&vti_ipcomp6_protocol, IPPROTO_COMP);
  1056. xfrm6_protocol_deregister(&vti_ah6_protocol, IPPROTO_AH);
  1057. xfrm6_protocol_deregister(&vti_esp6_protocol, IPPROTO_ESP);
  1058. unregister_pernet_device(&vti6_net_ops);
  1059. }
  1060. module_init(vti6_tunnel_init);
  1061. module_exit(vti6_tunnel_cleanup);
  1062. MODULE_LICENSE("GPL");
  1063. MODULE_ALIAS_RTNL_LINK("vti6");
  1064. MODULE_ALIAS_NETDEV("ip6_vti0");
  1065. MODULE_AUTHOR("Steffen Klassert");
  1066. MODULE_DESCRIPTION("IPv6 virtual tunnel interface");