libnl 3.9.0
vxlan.c
1/* SPDX-License-Identifier: LGPL-2.1-only */
2/*
3 * Copyright (c) 2013 Yasunobu Chiba <yasu@dsl.gr.jp>
4 */
5
6/**
7 * @ingroup link
8 * @defgroup vxlan VXLAN
9 * Virtual eXtensible Local Area Network link module
10 *
11 * @details
12 * \b Link Type Name: "vxlan"
13 *
14 * @route_doc{link_vxlan, VXLAN Documentation}
15 *
16 * @{
17 */
18
19#include "nl-default.h"
20
21#include <linux/if_link.h>
22
23#include <netlink/netlink.h>
24#include <netlink/attr.h>
25#include <netlink/utils.h>
26#include <netlink/object.h>
27#include <netlink/route/rtnl.h>
28#include <netlink/route/link/vxlan.h>
29
30#include "nl-route.h"
31#include "link-api.h"
32
33/** @cond SKIP */
34#define VXLAN_ATTR_ID (1<<0)
35#define VXLAN_ATTR_GROUP (1<<1)
36#define VXLAN_ATTR_LINK (1<<2)
37#define VXLAN_ATTR_LOCAL (1<<3)
38#define VXLAN_ATTR_TTL (1<<4)
39#define VXLAN_ATTR_TOS (1<<5)
40#define VXLAN_ATTR_LEARNING (1<<6)
41#define VXLAN_ATTR_AGEING (1<<7)
42#define VXLAN_ATTR_LIMIT (1<<8)
43#define VXLAN_ATTR_PORT_RANGE (1<<9)
44#define VXLAN_ATTR_PROXY (1<<10)
45#define VXLAN_ATTR_RSC (1<<11)
46#define VXLAN_ATTR_L2MISS (1<<12)
47#define VXLAN_ATTR_L3MISS (1<<13)
48#define VXLAN_ATTR_GROUP6 (1<<14)
49#define VXLAN_ATTR_LOCAL6 (1<<15)
50#define VXLAN_ATTR_PORT (1<<16)
51#define VXLAN_ATTR_UDP_CSUM (1<<17)
52#define VXLAN_ATTR_UDP_ZERO_CSUM6_TX (1<<18)
53#define VXLAN_ATTR_UDP_ZERO_CSUM6_RX (1<<19)
54#define VXLAN_ATTR_REMCSUM_TX (1<<20)
55#define VXLAN_ATTR_REMCSUM_RX (1<<21)
56#define VXLAN_ATTR_COLLECT_METADATA (1<<22)
57#define VXLAN_ATTR_LABEL (1<<23)
58#define VXLAN_ATTR_FLAGS (1<<24)
59
60struct vxlan_info
61{
62 uint32_t vxi_id;
63 uint32_t vxi_group;
64 struct in6_addr vxi_group6;
65 uint32_t vxi_link;
66 uint32_t vxi_local;
67 struct in6_addr vxi_local6;
68 uint8_t vxi_ttl;
69 uint8_t vxi_tos;
70 uint8_t vxi_learning;
71 uint8_t vxi_flags;
72 uint32_t vxi_ageing;
73 uint32_t vxi_limit;
74 struct ifla_vxlan_port_range vxi_port_range;
75 uint8_t vxi_proxy;
76 uint8_t vxi_rsc;
77 uint8_t vxi_l2miss;
78 uint8_t vxi_l3miss;
79 uint16_t vxi_port;
80 uint8_t vxi_udp_csum;
81 uint8_t vxi_udp_zero_csum6_tx;
82 uint8_t vxi_udp_zero_csum6_rx;
83 uint8_t vxi_remcsum_tx;
84 uint8_t vxi_remcsum_rx;
85 uint8_t vxi_collect_metadata;
86 uint32_t vxi_label;
87 uint32_t ce_mask;
88};
89
90/** @endcond */
91
92static struct nla_policy vxlan_policy[IFLA_VXLAN_MAX+1] = {
93 [IFLA_VXLAN_ID] = { .type = NLA_U32 },
94 [IFLA_VXLAN_GROUP] = { .minlen = sizeof(uint32_t) },
95 [IFLA_VXLAN_GROUP6] = { .minlen = sizeof(struct in6_addr) },
96 [IFLA_VXLAN_LINK] = { .type = NLA_U32 },
97 [IFLA_VXLAN_LOCAL] = { .minlen = sizeof(uint32_t) },
98 [IFLA_VXLAN_LOCAL6] = { .minlen = sizeof(struct in6_addr) },
99 [IFLA_VXLAN_TTL] = { .type = NLA_U8 },
100 [IFLA_VXLAN_TOS] = { .type = NLA_U8 },
101 [IFLA_VXLAN_LABEL] = { .type = NLA_U32 },
102 [IFLA_VXLAN_LEARNING] = { .type = NLA_U8 },
103 [IFLA_VXLAN_AGEING] = { .type = NLA_U32 },
104 [IFLA_VXLAN_LIMIT] = { .type = NLA_U32 },
105 [IFLA_VXLAN_PORT_RANGE] = { .minlen = sizeof(struct ifla_vxlan_port_range) },
106 [IFLA_VXLAN_PROXY] = { .type = NLA_U8 },
107 [IFLA_VXLAN_RSC] = { .type = NLA_U8 },
108 [IFLA_VXLAN_L2MISS] = { .type = NLA_U8 },
109 [IFLA_VXLAN_L3MISS] = { .type = NLA_U8 },
110 [IFLA_VXLAN_COLLECT_METADATA] = { .type = NLA_U8 },
111 [IFLA_VXLAN_PORT] = { .type = NLA_U16 },
112 [IFLA_VXLAN_UDP_CSUM] = { .type = NLA_U8 },
113 [IFLA_VXLAN_UDP_ZERO_CSUM6_TX] = { .type = NLA_U8 },
114 [IFLA_VXLAN_UDP_ZERO_CSUM6_RX] = { .type = NLA_U8 },
115 [IFLA_VXLAN_REMCSUM_TX] = { .type = NLA_U8 },
116 [IFLA_VXLAN_REMCSUM_RX] = { .type = NLA_U8 },
117 [IFLA_VXLAN_GBP] = { .type = NLA_FLAG, },
118 [IFLA_VXLAN_GPE] = { .type = NLA_FLAG, },
119 [IFLA_VXLAN_REMCSUM_NOPARTIAL] = { .type = NLA_FLAG },
120};
121
122static int vxlan_alloc(struct rtnl_link *link)
123{
124 struct vxlan_info *vxi;
125
126 if (link->l_info)
127 memset(link->l_info, 0, sizeof(*vxi));
128 else {
129 if ((vxi = calloc(1, sizeof(*vxi))) == NULL)
130 return -NLE_NOMEM;
131
132 link->l_info = vxi;
133 }
134
135 return 0;
136}
137
138static int vxlan_parse(struct rtnl_link *link, struct nlattr *data,
139 struct nlattr *xstats)
140{
141 struct nlattr *tb[IFLA_VXLAN_MAX+1];
142 struct vxlan_info *vxi;
143 int err;
144
145 NL_DBG(3, "Parsing VXLAN link info\n");
146
147 if ((err = nla_parse_nested(tb, IFLA_VXLAN_MAX, data, vxlan_policy)) < 0)
148 goto errout;
149
150 if ((err = vxlan_alloc(link)) < 0)
151 goto errout;
152
153 vxi = link->l_info;
154
155 if (tb[IFLA_VXLAN_ID]) {
156 vxi->vxi_id = nla_get_u32(tb[IFLA_VXLAN_ID]);
157 vxi->ce_mask |= VXLAN_ATTR_ID;
158 }
159
160 if (tb[IFLA_VXLAN_GROUP6]) {
161 nla_memcpy(&vxi->vxi_group6, tb[IFLA_VXLAN_GROUP6],
162 sizeof(vxi->vxi_group6));
163 vxi->ce_mask |= VXLAN_ATTR_GROUP6;
164 }
165
166 if (tb[IFLA_VXLAN_GROUP]) {
167 nla_memcpy(&vxi->vxi_group, tb[IFLA_VXLAN_GROUP],
168 sizeof(vxi->vxi_group));
169 vxi->ce_mask |= VXLAN_ATTR_GROUP;
170 vxi->ce_mask &= ~VXLAN_ATTR_GROUP6;
171 }
172
173 if (tb[IFLA_VXLAN_LINK]) {
174 vxi->vxi_link = nla_get_u32(tb[IFLA_VXLAN_LINK]);
175 vxi->ce_mask |= VXLAN_ATTR_LINK;
176 }
177
178 if (tb[IFLA_VXLAN_LOCAL6]) {
179 nla_memcpy(&vxi->vxi_local6, tb[IFLA_VXLAN_LOCAL6],
180 sizeof(vxi->vxi_local6));
181 vxi->ce_mask |= VXLAN_ATTR_LOCAL6;
182 }
183
184 if (tb[IFLA_VXLAN_LOCAL]) {
185 nla_memcpy(&vxi->vxi_local, tb[IFLA_VXLAN_LOCAL],
186 sizeof(vxi->vxi_local));
187 vxi->ce_mask |= VXLAN_ATTR_LOCAL;
188 vxi->ce_mask &= ~VXLAN_ATTR_LOCAL6;
189 }
190
191 if (tb[IFLA_VXLAN_TTL]) {
192 vxi->vxi_ttl = nla_get_u8(tb[IFLA_VXLAN_TTL]);
193 vxi->ce_mask |= VXLAN_ATTR_TTL;
194 }
195
196 if (tb[IFLA_VXLAN_TOS]) {
197 vxi->vxi_tos = nla_get_u8(tb[IFLA_VXLAN_TOS]);
198 vxi->ce_mask |= VXLAN_ATTR_TOS;
199 }
200
201 if (tb[IFLA_VXLAN_LEARNING]) {
202 vxi->vxi_learning = nla_get_u8(tb[IFLA_VXLAN_LEARNING]);
203 vxi->ce_mask |= VXLAN_ATTR_LEARNING;
204 }
205
206 if (tb[IFLA_VXLAN_AGEING]) {
207 vxi->vxi_ageing = nla_get_u32(tb[IFLA_VXLAN_AGEING]);
208 vxi->ce_mask |= VXLAN_ATTR_AGEING;
209 }
210
211 if (tb[IFLA_VXLAN_LIMIT]) {
212 vxi->vxi_limit = nla_get_u32(tb[IFLA_VXLAN_LIMIT]);
213 vxi->ce_mask |= VXLAN_ATTR_LIMIT;
214 }
215
216 if (tb[IFLA_VXLAN_PORT_RANGE]) {
217 nla_memcpy(&vxi->vxi_port_range, tb[IFLA_VXLAN_PORT_RANGE],
218 sizeof(vxi->vxi_port_range));
219 vxi->ce_mask |= VXLAN_ATTR_PORT_RANGE;
220 }
221
222 if (tb[IFLA_VXLAN_PROXY]) {
223 vxi->vxi_proxy = nla_get_u8(tb[IFLA_VXLAN_PROXY]);
224 vxi->ce_mask |= VXLAN_ATTR_PROXY;
225 }
226
227 if (tb[IFLA_VXLAN_RSC]) {
228 vxi->vxi_rsc = nla_get_u8(tb[IFLA_VXLAN_RSC]);
229 vxi->ce_mask |= VXLAN_ATTR_RSC;
230 }
231
232 if (tb[IFLA_VXLAN_L2MISS]) {
233 vxi->vxi_l2miss = nla_get_u8(tb[IFLA_VXLAN_L2MISS]);
234 vxi->ce_mask |= VXLAN_ATTR_L2MISS;
235 }
236
237 if (tb[IFLA_VXLAN_L3MISS]) {
238 vxi->vxi_l3miss = nla_get_u8(tb[IFLA_VXLAN_L3MISS]);
239 vxi->ce_mask |= VXLAN_ATTR_L3MISS;
240 }
241
242 if (tb[IFLA_VXLAN_PORT]) {
243 vxi->vxi_port = nla_get_u16(tb[IFLA_VXLAN_PORT]);
244 vxi->ce_mask |= VXLAN_ATTR_PORT;
245 }
246
247 if (tb[IFLA_VXLAN_UDP_CSUM]) {
248 vxi->vxi_udp_csum = nla_get_u8(tb[IFLA_VXLAN_UDP_CSUM]);
249 vxi->ce_mask |= VXLAN_ATTR_UDP_CSUM;
250 }
251
252 if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]) {
253 vxi->vxi_udp_zero_csum6_tx = nla_get_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]);
254 vxi->ce_mask |= VXLAN_ATTR_UDP_ZERO_CSUM6_TX;
255 }
256
257 if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) {
258 vxi->vxi_udp_zero_csum6_rx = nla_get_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]);
259 vxi->ce_mask |= VXLAN_ATTR_UDP_ZERO_CSUM6_RX;
260 }
261
262 if (tb[IFLA_VXLAN_REMCSUM_TX]) {
263 vxi->vxi_remcsum_tx = nla_get_u8(tb[IFLA_VXLAN_REMCSUM_TX]);
264 vxi->ce_mask |= VXLAN_ATTR_REMCSUM_TX;
265 }
266
267 if (tb[IFLA_VXLAN_REMCSUM_RX]) {
268 vxi->vxi_remcsum_rx = nla_get_u8(tb[IFLA_VXLAN_REMCSUM_RX]);
269 vxi->ce_mask |= VXLAN_ATTR_REMCSUM_RX;
270 }
271
272 if (tb[IFLA_VXLAN_GBP])
273 vxi->vxi_flags |= RTNL_LINK_VXLAN_F_GBP;
274
275 if (tb[IFLA_VXLAN_REMCSUM_NOPARTIAL])
276 vxi->vxi_flags |= RTNL_LINK_VXLAN_F_REMCSUM_NOPARTIAL;
277
278 if (tb[IFLA_VXLAN_COLLECT_METADATA]) {
279 vxi->vxi_collect_metadata = nla_get_u8(tb[IFLA_VXLAN_COLLECT_METADATA]);
280 vxi->ce_mask |= VXLAN_ATTR_COLLECT_METADATA;
281 }
282
283 if (tb[IFLA_VXLAN_LABEL]) {
284 vxi->vxi_label = nla_get_u32(tb[IFLA_VXLAN_LABEL]);
285 vxi->ce_mask |= VXLAN_ATTR_LABEL;
286 }
287
288 if (tb[IFLA_VXLAN_GPE])
289 vxi->vxi_flags |= RTNL_LINK_VXLAN_F_GPE;
290
291 err = 0;
292
293errout:
294 return err;
295}
296
297static void vxlan_free(struct rtnl_link *link)
298{
299 struct vxlan_info *vxi = link->l_info;
300
301 free(vxi);
302 link->l_info = NULL;
303}
304
305static void vxlan_dump_line(struct rtnl_link *link, struct nl_dump_params *p)
306{
307 struct vxlan_info *vxi = link->l_info;
308
309 nl_dump(p, "vxlan-id %u", vxi->vxi_id);
310}
311
312static void vxlan_dump_details(struct rtnl_link *link, struct nl_dump_params *p)
313{
314 struct vxlan_info *vxi = link->l_info;
315 char *name, addr[INET6_ADDRSTRLEN];
316 struct rtnl_link *parent;
317
318 nl_dump_line(p, " vxlan-id %u\n", vxi->vxi_id);
319
320 if (vxi->ce_mask & VXLAN_ATTR_GROUP) {
321 nl_dump(p, " group ");
322 nl_dump_line(p, "%s\n",
323 _nl_inet_ntop(AF_INET, &vxi->vxi_group, addr));
324 } else if (vxi->ce_mask & VXLAN_ATTR_GROUP6) {
325 nl_dump(p, " group ");
326 nl_dump_line(p, "%s\n",
327 _nl_inet_ntop(AF_INET6, &vxi->vxi_group6, addr));
328 }
329
330 if (vxi->ce_mask & VXLAN_ATTR_LINK) {
331 nl_dump(p, " link ");
332
333 name = NULL;
334 parent = link_lookup(link->ce_cache, vxi->vxi_link);
335 if (parent)
336 name = rtnl_link_get_name(parent);
337
338 if (name)
339 nl_dump_line(p, "%s\n", name);
340 else
341 nl_dump_line(p, "%u\n", vxi->vxi_link);
342 }
343
344 if (vxi->ce_mask & VXLAN_ATTR_LOCAL) {
345 nl_dump(p, " local ");
346 nl_dump_line(p, "%s\n",
347 _nl_inet_ntop(AF_INET, &vxi->vxi_local, addr));
348 } else if (vxi->ce_mask & VXLAN_ATTR_LOCAL6) {
349 nl_dump(p, " local ");
350 nl_dump_line(p, "%s\n",
351 _nl_inet_ntop(AF_INET6, &vxi->vxi_local6, addr));
352 }
353
354 if (vxi->ce_mask & VXLAN_ATTR_TTL) {
355 nl_dump(p, " ttl ");
356 if(vxi->vxi_ttl)
357 nl_dump_line(p, "%u\n", vxi->vxi_ttl);
358 else
359 nl_dump_line(p, "inherit\n");
360 }
361
362 if (vxi->ce_mask & VXLAN_ATTR_TOS) {
363 nl_dump(p, " tos ");
364 if (vxi->vxi_tos == 1)
365 nl_dump_line(p, "inherit\n");
366 else
367 nl_dump_line(p, "%#x\n", vxi->vxi_tos);
368 }
369
370 if (vxi->ce_mask & VXLAN_ATTR_LEARNING) {
371 nl_dump(p, " learning ");
372 if (vxi->vxi_learning)
373 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_learning);
374 else
375 nl_dump_line(p, "disabled\n");
376 }
377
378 if (vxi->ce_mask & VXLAN_ATTR_AGEING) {
379 nl_dump(p, " ageing ");
380 if (vxi->vxi_ageing)
381 nl_dump_line(p, "%u seconds\n", vxi->vxi_ageing);
382 else
383 nl_dump_line(p, "disabled\n");
384 }
385
386 if (vxi->ce_mask & VXLAN_ATTR_LIMIT) {
387 nl_dump(p, " limit ");
388 if (vxi->vxi_limit)
389 nl_dump_line(p, "%u\n", vxi->vxi_limit);
390 else
391 nl_dump_line(p, "unlimited\n");
392 }
393
394 if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE)
395 nl_dump_line(p, " port range %u - %u\n",
396 ntohs(vxi->vxi_port_range.low),
397 ntohs(vxi->vxi_port_range.high));
398
399 if (vxi->ce_mask & VXLAN_ATTR_PROXY) {
400 nl_dump(p, " proxy ");
401 if (vxi->vxi_proxy)
402 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_proxy);
403 else
404 nl_dump_line(p, "disabled\n");
405 }
406
407 if (vxi->ce_mask & VXLAN_ATTR_RSC) {
408 nl_dump(p, " rsc ");
409 if (vxi->vxi_rsc)
410 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_rsc);
411 else
412 nl_dump_line(p, "disabled\n");
413 }
414
415 if (vxi->ce_mask & VXLAN_ATTR_L2MISS) {
416 nl_dump(p, " l2miss ");
417 if (vxi->vxi_l2miss)
418 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_l2miss);
419 else
420 nl_dump_line(p, "disabled\n");
421 }
422
423 if (vxi->ce_mask & VXLAN_ATTR_L3MISS) {
424 nl_dump(p, " l3miss ");
425 if (vxi->vxi_l3miss)
426 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_l3miss);
427 else
428 nl_dump_line(p, "disabled\n");
429 }
430
431 if (vxi->ce_mask & VXLAN_ATTR_PORT) {
432 nl_dump(p, " port ");
433 nl_dump_line(p, "%u\n", ntohs(vxi->vxi_port));
434 }
435
436 if (vxi->ce_mask & VXLAN_ATTR_UDP_CSUM) {
437 nl_dump(p, " UDP checksums ");
438 if (vxi->vxi_udp_csum)
439 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_udp_csum);
440 else
441 nl_dump_line(p, "disabled\n");
442 }
443
444 if (vxi->ce_mask & VXLAN_ATTR_UDP_ZERO_CSUM6_TX) {
445 nl_dump(p, " udp-zero-csum6-tx ");
446 if (vxi->vxi_udp_zero_csum6_tx)
447 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_udp_zero_csum6_tx);
448 else
449 nl_dump_line(p, "disabled\n");
450 }
451
452 if (vxi->ce_mask & VXLAN_ATTR_UDP_ZERO_CSUM6_RX) {
453 nl_dump(p, " udp-zero-csum6-rx ");
454 if (vxi->vxi_udp_zero_csum6_rx)
455 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_udp_zero_csum6_rx);
456 else
457 nl_dump_line(p, "disabled\n");
458 }
459
460 if (vxi->ce_mask & VXLAN_ATTR_REMCSUM_TX) {
461 nl_dump(p, " remcsum-tx ");
462 if (vxi->vxi_remcsum_tx)
463 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_remcsum_tx);
464 else
465 nl_dump_line(p, "disabled\n");
466 }
467
468 if (vxi->ce_mask & VXLAN_ATTR_REMCSUM_RX) {
469 nl_dump(p, " remcsum-rx ");
470 if (vxi->vxi_remcsum_rx)
471 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_remcsum_rx);
472 else
473 nl_dump_line(p, "disabled\n");
474 }
475
476 if (vxi->vxi_flags & RTNL_LINK_VXLAN_F_GBP)
477 nl_dump(p, " gbp\n");
478
479 if (vxi->vxi_flags & RTNL_LINK_VXLAN_F_REMCSUM_NOPARTIAL)
480 nl_dump(p, " rncsum-nopartial\n");
481
482 if (vxi->ce_mask & VXLAN_ATTR_COLLECT_METADATA) {
483 nl_dump(p, " remcsum-rx ");
484 if (vxi->vxi_collect_metadata)
485 nl_dump_line(p, "enabled (%#x)\n", vxi->vxi_collect_metadata);
486 else
487 nl_dump_line(p, "disabled\n");
488 }
489
490 if (vxi->ce_mask & VXLAN_ATTR_LABEL) {
491 nl_dump(p, " label ");
492 nl_dump_line(p, "%u\n", ntohl(vxi->vxi_label));
493 }
494
495 if (vxi->vxi_flags & RTNL_LINK_VXLAN_F_GPE)
496 nl_dump(p, " gpe\n");
497}
498
499static int vxlan_clone(struct rtnl_link *dst, struct rtnl_link *src)
500{
501 struct vxlan_info *vdst, *vsrc = src->l_info;
502 int err;
503
504 dst->l_info = NULL;
505 if ((err = rtnl_link_set_type(dst, "vxlan")) < 0)
506 return err;
507 vdst = dst->l_info;
508
509 if (!vdst || !vsrc)
510 return -NLE_NOMEM;
511
512 memcpy(vdst, vsrc, sizeof(struct vxlan_info));
513
514 return 0;
515}
516
517static int vxlan_put_attrs(struct nl_msg *msg, struct rtnl_link *link)
518{
519 struct vxlan_info *vxi = link->l_info;
520 struct nlattr *data;
521
522 if (!(data = nla_nest_start(msg, IFLA_INFO_DATA)))
523 return -NLE_MSGSIZE;
524
525 if (vxi->ce_mask & VXLAN_ATTR_ID)
526 NLA_PUT_U32(msg, IFLA_VXLAN_ID, vxi->vxi_id);
527
528 if (vxi->ce_mask & VXLAN_ATTR_GROUP)
529 NLA_PUT(msg, IFLA_VXLAN_GROUP, sizeof(vxi->vxi_group), &vxi->vxi_group);
530
531 if (vxi->ce_mask & VXLAN_ATTR_GROUP6)
532 NLA_PUT(msg, IFLA_VXLAN_GROUP6, sizeof(vxi->vxi_group6), &vxi->vxi_group6);
533
534 if (vxi->ce_mask & VXLAN_ATTR_LINK)
535 NLA_PUT_U32(msg, IFLA_VXLAN_LINK, vxi->vxi_link);
536
537 if (vxi->ce_mask & VXLAN_ATTR_LOCAL)
538 NLA_PUT(msg, IFLA_VXLAN_LOCAL, sizeof(vxi->vxi_local), &vxi->vxi_local);
539
540 if (vxi->ce_mask & VXLAN_ATTR_LOCAL6)
541 NLA_PUT(msg, IFLA_VXLAN_LOCAL6, sizeof(vxi->vxi_local6), &vxi->vxi_local6);
542
543 if (vxi->ce_mask & VXLAN_ATTR_TTL)
544 NLA_PUT_U8(msg, IFLA_VXLAN_TTL, vxi->vxi_ttl);
545
546 if (vxi->ce_mask & VXLAN_ATTR_TOS)
547 NLA_PUT_U8(msg, IFLA_VXLAN_TOS, vxi->vxi_tos);
548
549 if (vxi->ce_mask & VXLAN_ATTR_LEARNING)
550 NLA_PUT_U8(msg, IFLA_VXLAN_LEARNING, vxi->vxi_learning);
551
552 if (vxi->ce_mask & VXLAN_ATTR_AGEING)
553 NLA_PUT_U32(msg, IFLA_VXLAN_AGEING, vxi->vxi_ageing);
554
555 if (vxi->ce_mask & VXLAN_ATTR_LIMIT)
556 NLA_PUT_U32(msg, IFLA_VXLAN_LIMIT, vxi->vxi_limit);
557
558 if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE)
559 NLA_PUT(msg, IFLA_VXLAN_PORT_RANGE, sizeof(vxi->vxi_port_range),
560 &vxi->vxi_port_range);
561
562 if (vxi->ce_mask & VXLAN_ATTR_PROXY)
563 NLA_PUT_U8(msg, IFLA_VXLAN_PROXY, vxi->vxi_proxy);
564
565 if (vxi->ce_mask & VXLAN_ATTR_RSC)
566 NLA_PUT_U8(msg, IFLA_VXLAN_RSC, vxi->vxi_rsc);
567
568 if (vxi->ce_mask & VXLAN_ATTR_L2MISS)
569 NLA_PUT_U8(msg, IFLA_VXLAN_L2MISS, vxi->vxi_l2miss);
570
571 if (vxi->ce_mask & VXLAN_ATTR_L3MISS)
572 NLA_PUT_U8(msg, IFLA_VXLAN_L3MISS, vxi->vxi_l3miss);
573
574 if (vxi->ce_mask & VXLAN_ATTR_PORT)
575 NLA_PUT_U32(msg, IFLA_VXLAN_PORT, vxi->vxi_port);
576
577 if (vxi->ce_mask & VXLAN_ATTR_UDP_CSUM)
578 NLA_PUT_U8(msg, IFLA_VXLAN_UDP_CSUM, vxi->vxi_udp_csum);
579
580 if (vxi->ce_mask & VXLAN_ATTR_UDP_ZERO_CSUM6_TX)
581 NLA_PUT_U8(msg, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, vxi->vxi_udp_zero_csum6_tx);
582
583 if (vxi->ce_mask & VXLAN_ATTR_UDP_ZERO_CSUM6_RX)
584 NLA_PUT_U8(msg, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, vxi->vxi_udp_zero_csum6_rx);
585
586 if (vxi->ce_mask & VXLAN_ATTR_REMCSUM_TX)
587 NLA_PUT_U8(msg, IFLA_VXLAN_REMCSUM_TX, vxi->vxi_remcsum_tx);
588
589 if (vxi->ce_mask & VXLAN_ATTR_REMCSUM_RX)
590 NLA_PUT_U8(msg, IFLA_VXLAN_REMCSUM_RX, vxi->vxi_remcsum_rx);
591
592 if (vxi->vxi_flags & RTNL_LINK_VXLAN_F_GBP)
593 NLA_PUT_FLAG(msg, IFLA_VXLAN_GBP);
594
595 if (vxi->vxi_flags & RTNL_LINK_VXLAN_F_REMCSUM_NOPARTIAL)
596 NLA_PUT_FLAG(msg, IFLA_VXLAN_REMCSUM_NOPARTIAL);
597
598 if (vxi->ce_mask & VXLAN_ATTR_COLLECT_METADATA)
599 NLA_PUT_U8(msg, IFLA_VXLAN_COLLECT_METADATA, vxi->vxi_collect_metadata);
600
601 if (vxi->ce_mask & VXLAN_ATTR_LABEL)
602 NLA_PUT_U32(msg, IFLA_VXLAN_LABEL, vxi->vxi_label);
603
604 if (vxi->vxi_flags & RTNL_LINK_VXLAN_F_GPE)
605 NLA_PUT_FLAG(msg, IFLA_VXLAN_GPE);
606
607 nla_nest_end(msg, data);
608
609nla_put_failure:
610
611 return 0;
612}
613
614static int vxlan_compare(struct rtnl_link *link_a, struct rtnl_link *link_b,
615 int flags)
616{
617 struct vxlan_info *a = link_a->l_info;
618 struct vxlan_info *b = link_b->l_info;
619 int diff = 0;
620 uint32_t attrs = flags & LOOSE_COMPARISON ? b->ce_mask : ~0;
621
622#define _DIFF(ATTR, EXPR) ATTR_DIFF(attrs, ATTR, a, b, EXPR)
623 diff |= _DIFF(VXLAN_ATTR_ID, a->vxi_id != b->vxi_id);
624 diff |= _DIFF(VXLAN_ATTR_GROUP, a->vxi_group != b->vxi_group);
625 diff |= _DIFF(VXLAN_ATTR_LINK, a->vxi_link != b->vxi_link);
626 diff |= _DIFF(VXLAN_ATTR_LOCAL, a->vxi_local != b->vxi_local);
627 diff |= _DIFF(VXLAN_ATTR_TOS, a->vxi_tos != b->vxi_tos);
628 diff |= _DIFF(VXLAN_ATTR_TTL, a->vxi_ttl != b->vxi_ttl);
629 diff |= _DIFF(VXLAN_ATTR_LEARNING, a->vxi_learning != b->vxi_learning);
630 diff |= _DIFF(VXLAN_ATTR_AGEING, a->vxi_ageing != b->vxi_ageing);
631 diff |= _DIFF(VXLAN_ATTR_LIMIT, a->vxi_limit != b->vxi_limit);
632 diff |= _DIFF(VXLAN_ATTR_PORT_RANGE,
633 a->vxi_port_range.low != b->vxi_port_range.low);
634 diff |= _DIFF(VXLAN_ATTR_PORT_RANGE,
635 a->vxi_port_range.high != b->vxi_port_range.high);
636 diff |= _DIFF(VXLAN_ATTR_PROXY, a->vxi_proxy != b->vxi_proxy);
637 diff |= _DIFF(VXLAN_ATTR_RSC, a->vxi_proxy != b->vxi_proxy);
638 diff |= _DIFF(VXLAN_ATTR_L2MISS, a->vxi_proxy != b->vxi_proxy);
639 diff |= _DIFF(VXLAN_ATTR_L3MISS, a->vxi_proxy != b->vxi_proxy);
640 diff |= _DIFF(VXLAN_ATTR_PORT, a->vxi_port != b->vxi_port);
641 diff |= _DIFF(VXLAN_ATTR_GROUP6, memcmp(&a->vxi_group6, &b->vxi_group6,
642 sizeof(a->vxi_group6)) != 0);
643 diff |= _DIFF(VXLAN_ATTR_LOCAL6, memcmp(&a->vxi_local6, &b->vxi_local6,
644 sizeof(a->vxi_local6)) != 0);
645 diff |= _DIFF(VXLAN_ATTR_UDP_CSUM, a->vxi_proxy != b->vxi_proxy);
646 diff |= _DIFF(VXLAN_ATTR_UDP_ZERO_CSUM6_TX,
647 a->vxi_proxy != b->vxi_proxy);
648 diff |= _DIFF(VXLAN_ATTR_UDP_ZERO_CSUM6_RX,
649 a->vxi_proxy != b->vxi_proxy);
650 diff |= _DIFF(VXLAN_ATTR_REMCSUM_TX, a->vxi_proxy != b->vxi_proxy);
651 diff |= _DIFF(VXLAN_ATTR_REMCSUM_RX, a->vxi_proxy != b->vxi_proxy);
652 diff |= _DIFF(VXLAN_ATTR_COLLECT_METADATA,
653 a->vxi_collect_metadata != b->vxi_collect_metadata);
654 diff |= _DIFF(VXLAN_ATTR_LABEL, a->vxi_label != b->vxi_label);
655 diff |= _DIFF(VXLAN_ATTR_FLAGS, a->vxi_flags != b->vxi_flags);
656#undef _DIFF
657
658 return diff;
659}
660
661static struct rtnl_link_info_ops vxlan_info_ops = {
662 .io_name = "vxlan",
663 .io_alloc = vxlan_alloc,
664 .io_parse = vxlan_parse,
665 .io_dump = {
666 [NL_DUMP_LINE] = vxlan_dump_line,
667 [NL_DUMP_DETAILS] = vxlan_dump_details,
668 },
669 .io_clone = vxlan_clone,
670 .io_put_attrs = vxlan_put_attrs,
671 .io_free = vxlan_free,
672 .io_compare = vxlan_compare,
673};
674
675/** @cond SKIP */
676#define IS_VXLAN_LINK_ASSERT(link) \
677 if ((link)->l_info_ops != &vxlan_info_ops) { \
678 APPBUG("Link is not a vxlan link. set type \"vxlan\" first."); \
679 return -NLE_OPNOTSUPP; \
680 }
681/** @endcond */
682
683/**
684 * @name VXLAN Object
685 * @{
686 */
687
688/**
689 * Allocate link object of type VXLAN
690 *
691 * @return Allocated link object or NULL.
692 */
694{
695 struct rtnl_link *link;
696
697 if (!(link = rtnl_link_alloc()))
698 return NULL;
699
700 if (rtnl_link_set_type(link, "vxlan") < 0) {
701 rtnl_link_put(link);
702 return NULL;
703 }
704
705 return link;
706}
707
708/**
709 * Check if link is a VXLAN link
710 * @arg link Link object
711 *
712 * @return True if link is a VXLAN link, otherwise false is returned.
713 */
715{
716 return link->l_info_ops && !strcmp(link->l_info_ops->io_name, "vxlan");
717}
718
719/**
720 * Set VXLAN Network Identifier
721 * @arg link Link object
722 * @arg id VXLAN network identifier (or VXLAN segment identifier)
723 *
724 * @return 0 on success or a negative error code
725 */
726int rtnl_link_vxlan_set_id(struct rtnl_link *link, uint32_t id)
727{
728 struct vxlan_info *vxi = link->l_info;
729
730 IS_VXLAN_LINK_ASSERT(link);
731
732 if (id > VXLAN_ID_MAX)
733 return -NLE_INVAL;
734
735 vxi->vxi_id = id;
736 vxi->ce_mask |= VXLAN_ATTR_ID;
737
738 return 0;
739}
740
741/**
742 * Get VXLAN Network Identifier
743 * @arg link Link object
744 * @arg id Pointer to store network identifier
745 *
746 * @return 0 on success or a negative error code
747 */
748int rtnl_link_vxlan_get_id(struct rtnl_link *link, uint32_t *id)
749{
750 struct vxlan_info *vxi = link->l_info;
751
752 IS_VXLAN_LINK_ASSERT(link);
753
754 if(!id)
755 return -NLE_INVAL;
756
757 if (vxi->ce_mask & VXLAN_ATTR_ID)
758 *id = vxi->vxi_id;
759 else
760 return -NLE_AGAIN;
761
762 return 0;
763}
764
765/**
766 * Set VXLAN multicast IP address
767 * @arg link Link object
768 * @arg addr Multicast IP address to join
769 *
770 * @return 0 on success or a negative error code
771 */
772int rtnl_link_vxlan_set_group(struct rtnl_link *link, struct nl_addr *addr)
773{
774 struct vxlan_info *vxi = link->l_info;
775
776 IS_VXLAN_LINK_ASSERT(link);
777
778 if ((nl_addr_get_family(addr) == AF_INET) &&
779 (nl_addr_get_len(addr) == sizeof(vxi->vxi_group))) {
780 memcpy(&vxi->vxi_group, nl_addr_get_binary_addr(addr),
781 sizeof(vxi->vxi_group));
782 vxi->ce_mask |= VXLAN_ATTR_GROUP;
783 vxi->ce_mask &= ~VXLAN_ATTR_GROUP6;
784 } else if ((nl_addr_get_family(addr) == AF_INET6) &&
785 (nl_addr_get_len(addr) == sizeof(vxi->vxi_group6))) {
786 memcpy(&vxi->vxi_group6, nl_addr_get_binary_addr(addr),
787 sizeof(vxi->vxi_group6));
788 vxi->ce_mask |= VXLAN_ATTR_GROUP6;
789 vxi->ce_mask &= ~VXLAN_ATTR_GROUP;
790 } else
791 return -NLE_INVAL;
792
793 return 0;
794}
795
796/**
797 * Get VXLAN multicast IP address
798 * @arg link Link object
799 * @arg addr Pointer to store multicast IP address
800 *
801 * @return 0 on success or a negative error code
802 */
803int rtnl_link_vxlan_get_group(struct rtnl_link *link, struct nl_addr **addr)
804{
805 struct vxlan_info *vxi = link->l_info;
806
807 IS_VXLAN_LINK_ASSERT(link);
808
809 if (!addr)
810 return -NLE_INVAL;
811
812 if (vxi->ce_mask & VXLAN_ATTR_GROUP)
813 *addr = nl_addr_build(AF_INET, &vxi->vxi_group, sizeof(vxi->vxi_group));
814 else if (vxi->ce_mask & VXLAN_ATTR_GROUP6)
815 *addr = nl_addr_build(AF_INET6, &vxi->vxi_group6, sizeof(vxi->vxi_group6));
816 else
817 return -NLE_AGAIN;
818
819 return 0;
820}
821
822/**
823 * Set physical device to use for VXLAN
824 * @arg link Link object
825 * @arg index Interface index
826 *
827 * @return 0 on success or a negative error code
828 */
829int rtnl_link_vxlan_set_link(struct rtnl_link *link, uint32_t index)
830{
831 struct vxlan_info *vxi = link->l_info;
832
833 IS_VXLAN_LINK_ASSERT(link);
834
835 vxi->vxi_link = index;
836 vxi->ce_mask |= VXLAN_ATTR_LINK;
837
838 return 0;
839}
840
841/**
842 * Get physical device to use for VXLAN
843 * @arg link Link object
844 * @arg index Pointer to store interface index
845 *
846 * @return 0 on success or a negative error code
847 */
848int rtnl_link_vxlan_get_link(struct rtnl_link *link, uint32_t *index)
849{
850 struct vxlan_info *vxi = link->l_info;
851
852 IS_VXLAN_LINK_ASSERT(link);
853
854 if (!index)
855 return -NLE_INVAL;
856
857 if (!(vxi->ce_mask & VXLAN_ATTR_LINK))
858 return -NLE_AGAIN;
859
860 *index = vxi->vxi_link;
861
862 return 0;
863}
864
865/**
866 * Set source address to use for VXLAN
867 * @arg link Link object
868 * @arg addr Local address
869 *
870 * @return 0 on success or a negative error code
871 */
872int rtnl_link_vxlan_set_local(struct rtnl_link *link, struct nl_addr *addr)
873{
874 struct vxlan_info *vxi = link->l_info;
875
876 IS_VXLAN_LINK_ASSERT(link);
877
878 if ((nl_addr_get_family(addr) == AF_INET) &&
879 (nl_addr_get_len(addr) == sizeof(vxi->vxi_local))) {
880 memcpy(&vxi->vxi_local, nl_addr_get_binary_addr(addr),
881 sizeof(vxi->vxi_local));
882 vxi->ce_mask |= VXLAN_ATTR_LOCAL;
883 vxi->ce_mask &= ~VXLAN_ATTR_LOCAL6;
884 } else if ((nl_addr_get_family(addr) == AF_INET6) &&
885 (nl_addr_get_len(addr) == sizeof(vxi->vxi_local6))) {
886 memcpy(&vxi->vxi_local6, nl_addr_get_binary_addr(addr),
887 sizeof(vxi->vxi_local6));
888 vxi->ce_mask |= VXLAN_ATTR_LOCAL6;
889 vxi->ce_mask &= ~VXLAN_ATTR_LOCAL;
890 } else
891 return -NLE_INVAL;
892
893 return 0;
894}
895
896/**
897 * Get source address to use for VXLAN
898 * @arg link Link object
899 * @arg addr Pointer to store local address
900 *
901 * @return 0 on success or a negative error code
902 */
903int rtnl_link_vxlan_get_local(struct rtnl_link *link, struct nl_addr **addr)
904{
905 struct vxlan_info *vxi = link->l_info;
906
907 IS_VXLAN_LINK_ASSERT(link);
908
909 if (!addr)
910 return -NLE_INVAL;
911
912 if (vxi->ce_mask & VXLAN_ATTR_LOCAL)
913 *addr = nl_addr_build(AF_INET, &vxi->vxi_local, sizeof(vxi->vxi_local));
914 else if (vxi->ce_mask & VXLAN_ATTR_LOCAL6)
915 *addr = nl_addr_build(AF_INET6, &vxi->vxi_local6, sizeof(vxi->vxi_local6));
916 else
917 return -NLE_AGAIN;
918
919 return 0;
920}
921
922/**
923 * Set IP TTL value to use for VXLAN
924 * @arg link Link object
925 * @arg ttl TTL value
926 *
927 * @return 0 on success or a negative error code
928 */
929int rtnl_link_vxlan_set_ttl(struct rtnl_link *link, uint8_t ttl)
930{
931 struct vxlan_info *vxi = link->l_info;
932
933 IS_VXLAN_LINK_ASSERT(link);
934
935 vxi->vxi_ttl = ttl;
936 vxi->ce_mask |= VXLAN_ATTR_TTL;
937
938 return 0;
939}
940
941/**
942 * Get IP TTL value to use for VXLAN
943 * @arg link Link object
944 *
945 * @return TTL value on success or a negative error code
946 */
948{
949 struct vxlan_info *vxi = link->l_info;
950
951 IS_VXLAN_LINK_ASSERT(link);
952
953 if (!(vxi->ce_mask & VXLAN_ATTR_TTL))
954 return -NLE_AGAIN;
955
956 return vxi->vxi_ttl;
957}
958
959/**
960 * Set IP ToS value to use for VXLAN
961 * @arg link Link object
962 * @arg tos ToS value
963 *
964 * @return 0 on success or a negative error code
965 */
966int rtnl_link_vxlan_set_tos(struct rtnl_link *link, uint8_t tos)
967{
968 struct vxlan_info *vxi = link->l_info;
969
970 IS_VXLAN_LINK_ASSERT(link);
971
972 vxi->vxi_tos = tos;
973 vxi->ce_mask |= VXLAN_ATTR_TOS;
974
975 return 0;
976}
977
978/**
979 * Get IP ToS value to use for VXLAN
980 * @arg link Link object
981 *
982 * @return ToS value on success or a negative error code
983 */
985{
986 struct vxlan_info *vxi = link->l_info;
987
988 IS_VXLAN_LINK_ASSERT(link);
989
990 if (!(vxi->ce_mask & VXLAN_ATTR_TOS))
991 return -NLE_AGAIN;
992
993 return vxi->vxi_tos;
994}
995
996/**
997 * Set VXLAN learning status
998 * @arg link Link object
999 * @arg learning Learning status value
1000 *
1001 * @return 0 on success or a negative error code
1002 */
1003int rtnl_link_vxlan_set_learning(struct rtnl_link *link, uint8_t learning)
1004{
1005 struct vxlan_info *vxi = link->l_info;
1006
1007 IS_VXLAN_LINK_ASSERT(link);
1008
1009 vxi->vxi_learning = learning;
1010 vxi->ce_mask |= VXLAN_ATTR_LEARNING;
1011
1012 return 0;
1013}
1014
1015/**
1016 * Get VXLAN learning status
1017 * @arg link Link object
1018 *
1019 * @return Learning status value on success or a negative error code
1020 */
1022{
1023 struct vxlan_info *vxi = link->l_info;
1024
1025 IS_VXLAN_LINK_ASSERT(link);
1026
1027 if (!(vxi->ce_mask & VXLAN_ATTR_LEARNING))
1028 return -NLE_AGAIN;
1029
1030 return vxi->vxi_learning;
1031}
1032
1033/**
1034 * Enable VXLAN address learning
1035 * @arg link Link object
1036 *
1037 * @return 0 on success or a negative error code
1038 */
1040{
1041 return rtnl_link_vxlan_set_learning(link, 1);
1042}
1043
1044/**
1045 * Disable VXLAN address learning
1046 * @arg link Link object
1047 *
1048 * @return 0 on success or a negative error code
1049 */
1051{
1052 return rtnl_link_vxlan_set_learning(link, 0);
1053}
1054
1055/**
1056 * Set expiration timer value to use for VXLAN
1057 * @arg link Link object
1058 * @arg expiry Expiration timer value
1059 *
1060 * @return 0 on success or a negative error code
1061 */
1062int rtnl_link_vxlan_set_ageing(struct rtnl_link *link, uint32_t expiry)
1063{
1064 struct vxlan_info *vxi = link->l_info;
1065
1066 IS_VXLAN_LINK_ASSERT(link);
1067
1068 vxi->vxi_ageing = expiry;
1069 vxi->ce_mask |= VXLAN_ATTR_AGEING;
1070
1071 return 0;
1072}
1073
1074/**
1075 * Get expiration timer value to use for VXLAN
1076 * @arg link Link object
1077 * @arg expiry Pointer to store expiration timer value
1078 *
1079 * @return 0 on success or a negative error code
1080 */
1081int rtnl_link_vxlan_get_ageing(struct rtnl_link *link, uint32_t *expiry)
1082{
1083 struct vxlan_info *vxi = link->l_info;
1084
1085 IS_VXLAN_LINK_ASSERT(link);
1086
1087 if (!expiry)
1088 return -NLE_INVAL;
1089
1090 if (vxi->ce_mask & VXLAN_ATTR_AGEING)
1091 *expiry = vxi->vxi_ageing;
1092 else
1093 return -NLE_AGAIN;
1094
1095 return 0;
1096}
1097
1098/**
1099 * Set maximum number of forwarding database entries to use for VXLAN
1100 * @arg link Link object
1101 * @arg limit Maximum number
1102 *
1103 * @return 0 on success or a negative error code
1104 */
1105int rtnl_link_vxlan_set_limit(struct rtnl_link *link, uint32_t limit)
1106{
1107 struct vxlan_info *vxi = link->l_info;
1108
1109 IS_VXLAN_LINK_ASSERT(link);
1110
1111 vxi->vxi_limit = limit;
1112 vxi->ce_mask |= VXLAN_ATTR_LIMIT;
1113
1114 return 0;
1115}
1116
1117/**
1118 * Get maximum number of forwarding database entries to use for VXLAN
1119 * @arg link Link object
1120 * @arg limit Pointer to store maximum number
1121 *
1122 * @return 0 on success or a negative error code
1123 */
1124int rtnl_link_vxlan_get_limit(struct rtnl_link *link, uint32_t *limit)
1125{
1126 struct vxlan_info *vxi = link->l_info;
1127
1128 IS_VXLAN_LINK_ASSERT(link);
1129
1130 if (!limit)
1131 return -NLE_INVAL;
1132
1133 if (vxi->ce_mask & VXLAN_ATTR_LIMIT)
1134 *limit = vxi->vxi_limit;
1135 else
1136 return -NLE_AGAIN;
1137
1138 return 0;
1139}
1140
1141/**
1142 * Set range of UDP port numbers to use for VXLAN
1143 * @arg link Link object
1144 * @arg range Port number range
1145 *
1146 * @return 0 on success or a negative error code
1147 */
1149 struct ifla_vxlan_port_range *range)
1150{
1151 struct vxlan_info *vxi = link->l_info;
1152
1153 IS_VXLAN_LINK_ASSERT(link);
1154
1155 if (!range)
1156 return -NLE_INVAL;
1157
1158 memcpy(&vxi->vxi_port_range, range, sizeof(vxi->vxi_port_range));
1159 vxi->ce_mask |= VXLAN_ATTR_PORT_RANGE;
1160
1161 return 0;
1162}
1163
1164/**
1165 * Get range of UDP port numbers to use for VXLAN
1166 * @arg link Link object
1167 * @arg range Pointer to store port range
1168 *
1169 * @return 0 on success or a negative error code
1170 */
1172 struct ifla_vxlan_port_range *range)
1173{
1174 struct vxlan_info *vxi = link->l_info;
1175
1176 IS_VXLAN_LINK_ASSERT(link);
1177
1178 if (!range)
1179 return -NLE_INVAL;
1180
1181 if (vxi->ce_mask & VXLAN_ATTR_PORT_RANGE)
1182 memcpy(range, &vxi->vxi_port_range, sizeof(*range));
1183 else
1184 return -NLE_AGAIN;
1185
1186 return 0;
1187}
1188
1189/**
1190 * Set ARP proxy status to use for VXLAN
1191 * @arg link Link object
1192 * @arg proxy Status value
1193 *
1194 * @return 0 on success or a negative error code
1195 */
1196int rtnl_link_vxlan_set_proxy(struct rtnl_link *link, uint8_t proxy)
1197{
1198 struct vxlan_info *vxi = link->l_info;
1199
1200 IS_VXLAN_LINK_ASSERT(link);
1201
1202 vxi->vxi_proxy = proxy;
1203 vxi->ce_mask |= VXLAN_ATTR_PROXY;
1204
1205 return 0;
1206}
1207
1208/**
1209 * Get ARP proxy status to use for VXLAN
1210 * @arg link Link object
1211 *
1212 * @return Status value on success or a negative error code
1213 */
1215{
1216 struct vxlan_info *vxi = link->l_info;
1217
1218 IS_VXLAN_LINK_ASSERT(link);
1219
1220 if (!(vxi->ce_mask & VXLAN_ATTR_PROXY))
1221 return -NLE_AGAIN;
1222
1223 return vxi->vxi_proxy;
1224}
1225
1226/**
1227 * Enable ARP proxy
1228 * @arg link Link object
1229 *
1230 * @return 0 on success or a negative error code
1231 */
1233{
1234 return rtnl_link_vxlan_set_proxy(link, 1);
1235}
1236
1237/**
1238 * Disable ARP proxy
1239 * @arg link Link object
1240 *
1241 * @return 0 on success or a negative error code
1242 */
1244{
1245 return rtnl_link_vxlan_set_proxy(link, 0);
1246}
1247
1248/**
1249 * Set Route Short Circuit status to use for VXLAN
1250 * @arg link Link object
1251 * @arg rsc Status value
1252 *
1253 * @return 0 on success or a negative error code
1254 */
1255int rtnl_link_vxlan_set_rsc(struct rtnl_link *link, uint8_t rsc)
1256{
1257 struct vxlan_info *vxi = link->l_info;
1258
1259 IS_VXLAN_LINK_ASSERT(link);
1260
1261 vxi->vxi_rsc = rsc;
1262 vxi->ce_mask |= VXLAN_ATTR_RSC;
1263
1264 return 0;
1265}
1266
1267/**
1268 * Get Route Short Circuit status to use for VXLAN
1269 * @arg link Link object
1270 *
1271 * @return Status value on success or a negative error code
1272 */
1274{
1275 struct vxlan_info *vxi = link->l_info;
1276
1277 IS_VXLAN_LINK_ASSERT(link);
1278
1279 if (!(vxi->ce_mask & VXLAN_ATTR_RSC))
1280 return -NLE_AGAIN;
1281
1282 return vxi->vxi_rsc;
1283}
1284
1285/**
1286 * Enable Route Short Circuit
1287 * @arg link Link object
1288 *
1289 * @return 0 on success or a negative error code
1290 */
1292{
1293 return rtnl_link_vxlan_set_rsc(link, 1);
1294}
1295
1296/**
1297 * Disable Route Short Circuit
1298 * @arg link Link object
1299 *
1300 * @return 0 on success or a negative error code
1301 */
1303{
1304 return rtnl_link_vxlan_set_rsc(link, 0);
1305}
1306
1307/**
1308 * Set netlink LLADDR miss notification status to use for VXLAN
1309 * @arg link Link object
1310 * @arg miss Status value
1311 *
1312 * @return 0 on success or a negative error code
1313 */
1314int rtnl_link_vxlan_set_l2miss(struct rtnl_link *link, uint8_t miss)
1315{
1316 struct vxlan_info *vxi = link->l_info;
1317
1318 IS_VXLAN_LINK_ASSERT(link);
1319
1320 vxi->vxi_l2miss = miss;
1321 vxi->ce_mask |= VXLAN_ATTR_L2MISS;
1322
1323 return 0;
1324}
1325
1326/**
1327 * Get netlink LLADDR miss notification status to use for VXLAN
1328 * @arg link Link object
1329 *
1330 * @return Status value on success or a negative error code
1331 */
1333{
1334 struct vxlan_info *vxi = link->l_info;
1335
1336 IS_VXLAN_LINK_ASSERT(link);
1337
1338 if (!(vxi->ce_mask & VXLAN_ATTR_L2MISS))
1339 return -NLE_AGAIN;
1340
1341 return vxi->vxi_l2miss;
1342}
1343
1344/**
1345 * Enable netlink LLADDR miss notifications
1346 * @arg link Link object
1347 *
1348 * @return 0 on success or a negative error code
1349 */
1351{
1352 return rtnl_link_vxlan_set_l2miss(link, 1);
1353}
1354
1355/**
1356 * Disable netlink LLADDR miss notifications
1357 * @arg link Link object
1358 *
1359 * @return 0 on success or a negative error code
1360 */
1362{
1363 return rtnl_link_vxlan_set_l2miss(link, 0);
1364}
1365
1366/**
1367 * Set netlink IP ADDR miss notification status to use for VXLAN
1368 * @arg link Link object
1369 * @arg miss Status value
1370 *
1371 * @return 0 on success or a negative error code
1372 */
1373int rtnl_link_vxlan_set_l3miss(struct rtnl_link *link, uint8_t miss)
1374{
1375 struct vxlan_info *vxi = link->l_info;
1376
1377 IS_VXLAN_LINK_ASSERT(link);
1378
1379 vxi->vxi_l3miss = miss;
1380 vxi->ce_mask |= VXLAN_ATTR_L3MISS;
1381
1382 return 0;
1383}
1384
1385/**
1386 * Get netlink IP ADDR miss notification status to use for VXLAN
1387 * @arg link Link object
1388 *
1389 * @return Status value on success or a negative error code
1390 */
1392{
1393 struct vxlan_info *vxi = link->l_info;
1394
1395 IS_VXLAN_LINK_ASSERT(link);
1396
1397 if (!(vxi->ce_mask & VXLAN_ATTR_L3MISS))
1398 return -NLE_AGAIN;
1399
1400 return vxi->vxi_l3miss;
1401}
1402
1403/**
1404 * Enable netlink IP ADDR miss notifications
1405 * @arg link Link object
1406 *
1407 * @return 0 on success or a negative error code
1408 */
1410{
1411 return rtnl_link_vxlan_set_l3miss(link, 1);
1412}
1413
1414/**
1415 * Disable netlink IP ADDR miss notifications
1416 * @arg link Link object
1417 *
1418 * @return 0 on success or a negative error code
1419 */
1421{
1422 return rtnl_link_vxlan_set_l3miss(link, 0);
1423}
1424
1425/**
1426 * Set UDP destination port to use for VXLAN
1427 * @arg link Link object
1428 * @arg port Destination port
1429 *
1430 * @return 0 on success or a negative error code
1431 */
1432int rtnl_link_vxlan_set_port(struct rtnl_link *link, uint32_t port)
1433{
1434 struct vxlan_info *vxi = link->l_info;
1435
1436 IS_VXLAN_LINK_ASSERT(link);
1437
1438 vxi->vxi_port = htons(port);
1439 vxi->ce_mask |= VXLAN_ATTR_PORT;
1440
1441 return 0;
1442}
1443
1444/**
1445 * Get UDP destination port to use for VXLAN
1446 * @arg link Link object
1447 * @arg port Pointer to store destination port
1448 *
1449 * @return 0 on success or a negative error code
1450 */
1451int rtnl_link_vxlan_get_port(struct rtnl_link *link, uint32_t *port)
1452{
1453 struct vxlan_info *vxi = link->l_info;
1454
1455 IS_VXLAN_LINK_ASSERT(link);
1456
1457 if (!port)
1458 return -NLE_INVAL;
1459
1460 if (!(vxi->ce_mask & VXLAN_ATTR_PORT))
1461 return -NLE_NOATTR;
1462
1463 *port = ntohs(vxi->vxi_port);
1464
1465 return 0;
1466}
1467
1468/**
1469 * Set UDP checksum status to use for VXLAN
1470 * @arg link Link object
1471 * @arg csum Status value
1472 *
1473 * @return 0 on success or a negative error code
1474 */
1475int rtnl_link_vxlan_set_udp_csum(struct rtnl_link *link, uint8_t csum)
1476{
1477 struct vxlan_info *vxi = link->l_info;
1478
1479 IS_VXLAN_LINK_ASSERT(link);
1480
1481 vxi->vxi_udp_csum = csum;
1482 vxi->ce_mask |= VXLAN_ATTR_UDP_CSUM;
1483
1484 return 0;
1485}
1486
1487/**
1488 * Get UDP checksum status to use for VXLAN
1489 * @arg link Link object
1490 *
1491 * @return Status value on success or a negative error code
1492 */
1494{
1495 struct vxlan_info *vxi = link->l_info;
1496
1497 IS_VXLAN_LINK_ASSERT(link);
1498
1499 if (!(vxi->ce_mask & VXLAN_ATTR_UDP_CSUM))
1500 return -NLE_NOATTR;
1501
1502 return vxi->vxi_udp_csum;
1503}
1504
1505/**
1506 * Set skip UDP checksum transmitted over IPv6 status to use for VXLAN
1507 * @arg link Link object
1508 * @arg csum Status value
1509 *
1510 * @return 0 on success or a negative error code
1511 */
1513{
1514 struct vxlan_info *vxi = link->l_info;
1515
1516 IS_VXLAN_LINK_ASSERT(link);
1517
1518 vxi->vxi_udp_zero_csum6_tx = csum;
1519 vxi->ce_mask |= VXLAN_ATTR_UDP_ZERO_CSUM6_TX;
1520
1521 return 0;
1522}
1523
1524/**
1525 * Get skip UDP checksum transmitted over IPv6 status to use for VXLAN
1526 * @arg link Link object
1527 *
1528 * @return Status value on success or a negative error code
1529 */
1531{
1532 struct vxlan_info *vxi = link->l_info;
1533
1534 IS_VXLAN_LINK_ASSERT(link);
1535
1536 if (!(vxi->ce_mask & VXLAN_ATTR_UDP_ZERO_CSUM6_TX))
1537 return -NLE_NOATTR;
1538
1539 return vxi->vxi_udp_zero_csum6_tx;
1540}
1541
1542/**
1543 * Set skip UDP checksum received over IPv6 status to use for VXLAN
1544 * @arg link Link object
1545 * @arg csum Status value
1546 *
1547 * @return 0 on success or a negative error code
1548 */
1550{
1551 struct vxlan_info *vxi = link->l_info;
1552
1553 IS_VXLAN_LINK_ASSERT(link);
1554
1555 vxi->vxi_udp_zero_csum6_rx = csum;
1556 vxi->ce_mask |= VXLAN_ATTR_UDP_ZERO_CSUM6_RX;
1557
1558 return 0;
1559}
1560
1561/**
1562 * Get skip UDP checksum received over IPv6 status to use for VXLAN
1563 * @arg link Link object
1564 *
1565 * @return Status value on success or a negative error code
1566 */
1568{
1569 struct vxlan_info *vxi = link->l_info;
1570
1571 IS_VXLAN_LINK_ASSERT(link);
1572
1573 if (!(vxi->ce_mask & VXLAN_ATTR_UDP_ZERO_CSUM6_RX))
1574 return -NLE_NOATTR;
1575
1576 return vxi->vxi_udp_zero_csum6_rx;
1577}
1578
1579/**
1580 * Set remote offload transmit checksum status to use for VXLAN
1581 * @arg link Link object
1582 * @arg csum Status value
1583 *
1584 * @return 0 on success or a negative error code
1585 */
1586int rtnl_link_vxlan_set_remcsum_tx(struct rtnl_link *link, uint8_t csum)
1587{
1588 struct vxlan_info *vxi = link->l_info;
1589
1590 IS_VXLAN_LINK_ASSERT(link);
1591
1592 vxi->vxi_remcsum_tx = csum;
1593 vxi->ce_mask |= VXLAN_ATTR_REMCSUM_TX;
1594
1595 return 0;
1596}
1597
1598/**
1599 * Get remote offload transmit checksum status to use for VXLAN
1600 * @arg link Link object
1601 *
1602 * @return Status value on success or a negative error code
1603 */
1605{
1606 struct vxlan_info *vxi = link->l_info;
1607
1608 IS_VXLAN_LINK_ASSERT(link);
1609
1610 if (!(vxi->ce_mask & VXLAN_ATTR_REMCSUM_TX))
1611 return -NLE_NOATTR;
1612
1613 return vxi->vxi_remcsum_tx;
1614}
1615
1616/**
1617 * Set remote offload receive checksum status to use for VXLAN
1618 * @arg link Link object
1619 * @arg csum Status value
1620 *
1621 * @return 0 on success or a negative error code
1622 */
1623int rtnl_link_vxlan_set_remcsum_rx(struct rtnl_link *link, uint8_t csum)
1624{
1625 struct vxlan_info *vxi = link->l_info;
1626
1627 IS_VXLAN_LINK_ASSERT(link);
1628
1629 vxi->vxi_remcsum_rx = csum;
1630 vxi->ce_mask |= VXLAN_ATTR_REMCSUM_RX;
1631
1632 return 0;
1633}
1634
1635/**
1636 * Get remote offload receive checksum status to use for VXLAN
1637 * @arg link Link object
1638 *
1639 * @return Status value on success or a negative error code
1640 */
1642{
1643 struct vxlan_info *vxi = link->l_info;
1644
1645 IS_VXLAN_LINK_ASSERT(link);
1646
1647 if (!(vxi->ce_mask & VXLAN_ATTR_REMCSUM_RX))
1648 return -NLE_NOATTR;
1649
1650 return vxi->vxi_remcsum_rx;
1651}
1652
1653/**
1654 * Set collect metadata status to use for VXLAN
1655 * @arg link Link object
1656 * @arg collect Status value
1657 *
1658 * @return 0 on success or a negative error code
1659 */
1660int rtnl_link_vxlan_set_collect_metadata(struct rtnl_link *link, uint8_t collect)
1661{
1662 struct vxlan_info *vxi = link->l_info;
1663
1664 IS_VXLAN_LINK_ASSERT(link);
1665
1666 vxi->vxi_collect_metadata = collect;
1667 vxi->ce_mask |= VXLAN_ATTR_COLLECT_METADATA;
1668
1669 return 0;
1670}
1671
1672/**
1673 * Get collect metadata status to use for VXLAN
1674 * @arg link Link object
1675 *
1676 * @return Status value on success or a negative error code
1677 */
1679{
1680 struct vxlan_info *vxi = link->l_info;
1681
1682 IS_VXLAN_LINK_ASSERT(link);
1683
1684 if (!(vxi->ce_mask & VXLAN_ATTR_COLLECT_METADATA))
1685 return -NLE_NOATTR;
1686
1687 return vxi->vxi_collect_metadata;
1688}
1689
1690/**
1691 * Set flow label to use for VXLAN
1692 * @arg link Link object
1693 * @arg label Destination label
1694 *
1695 * @return 0 on success or a negative error code
1696 */
1697int rtnl_link_vxlan_set_label(struct rtnl_link *link, uint32_t label)
1698{
1699 struct vxlan_info *vxi = link->l_info;
1700
1701 IS_VXLAN_LINK_ASSERT(link);
1702
1703 vxi->vxi_label = htonl(label);
1704 vxi->ce_mask |= VXLAN_ATTR_LABEL;
1705
1706 return 0;
1707}
1708
1709/**
1710 * Get flow label to use for VXLAN
1711 * @arg link Link object
1712 * @arg label Pointer to store destination label
1713 *
1714 * @return 0 on success or a negative error code
1715 */
1716int rtnl_link_vxlan_get_label(struct rtnl_link *link, uint32_t *label)
1717{
1718 struct vxlan_info *vxi = link->l_info;
1719
1720 IS_VXLAN_LINK_ASSERT(link);
1721
1722 if (!label)
1723 return -NLE_INVAL;
1724
1725 if (!(vxi->ce_mask & VXLAN_ATTR_LABEL))
1726 return -NLE_NOATTR;
1727
1728 *label = ntohl(vxi->vxi_label);
1729
1730 return 0;
1731}
1732
1733/**
1734 * Set VXLAN flags RTNL_LINK_VXLAN_F_*
1735 * @arg link Link object
1736 * @flags Which flags to set
1737 * @arg enable Boolean enabling or disabling flag
1738 *
1739 * @return 0 on success or a negative error code
1740 */
1741int rtnl_link_vxlan_set_flags(struct rtnl_link *link, uint32_t flags, int enable)
1742{
1743 struct vxlan_info *vxi = link->l_info;
1744
1745 IS_VXLAN_LINK_ASSERT(link);
1746
1747 if (flags & ~(RTNL_LINK_VXLAN_F_GBP | RTNL_LINK_VXLAN_F_GPE | RTNL_LINK_VXLAN_F_REMCSUM_NOPARTIAL))
1748 return -NLE_INVAL;
1749
1750 if (enable)
1751 vxi->vxi_flags |= flags;
1752 else
1753 vxi->vxi_flags &= ~flags;
1754
1755 return 0;
1756}
1757
1758/**
1759 * Get VXLAN flags RTNL_LINK_VXLAN_F_*
1760 * @arg link Link object
1761 * @arg out_flags Output value for flags. Must be present.
1762 *
1763 * @return Zero on success or a negative error code
1764 */
1765int rtnl_link_vxlan_get_flags(struct rtnl_link *link, uint32_t *out_flags)
1766{
1767 struct vxlan_info *vxi = link->l_info;
1768
1769 IS_VXLAN_LINK_ASSERT(link);
1770
1771 *out_flags = vxi->vxi_flags;
1772 return 0;
1773}
1774
1775/** @} */
1776
1777static void _nl_init vxlan_init(void)
1778{
1779 rtnl_link_register_info(&vxlan_info_ops);
1780}
1781
1782static void _nl_exit vxlan_exit(void)
1783{
1784 rtnl_link_unregister_info(&vxlan_info_ops);
1785}
1786
1787/** @} */
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
void * nl_addr_get_binary_addr(const struct nl_addr *addr)
Get binary address of abstract address object.
Definition addr.c:943
int nl_addr_get_family(const struct nl_addr *addr)
Return address family.
Definition addr.c:895
unsigned int nl_addr_get_len(const struct nl_addr *addr)
Get length of binary address of abstract address object.
Definition addr.c:955
uint32_t nla_get_u32(const struct nlattr *nla)
Return payload of 32 bit integer attribute.
Definition attr.c:710
uint16_t nla_get_u16(const struct nlattr *nla)
Return payload of 16 bit integer attribute.
Definition attr.c:660
#define NLA_PUT_FLAG(msg, attrtype)
Add flag attribute to netlink message.
Definition attr.h:265
#define NLA_PUT_U8(msg, attrtype, value)
Add 8 bit integer attribute to netlink message.
Definition attr.h:194
#define NLA_PUT(msg, attrtype, attrlen, data)
Add unspecific attribute to netlink message.
Definition attr.h:159
#define NLA_PUT_U32(msg, attrtype, value)
Add 32 bit integer attribute to netlink message.
Definition attr.h:230
uint8_t nla_get_u8(const struct nlattr *nla)
Return value of 8 bit integer attribute.
Definition attr.c:610
int nla_memcpy(void *dest, const struct nlattr *src, int count)
Copy attribute payload to another memory area.
Definition attr.c:351
struct nlattr * nla_nest_start(struct nl_msg *msg, int attrtype)
Start a new level of nested attributes.
Definition attr.c:906
int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, const struct nla_policy *policy)
Create attribute index based on nested attribute.
Definition attr.c:1033
int nla_nest_end(struct nl_msg *msg, struct nlattr *start)
Finalize nesting of attributes.
Definition attr.c:969
@ NLA_U8
8 bit integer
Definition attr.h:35
@ NLA_FLAG
Flag.
Definition attr.h:40
@ NLA_U16
16 bit integer
Definition attr.h:36
@ NLA_U32
32 bit integer
Definition attr.h:37
void nl_dump(struct nl_dump_params *params, const char *fmt,...)
Dump a formatted character string.
Definition utils.c:1017
@ NL_DUMP_LINE
Dump object briefly on one line.
Definition types.h:20
@ NL_DUMP_DETAILS
Dump all attributes but no statistics.
Definition types.h:21
int rtnl_link_vxlan_get_tos(struct rtnl_link *link)
Get IP ToS value to use for VXLAN.
Definition vxlan.c:984
int rtnl_link_vxlan_get_rsc(struct rtnl_link *link)
Get Route Short Circuit status to use for VXLAN.
Definition vxlan.c:1273
int rtnl_link_vxlan_disable_learning(struct rtnl_link *link)
Disable VXLAN address learning.
Definition vxlan.c:1050
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:1171
int rtnl_link_vxlan_set_udp_zero_csum6_rx(struct rtnl_link *link, uint8_t csum)
Set skip UDP checksum received over IPv6 status to use for VXLAN.
Definition vxlan.c:1549
int rtnl_link_vxlan_get_ttl(struct rtnl_link *link)
Get IP TTL value to use for VXLAN.
Definition vxlan.c:947
int rtnl_link_vxlan_get_learning(struct rtnl_link *link)
Get VXLAN learning status.
Definition vxlan.c:1021
int rtnl_link_vxlan_set_learning(struct rtnl_link *link, uint8_t learning)
Set VXLAN learning status.
Definition vxlan.c:1003
int rtnl_link_vxlan_get_label(struct rtnl_link *link, uint32_t *label)
Get flow label to use for VXLAN.
Definition vxlan.c:1716
int rtnl_link_vxlan_set_tos(struct rtnl_link *link, uint8_t tos)
Set IP ToS value to use for VXLAN.
Definition vxlan.c:966
int rtnl_link_vxlan_set_port(struct rtnl_link *link, uint32_t port)
Set UDP destination port to use for VXLAN.
Definition vxlan.c:1432
int rtnl_link_vxlan_get_proxy(struct rtnl_link *link)
Get ARP proxy status to use for VXLAN.
Definition vxlan.c:1214
int rtnl_link_vxlan_enable_rsc(struct rtnl_link *link)
Enable Route Short Circuit.
Definition vxlan.c:1291
int rtnl_link_vxlan_set_group(struct rtnl_link *link, struct nl_addr *addr)
Set VXLAN multicast IP address.
Definition vxlan.c:772
int rtnl_link_vxlan_enable_proxy(struct rtnl_link *link)
Enable ARP proxy.
Definition vxlan.c:1232
int rtnl_link_vxlan_disable_l3miss(struct rtnl_link *link)
Disable netlink IP ADDR miss notifications.
Definition vxlan.c:1420
int rtnl_link_vxlan_set_local(struct rtnl_link *link, struct nl_addr *addr)
Set source address to use for VXLAN.
Definition vxlan.c:872
int rtnl_link_vxlan_set_remcsum_rx(struct rtnl_link *link, uint8_t csum)
Set remote offload receive checksum status to use for VXLAN.
Definition vxlan.c:1623
int rtnl_link_vxlan_set_flags(struct rtnl_link *link, uint32_t flags, int enable)
Set VXLAN flags RTNL_LINK_VXLAN_F_*.
Definition vxlan.c:1741
int rtnl_link_vxlan_set_udp_csum(struct rtnl_link *link, uint8_t csum)
Set UDP checksum status to use for VXLAN.
Definition vxlan.c:1475
int rtnl_link_vxlan_get_udp_zero_csum6_rx(struct rtnl_link *link)
Get skip UDP checksum received over IPv6 status to use for VXLAN.
Definition vxlan.c:1567
int rtnl_link_vxlan_set_link(struct rtnl_link *link, uint32_t index)
Set physical device to use for VXLAN.
Definition vxlan.c:829
int rtnl_link_vxlan_enable_l2miss(struct rtnl_link *link)
Enable netlink LLADDR miss notifications.
Definition vxlan.c:1350
int rtnl_link_vxlan_get_flags(struct rtnl_link *link, uint32_t *out_flags)
Get VXLAN flags RTNL_LINK_VXLAN_F_*.
Definition vxlan.c:1765
int rtnl_link_vxlan_get_remcsum_rx(struct rtnl_link *link)
Get remote offload receive checksum status to use for VXLAN.
Definition vxlan.c:1641
int rtnl_link_vxlan_get_group(struct rtnl_link *link, struct nl_addr **addr)
Get VXLAN multicast IP address.
Definition vxlan.c:803
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:1148
int rtnl_link_vxlan_set_collect_metadata(struct rtnl_link *link, uint8_t collect)
Set collect metadata status to use for VXLAN.
Definition vxlan.c:1660
int rtnl_link_vxlan_get_l2miss(struct rtnl_link *link)
Get netlink LLADDR miss notification status to use for VXLAN.
Definition vxlan.c:1332
int rtnl_link_vxlan_set_id(struct rtnl_link *link, uint32_t id)
Set VXLAN Network Identifier.
Definition vxlan.c:726
int rtnl_link_vxlan_get_collect_metadata(struct rtnl_link *link)
Get collect metadata status to use for VXLAN.
Definition vxlan.c:1678
int rtnl_link_vxlan_disable_l2miss(struct rtnl_link *link)
Disable netlink LLADDR miss notifications.
Definition vxlan.c:1361
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:1105
int rtnl_link_vxlan_set_label(struct rtnl_link *link, uint32_t label)
Set flow label to use for VXLAN.
Definition vxlan.c:1697
int rtnl_link_is_vxlan(struct rtnl_link *link)
Check if link is a VXLAN link.
Definition vxlan.c:714
int rtnl_link_vxlan_set_remcsum_tx(struct rtnl_link *link, uint8_t csum)
Set remote offload transmit checksum status to use for VXLAN.
Definition vxlan.c:1586
int rtnl_link_vxlan_get_local(struct rtnl_link *link, struct nl_addr **addr)
Get source address to use for VXLAN.
Definition vxlan.c:903
int rtnl_link_vxlan_get_link(struct rtnl_link *link, uint32_t *index)
Get physical device to use for VXLAN.
Definition vxlan.c:848
int rtnl_link_vxlan_set_proxy(struct rtnl_link *link, uint8_t proxy)
Set ARP proxy status to use for VXLAN.
Definition vxlan.c:1196
int rtnl_link_vxlan_enable_learning(struct rtnl_link *link)
Enable VXLAN address learning.
Definition vxlan.c:1039
int rtnl_link_vxlan_set_ttl(struct rtnl_link *link, uint8_t ttl)
Set IP TTL value to use for VXLAN.
Definition vxlan.c:929
struct rtnl_link * rtnl_link_vxlan_alloc(void)
Allocate link object of type VXLAN.
Definition vxlan.c:693
int rtnl_link_vxlan_get_udp_zero_csum6_tx(struct rtnl_link *link)
Get skip UDP checksum transmitted over IPv6 status to use for VXLAN.
Definition vxlan.c:1530
int rtnl_link_vxlan_get_l3miss(struct rtnl_link *link)
Get netlink IP ADDR miss notification status to use for VXLAN.
Definition vxlan.c:1391
int rtnl_link_vxlan_get_remcsum_tx(struct rtnl_link *link)
Get remote offload transmit checksum status to use for VXLAN.
Definition vxlan.c:1604
int rtnl_link_vxlan_get_port(struct rtnl_link *link, uint32_t *port)
Get UDP destination port to use for VXLAN.
Definition vxlan.c:1451
int rtnl_link_vxlan_disable_proxy(struct rtnl_link *link)
Disable ARP proxy.
Definition vxlan.c:1243
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:1314
int rtnl_link_vxlan_set_ageing(struct rtnl_link *link, uint32_t expiry)
Set expiration timer value to use for VXLAN.
Definition vxlan.c:1062
int rtnl_link_vxlan_get_id(struct rtnl_link *link, uint32_t *id)
Get VXLAN Network Identifier.
Definition vxlan.c:748
int rtnl_link_vxlan_disable_rsc(struct rtnl_link *link)
Disable Route Short Circuit.
Definition vxlan.c:1302
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:1255
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:1373
int rtnl_link_vxlan_set_udp_zero_csum6_tx(struct rtnl_link *link, uint8_t csum)
Set skip UDP checksum transmitted over IPv6 status to use for VXLAN.
Definition vxlan.c:1512
int rtnl_link_vxlan_get_udp_csum(struct rtnl_link *link)
Get UDP checksum status to use for VXLAN.
Definition vxlan.c:1493
int rtnl_link_vxlan_enable_l3miss(struct rtnl_link *link)
Enable netlink IP ADDR miss notifications.
Definition vxlan.c:1409
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:1124
int rtnl_link_vxlan_get_ageing(struct rtnl_link *link, uint32_t *expiry)
Get expiration timer value to use for VXLAN.
Definition vxlan.c:1081
Dumping parameters.
Definition types.h:32
Attribute validation policy.
Definition attr.h:63
uint16_t type
Type of attribute or NLA_UNSPEC.
Definition attr.h:65