libnl  3.2.28
vxlan.c
1 /*
2  * lib/route/link/vxlan.c VXLAN Link Info
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation version 2.1
7  * of the License.
8  *
9  * Copyright (c) 2013 Yasunobu Chiba <yasu@dsl.gr.jp>
10  */
11 
12 /**
13  * @ingroup link
14  * @defgroup vxlan VXLAN
15  * Virtual eXtensible Local Area Network link module
16  *
17  * @details
18  * \b Link Type Name: "vxlan"
19  *
20  * @route_doc{link_vxlan, VXLAN Documentation}
21  *
22  * @{
23  */
24 
25 #include <netlink-private/netlink.h>
26 #include <netlink/netlink.h>
27 #include <netlink/attr.h>
28 #include <netlink/utils.h>
29 #include <netlink/object.h>
30 #include <netlink/route/rtnl.h>
31 #include <netlink-private/route/link/api.h>
32 #include <netlink/route/link/vxlan.h>
33 
34 #include <linux/if_link.h>
35 
36 /** @cond SKIP */
37 #define VXLAN_ATTR_ID (1<<0)
38 #define VXLAN_ATTR_GROUP (1<<1)
39 #define VXLAN_ATTR_LINK (1<<2)
40 #define VXLAN_ATTR_LOCAL (1<<3)
41 #define VXLAN_ATTR_TTL (1<<4)
42 #define VXLAN_ATTR_TOS (1<<5)
43 #define VXLAN_ATTR_LEARNING (1<<6)
44 #define VXLAN_ATTR_AGEING (1<<7)
45 #define VXLAN_ATTR_LIMIT (1<<8)
46 #define VXLAN_ATTR_PORT_RANGE (1<<9)
47 #define VXLAN_ATTR_PROXY (1<<10)
48 #define VXLAN_ATTR_RSC (1<<11)
49 #define VXLAN_ATTR_L2MISS (1<<12)
50 #define VXLAN_ATTR_L3MISS (1<<13)
51 #define VXLAN_ATTR_GROUP6 (1<<14)
52 #define VXLAN_ATTR_LOCAL6 (1<<15)
53 
54 struct vxlan_info
55 {
56  uint32_t vxi_id;
57  uint32_t vxi_group;
58  struct in6_addr vxi_group6;
59  uint32_t vxi_link;
60  uint32_t vxi_local;
61  struct in6_addr vxi_local6;
62  uint8_t vxi_ttl;
63  uint8_t vxi_tos;
64  uint8_t vxi_learning;
65  uint32_t vxi_ageing;
66  uint32_t vxi_limit;
67  struct ifla_vxlan_port_range vxi_port_range;
68  uint8_t vxi_proxy;
69  uint8_t vxi_rsc;
70  uint8_t vxi_l2miss;
71  uint8_t vxi_l3miss;
72  uint32_t ce_mask;
73 };
74 
75 /** @endcond */
76 
77 static struct nla_policy vxlan_policy[IFLA_VXLAN_MAX+1] = {
78  [IFLA_VXLAN_ID] = { .type = NLA_U32 },
79  [IFLA_VXLAN_GROUP] = { .minlen = sizeof(uint32_t) },
80  [IFLA_VXLAN_GROUP6] = { .minlen = sizeof(struct in6_addr) },
81  [IFLA_VXLAN_LINK] = { .type = NLA_U32 },
82  [IFLA_VXLAN_LOCAL] = { .minlen = sizeof(uint32_t) },
83  [IFLA_VXLAN_LOCAL6] = { .minlen = sizeof(struct in6_addr) },
84  [IFLA_VXLAN_TTL] = { .type = NLA_U8 },
85  [IFLA_VXLAN_TOS] = { .type = NLA_U8 },
86  [IFLA_VXLAN_LEARNING] = { .type = NLA_U8 },
87  [IFLA_VXLAN_AGEING] = { .type = NLA_U32 },
88  [IFLA_VXLAN_LIMIT] = { .type = NLA_U32 },
89  [IFLA_VXLAN_PORT_RANGE] = { .minlen = sizeof(struct ifla_vxlan_port_range) },
90  [IFLA_VXLAN_PROXY] = { .type = NLA_U8 },
91  [IFLA_VXLAN_RSC] = { .type = NLA_U8 },
92  [IFLA_VXLAN_L2MISS] = { .type = NLA_U8 },
93  [IFLA_VXLAN_L3MISS] = { .type = NLA_U8 },
94 };
95 
96 static int vxlan_alloc(struct rtnl_link *link)
97 {
98  struct vxlan_info *vxi;
99 
100  if (link->l_info)
101  memset(link->l_info, 0, sizeof(*vxi));
102  else {
103  if ((vxi = calloc(1, sizeof(*vxi))) == NULL)
104  return -NLE_NOMEM;
105 
106  link->l_info = vxi;
107  }
108 
109  return 0;
110 }
111 
112 static int vxlan_parse(struct rtnl_link *link, struct nlattr *data,
113  struct nlattr *xstats)
114 {
115  struct nlattr *tb[IFLA_VXLAN_MAX+1];
116  struct vxlan_info *vxi;
117  int err;
118 
119  NL_DBG(3, "Parsing VXLAN link info\n");
120 
121  if ((err = nla_parse_nested(tb, IFLA_VXLAN_MAX, data, vxlan_policy)) < 0)
122  goto errout;
123 
124  if ((err = vxlan_alloc(link)) < 0)
125  goto errout;
126 
127  vxi = link->l_info;
128 
129  if (tb[IFLA_VXLAN_ID]) {
130  vxi->vxi_id = nla_get_u32(tb[IFLA_VXLAN_ID]);
131  vxi->ce_mask |= VXLAN_ATTR_ID;
132  }
133 
134  if (tb[IFLA_VXLAN_GROUP6]) {
135  nla_memcpy(&vxi->vxi_group6, tb[IFLA_VXLAN_GROUP6],
136  sizeof(vxi->vxi_group6));
137  vxi->ce_mask |= VXLAN_ATTR_GROUP6;
138  }
139 
140  if (tb[IFLA_VXLAN_GROUP]) {
141  nla_memcpy(&vxi->vxi_group, tb[IFLA_VXLAN_GROUP],
142  sizeof(vxi->vxi_group));
143  vxi->ce_mask |= VXLAN_ATTR_GROUP;
144  vxi->ce_mask &= ~VXLAN_ATTR_GROUP6;
145  }
146 
147  if (tb[IFLA_VXLAN_LINK]) {
148  vxi->vxi_link = nla_get_u32(tb[IFLA_VXLAN_LINK]);
149  vxi->ce_mask |= VXLAN_ATTR_LINK;
150  }
151 
152  if (tb[IFLA_VXLAN_LOCAL6]) {
153  nla_memcpy(&vxi->vxi_local6, tb[IFLA_VXLAN_LOCAL6],
154  sizeof(vxi->vxi_local6));
155  vxi->ce_mask |= VXLAN_ATTR_LOCAL6;
156  }
157 
158  if (tb[IFLA_VXLAN_LOCAL]) {
159  nla_memcpy(&vxi->vxi_local, tb[IFLA_VXLAN_LOCAL],
160  sizeof(vxi->vxi_local));
161  vxi->ce_mask |= VXLAN_ATTR_LOCAL;
162  vxi->ce_mask &= ~VXLAN_ATTR_LOCAL6;
163  }
164 
165  if (tb[IFLA_VXLAN_TTL]) {
166  vxi->vxi_ttl = nla_get_u8(tb[IFLA_VXLAN_TTL]);
167  vxi->ce_mask |= VXLAN_ATTR_TTL;
168  }
169 
170  if (tb[IFLA_VXLAN_TOS]) {
171  vxi->vxi_tos = nla_get_u8(tb[IFLA_VXLAN_TOS]);
172  vxi->ce_mask |= VXLAN_ATTR_TOS;
173  }
174 
175  if (tb[IFLA_VXLAN_LEARNING]) {
176  vxi->vxi_learning = nla_get_u8(tb[IFLA_VXLAN_LEARNING]);
177  vxi->ce_mask |= VXLAN_ATTR_LEARNING;
178  }
179 
180  if (tb[IFLA_VXLAN_AGEING]) {
181  vxi->vxi_ageing = nla_get_u32(tb[IFLA_VXLAN_AGEING]);
182  vxi->ce_mask |= VXLAN_ATTR_AGEING;
183  }
184 
185  if (tb[IFLA_VXLAN_LIMIT]) {
186  vxi->vxi_limit = nla_get_u32(tb[IFLA_VXLAN_LIMIT]);
187  vxi->ce_mask |= VXLAN_ATTR_LIMIT;
188  }
189 
190  if (tb[IFLA_VXLAN_PORT_RANGE]) {
191  nla_memcpy(&vxi->vxi_port_range, tb[IFLA_VXLAN_PORT_RANGE],
192  sizeof(vxi->vxi_port_range));
193  vxi->ce_mask |= VXLAN_ATTR_PORT_RANGE;
194  }
195 
196  if (tb[IFLA_VXLAN_PROXY]) {
197  vxi->vxi_proxy = nla_get_u8(tb[IFLA_VXLAN_PROXY]);
198  vxi->ce_mask |= VXLAN_ATTR_PROXY;
199  }
200 
201  if (tb[IFLA_VXLAN_RSC]) {
202  vxi->vxi_rsc = nla_get_u8(tb[IFLA_VXLAN_RSC]);
203  vxi->ce_mask |= VXLAN_ATTR_RSC;
204  }
205 
206  if (tb[IFLA_VXLAN_L2MISS]) {
207  vxi->vxi_l2miss = nla_get_u8(tb[IFLA_VXLAN_L2MISS]);
208  vxi->ce_mask |= VXLAN_ATTR_L2MISS;
209  }
210 
211  if (tb[IFLA_VXLAN_L3MISS]) {
212  vxi->vxi_l3miss = nla_get_u8(tb[IFLA_VXLAN_L3MISS]);
213  vxi->ce_mask |= VXLAN_ATTR_L3MISS;
214  }
215 
216  err = 0;
217 
218 errout:
219  return err;
220 }
221 
222 static void vxlan_free(struct rtnl_link *link)
223 {
224  struct vxlan_info *vxi = link->l_info;
225 
226  free(vxi);
227  link->l_info = NULL;
228 }
229 
230 static void vxlan_dump_line(struct rtnl_link *link, struct nl_dump_params *p)
231 {
232  struct vxlan_info *vxi = link->l_info;
233 
234  nl_dump(p, "vxlan-id %u", vxi->vxi_id);
235 }
236 
237 static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p)
238 {
239  struct vxlan_info *vxi = link->l_info;
240  char *name, addr[INET6_ADDRSTRLEN];
241  struct rtnl_link *parent;
242 
243  nl_dump_line(p, " vxlan-id %u\n", vxi->vxi_id);
244 
245  if (vxi->ce_mask & VXLAN_ATTR_GROUP) {
246  nl_dump(p, " group ");
247  if (inet_ntop(AF_INET, &vxi->vxi_group, addr, sizeof(addr)))
248  nl_dump_line(p, "%s\n", addr);
249  else
250  nl_dump_line(p, "%#x\n", ntohs(vxi->vxi_group));
251  } else if (vxi->ce_mask & VXLAN_ATTR_GROUP6) {
252  nl_dump(p, " group ");
253  if (inet_ntop(AF_INET6, &vxi->vxi_group6, addr, sizeof(addr)))
254  nl_dump_line(p, "%s\n", addr);
255  else
256  nl_dump_line(p, "%#x\n", vxi->vxi_group6);
257  }
258 
259  if (vxi->ce_mask & VXLAN_ATTR_LINK) {
260  nl_dump(p, " link ");
261 
262  name = NULL;
263  parent = link_lookup(link->ce_cache, vxi->vxi_link);
264  if (parent)
265  name = rtnl_link_get_name(parent);
266 
267  if (name)
268  nl_dump_line(p, "%s\n", name);
269  else
270  nl_dump_line(p, "%u\n", vxi->vxi_link);
271  }
272 
273  if (vxi->ce_mask & VXLAN_ATTR_LOCAL) {
274  nl_dump(p, " local ");
275  if (inet_ntop(AF_INET, &vxi->vxi_local, addr, sizeof(addr)))
276  nl_dump_line(p, "%s\n", addr);
277  else
278  nl_dump_line(p, "%#x\n", ntohs(vxi->vxi_local));
279  } else if (vxi->ce_mask & VXLAN_ATTR_LOCAL6) {
280  nl_dump(p, " local ");
281  if (inet_ntop(AF_INET6, &vxi->vxi_local6, addr, sizeof(addr)))
282  nl_dump_line(p, "%s\n", addr);
283  else
284  nl_dump_line(p, "%#x\n", vxi->vxi_local6);
285  }
286 
287 
288  if (vxi->ce_mask & VXLAN_ATTR_TTL) {
289  nl_dump(p, " ttl ");
290  if(vxi->vxi_ttl)
291  nl_dump_line(p, "%u\n", vxi->vxi_ttl);
292  else
293  nl_dump_line(p, "inherit\n");
294  }
295 
296  if (vxi->ce_mask & VXLAN_ATTR_TOS) {
297  nl_dump(p, " tos ");
298  if (vxi->vxi_tos == 1)
299  nl_dump_line(p, "inherit\n", vxi->vxi_tos);
300  else
301  nl_dump_line(p, "%#x\n", vxi->vxi_tos);
302  }
303 
304  if (vxi->ce_mask & VXLAN_ATTR_LEARNING) {
305  nl_dump(p, " learning ");
306  if (vxi->vxi_learning)
307  nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_learning);
308  else
309  nl_dump_line(p, "disabled\n");
310  }
311 
312  if (vxi->ce_mask & VXLAN_ATTR_AGEING) {
313  nl_dump(p, " ageing ");
314  if (vxi->vxi_ageing)
315  nl_dump_line(p, "%u seconds\n", vxi->vxi_ageing);
316  else
317  nl_dump_line(p, "disabled\n");
318  }
319 
320  if (vxi->ce_mask & VXLAN_ATTR_LIMIT) {
321  nl_dump(p, " limit ");
322  if (vxi->vxi_limit)
323  nl_dump_line(p, "%u\n", vxi->vxi_limit);
324  else
325  nl_dump_line(p, "unlimited\n");
326  }
327 
328  if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE)
329  nl_dump_line(p, " port range %u - %u\n",
330  ntohs(vxi->vxi_port_range.low),
331  ntohs(vxi->vxi_port_range.high));
332 
333  if (vxi->ce_mask & VXLAN_ATTR_PROXY) {
334  nl_dump(p, " proxy ");
335  if (vxi->vxi_proxy)
336  nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_proxy);
337  else
338  nl_dump_line(p, "disabled\n");
339  }
340 
341  if (vxi->ce_mask & VXLAN_ATTR_RSC) {
342  nl_dump(p, " rsc ");
343  if (vxi->vxi_rsc)
344  nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_rsc);
345  else
346  nl_dump_line(p, "disabled\n");
347  }
348 
349  if (vxi->ce_mask & VXLAN_ATTR_L2MISS) {
350  nl_dump(p, " l2miss ");
351  if (vxi->vxi_l2miss)
352  nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_l2miss);
353  else
354  nl_dump_line(p, "disabled\n");
355  }
356 
357  if (vxi->ce_mask & VXLAN_ATTR_L3MISS) {
358  nl_dump(p, " l3miss ");
359  if (vxi->vxi_l3miss)
360  nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_l3miss);
361  else
362  nl_dump_line(p, "disabled\n");
363  }
364 }
365 
366 static int vxlan_clone(struct rtnl_link *dst, struct rtnl_link *src)
367 {
368  struct vxlan_info *vdst, *vsrc = src->l_info;
369  int err;
370 
371  dst->l_info = NULL;
372  if ((err = rtnl_link_set_type(dst, "vxlan")) < 0)
373  return err;
374  vdst = dst->l_info;
375 
376  if (!vdst || !vsrc)
377  return -NLE_NOMEM;
378 
379  memcpy(vdst, vsrc, sizeof(struct vxlan_info));
380 
381  return 0;
382 }
383 
384 static int vxlan_put_attrs(struct nl_msg *msg, struct rtnl_link *link)
385 {
386  struct vxlan_info *vxi = link->l_info;
387  struct nlattr *data;
388 
389  if (!(data = nla_nest_start(msg, IFLA_INFO_DATA)))
390  return -NLE_MSGSIZE;
391 
392  if (vxi->ce_mask & VXLAN_ATTR_ID)
393  NLA_PUT_U32(msg, IFLA_VXLAN_ID, vxi->vxi_id);
394 
395  if (vxi->ce_mask & VXLAN_ATTR_GROUP)
396  NLA_PUT(msg, IFLA_VXLAN_GROUP, sizeof(vxi->vxi_group), &vxi->vxi_group);
397 
398  if (vxi->ce_mask & VXLAN_ATTR_GROUP6)
399  NLA_PUT(msg, IFLA_VXLAN_GROUP6, sizeof(vxi->vxi_group6), &vxi->vxi_group6);
400 
401  if (vxi->ce_mask & VXLAN_ATTR_LINK)
402  NLA_PUT_U32(msg, IFLA_VXLAN_LINK, vxi->vxi_link);
403 
404  if (vxi->ce_mask & VXLAN_ATTR_LOCAL)
405  NLA_PUT(msg, IFLA_VXLAN_LOCAL, sizeof(vxi->vxi_local), &vxi->vxi_local);
406 
407  if (vxi->ce_mask & VXLAN_ATTR_LOCAL6)
408  NLA_PUT(msg, IFLA_VXLAN_LOCAL6, sizeof(vxi->vxi_local6), &vxi->vxi_local6);
409 
410  if (vxi->ce_mask & VXLAN_ATTR_TTL)
411  NLA_PUT_U8(msg, IFLA_VXLAN_TTL, vxi->vxi_ttl);
412 
413  if (vxi->ce_mask & VXLAN_ATTR_TOS)
414  NLA_PUT_U8(msg, IFLA_VXLAN_TOS, vxi->vxi_tos);
415 
416  if (vxi->ce_mask & VXLAN_ATTR_LEARNING)
417  NLA_PUT_U8(msg, IFLA_VXLAN_LEARNING, vxi->vxi_learning);
418 
419  if (vxi->ce_mask & VXLAN_ATTR_AGEING)
420  NLA_PUT_U32(msg, IFLA_VXLAN_AGEING, vxi->vxi_ageing);
421 
422  if (vxi->ce_mask & VXLAN_ATTR_LIMIT)
423  NLA_PUT_U32(msg, IFLA_VXLAN_LIMIT, vxi->vxi_limit);
424 
425  if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE)
426  NLA_PUT(msg, IFLA_VXLAN_PORT_RANGE, sizeof(vxi->vxi_port_range),
427  &vxi->vxi_port_range);
428 
429  if (vxi->ce_mask & VXLAN_ATTR_PROXY)
430  NLA_PUT_U8(msg, IFLA_VXLAN_PROXY, vxi->vxi_proxy);
431 
432  if (vxi->ce_mask & VXLAN_ATTR_RSC)
433  NLA_PUT_U8(msg, IFLA_VXLAN_RSC, vxi->vxi_rsc);
434 
435  if (vxi->ce_mask & VXLAN_ATTR_L2MISS)
436  NLA_PUT_U8(msg, IFLA_VXLAN_L2MISS, vxi->vxi_l2miss);
437 
438  if (vxi->ce_mask & VXLAN_ATTR_L3MISS)
439  NLA_PUT_U8(msg, IFLA_VXLAN_L3MISS, vxi->vxi_l3miss);
440 
441  nla_nest_end(msg, data);
442 
443 nla_put_failure:
444 
445  return 0;
446 }
447 
448 static int vxlan_compare(struct rtnl_link *link_a, struct rtnl_link *link_b,
449  int flags)
450 {
451  struct vxlan_info *a = link_a->l_info;
452  struct vxlan_info *b = link_b->l_info;
453  int diff = 0;
454  uint32_t attrs = flags & LOOSE_COMPARISON ? b->ce_mask : ~0;
455 
456 #define VXLAN_DIFF(ATTR, EXPR) ATTR_DIFF(attrs, VXLAN_ATTR_##ATTR, a, b, EXPR)
457 
458  diff |= VXLAN_DIFF(ID, a->vxi_id != b->vxi_id);
459  diff |= VXLAN_DIFF(GROUP, a->vxi_group != b->vxi_group);
460  diff |= VXLAN_DIFF(LINK, a->vxi_link != b->vxi_link);
461  diff |= VXLAN_DIFF(LOCAL, a->vxi_local != b->vxi_local);
462  diff |= VXLAN_DIFF(TOS, a->vxi_tos != b->vxi_tos);
463  diff |= VXLAN_DIFF(TTL, a->vxi_ttl != b->vxi_ttl);
464  diff |= VXLAN_DIFF(LEARNING, a->vxi_learning != b->vxi_learning);
465  diff |= VXLAN_DIFF(AGEING, a->vxi_ageing != b->vxi_ageing);
466  diff |= VXLAN_DIFF(PORT_RANGE,
467  a->vxi_port_range.low != b->vxi_port_range.low);
468  diff |= VXLAN_DIFF(PORT_RANGE,
469  a->vxi_port_range.high != b->vxi_port_range.high);
470  diff |= VXLAN_DIFF(GROUP6, memcmp(&a->vxi_group6, &b->vxi_group6, sizeof(a->vxi_group6)) != 0);
471  diff |= VXLAN_DIFF(LOCAL6, memcmp(&a->vxi_local6, &b->vxi_local6, sizeof(a->vxi_local6)) != 0);
472 #undef VXLAN_DIFF
473 
474  return diff;
475 }
476 
477 static struct rtnl_link_info_ops vxlan_info_ops = {
478  .io_name = "vxlan",
479  .io_alloc = vxlan_alloc,
480  .io_parse = vxlan_parse,
481  .io_dump = {
482  [NL_DUMP_LINE] = vxlan_dump_line,
483  [NL_DUMP_DETAILS] = vxlan_dump_details,
484  },
485  .io_clone = vxlan_clone,
486  .io_put_attrs = vxlan_put_attrs,
487  .io_free = vxlan_free,
488  .io_compare = vxlan_compare,
489 };
490 
491 /** @cond SKIP */
492 #define IS_VXLAN_LINK_ASSERT(link) \
493  if ((link)->l_info_ops != &vxlan_info_ops) { \
494  APPBUG("Link is not a vxlan link. set type \"vxlan\" first."); \
495  return -NLE_OPNOTSUPP; \
496  }
497 /** @endcond */
498 
499 /**
500  * @name VXLAN Object
501  * @{
502  */
503 
504 /**
505  * Allocate link object of type VXLAN
506  *
507  * @return Allocated link object or NULL.
508  */
510 {
511  struct rtnl_link *link;
512  int err;
513 
514  if (!(link = rtnl_link_alloc()))
515  return NULL;
516 
517  if ((err = rtnl_link_set_type(link, "vxlan")) < 0) {
518  rtnl_link_put(link);
519  return NULL;
520  }
521 
522  return link;
523 }
524 
525 /**
526  * Check if link is a VXLAN link
527  * @arg link Link object
528  *
529  * @return True if link is a VXLAN link, otherwise false is returned.
530  */
531 int rtnl_link_is_vxlan(struct rtnl_link *link)
532 {
533  return link->l_info_ops && !strcmp(link->l_info_ops->io_name, "vxlan");
534 }
535 
536 /**
537  * Set VXLAN Network Identifier
538  * @arg link Link object
539  * @arg id VXLAN network identifier (or VXLAN segment identifier)
540  *
541  * @return 0 on success or a negative error code
542  */
543 int rtnl_link_vxlan_set_id(struct rtnl_link *link, uint32_t id)
544 {
545  struct vxlan_info *vxi = link->l_info;
546 
547  IS_VXLAN_LINK_ASSERT(link);
548 
549  if (id > VXLAN_ID_MAX)
550  return -NLE_INVAL;
551 
552  vxi->vxi_id = id;
553  vxi->ce_mask |= VXLAN_ATTR_ID;
554 
555  return 0;
556 }
557 
558 /**
559  * Get VXLAN Network Identifier
560  * @arg link Link object
561  * @arg id Pointer to store network identifier
562  *
563  * @return 0 on success or a negative error code
564  */
565 int rtnl_link_vxlan_get_id(struct rtnl_link *link, uint32_t *id)
566 {
567  struct vxlan_info *vxi = link->l_info;
568 
569  IS_VXLAN_LINK_ASSERT(link);
570 
571  if(!id)
572  return -NLE_INVAL;
573 
574  if (vxi->ce_mask & VXLAN_ATTR_ID)
575  *id = vxi->vxi_id;
576  else
577  return -NLE_AGAIN;
578 
579  return 0;
580 }
581 
582 /**
583  * Set VXLAN multicast IP address
584  * @arg link Link object
585  * @arg addr Multicast IP address to join
586  *
587  * @return 0 on success or a negative error code
588  */
589 int rtnl_link_vxlan_set_group(struct rtnl_link *link, struct nl_addr *addr)
590 {
591  struct vxlan_info *vxi = link->l_info;
592 
593  IS_VXLAN_LINK_ASSERT(link);
594 
595  if ((nl_addr_get_family(addr) == AF_INET) &&
596  (nl_addr_get_len(addr) == sizeof(vxi->vxi_group))) {
597  memcpy(&vxi->vxi_group, nl_addr_get_binary_addr(addr),
598  sizeof(vxi->vxi_group));
599  vxi->ce_mask |= VXLAN_ATTR_GROUP;
600  vxi->ce_mask &= ~VXLAN_ATTR_GROUP6;
601  } else if ((nl_addr_get_family(addr) == AF_INET6) &&
602  (nl_addr_get_len(addr) == sizeof(vxi->vxi_group6))) {
603  memcpy(&vxi->vxi_group6, nl_addr_get_binary_addr(addr),
604  sizeof(vxi->vxi_group6));
605  vxi->ce_mask |= VXLAN_ATTR_GROUP6;
606  vxi->ce_mask &= ~VXLAN_ATTR_GROUP;
607  } else
608  return -NLE_INVAL;
609 
610  return 0;
611 }
612 
613 /**
614  * Get VXLAN multicast IP address
615  * @arg link Link object
616  * @arg addr Pointer to store multicast IP address
617  *
618  * @return 0 on success or a negative error code
619  */
620 int rtnl_link_vxlan_get_group(struct rtnl_link *link, struct nl_addr **addr)
621 {
622  struct vxlan_info *vxi = link->l_info;
623 
624  IS_VXLAN_LINK_ASSERT(link);
625 
626  if (!addr)
627  return -NLE_INVAL;
628 
629  if (vxi->ce_mask & VXLAN_ATTR_GROUP)
630  *addr = nl_addr_build(AF_INET, &vxi->vxi_group, sizeof(vxi->vxi_group));
631  else if (vxi->ce_mask & VXLAN_ATTR_GROUP6)
632  *addr = nl_addr_build(AF_INET6, &vxi->vxi_group6, sizeof(vxi->vxi_group6));
633  else
634  return -NLE_AGAIN;
635 
636  return 0;
637 }
638 
639 /**
640  * Set physical device to use for VXLAN
641  * @arg link Link object
642  * @arg index Interface index
643  *
644  * @return 0 on success or a negative error code
645  */
646 int rtnl_link_vxlan_set_link(struct rtnl_link *link, uint32_t index)
647 {
648  struct vxlan_info *vxi = link->l_info;
649 
650  IS_VXLAN_LINK_ASSERT(link);
651 
652  vxi->vxi_link = index;
653  vxi->ce_mask |= VXLAN_ATTR_LINK;
654 
655  return 0;
656 }
657 
658 /**
659  * Get physical device to use for VXLAN
660  * @arg link Link object
661  * @arg index Pointer to store interface index
662  *
663  * @return 0 on success or a negative error code
664  */
665 int rtnl_link_vxlan_get_link(struct rtnl_link *link, uint32_t *index)
666 {
667  struct vxlan_info *vxi = link->l_info;
668 
669  IS_VXLAN_LINK_ASSERT(link);
670 
671  if (!index)
672  return -NLE_INVAL;
673 
674  if (!(vxi->ce_mask & VXLAN_ATTR_LINK))
675  return -NLE_AGAIN;
676 
677  *index = vxi->vxi_link;
678 
679  return 0;
680 }
681 
682 /**
683  * Set source address to use for VXLAN
684  * @arg link Link object
685  * @arg addr Local address
686  *
687  * @return 0 on success or a negative error code
688  */
689 int rtnl_link_vxlan_set_local(struct rtnl_link *link, struct nl_addr *addr)
690 {
691  struct vxlan_info *vxi = link->l_info;
692 
693  IS_VXLAN_LINK_ASSERT(link);
694 
695  if ((nl_addr_get_family(addr) == AF_INET) &&
696  (nl_addr_get_len(addr) == sizeof(vxi->vxi_local))) {
697  memcpy(&vxi->vxi_local, nl_addr_get_binary_addr(addr),
698  sizeof(vxi->vxi_local));
699  vxi->ce_mask |= VXLAN_ATTR_LOCAL;
700  vxi->ce_mask &= VXLAN_ATTR_LOCAL6;
701  } else if ((nl_addr_get_family(addr) == AF_INET6) &&
702  (nl_addr_get_len(addr) == sizeof(vxi->vxi_local6))) {
703  memcpy(&vxi->vxi_local6, nl_addr_get_binary_addr(addr),
704  sizeof(vxi->vxi_local6));
705  vxi->ce_mask |= VXLAN_ATTR_LOCAL6;
706  vxi->ce_mask &= ~VXLAN_ATTR_LOCAL;
707  } else
708  return -NLE_INVAL;
709 
710  return 0;
711 }
712 
713 /**
714  * Get source address to use for VXLAN
715  * @arg link Link object
716  * @arg addr Pointer to store local address
717  *
718  * @return 0 on success or a negative error code
719  */
720 int rtnl_link_vxlan_get_local(struct rtnl_link *link, struct nl_addr **addr)
721 {
722  struct vxlan_info *vxi = link->l_info;
723 
724  IS_VXLAN_LINK_ASSERT(link);
725 
726  if (!addr)
727  return -NLE_INVAL;
728 
729  if (vxi->ce_mask & VXLAN_ATTR_LOCAL)
730  *addr = nl_addr_build(AF_INET, &vxi->vxi_local, sizeof(vxi->vxi_local));
731  else if (vxi->ce_mask & VXLAN_ATTR_LOCAL6)
732  *addr = nl_addr_build(AF_INET6, &vxi->vxi_local6, sizeof(vxi->vxi_local6));
733  else
734  return -NLE_AGAIN;
735 
736  return 0;
737 }
738 
739 /**
740  * Set IP TTL value to use for VXLAN
741  * @arg link Link object
742  * @arg ttl TTL value
743  *
744  * @return 0 on success or a negative error code
745  */
746 int rtnl_link_vxlan_set_ttl(struct rtnl_link *link, uint8_t ttl)
747 {
748  struct vxlan_info *vxi = link->l_info;
749 
750  IS_VXLAN_LINK_ASSERT(link);
751 
752  vxi->vxi_ttl = ttl;
753  vxi->ce_mask |= VXLAN_ATTR_TTL;
754 
755  return 0;
756 }
757 
758 /**
759  * Get IP TTL value to use for VXLAN
760  * @arg link Link object
761  *
762  * @return TTL value on success or a negative error code
763  */
765 {
766  struct vxlan_info *vxi = link->l_info;
767 
768  IS_VXLAN_LINK_ASSERT(link);
769 
770  if (!(vxi->ce_mask & VXLAN_ATTR_TTL))
771  return -NLE_AGAIN;
772 
773  return vxi->vxi_ttl;
774 }
775 
776 /**
777  * Set IP ToS value to use for VXLAN
778  * @arg link Link object
779  * @arg tos ToS value
780  *
781  * @return 0 on success or a negative error code
782  */
783 int rtnl_link_vxlan_set_tos(struct rtnl_link *link, uint8_t tos)
784 {
785  struct vxlan_info *vxi = link->l_info;
786 
787  IS_VXLAN_LINK_ASSERT(link);
788 
789  vxi->vxi_tos = tos;
790  vxi->ce_mask |= VXLAN_ATTR_TOS;
791 
792  return 0;
793 }
794 
795 /**
796  * Get IP ToS value to use for VXLAN
797  * @arg link Link object
798  *
799  * @return ToS value on success or a negative error code
800  */
802 {
803  struct vxlan_info *vxi = link->l_info;
804 
805  IS_VXLAN_LINK_ASSERT(link);
806 
807  if (!(vxi->ce_mask & VXLAN_ATTR_TOS))
808  return -NLE_AGAIN;
809 
810  return vxi->vxi_tos;
811 }
812 
813 /**
814  * Set VXLAN learning status
815  * @arg link Link object
816  * @arg learning Learning status value
817  *
818  * @return 0 on success or a negative error code
819  */
820 int rtnl_link_vxlan_set_learning(struct rtnl_link *link, uint8_t learning)
821 {
822  struct vxlan_info *vxi = link->l_info;
823 
824  IS_VXLAN_LINK_ASSERT(link);
825 
826  vxi->vxi_learning = learning;
827  vxi->ce_mask |= VXLAN_ATTR_LEARNING;
828 
829  return 0;
830 }
831 
832 /**
833  * Get VXLAN learning status
834  * @arg link Link object
835  *
836  * @return Learning status value on success or a negative error code
837  */
839 {
840  struct vxlan_info *vxi = link->l_info;
841 
842  IS_VXLAN_LINK_ASSERT(link);
843 
844  if (!(vxi->ce_mask & VXLAN_ATTR_LEARNING))
845  return -NLE_AGAIN;
846 
847  return vxi->vxi_learning;
848 }
849 
850 /**
851  * Enable VXLAN address learning
852  * @arg link Link object
853  *
854  * @return 0 on success or a negative error code
855  */
857 {
858  return rtnl_link_vxlan_set_learning(link, 1);
859 }
860 
861 /**
862  * Disable VXLAN address learning
863  * @arg link Link object
864  *
865  * @return 0 on success or a negative error code
866  */
868 {
869  return rtnl_link_vxlan_set_learning(link, 0);
870 }
871 
872 /**
873  * Set expiration timer value to use for VXLAN
874  * @arg link Link object
875  * @arg expiry Expiration timer value
876  *
877  * @return 0 on success or a negative error code
878  */
879 int rtnl_link_vxlan_set_ageing(struct rtnl_link *link, uint32_t expiry)
880 {
881  struct vxlan_info *vxi = link->l_info;
882 
883  IS_VXLAN_LINK_ASSERT(link);
884 
885  vxi->vxi_ageing = expiry;
886  vxi->ce_mask |= VXLAN_ATTR_AGEING;
887 
888  return 0;
889 }
890 
891 /**
892  * Get expiration timer value to use for VXLAN
893  * @arg link Link object
894  * @arg expiry Pointer to store expiration timer value
895  *
896  * @return 0 on success or a negative error code
897  */
898 int rtnl_link_vxlan_get_ageing(struct rtnl_link *link, uint32_t *expiry)
899 {
900  struct vxlan_info *vxi = link->l_info;
901 
902  IS_VXLAN_LINK_ASSERT(link);
903 
904  if (!expiry)
905  return -NLE_INVAL;
906 
907  if (vxi->ce_mask & VXLAN_ATTR_AGEING)
908  *expiry = vxi->vxi_ageing;
909  else
910  return -NLE_AGAIN;
911 
912  return 0;
913 }
914 
915 /**
916  * Set maximum number of forwarding database entries to use for VXLAN
917  * @arg link Link object
918  * @arg limit Maximum number
919  *
920  * @return 0 on success or a negative error code
921  */
922 int rtnl_link_vxlan_set_limit(struct rtnl_link *link, uint32_t limit)
923 {
924  struct vxlan_info *vxi = link->l_info;
925 
926  IS_VXLAN_LINK_ASSERT(link);
927 
928  vxi->vxi_limit = limit;
929  vxi->ce_mask |= VXLAN_ATTR_LIMIT;
930 
931  return 0;
932 }
933 
934 /**
935  * Get maximum number of forwarding database entries to use for VXLAN
936  * @arg link Link object
937  * @arg limit Pointer to store maximum number
938  *
939  * @return 0 on success or a negative error code
940  */
941 int rtnl_link_vxlan_get_limit(struct rtnl_link *link, uint32_t *limit)
942 {
943  struct vxlan_info *vxi = link->l_info;
944 
945  IS_VXLAN_LINK_ASSERT(link);
946 
947  if (!limit)
948  return -NLE_INVAL;
949 
950  if (vxi->ce_mask & VXLAN_ATTR_LIMIT)
951  *limit = vxi->vxi_limit;
952  else
953  return -NLE_AGAIN;
954 
955  return 0;
956 }
957 
958 /**
959  * Set range of UDP port numbers to use for VXLAN
960  * @arg link Link object
961  * @arg range Port number range
962  *
963  * @return 0 on success or a negative error code
964  */
966  struct ifla_vxlan_port_range *range)
967 {
968  struct vxlan_info *vxi = link->l_info;
969 
970  IS_VXLAN_LINK_ASSERT(link);
971 
972  if (!range)
973  return -NLE_INVAL;
974 
975  memcpy(&vxi->vxi_port_range, range, sizeof(vxi->vxi_port_range));
976  vxi->ce_mask |= VXLAN_ATTR_PORT_RANGE;
977 
978  return 0;
979 }
980 
981 /**
982  * Get range of UDP port numbers to use for VXLAN
983  * @arg link Link object
984  * @arg range Pointer to store port range
985  *
986  * @return 0 on success or a negative error code
987  */
989  struct ifla_vxlan_port_range *range)
990 {
991  struct vxlan_info *vxi = link->l_info;
992 
993  IS_VXLAN_LINK_ASSERT(link);
994 
995  if (!range)
996  return -NLE_INVAL;
997 
998  if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE)
999  memcpy(range, &vxi->vxi_port_range, sizeof(*range));
1000  else
1001  return -NLE_AGAIN;
1002 
1003  return 0;
1004 }
1005 
1006 /**
1007  * Set ARP proxy status to use for VXLAN
1008  * @arg link Link object
1009  * @arg proxy Status value
1010  *
1011  * @return 0 on success or a negative error code
1012  */
1013 int rtnl_link_vxlan_set_proxy(struct rtnl_link *link, uint8_t proxy)
1014 {
1015  struct vxlan_info *vxi = link->l_info;
1016 
1017  IS_VXLAN_LINK_ASSERT(link);
1018 
1019  vxi->vxi_proxy = proxy;
1020  vxi->ce_mask |= VXLAN_ATTR_PROXY;
1021 
1022  return 0;
1023 }
1024 
1025 /**
1026  * Get ARP proxy status to use for VXLAN
1027  * @arg link Link object
1028  *
1029  * @return Status value on success or a negative error code
1030  */
1032 {
1033  struct vxlan_info *vxi = link->l_info;
1034 
1035  IS_VXLAN_LINK_ASSERT(link);
1036 
1037  if (!(vxi->ce_mask & VXLAN_ATTR_PROXY))
1038  return -NLE_AGAIN;
1039 
1040  return vxi->vxi_proxy;
1041 }
1042 
1043 /**
1044  * Enable ARP proxy
1045  * @arg link Link object
1046  *
1047  * @return 0 on success or a negative error code
1048  */
1050 {
1051  return rtnl_link_vxlan_set_proxy(link, 1);
1052 }
1053 
1054 /**
1055  * Disable ARP proxy
1056  * @arg link Link object
1057  *
1058  * @return 0 on success or a negative error code
1059  */
1061 {
1062  return rtnl_link_vxlan_set_proxy(link, 0);
1063 }
1064 
1065 /**
1066  * Set Route Short Circuit status to use for VXLAN
1067  * @arg link Link object
1068  * @arg rsc Status value
1069  *
1070  * @return 0 on success or a negative error code
1071  */
1072 int rtnl_link_vxlan_set_rsc(struct rtnl_link *link, uint8_t rsc)
1073 {
1074  struct vxlan_info *vxi = link->l_info;
1075 
1076  IS_VXLAN_LINK_ASSERT(link);
1077 
1078  vxi->vxi_rsc = rsc;
1079  vxi->ce_mask |= VXLAN_ATTR_RSC;
1080 
1081  return 0;
1082 }
1083 
1084 /**
1085  * Get Route Short Circuit status to use for VXLAN
1086  * @arg link Link object
1087  *
1088  * @return Status value on success or a negative error code
1089  */
1091 {
1092  struct vxlan_info *vxi = link->l_info;
1093 
1094  IS_VXLAN_LINK_ASSERT(link);
1095 
1096  if (!(vxi->ce_mask & VXLAN_ATTR_RSC))
1097  return -NLE_AGAIN;
1098 
1099  return vxi->vxi_rsc;
1100 }
1101 
1102 /**
1103  * Enable Route Short Circuit
1104  * @arg link Link object
1105  *
1106  * @return 0 on success or a negative error code
1107  */
1109 {
1110  return rtnl_link_vxlan_set_rsc(link, 1);
1111 }
1112 
1113 /**
1114  * Disable Route Short Circuit
1115  * @arg link Link object
1116  *
1117  * @return 0 on success or a negative error code
1118  */
1120 {
1121  return rtnl_link_vxlan_set_rsc(link, 0);
1122 }
1123 
1124 /**
1125  * Set netlink LLADDR miss notification status to use for VXLAN
1126  * @arg link Link object
1127  * @arg miss Status value
1128  *
1129  * @return 0 on success or a negative error code
1130  */
1131 int rtnl_link_vxlan_set_l2miss(struct rtnl_link *link, uint8_t miss)
1132 {
1133  struct vxlan_info *vxi = link->l_info;
1134 
1135  IS_VXLAN_LINK_ASSERT(link);
1136 
1137  vxi->vxi_l2miss = miss;
1138  vxi->ce_mask |= VXLAN_ATTR_L2MISS;
1139 
1140  return 0;
1141 }
1142 
1143 /**
1144  * Get netlink LLADDR miss notification status to use for VXLAN
1145  * @arg link Link object
1146  *
1147  * @return Status value on success or a negative error code
1148  */
1150 {
1151  struct vxlan_info *vxi = link->l_info;
1152 
1153  IS_VXLAN_LINK_ASSERT(link);
1154 
1155  if (!(vxi->ce_mask & VXLAN_ATTR_L2MISS))
1156  return -NLE_AGAIN;
1157 
1158  return vxi->vxi_l2miss;
1159 }
1160 
1161 /**
1162  * Enable netlink LLADDR miss notifications
1163  * @arg link Link object
1164  *
1165  * @return 0 on success or a negative error code
1166  */
1168 {
1169  return rtnl_link_vxlan_set_l2miss(link, 1);
1170 }
1171 
1172 /**
1173  * Disable netlink LLADDR miss notifications
1174  * @arg link Link object
1175  *
1176  * @return 0 on success or a negative error code
1177  */
1179 {
1180  return rtnl_link_vxlan_set_l2miss(link, 0);
1181 }
1182 
1183 /**
1184  * Set netlink IP ADDR miss notification status to use for VXLAN
1185  * @arg link Link object
1186  * @arg miss Status value
1187  *
1188  * @return 0 on success or a negative error code
1189  */
1190 int rtnl_link_vxlan_set_l3miss(struct rtnl_link *link, uint8_t miss)
1191 {
1192  struct vxlan_info *vxi = link->l_info;
1193 
1194  IS_VXLAN_LINK_ASSERT(link);
1195 
1196  vxi->vxi_l3miss = miss;
1197  vxi->ce_mask |= VXLAN_ATTR_L3MISS;
1198 
1199  return 0;
1200 }
1201 
1202 /**
1203  * Get netlink IP ADDR miss notification status to use for VXLAN
1204  * @arg link Link object
1205  *
1206  * @return Status value on success or a negative error code
1207  */
1209 {
1210  struct vxlan_info *vxi = link->l_info;
1211 
1212  IS_VXLAN_LINK_ASSERT(link);
1213 
1214  if (!(vxi->ce_mask & VXLAN_ATTR_L3MISS))
1215  return -NLE_AGAIN;
1216 
1217  return vxi->vxi_l3miss;
1218 }
1219 
1220 /**
1221  * Enable netlink IP DDR miss notifications
1222  * @arg link Link object
1223  *
1224  * @return 0 on success or a negative error code
1225  */
1227 {
1228  return rtnl_link_vxlan_set_l3miss(link, 1);
1229 }
1230 
1231 /**
1232  * Disable netlink IP ADDR miss notifications
1233  * @arg link Link object
1234  *
1235  * @return 0 on success or a negative error code
1236  */
1238 {
1239  return rtnl_link_vxlan_set_l3miss(link, 0);
1240 }
1241 
1242 /** @} */
1243 
1244 static void __init vxlan_init(void)
1245 {
1246  rtnl_link_register_info(&vxlan_info_ops);
1247 }
1248 
1249 static void __exit vxlan_exit(void)
1250 {
1251  rtnl_link_unregister_info(&vxlan_info_ops);
1252 }
1253 
1254 /** @} */
Dump object briefly on one line.
Definition: types.h:22
8 bit integer
Definition: attr.h:39
int rtnl_link_vxlan_disable_rsc(struct rtnl_link *link)
Disable Route Short Circuit.
Definition: vxlan.c:1119
int rtnl_link_vxlan_set_proxy(struct rtnl_link *link, uint8_t proxy)
Set ARP proxy status to use for VXLAN.
Definition: vxlan.c:1013
Attribute validation policy.
Definition: attr.h:67
uint8_t nla_get_u8(const struct nlattr *nla)
Return value of 8 bit integer attribute.
Definition: attr.c:599
int rtnl_link_vxlan_enable_l3miss(struct rtnl_link *link)
Enable netlink IP DDR miss notifications.
Definition: vxlan.c:1226
int rtnl_link_vxlan_get_id(struct rtnl_link *link, uint32_t *id)
Get VXLAN Network Identifier.
Definition: vxlan.c:565
struct nl_addr * nl_addr_build(int family, const void *buf, size_t size)
Allocate abstract address based on a binary address.
Definition: addr.c:216
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
Definition: attr.c:699
int rtnl_link_vxlan_set_tos(struct rtnl_link *link, uint8_t tos)
Set IP ToS value to use for VXLAN.
Definition: vxlan.c:783
int rtnl_link_vxlan_disable_l3miss(struct rtnl_link *link)
Disable netlink IP ADDR miss notifications.
Definition: vxlan.c:1237
int rtnl_link_vxlan_set_local(struct rtnl_link *link, struct nl_addr *addr)
Set source address to use for VXLAN.
Definition: vxlan.c:689
int rtnl_link_vxlan_get_rsc(struct rtnl_link *link)
Get Route Short Circuit status to use for VXLAN.
Definition: vxlan.c:1090
#define NLA_PUT_U8(msg, attrtype, value)
Add 8 bit integer attribute to netlink message.
Definition: attr.h:197
int rtnl_link_vxlan_enable_l2miss(struct rtnl_link *link)
Enable netlink LLADDR miss notifications.
Definition: vxlan.c:1167
int rtnl_link_vxlan_set_ttl(struct rtnl_link *link, uint8_t ttl)
Set IP TTL value to use for VXLAN.
Definition: vxlan.c:746
Dump all attributes but no statistics.
Definition: types.h:23
int rtnl_link_vxlan_enable_learning(struct rtnl_link *link)
Enable VXLAN address learning.
Definition: vxlan.c:856
int rtnl_link_vxlan_set_rsc(struct rtnl_link *link, uint8_t rsc)
Set Route Short Circuit status to use for VXLAN.
Definition: vxlan.c:1072
int rtnl_link_vxlan_set_l3miss(struct rtnl_link *link, uint8_t miss)
Set netlink IP ADDR miss notification status to use for VXLAN.
Definition: vxlan.c:1190
int rtnl_link_vxlan_get_limit(struct rtnl_link *link, uint32_t *limit)
Get maximum number of forwarding database entries to use for VXLAN.
Definition: vxlan.c:941
int rtnl_link_vxlan_get_group(struct rtnl_link *link, struct nl_addr **addr)
Get VXLAN multicast IP address.
Definition: vxlan.c:620
int rtnl_link_vxlan_set_learning(struct rtnl_link *link, uint8_t learning)
Set VXLAN learning status.
Definition: vxlan.c:820
int nla_nest_end(struct nl_msg *msg, struct nlattr *start)
Finalize nesting of attributes.
Definition: attr.c:917
int rtnl_link_vxlan_get_local(struct rtnl_link *link, struct nl_addr **addr)
Get source address to use for VXLAN.
Definition: vxlan.c:720
int rtnl_link_vxlan_get_learning(struct rtnl_link *link)
Get VXLAN learning status.
Definition: vxlan.c:838
int rtnl_link_vxlan_get_l3miss(struct rtnl_link *link)
Get netlink IP ADDR miss notification status to use for VXLAN.
Definition: vxlan.c:1208
int rtnl_link_vxlan_set_l2miss(struct rtnl_link *link, uint8_t miss)
Set netlink LLADDR miss notification status to use for VXLAN.
Definition: vxlan.c:1131
int nla_memcpy(void *dest, const struct nlattr *src, int count)
Copy attribute payload to another memory area.
Definition: attr.c:353
#define NLA_PUT(msg, attrtype, attrlen, data)
Add unspecific attribute to netlink message.
Definition: attr.h:162
int rtnl_link_vxlan_get_link(struct rtnl_link *link, uint32_t *index)
Get physical device to use for VXLAN.
Definition: vxlan.c:665
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, struct nla_policy *policy)
Create attribute index based on nested attribute.
Definition: attr.c:992
int rtnl_link_vxlan_get_tos(struct rtnl_link *link)
Get IP ToS value to use for VXLAN.
Definition: vxlan.c:801
int rtnl_link_vxlan_disable_learning(struct rtnl_link *link)
Disable VXLAN address learning.
Definition: vxlan.c:867
#define NLA_PUT_U32(msg, attrtype, value)
Add 32 bit integer attribute to netlink message.
Definition: attr.h:233
int rtnl_link_vxlan_disable_l2miss(struct rtnl_link *link)
Disable netlink LLADDR miss notifications.
Definition: vxlan.c:1178
int rtnl_link_vxlan_get_l2miss(struct rtnl_link *link)
Get netlink LLADDR miss notification status to use for VXLAN.
Definition: vxlan.c:1149
int rtnl_link_vxlan_enable_rsc(struct rtnl_link *link)
Enable Route Short Circuit.
Definition: vxlan.c:1108
uint16_t type
Type of attribute or NLA_UNSPEC.
Definition: attr.h:69
32 bit integer
Definition: attr.h:41
int rtnl_link_is_vxlan(struct rtnl_link *link)
Check if link is a VXLAN link.
Definition: vxlan.c:531
int rtnl_link_vxlan_get_ageing(struct rtnl_link *link, uint32_t *expiry)
Get expiration timer value to use for VXLAN.
Definition: vxlan.c:898
int rtnl_link_vxlan_set_id(struct rtnl_link *link, uint32_t id)
Set VXLAN Network Identifier.
Definition: vxlan.c:543
Dumping parameters.
Definition: types.h:33
struct rtnl_link * rtnl_link_vxlan_alloc(void)
Allocate link object of type VXLAN.
Definition: vxlan.c:509
int rtnl_link_vxlan_get_proxy(struct rtnl_link *link)
Get ARP proxy status to use for VXLAN.
Definition: vxlan.c:1031
int rtnl_link_vxlan_get_port_range(struct rtnl_link *link, struct ifla_vxlan_port_range *range)
Get range of UDP port numbers to use for VXLAN.
Definition: vxlan.c:988
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
Definition: utils.c:914
int rtnl_link_vxlan_disable_proxy(struct rtnl_link *link)
Disable ARP proxy.
Definition: vxlan.c:1060
int rtnl_link_vxlan_set_group(struct rtnl_link *link, struct nl_addr *addr)
Set VXLAN multicast IP address.
Definition: vxlan.c:589
unsigned int nl_addr_get_len(const struct nl_addr *addr)
Get length of binary address of abstract address object.
Definition: addr.c:905
int rtnl_link_vxlan_get_ttl(struct rtnl_link *link)
Get IP TTL value to use for VXLAN.
Definition: vxlan.c:764
void * nl_addr_get_binary_addr(const struct nl_addr *addr)
Get binary address of abstract address object.
Definition: addr.c:893
int rtnl_link_vxlan_set_limit(struct rtnl_link *link, uint32_t limit)
Set maximum number of forwarding database entries to use for VXLAN.
Definition: vxlan.c:922
int rtnl_link_vxlan_set_ageing(struct rtnl_link *link, uint32_t expiry)
Set expiration timer value to use for VXLAN.
Definition: vxlan.c:879
struct nlattr * nla_nest_start(struct nl_msg *msg, int attrtype)
Start a new level of nested attributes.
Definition: attr.c:895
int rtnl_link_vxlan_enable_proxy(struct rtnl_link *link)
Enable ARP proxy.
Definition: vxlan.c:1049
int rtnl_link_vxlan_set_port_range(struct rtnl_link *link, struct ifla_vxlan_port_range *range)
Set range of UDP port numbers to use for VXLAN.
Definition: vxlan.c:965
int rtnl_link_vxlan_set_link(struct rtnl_link *link, uint32_t index)
Set physical device to use for VXLAN.
Definition: vxlan.c:646
int nl_addr_get_family(const struct nl_addr *addr)
Return address family.
Definition: addr.c:845