vxlan.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231
  1. /*
  2. * VXLAN: Virtual eXtensiable Local Area Network
  3. *
  4. * Copyright (c) 2012 Vyatta Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * TODO
  11. * - use IANA UDP port number (when defined)
  12. * - IPv6 (not in RFC)
  13. */
  14. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  15. #include <linux/kernel.h>
  16. #include <linux/types.h>
  17. #include <linux/module.h>
  18. #include <linux/errno.h>
  19. #include <linux/slab.h>
  20. #include <linux/skbuff.h>
  21. #include <linux/rculist.h>
  22. #include <linux/netdevice.h>
  23. #include <linux/in.h>
  24. #include <linux/ip.h>
  25. #include <linux/udp.h>
  26. #include <linux/igmp.h>
  27. #include <linux/etherdevice.h>
  28. #include <linux/if_ether.h>
  29. #include <linux/hash.h>
  30. #include <net/ip.h>
  31. #include <net/icmp.h>
  32. #include <net/udp.h>
  33. #include <net/rtnetlink.h>
  34. #include <net/route.h>
  35. #include <net/dsfield.h>
  36. #include <net/inet_ecn.h>
  37. #include <net/net_namespace.h>
  38. #include <net/netns/generic.h>
  39. #define VXLAN_VERSION "0.1"
  40. #define VNI_HASH_BITS 10
  41. #define VNI_HASH_SIZE (1<<VNI_HASH_BITS)
  42. #define FDB_HASH_BITS 8
  43. #define FDB_HASH_SIZE (1<<FDB_HASH_BITS)
  44. #define FDB_AGE_DEFAULT 300 /* 5 min */
  45. #define FDB_AGE_INTERVAL (10 * HZ) /* rescan interval */
  46. #define VXLAN_N_VID (1u << 24)
  47. #define VXLAN_VID_MASK (VXLAN_N_VID - 1)
  48. /* VLAN + IP header + UDP + VXLAN */
  49. #define VXLAN_HEADROOM (4 + 20 + 8 + 8)
  50. #define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */
  51. /* VXLAN protocol header */
  52. struct vxlanhdr {
  53. __be32 vx_flags;
  54. __be32 vx_vni;
  55. };
  56. /* UDP port for VXLAN traffic. */
  57. static unsigned int vxlan_port __read_mostly = 8472;
  58. module_param_named(udp_port, vxlan_port, uint, 0444);
  59. MODULE_PARM_DESC(udp_port, "Destination UDP port");
  60. static bool log_ecn_error = true;
  61. module_param(log_ecn_error, bool, 0644);
  62. MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
  63. /* per-net private data for this module */
  64. static unsigned int vxlan_net_id;
  65. struct vxlan_net {
  66. struct socket *sock; /* UDP encap socket */
  67. struct hlist_head vni_list[VNI_HASH_SIZE];
  68. };
  69. /* Forwarding table entry */
  70. struct vxlan_fdb {
  71. struct hlist_node hlist; /* linked list of entries */
  72. struct rcu_head rcu;
  73. unsigned long updated; /* jiffies */
  74. unsigned long used;
  75. __be32 remote_ip;
  76. u16 state; /* see ndm_state */
  77. u8 eth_addr[ETH_ALEN];
  78. };
  79. /* Per-cpu network traffic stats */
  80. struct vxlan_stats {
  81. u64 rx_packets;
  82. u64 rx_bytes;
  83. u64 tx_packets;
  84. u64 tx_bytes;
  85. struct u64_stats_sync syncp;
  86. };
  87. /* Pseudo network device */
  88. struct vxlan_dev {
  89. struct hlist_node hlist;
  90. struct net_device *dev;
  91. struct vxlan_stats __percpu *stats;
  92. __u32 vni; /* virtual network id */
  93. __be32 gaddr; /* multicast group */
  94. __be32 saddr; /* source address */
  95. unsigned int link; /* link to multicast over */
  96. __u8 tos; /* TOS override */
  97. __u8 ttl;
  98. bool learn;
  99. unsigned long age_interval;
  100. struct timer_list age_timer;
  101. spinlock_t hash_lock;
  102. unsigned int addrcnt;
  103. unsigned int addrmax;
  104. unsigned int addrexceeded;
  105. struct hlist_head fdb_head[FDB_HASH_SIZE];
  106. };
  107. /* salt for hash table */
  108. static u32 vxlan_salt __read_mostly;
  109. static inline struct hlist_head *vni_head(struct net *net, u32 id)
  110. {
  111. struct vxlan_net *vn = net_generic(net, vxlan_net_id);
  112. return &vn->vni_list[hash_32(id, VNI_HASH_BITS)];
  113. }
  114. /* Look up VNI in a per net namespace table */
  115. static struct vxlan_dev *vxlan_find_vni(struct net *net, u32 id)
  116. {
  117. struct vxlan_dev *vxlan;
  118. struct hlist_node *node;
  119. hlist_for_each_entry_rcu(vxlan, node, vni_head(net, id), hlist) {
  120. if (vxlan->vni == id)
  121. return vxlan;
  122. }
  123. return NULL;
  124. }
  125. /* Fill in neighbour message in skbuff. */
  126. static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan,
  127. const struct vxlan_fdb *fdb,
  128. u32 portid, u32 seq, int type, unsigned int flags)
  129. {
  130. unsigned long now = jiffies;
  131. struct nda_cacheinfo ci;
  132. struct nlmsghdr *nlh;
  133. struct ndmsg *ndm;
  134. nlh = nlmsg_put(skb, portid, seq, type, sizeof(*ndm), flags);
  135. if (nlh == NULL)
  136. return -EMSGSIZE;
  137. ndm = nlmsg_data(nlh);
  138. memset(ndm, 0, sizeof(*ndm));
  139. ndm->ndm_family = AF_BRIDGE;
  140. ndm->ndm_state = fdb->state;
  141. ndm->ndm_ifindex = vxlan->dev->ifindex;
  142. ndm->ndm_flags = NTF_SELF;
  143. ndm->ndm_type = NDA_DST;
  144. if (nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->eth_addr))
  145. goto nla_put_failure;
  146. if (nla_put_be32(skb, NDA_DST, fdb->remote_ip))
  147. goto nla_put_failure;
  148. ci.ndm_used = jiffies_to_clock_t(now - fdb->used);
  149. ci.ndm_confirmed = 0;
  150. ci.ndm_updated = jiffies_to_clock_t(now - fdb->updated);
  151. ci.ndm_refcnt = 0;
  152. if (nla_put(skb, NDA_CACHEINFO, sizeof(ci), &ci))
  153. goto nla_put_failure;
  154. return nlmsg_end(skb, nlh);
  155. nla_put_failure:
  156. nlmsg_cancel(skb, nlh);
  157. return -EMSGSIZE;
  158. }
  159. static inline size_t vxlan_nlmsg_size(void)
  160. {
  161. return NLMSG_ALIGN(sizeof(struct ndmsg))
  162. + nla_total_size(ETH_ALEN) /* NDA_LLADDR */
  163. + nla_total_size(sizeof(__be32)) /* NDA_DST */
  164. + nla_total_size(sizeof(struct nda_cacheinfo));
  165. }
  166. static void vxlan_fdb_notify(struct vxlan_dev *vxlan,
  167. const struct vxlan_fdb *fdb, int type)
  168. {
  169. struct net *net = dev_net(vxlan->dev);
  170. struct sk_buff *skb;
  171. int err = -ENOBUFS;
  172. skb = nlmsg_new(vxlan_nlmsg_size(), GFP_ATOMIC);
  173. if (skb == NULL)
  174. goto errout;
  175. err = vxlan_fdb_info(skb, vxlan, fdb, 0, 0, type, 0);
  176. if (err < 0) {
  177. /* -EMSGSIZE implies BUG in vxlan_nlmsg_size() */
  178. WARN_ON(err == -EMSGSIZE);
  179. kfree_skb(skb);
  180. goto errout;
  181. }
  182. rtnl_notify(skb, net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
  183. return;
  184. errout:
  185. if (err < 0)
  186. rtnl_set_sk_err(net, RTNLGRP_NEIGH, err);
  187. }
  188. /* Hash Ethernet address */
  189. static u32 eth_hash(const unsigned char *addr)
  190. {
  191. u64 value = get_unaligned((u64 *)addr);
  192. /* only want 6 bytes */
  193. #ifdef __BIG_ENDIAN
  194. value >>= 16;
  195. #else
  196. value <<= 16;
  197. #endif
  198. return hash_64(value, FDB_HASH_BITS);
  199. }
  200. /* Hash chain to use given mac address */
  201. static inline struct hlist_head *vxlan_fdb_head(struct vxlan_dev *vxlan,
  202. const u8 *mac)
  203. {
  204. return &vxlan->fdb_head[eth_hash(mac)];
  205. }
  206. /* Look up Ethernet address in forwarding table */
  207. static struct vxlan_fdb *vxlan_find_mac(struct vxlan_dev *vxlan,
  208. const u8 *mac)
  209. {
  210. struct hlist_head *head = vxlan_fdb_head(vxlan, mac);
  211. struct vxlan_fdb *f;
  212. struct hlist_node *node;
  213. hlist_for_each_entry_rcu(f, node, head, hlist) {
  214. if (compare_ether_addr(mac, f->eth_addr) == 0)
  215. return f;
  216. }
  217. return NULL;
  218. }
  219. /* Add new entry to forwarding table -- assumes lock held */
  220. static int vxlan_fdb_create(struct vxlan_dev *vxlan,
  221. const u8 *mac, __be32 ip,
  222. __u16 state, __u16 flags)
  223. {
  224. struct vxlan_fdb *f;
  225. int notify = 0;
  226. f = vxlan_find_mac(vxlan, mac);
  227. if (f) {
  228. if (flags & NLM_F_EXCL) {
  229. netdev_dbg(vxlan->dev,
  230. "lost race to create %pM\n", mac);
  231. return -EEXIST;
  232. }
  233. if (f->state != state) {
  234. f->state = state;
  235. f->updated = jiffies;
  236. notify = 1;
  237. }
  238. } else {
  239. if (!(flags & NLM_F_CREATE))
  240. return -ENOENT;
  241. if (vxlan->addrmax && vxlan->addrcnt >= vxlan->addrmax)
  242. return -ENOSPC;
  243. netdev_dbg(vxlan->dev, "add %pM -> %pI4\n", mac, &ip);
  244. f = kmalloc(sizeof(*f), GFP_ATOMIC);
  245. if (!f)
  246. return -ENOMEM;
  247. notify = 1;
  248. f->remote_ip = ip;
  249. f->state = state;
  250. f->updated = f->used = jiffies;
  251. memcpy(f->eth_addr, mac, ETH_ALEN);
  252. ++vxlan->addrcnt;
  253. hlist_add_head_rcu(&f->hlist,
  254. vxlan_fdb_head(vxlan, mac));
  255. }
  256. if (notify)
  257. vxlan_fdb_notify(vxlan, f, RTM_NEWNEIGH);
  258. return 0;
  259. }
  260. static void vxlan_fdb_destroy(struct vxlan_dev *vxlan, struct vxlan_fdb *f)
  261. {
  262. netdev_dbg(vxlan->dev,
  263. "delete %pM\n", f->eth_addr);
  264. --vxlan->addrcnt;
  265. vxlan_fdb_notify(vxlan, f, RTM_DELNEIGH);
  266. hlist_del_rcu(&f->hlist);
  267. kfree_rcu(f, rcu);
  268. }
  269. /* Add static entry (via netlink) */
  270. static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
  271. struct net_device *dev,
  272. const unsigned char *addr, u16 flags)
  273. {
  274. struct vxlan_dev *vxlan = netdev_priv(dev);
  275. __be32 ip;
  276. int err;
  277. if (!(ndm->ndm_state & (NUD_PERMANENT|NUD_REACHABLE))) {
  278. pr_info("RTM_NEWNEIGH with invalid state %#x\n",
  279. ndm->ndm_state);
  280. return -EINVAL;
  281. }
  282. if (tb[NDA_DST] == NULL)
  283. return -EINVAL;
  284. if (nla_len(tb[NDA_DST]) != sizeof(__be32))
  285. return -EAFNOSUPPORT;
  286. ip = nla_get_be32(tb[NDA_DST]);
  287. spin_lock_bh(&vxlan->hash_lock);
  288. err = vxlan_fdb_create(vxlan, addr, ip, ndm->ndm_state, flags);
  289. spin_unlock_bh(&vxlan->hash_lock);
  290. return err;
  291. }
  292. /* Delete entry (via netlink) */
  293. static int vxlan_fdb_delete(struct ndmsg *ndm, struct net_device *dev,
  294. const unsigned char *addr)
  295. {
  296. struct vxlan_dev *vxlan = netdev_priv(dev);
  297. struct vxlan_fdb *f;
  298. int err = -ENOENT;
  299. spin_lock_bh(&vxlan->hash_lock);
  300. f = vxlan_find_mac(vxlan, addr);
  301. if (f) {
  302. vxlan_fdb_destroy(vxlan, f);
  303. err = 0;
  304. }
  305. spin_unlock_bh(&vxlan->hash_lock);
  306. return err;
  307. }
  308. /* Dump forwarding table */
  309. static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
  310. struct net_device *dev, int idx)
  311. {
  312. struct vxlan_dev *vxlan = netdev_priv(dev);
  313. unsigned int h;
  314. for (h = 0; h < FDB_HASH_SIZE; ++h) {
  315. struct vxlan_fdb *f;
  316. struct hlist_node *n;
  317. int err;
  318. hlist_for_each_entry_rcu(f, n, &vxlan->fdb_head[h], hlist) {
  319. if (idx < cb->args[0])
  320. goto skip;
  321. err = vxlan_fdb_info(skb, vxlan, f,
  322. NETLINK_CB(cb->skb).portid,
  323. cb->nlh->nlmsg_seq,
  324. RTM_NEWNEIGH,
  325. NLM_F_MULTI);
  326. if (err < 0)
  327. break;
  328. skip:
  329. ++idx;
  330. }
  331. }
  332. return idx;
  333. }
  334. /* Watch incoming packets to learn mapping between Ethernet address
  335. * and Tunnel endpoint.
  336. */
  337. static void vxlan_snoop(struct net_device *dev,
  338. __be32 src_ip, const u8 *src_mac)
  339. {
  340. struct vxlan_dev *vxlan = netdev_priv(dev);
  341. struct vxlan_fdb *f;
  342. int err;
  343. f = vxlan_find_mac(vxlan, src_mac);
  344. if (likely(f)) {
  345. f->used = jiffies;
  346. if (likely(f->remote_ip == src_ip))
  347. return;
  348. if (net_ratelimit())
  349. netdev_info(dev,
  350. "%pM migrated from %pI4 to %pI4\n",
  351. src_mac, &f->remote_ip, &src_ip);
  352. f->remote_ip = src_ip;
  353. f->updated = jiffies;
  354. } else {
  355. /* learned new entry */
  356. spin_lock(&vxlan->hash_lock);
  357. err = vxlan_fdb_create(vxlan, src_mac, src_ip,
  358. NUD_REACHABLE,
  359. NLM_F_EXCL|NLM_F_CREATE);
  360. spin_unlock(&vxlan->hash_lock);
  361. }
  362. }
  363. /* See if multicast group is already in use by other ID */
  364. static bool vxlan_group_used(struct vxlan_net *vn,
  365. const struct vxlan_dev *this)
  366. {
  367. const struct vxlan_dev *vxlan;
  368. struct hlist_node *node;
  369. unsigned h;
  370. for (h = 0; h < VNI_HASH_SIZE; ++h)
  371. hlist_for_each_entry(vxlan, node, &vn->vni_list[h], hlist) {
  372. if (vxlan == this)
  373. continue;
  374. if (!netif_running(vxlan->dev))
  375. continue;
  376. if (vxlan->gaddr == this->gaddr)
  377. return true;
  378. }
  379. return false;
  380. }
  381. /* kernel equivalent to IP_ADD_MEMBERSHIP */
  382. static int vxlan_join_group(struct net_device *dev)
  383. {
  384. struct vxlan_dev *vxlan = netdev_priv(dev);
  385. struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
  386. struct sock *sk = vn->sock->sk;
  387. struct ip_mreqn mreq = {
  388. .imr_multiaddr.s_addr = vxlan->gaddr,
  389. };
  390. int err;
  391. /* Already a member of group */
  392. if (vxlan_group_used(vn, vxlan))
  393. return 0;
  394. /* Need to drop RTNL to call multicast join */
  395. rtnl_unlock();
  396. lock_sock(sk);
  397. err = ip_mc_join_group(sk, &mreq);
  398. release_sock(sk);
  399. rtnl_lock();
  400. return err;
  401. }
  402. /* kernel equivalent to IP_DROP_MEMBERSHIP */
  403. static int vxlan_leave_group(struct net_device *dev)
  404. {
  405. struct vxlan_dev *vxlan = netdev_priv(dev);
  406. struct vxlan_net *vn = net_generic(dev_net(dev), vxlan_net_id);
  407. int err = 0;
  408. struct sock *sk = vn->sock->sk;
  409. struct ip_mreqn mreq = {
  410. .imr_multiaddr.s_addr = vxlan->gaddr,
  411. };
  412. /* Only leave group when last vxlan is done. */
  413. if (vxlan_group_used(vn, vxlan))
  414. return 0;
  415. /* Need to drop RTNL to call multicast leave */
  416. rtnl_unlock();
  417. lock_sock(sk);
  418. err = ip_mc_leave_group(sk, &mreq);
  419. release_sock(sk);
  420. rtnl_lock();
  421. return err;
  422. }
  423. /* Callback from net/ipv4/udp.c to receive packets */
  424. static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
  425. {
  426. struct iphdr *oip;
  427. struct vxlanhdr *vxh;
  428. struct vxlan_dev *vxlan;
  429. struct vxlan_stats *stats;
  430. __u32 vni;
  431. int err;
  432. /* pop off outer UDP header */
  433. __skb_pull(skb, sizeof(struct udphdr));
  434. /* Need Vxlan and inner Ethernet header to be present */
  435. if (!pskb_may_pull(skb, sizeof(struct vxlanhdr)))
  436. goto error;
  437. /* Drop packets with reserved bits set */
  438. vxh = (struct vxlanhdr *) skb->data;
  439. if (vxh->vx_flags != htonl(VXLAN_FLAGS) ||
  440. (vxh->vx_vni & htonl(0xff))) {
  441. netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n",
  442. ntohl(vxh->vx_flags), ntohl(vxh->vx_vni));
  443. goto error;
  444. }
  445. __skb_pull(skb, sizeof(struct vxlanhdr));
  446. skb_postpull_rcsum(skb, eth_hdr(skb), sizeof(struct vxlanhdr));
  447. /* Is this VNI defined? */
  448. vni = ntohl(vxh->vx_vni) >> 8;
  449. vxlan = vxlan_find_vni(sock_net(sk), vni);
  450. if (!vxlan) {
  451. netdev_dbg(skb->dev, "unknown vni %d\n", vni);
  452. goto drop;
  453. }
  454. if (!pskb_may_pull(skb, ETH_HLEN)) {
  455. vxlan->dev->stats.rx_length_errors++;
  456. vxlan->dev->stats.rx_errors++;
  457. goto drop;
  458. }
  459. /* Re-examine inner Ethernet packet */
  460. oip = ip_hdr(skb);
  461. skb->protocol = eth_type_trans(skb, vxlan->dev);
  462. skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
  463. /* Ignore packet loops (and multicast echo) */
  464. if (compare_ether_addr(eth_hdr(skb)->h_source,
  465. vxlan->dev->dev_addr) == 0)
  466. goto drop;
  467. if (vxlan->learn)
  468. vxlan_snoop(skb->dev, oip->saddr, eth_hdr(skb)->h_source);
  469. __skb_tunnel_rx(skb, vxlan->dev);
  470. skb_reset_network_header(skb);
  471. err = IP_ECN_decapsulate(oip, skb);
  472. if (unlikely(err)) {
  473. if (log_ecn_error)
  474. net_info_ratelimited("non-ECT from %pI4 with TOS=%#x\n",
  475. &oip->saddr, oip->tos);
  476. if (err > 1) {
  477. ++vxlan->dev->stats.rx_frame_errors;
  478. ++vxlan->dev->stats.rx_errors;
  479. goto drop;
  480. }
  481. }
  482. stats = this_cpu_ptr(vxlan->stats);
  483. u64_stats_update_begin(&stats->syncp);
  484. stats->rx_packets++;
  485. stats->rx_bytes += skb->len;
  486. u64_stats_update_end(&stats->syncp);
  487. netif_rx(skb);
  488. return 0;
  489. error:
  490. /* Put UDP header back */
  491. __skb_push(skb, sizeof(struct udphdr));
  492. return 1;
  493. drop:
  494. /* Consume bad packet */
  495. kfree_skb(skb);
  496. return 0;
  497. }
  498. /* Extract dsfield from inner protocol */
  499. static inline u8 vxlan_get_dsfield(const struct iphdr *iph,
  500. const struct sk_buff *skb)
  501. {
  502. if (skb->protocol == htons(ETH_P_IP))
  503. return iph->tos;
  504. else if (skb->protocol == htons(ETH_P_IPV6))
  505. return ipv6_get_dsfield((const struct ipv6hdr *)iph);
  506. else
  507. return 0;
  508. }
  509. /* Propogate ECN bits out */
  510. static inline u8 vxlan_ecn_encap(u8 tos,
  511. const struct iphdr *iph,
  512. const struct sk_buff *skb)
  513. {
  514. u8 inner = vxlan_get_dsfield(iph, skb);
  515. return INET_ECN_encapsulate(tos, inner);
  516. }
  517. static __be32 vxlan_find_dst(struct vxlan_dev *vxlan, struct sk_buff *skb)
  518. {
  519. const struct ethhdr *eth = (struct ethhdr *) skb->data;
  520. const struct vxlan_fdb *f;
  521. if (is_multicast_ether_addr(eth->h_dest))
  522. return vxlan->gaddr;
  523. f = vxlan_find_mac(vxlan, eth->h_dest);
  524. if (f)
  525. return f->remote_ip;
  526. else
  527. return vxlan->gaddr;
  528. }
  529. /* Transmit local packets over Vxlan
  530. *
  531. * Outer IP header inherits ECN and DF from inner header.
  532. * Outer UDP destination is the VXLAN assigned port.
  533. * source port is based on hash of flow if available
  534. * otherwise use a random value
  535. */
  536. static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
  537. {
  538. struct vxlan_dev *vxlan = netdev_priv(dev);
  539. struct rtable *rt;
  540. const struct iphdr *old_iph;
  541. struct iphdr *iph;
  542. struct vxlanhdr *vxh;
  543. struct udphdr *uh;
  544. struct flowi4 fl4;
  545. unsigned int pkt_len = skb->len;
  546. u32 hash;
  547. __be32 dst;
  548. __be16 df = 0;
  549. __u8 tos, ttl;
  550. int err;
  551. dst = vxlan_find_dst(vxlan, skb);
  552. if (!dst)
  553. goto drop;
  554. /* Need space for new headers (invalidates iph ptr) */
  555. if (skb_cow_head(skb, VXLAN_HEADROOM))
  556. goto drop;
  557. old_iph = ip_hdr(skb);
  558. ttl = vxlan->ttl;
  559. if (!ttl && IN_MULTICAST(ntohl(dst)))
  560. ttl = 1;
  561. tos = vxlan->tos;
  562. if (tos == 1)
  563. tos = vxlan_get_dsfield(old_iph, skb);
  564. hash = skb_get_rxhash(skb);
  565. memset(&fl4, 0, sizeof(fl4));
  566. fl4.flowi4_oif = vxlan->link;
  567. fl4.flowi4_tos = RT_TOS(tos);
  568. fl4.daddr = dst;
  569. fl4.saddr = vxlan->saddr;
  570. rt = ip_route_output_key(dev_net(dev), &fl4);
  571. if (IS_ERR(rt)) {
  572. netdev_dbg(dev, "no route to %pI4\n", &dst);
  573. dev->stats.tx_carrier_errors++;
  574. goto tx_error;
  575. }
  576. if (rt->dst.dev == dev) {
  577. netdev_dbg(dev, "circular route to %pI4\n", &dst);
  578. ip_rt_put(rt);
  579. dev->stats.collisions++;
  580. goto tx_error;
  581. }
  582. memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
  583. IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
  584. IPSKB_REROUTED);
  585. skb_dst_drop(skb);
  586. skb_dst_set(skb, &rt->dst);
  587. vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
  588. vxh->vx_flags = htonl(VXLAN_FLAGS);
  589. vxh->vx_vni = htonl(vxlan->vni << 8);
  590. __skb_push(skb, sizeof(*uh));
  591. skb_reset_transport_header(skb);
  592. uh = udp_hdr(skb);
  593. uh->dest = htons(vxlan_port);
  594. uh->source = hash ? :random32();
  595. uh->len = htons(skb->len);
  596. uh->check = 0;
  597. __skb_push(skb, sizeof(*iph));
  598. skb_reset_network_header(skb);
  599. iph = ip_hdr(skb);
  600. iph->version = 4;
  601. iph->ihl = sizeof(struct iphdr) >> 2;
  602. iph->frag_off = df;
  603. iph->protocol = IPPROTO_UDP;
  604. iph->tos = vxlan_ecn_encap(tos, old_iph, skb);
  605. iph->daddr = dst;
  606. iph->saddr = fl4.saddr;
  607. iph->ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
  608. /* See __IPTUNNEL_XMIT */
  609. skb->ip_summed = CHECKSUM_NONE;
  610. ip_select_ident(iph, &rt->dst, NULL);
  611. err = ip_local_out(skb);
  612. if (likely(net_xmit_eval(err) == 0)) {
  613. struct vxlan_stats *stats = this_cpu_ptr(vxlan->stats);
  614. u64_stats_update_begin(&stats->syncp);
  615. stats->tx_packets++;
  616. stats->tx_bytes += pkt_len;
  617. u64_stats_update_end(&stats->syncp);
  618. } else {
  619. dev->stats.tx_errors++;
  620. dev->stats.tx_aborted_errors++;
  621. }
  622. return NETDEV_TX_OK;
  623. drop:
  624. dev->stats.tx_dropped++;
  625. goto tx_free;
  626. tx_error:
  627. dev->stats.tx_errors++;
  628. tx_free:
  629. dev_kfree_skb(skb);
  630. return NETDEV_TX_OK;
  631. }
  632. /* Walk the forwarding table and purge stale entries */
  633. static void vxlan_cleanup(unsigned long arg)
  634. {
  635. struct vxlan_dev *vxlan = (struct vxlan_dev *) arg;
  636. unsigned long next_timer = jiffies + FDB_AGE_INTERVAL;
  637. unsigned int h;
  638. if (!netif_running(vxlan->dev))
  639. return;
  640. spin_lock_bh(&vxlan->hash_lock);
  641. for (h = 0; h < FDB_HASH_SIZE; ++h) {
  642. struct hlist_node *p, *n;
  643. hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) {
  644. struct vxlan_fdb *f
  645. = container_of(p, struct vxlan_fdb, hlist);
  646. unsigned long timeout;
  647. if (f->state == NUD_PERMANENT)
  648. continue;
  649. timeout = f->used + vxlan->age_interval * HZ;
  650. if (time_before_eq(timeout, jiffies)) {
  651. netdev_dbg(vxlan->dev,
  652. "garbage collect %pM\n",
  653. f->eth_addr);
  654. f->state = NUD_STALE;
  655. vxlan_fdb_destroy(vxlan, f);
  656. } else if (time_before(timeout, next_timer))
  657. next_timer = timeout;
  658. }
  659. }
  660. spin_unlock_bh(&vxlan->hash_lock);
  661. mod_timer(&vxlan->age_timer, next_timer);
  662. }
  663. /* Setup stats when device is created */
  664. static int vxlan_init(struct net_device *dev)
  665. {
  666. struct vxlan_dev *vxlan = netdev_priv(dev);
  667. vxlan->stats = alloc_percpu(struct vxlan_stats);
  668. if (!vxlan->stats)
  669. return -ENOMEM;
  670. return 0;
  671. }
  672. /* Start ageing timer and join group when device is brought up */
  673. static int vxlan_open(struct net_device *dev)
  674. {
  675. struct vxlan_dev *vxlan = netdev_priv(dev);
  676. int err;
  677. if (vxlan->gaddr) {
  678. err = vxlan_join_group(dev);
  679. if (err)
  680. return err;
  681. }
  682. if (vxlan->age_interval)
  683. mod_timer(&vxlan->age_timer, jiffies + FDB_AGE_INTERVAL);
  684. return 0;
  685. }
  686. /* Purge the forwarding table */
  687. static void vxlan_flush(struct vxlan_dev *vxlan)
  688. {
  689. unsigned h;
  690. spin_lock_bh(&vxlan->hash_lock);
  691. for (h = 0; h < FDB_HASH_SIZE; ++h) {
  692. struct hlist_node *p, *n;
  693. hlist_for_each_safe(p, n, &vxlan->fdb_head[h]) {
  694. struct vxlan_fdb *f
  695. = container_of(p, struct vxlan_fdb, hlist);
  696. vxlan_fdb_destroy(vxlan, f);
  697. }
  698. }
  699. spin_unlock_bh(&vxlan->hash_lock);
  700. }
  701. /* Cleanup timer and forwarding table on shutdown */
  702. static int vxlan_stop(struct net_device *dev)
  703. {
  704. struct vxlan_dev *vxlan = netdev_priv(dev);
  705. if (vxlan->gaddr)
  706. vxlan_leave_group(dev);
  707. del_timer_sync(&vxlan->age_timer);
  708. vxlan_flush(vxlan);
  709. return 0;
  710. }
  711. /* Merge per-cpu statistics */
  712. static struct rtnl_link_stats64 *vxlan_stats64(struct net_device *dev,
  713. struct rtnl_link_stats64 *stats)
  714. {
  715. struct vxlan_dev *vxlan = netdev_priv(dev);
  716. struct vxlan_stats tmp, sum = { 0 };
  717. unsigned int cpu;
  718. for_each_possible_cpu(cpu) {
  719. unsigned int start;
  720. const struct vxlan_stats *stats
  721. = per_cpu_ptr(vxlan->stats, cpu);
  722. do {
  723. start = u64_stats_fetch_begin_bh(&stats->syncp);
  724. memcpy(&tmp, stats, sizeof(tmp));
  725. } while (u64_stats_fetch_retry_bh(&stats->syncp, start));
  726. sum.tx_bytes += tmp.tx_bytes;
  727. sum.tx_packets += tmp.tx_packets;
  728. sum.rx_bytes += tmp.rx_bytes;
  729. sum.rx_packets += tmp.rx_packets;
  730. }
  731. stats->tx_bytes = sum.tx_bytes;
  732. stats->tx_packets = sum.tx_packets;
  733. stats->rx_bytes = sum.rx_bytes;
  734. stats->rx_packets = sum.rx_packets;
  735. stats->multicast = dev->stats.multicast;
  736. stats->rx_length_errors = dev->stats.rx_length_errors;
  737. stats->rx_frame_errors = dev->stats.rx_frame_errors;
  738. stats->rx_errors = dev->stats.rx_errors;
  739. stats->tx_dropped = dev->stats.tx_dropped;
  740. stats->tx_carrier_errors = dev->stats.tx_carrier_errors;
  741. stats->tx_aborted_errors = dev->stats.tx_aborted_errors;
  742. stats->collisions = dev->stats.collisions;
  743. stats->tx_errors = dev->stats.tx_errors;
  744. return stats;
  745. }
  746. /* Stub, nothing needs to be done. */
  747. static void vxlan_set_multicast_list(struct net_device *dev)
  748. {
  749. }
  750. static const struct net_device_ops vxlan_netdev_ops = {
  751. .ndo_init = vxlan_init,
  752. .ndo_open = vxlan_open,
  753. .ndo_stop = vxlan_stop,
  754. .ndo_start_xmit = vxlan_xmit,
  755. .ndo_get_stats64 = vxlan_stats64,
  756. .ndo_set_rx_mode = vxlan_set_multicast_list,
  757. .ndo_change_mtu = eth_change_mtu,
  758. .ndo_validate_addr = eth_validate_addr,
  759. .ndo_set_mac_address = eth_mac_addr,
  760. .ndo_fdb_add = vxlan_fdb_add,
  761. .ndo_fdb_del = vxlan_fdb_delete,
  762. .ndo_fdb_dump = vxlan_fdb_dump,
  763. };
  764. /* Info for udev, that this is a virtual tunnel endpoint */
  765. static struct device_type vxlan_type = {
  766. .name = "vxlan",
  767. };
  768. static void vxlan_free(struct net_device *dev)
  769. {
  770. struct vxlan_dev *vxlan = netdev_priv(dev);
  771. free_percpu(vxlan->stats);
  772. free_netdev(dev);
  773. }
  774. /* Initialize the device structure. */
  775. static void vxlan_setup(struct net_device *dev)
  776. {
  777. struct vxlan_dev *vxlan = netdev_priv(dev);
  778. unsigned h;
  779. eth_hw_addr_random(dev);
  780. ether_setup(dev);
  781. dev->netdev_ops = &vxlan_netdev_ops;
  782. dev->destructor = vxlan_free;
  783. SET_NETDEV_DEVTYPE(dev, &vxlan_type);
  784. dev->tx_queue_len = 0;
  785. dev->features |= NETIF_F_LLTX;
  786. dev->features |= NETIF_F_NETNS_LOCAL;
  787. dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
  788. spin_lock_init(&vxlan->hash_lock);
  789. init_timer_deferrable(&vxlan->age_timer);
  790. vxlan->age_timer.function = vxlan_cleanup;
  791. vxlan->age_timer.data = (unsigned long) vxlan;
  792. vxlan->dev = dev;
  793. for (h = 0; h < FDB_HASH_SIZE; ++h)
  794. INIT_HLIST_HEAD(&vxlan->fdb_head[h]);
  795. }
  796. static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = {
  797. [IFLA_VXLAN_ID] = { .type = NLA_U32 },
  798. [IFLA_VXLAN_GROUP] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
  799. [IFLA_VXLAN_LINK] = { .type = NLA_U32 },
  800. [IFLA_VXLAN_LOCAL] = { .len = FIELD_SIZEOF(struct iphdr, saddr) },
  801. [IFLA_VXLAN_TOS] = { .type = NLA_U8 },
  802. [IFLA_VXLAN_TTL] = { .type = NLA_U8 },
  803. [IFLA_VXLAN_LEARNING] = { .type = NLA_U8 },
  804. [IFLA_VXLAN_AGEING] = { .type = NLA_U32 },
  805. [IFLA_VXLAN_LIMIT] = { .type = NLA_U32 },
  806. };
  807. static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[])
  808. {
  809. if (tb[IFLA_ADDRESS]) {
  810. if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) {
  811. pr_debug("invalid link address (not ethernet)\n");
  812. return -EINVAL;
  813. }
  814. if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) {
  815. pr_debug("invalid all zero ethernet address\n");
  816. return -EADDRNOTAVAIL;
  817. }
  818. }
  819. if (!data)
  820. return -EINVAL;
  821. if (data[IFLA_VXLAN_ID]) {
  822. __u32 id = nla_get_u32(data[IFLA_VXLAN_ID]);
  823. if (id >= VXLAN_VID_MASK)
  824. return -ERANGE;
  825. }
  826. if (data[IFLA_VXLAN_GROUP]) {
  827. __be32 gaddr = nla_get_be32(data[IFLA_VXLAN_GROUP]);
  828. if (!IN_MULTICAST(ntohl(gaddr))) {
  829. pr_debug("group address is not IPv4 multicast\n");
  830. return -EADDRNOTAVAIL;
  831. }
  832. }
  833. return 0;
  834. }
  835. static int vxlan_newlink(struct net *net, struct net_device *dev,
  836. struct nlattr *tb[], struct nlattr *data[])
  837. {
  838. struct vxlan_dev *vxlan = netdev_priv(dev);
  839. __u32 vni;
  840. int err;
  841. if (!data[IFLA_VXLAN_ID])
  842. return -EINVAL;
  843. vni = nla_get_u32(data[IFLA_VXLAN_ID]);
  844. if (vxlan_find_vni(net, vni)) {
  845. pr_info("duplicate VNI %u\n", vni);
  846. return -EEXIST;
  847. }
  848. vxlan->vni = vni;
  849. if (data[IFLA_VXLAN_GROUP])
  850. vxlan->gaddr = nla_get_be32(data[IFLA_VXLAN_GROUP]);
  851. if (data[IFLA_VXLAN_LOCAL])
  852. vxlan->saddr = nla_get_be32(data[IFLA_VXLAN_LOCAL]);
  853. if (data[IFLA_VXLAN_LINK]) {
  854. vxlan->link = nla_get_u32(data[IFLA_VXLAN_LINK]);
  855. if (!tb[IFLA_MTU]) {
  856. struct net_device *lowerdev;
  857. lowerdev = __dev_get_by_index(net, vxlan->link);
  858. dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
  859. }
  860. }
  861. if (data[IFLA_VXLAN_TOS])
  862. vxlan->tos = nla_get_u8(data[IFLA_VXLAN_TOS]);
  863. if (!data[IFLA_VXLAN_LEARNING] || nla_get_u8(data[IFLA_VXLAN_LEARNING]))
  864. vxlan->learn = true;
  865. if (data[IFLA_VXLAN_AGEING])
  866. vxlan->age_interval = nla_get_u32(data[IFLA_VXLAN_AGEING]);
  867. else
  868. vxlan->age_interval = FDB_AGE_DEFAULT;
  869. if (data[IFLA_VXLAN_LIMIT])
  870. vxlan->addrmax = nla_get_u32(data[IFLA_VXLAN_LIMIT]);
  871. err = register_netdevice(dev);
  872. if (!err)
  873. hlist_add_head_rcu(&vxlan->hlist, vni_head(net, vxlan->vni));
  874. return err;
  875. }
  876. static void vxlan_dellink(struct net_device *dev, struct list_head *head)
  877. {
  878. struct vxlan_dev *vxlan = netdev_priv(dev);
  879. hlist_del_rcu(&vxlan->hlist);
  880. unregister_netdevice_queue(dev, head);
  881. }
  882. static size_t vxlan_get_size(const struct net_device *dev)
  883. {
  884. return nla_total_size(sizeof(__u32)) + /* IFLA_VXLAN_ID */
  885. nla_total_size(sizeof(__be32)) +/* IFLA_VXLAN_GROUP */
  886. nla_total_size(sizeof(__u32)) + /* IFLA_VXLAN_LINK */
  887. nla_total_size(sizeof(__be32))+ /* IFLA_VXLAN_LOCAL */
  888. nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_TTL */
  889. nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_TOS */
  890. nla_total_size(sizeof(__u8)) + /* IFLA_VXLAN_LEARNING */
  891. nla_total_size(sizeof(__u32)) + /* IFLA_VXLAN_AGEING */
  892. nla_total_size(sizeof(__u32)) + /* IFLA_VXLAN_LIMIT */
  893. 0;
  894. }
  895. static int vxlan_fill_info(struct sk_buff *skb, const struct net_device *dev)
  896. {
  897. const struct vxlan_dev *vxlan = netdev_priv(dev);
  898. if (nla_put_u32(skb, IFLA_VXLAN_ID, vxlan->vni))
  899. goto nla_put_failure;
  900. if (vxlan->gaddr && nla_put_be32(skb, IFLA_VXLAN_GROUP, vxlan->gaddr))
  901. goto nla_put_failure;
  902. if (vxlan->link && nla_put_u32(skb, IFLA_VXLAN_LINK, vxlan->link))
  903. goto nla_put_failure;
  904. if (vxlan->saddr && nla_put_be32(skb, IFLA_VXLAN_LOCAL, vxlan->saddr))
  905. goto nla_put_failure;
  906. if (nla_put_u8(skb, IFLA_VXLAN_TTL, vxlan->ttl) ||
  907. nla_put_u8(skb, IFLA_VXLAN_TOS, vxlan->tos) ||
  908. nla_put_u8(skb, IFLA_VXLAN_LEARNING, vxlan->learn) ||
  909. nla_put_u32(skb, IFLA_VXLAN_AGEING, vxlan->age_interval) ||
  910. nla_put_u32(skb, IFLA_VXLAN_LIMIT, vxlan->addrmax))
  911. goto nla_put_failure;
  912. return 0;
  913. nla_put_failure:
  914. return -EMSGSIZE;
  915. }
  916. static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
  917. .kind = "vxlan",
  918. .maxtype = IFLA_VXLAN_MAX,
  919. .policy = vxlan_policy,
  920. .priv_size = sizeof(struct vxlan_dev),
  921. .setup = vxlan_setup,
  922. .validate = vxlan_validate,
  923. .newlink = vxlan_newlink,
  924. .dellink = vxlan_dellink,
  925. .get_size = vxlan_get_size,
  926. .fill_info = vxlan_fill_info,
  927. };
  928. static __net_init int vxlan_init_net(struct net *net)
  929. {
  930. struct vxlan_net *vn = net_generic(net, vxlan_net_id);
  931. struct sock *sk;
  932. struct sockaddr_in vxlan_addr = {
  933. .sin_family = AF_INET,
  934. .sin_addr.s_addr = htonl(INADDR_ANY),
  935. };
  936. int rc;
  937. unsigned h;
  938. /* Create UDP socket for encapsulation receive. */
  939. rc = sock_create_kern(AF_INET, SOCK_DGRAM, IPPROTO_UDP, &vn->sock);
  940. if (rc < 0) {
  941. pr_debug("UDP socket create failed\n");
  942. return rc;
  943. }
  944. /* Put in proper namespace */
  945. sk = vn->sock->sk;
  946. sk_change_net(sk, net);
  947. vxlan_addr.sin_port = htons(vxlan_port);
  948. rc = kernel_bind(vn->sock, (struct sockaddr *) &vxlan_addr,
  949. sizeof(vxlan_addr));
  950. if (rc < 0) {
  951. pr_debug("bind for UDP socket %pI4:%u (%d)\n",
  952. &vxlan_addr.sin_addr, ntohs(vxlan_addr.sin_port), rc);
  953. sk_release_kernel(sk);
  954. vn->sock = NULL;
  955. return rc;
  956. }
  957. /* Disable multicast loopback */
  958. inet_sk(sk)->mc_loop = 0;
  959. /* Mark socket as an encapsulation socket. */
  960. udp_sk(sk)->encap_type = 1;
  961. udp_sk(sk)->encap_rcv = vxlan_udp_encap_recv;
  962. udp_encap_enable();
  963. for (h = 0; h < VNI_HASH_SIZE; ++h)
  964. INIT_HLIST_HEAD(&vn->vni_list[h]);
  965. return 0;
  966. }
  967. static __net_exit void vxlan_exit_net(struct net *net)
  968. {
  969. struct vxlan_net *vn = net_generic(net, vxlan_net_id);
  970. if (vn->sock) {
  971. sk_release_kernel(vn->sock->sk);
  972. vn->sock = NULL;
  973. }
  974. }
  975. static struct pernet_operations vxlan_net_ops = {
  976. .init = vxlan_init_net,
  977. .exit = vxlan_exit_net,
  978. .id = &vxlan_net_id,
  979. .size = sizeof(struct vxlan_net),
  980. };
  981. static int __init vxlan_init_module(void)
  982. {
  983. int rc;
  984. get_random_bytes(&vxlan_salt, sizeof(vxlan_salt));
  985. rc = register_pernet_device(&vxlan_net_ops);
  986. if (rc)
  987. goto out1;
  988. rc = rtnl_link_register(&vxlan_link_ops);
  989. if (rc)
  990. goto out2;
  991. return 0;
  992. out2:
  993. unregister_pernet_device(&vxlan_net_ops);
  994. out1:
  995. return rc;
  996. }
  997. module_init(vxlan_init_module);
  998. static void __exit vxlan_cleanup_module(void)
  999. {
  1000. rtnl_link_unregister(&vxlan_link_ops);
  1001. unregister_pernet_device(&vxlan_net_ops);
  1002. }
  1003. module_exit(vxlan_cleanup_module);
  1004. MODULE_LICENSE("GPL");
  1005. MODULE_VERSION(VXLAN_VERSION);
  1006. MODULE_AUTHOR("Stephen Hemminger <shemminger@vyatta.com>");
  1007. MODULE_ALIAS_RTNL_LINK("vxlan");