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