]>
Commit | Line | Data |
---|---|---|
a5494df2 SH |
1 | /* |
2 | * iplink_vxlan.c VXLAN device support | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation; either version | |
7 | * 2 of the License, or (at your option) any later version. | |
8 | * | |
9 | * Authors: Stephen Hemminger <shemminger@vyatta.com | |
10 | */ | |
11 | ||
12 | #include <stdio.h> | |
13 | #include <stdlib.h> | |
14 | #include <string.h> | |
15 | #include <net/if.h> | |
16 | #include <linux/ip.h> | |
17 | #include <linux/if_link.h> | |
18 | #include <arpa/inet.h> | |
19 | ||
20 | #include "rt_names.h" | |
21 | #include "utils.h" | |
22 | #include "ip_common.h" | |
23 | ||
561e650e | 24 | static void print_explain(FILE *f) |
25 | { | |
5cd64c97 | 26 | fprintf(f, "Usage: ... vxlan id VNI [ { group | remote } IP_ADDRESS ] [ local ADDR ]\n"); |
561e650e | 27 | fprintf(f, " [ ttl TTL ] [ tos TOS ] [ dev PHYS_DEV ]\n"); |
28 | fprintf(f, " [ dstport PORT ] [ srcport MIN MAX ]\n"); | |
29 | fprintf(f, " [ [no]learning ] [ [no]proxy ] [ [no]rsc ]\n"); | |
30 | fprintf(f, " [ [no]l2miss ] [ [no]l3miss ]\n"); | |
31 | fprintf(f, " [ ageing SECONDS ] [ maxaddress NUMBER ]\n"); | |
666cdc50 | 32 | fprintf(f, " [ [no]udpcsum ] [ [no]udp6zerocsumtx ] [ [no]udp6zerocsumrx ]\n"); |
35f59d86 | 33 | fprintf(f, " [ [no]remcsumtx ] [ [no]remcsumrx ]\n"); |
e79c327e | 34 | fprintf(f, " [ [no]external ] [ gbp ]\n"); |
561e650e | 35 | fprintf(f, "\n"); |
36 | fprintf(f, "Where: VNI := 0-16777215\n"); | |
37 | fprintf(f, " ADDR := { IP_ADDRESS | any }\n"); | |
38 | fprintf(f, " TOS := { NUMBER | inherit }\n"); | |
39 | fprintf(f, " TTL := { 1..255 | inherit }\n"); | |
40 | } | |
41 | ||
a5494df2 SH |
42 | static void explain(void) |
43 | { | |
561e650e | 44 | print_explain(stderr); |
a5494df2 SH |
45 | } |
46 | ||
47 | static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv, | |
48 | struct nlmsghdr *n) | |
49 | { | |
50 | __u32 vni = 0; | |
51 | int vni_set = 0; | |
52 | __u32 saddr = 0; | |
53 | __u32 gaddr = 0; | |
7cfa3802 | 54 | __u32 daddr = 0; |
aa574cd6 WC |
55 | struct in6_addr saddr6 = IN6ADDR_ANY_INIT; |
56 | struct in6_addr gaddr6 = IN6ADDR_ANY_INIT; | |
57 | struct in6_addr daddr6 = IN6ADDR_ANY_INIT; | |
56f5daac | 58 | unsigned int link = 0; |
a5494df2 SH |
59 | __u8 tos = 0; |
60 | __u8 ttl = 0; | |
61 | __u8 learning = 1; | |
1556e29d DS |
62 | __u8 proxy = 0; |
63 | __u8 rsc = 0; | |
64 | __u8 l2miss = 0; | |
65 | __u8 l3miss = 0; | |
a5494df2 SH |
66 | __u8 noage = 0; |
67 | __u32 age = 0; | |
68 | __u32 maxaddr = 0; | |
514cdfb4 | 69 | __u16 dstport = 0; |
666cdc50 TH |
70 | __u8 udpcsum = 0; |
71 | __u8 udp6zerocsumtx = 0; | |
72 | __u8 udp6zerocsumrx = 0; | |
35f59d86 TH |
73 | __u8 remcsumtx = 0; |
74 | __u8 remcsumrx = 0; | |
e79c327e | 75 | __u8 metadata = 0; |
2eb90dc7 | 76 | __u8 gbp = 0; |
514cdfb4 | 77 | int dst_port_set = 0; |
2d596120 | 78 | struct ifla_vxlan_port_range range = { 0, 0 }; |
a5494df2 SH |
79 | |
80 | while (argc > 0) { | |
81 | if (!matches(*argv, "id") || | |
82 | !matches(*argv, "vni")) { | |
83 | NEXT_ARG(); | |
84 | if (get_u32(&vni, *argv, 0) || | |
85 | vni >= 1u << 24) | |
86 | invarg("invalid id", *argv); | |
87 | vni_set = 1; | |
88 | } else if (!matches(*argv, "group")) { | |
89 | NEXT_ARG(); | |
aa574cd6 WC |
90 | if (!inet_get_addr(*argv, &gaddr, &gaddr6)) { |
91 | fprintf(stderr, "Invalid address \"%s\"\n", *argv); | |
92 | return -1; | |
93 | } | |
94 | if (!IN6_IS_ADDR_MULTICAST(&gaddr6) && !IN_MULTICAST(ntohl(gaddr))) | |
7cfa3802 AW |
95 | invarg("invalid group address", *argv); |
96 | } else if (!matches(*argv, "remote")) { | |
97 | NEXT_ARG(); | |
aa574cd6 WC |
98 | if (!inet_get_addr(*argv, &daddr, &daddr6)) { |
99 | fprintf(stderr, "Invalid address \"%s\"\n", *argv); | |
100 | return -1; | |
101 | } | |
102 | if (IN6_IS_ADDR_MULTICAST(&daddr6) || IN_MULTICAST(ntohl(daddr))) | |
7cfa3802 | 103 | invarg("invalid remote address", *argv); |
a5494df2 SH |
104 | } else if (!matches(*argv, "local")) { |
105 | NEXT_ARG(); | |
aa574cd6 WC |
106 | if (strcmp(*argv, "any")) { |
107 | if (!inet_get_addr(*argv, &saddr, &saddr6)) { | |
108 | fprintf(stderr, "Invalid address \"%s\"\n", *argv); | |
109 | return -1; | |
110 | } | |
111 | } | |
112 | ||
113 | if (IN_MULTICAST(ntohl(saddr)) || IN6_IS_ADDR_MULTICAST(&saddr6)) | |
a5494df2 SH |
114 | invarg("invalid local address", *argv); |
115 | } else if (!matches(*argv, "dev")) { | |
116 | NEXT_ARG(); | |
117 | link = if_nametoindex(*argv); | |
0cb6bb51 CW |
118 | if (link == 0) { |
119 | fprintf(stderr, "Cannot find device \"%s\"\n", | |
120 | *argv); | |
a5494df2 | 121 | exit(-1); |
0cb6bb51 | 122 | } |
a5494df2 SH |
123 | } else if (!matches(*argv, "ttl") || |
124 | !matches(*argv, "hoplimit")) { | |
56f5daac | 125 | unsigned int uval; |
a5494df2 SH |
126 | |
127 | NEXT_ARG(); | |
128 | if (strcmp(*argv, "inherit") != 0) { | |
129 | if (get_unsigned(&uval, *argv, 0)) | |
2d596120 | 130 | invarg("invalid TTL", *argv); |
a5494df2 | 131 | if (uval > 255) |
2d596120 | 132 | invarg("TTL must be <= 255", *argv); |
a5494df2 SH |
133 | ttl = uval; |
134 | } | |
135 | } else if (!matches(*argv, "tos") || | |
136 | !matches(*argv, "dsfield")) { | |
137 | __u32 uval; | |
138 | ||
139 | NEXT_ARG(); | |
140 | if (strcmp(*argv, "inherit") != 0) { | |
141 | if (rtnl_dsfield_a2n(&uval, *argv)) | |
142 | invarg("bad TOS value", *argv); | |
143 | tos = uval; | |
144 | } else | |
145 | tos = 1; | |
146 | } else if (!matches(*argv, "ageing")) { | |
147 | NEXT_ARG(); | |
148 | if (strcmp(*argv, "none") == 0) | |
149 | noage = 1; | |
150 | else if (get_u32(&age, *argv, 0)) | |
2d596120 | 151 | invarg("ageing timer", *argv); |
a5494df2 SH |
152 | } else if (!matches(*argv, "maxaddress")) { |
153 | NEXT_ARG(); | |
154 | if (strcmp(*argv, "unlimited") == 0) | |
155 | maxaddr = 0; | |
156 | else if (get_u32(&maxaddr, *argv, 0)) | |
2d596120 | 157 | invarg("max addresses", *argv); |
514cdfb4 SH |
158 | } else if (!matches(*argv, "port") || |
159 | !matches(*argv, "srcport")) { | |
2d596120 | 160 | __u16 minport, maxport; |
56f5daac | 161 | |
2d596120 SH |
162 | NEXT_ARG(); |
163 | if (get_u16(&minport, *argv, 0)) | |
164 | invarg("min port", *argv); | |
165 | NEXT_ARG(); | |
166 | if (get_u16(&maxport, *argv, 0)) | |
167 | invarg("max port", *argv); | |
168 | range.low = htons(minport); | |
169 | range.high = htons(maxport); | |
56f5daac | 170 | } else if (!matches(*argv, "dstport")) { |
514cdfb4 SH |
171 | NEXT_ARG(); |
172 | if (get_u16(&dstport, *argv, 0)) | |
173 | invarg("dst port", *argv); | |
174 | dst_port_set = 1; | |
a5494df2 SH |
175 | } else if (!matches(*argv, "nolearning")) { |
176 | learning = 0; | |
177 | } else if (!matches(*argv, "learning")) { | |
178 | learning = 1; | |
1556e29d DS |
179 | } else if (!matches(*argv, "noproxy")) { |
180 | proxy = 0; | |
181 | } else if (!matches(*argv, "proxy")) { | |
182 | proxy = 1; | |
183 | } else if (!matches(*argv, "norsc")) { | |
184 | rsc = 0; | |
185 | } else if (!matches(*argv, "rsc")) { | |
186 | rsc = 1; | |
187 | } else if (!matches(*argv, "nol2miss")) { | |
188 | l2miss = 0; | |
189 | } else if (!matches(*argv, "l2miss")) { | |
190 | l2miss = 1; | |
191 | } else if (!matches(*argv, "nol3miss")) { | |
192 | l3miss = 0; | |
193 | } else if (!matches(*argv, "l3miss")) { | |
194 | l3miss = 1; | |
666cdc50 TH |
195 | } else if (!matches(*argv, "udpcsum")) { |
196 | udpcsum = 1; | |
197 | } else if (!matches(*argv, "noudpcsum")) { | |
198 | udpcsum = 0; | |
199 | } else if (!matches(*argv, "udp6zerocsumtx")) { | |
200 | udp6zerocsumtx = 1; | |
201 | } else if (!matches(*argv, "noudp6zerocsumtx")) { | |
202 | udp6zerocsumtx = 0; | |
203 | } else if (!matches(*argv, "udp6zerocsumrx")) { | |
204 | udp6zerocsumrx = 1; | |
205 | } else if (!matches(*argv, "noudp6zerocsumrx")) { | |
206 | udp6zerocsumrx = 0; | |
35f59d86 TH |
207 | } else if (!matches(*argv, "remcsumtx")) { |
208 | remcsumtx = 1; | |
209 | } else if (!matches(*argv, "noremcsumtx")) { | |
210 | remcsumtx = 0; | |
211 | } else if (!matches(*argv, "remcsumrx")) { | |
212 | remcsumrx = 1; | |
213 | } else if (!matches(*argv, "noremcsumrx")) { | |
214 | remcsumrx = 0; | |
e79c327e PA |
215 | } else if (!matches(*argv, "external")) { |
216 | metadata = 1; | |
217 | } else if (!matches(*argv, "noexternal")) { | |
218 | metadata = 0; | |
2eb90dc7 TG |
219 | } else if (!matches(*argv, "gbp")) { |
220 | gbp = 1; | |
a5494df2 SH |
221 | } else if (matches(*argv, "help") == 0) { |
222 | explain(); | |
223 | return -1; | |
224 | } else { | |
14645ec2 | 225 | fprintf(stderr, "vxlan: unknown command \"%s\"?\n", *argv); |
a5494df2 SH |
226 | explain(); |
227 | return -1; | |
228 | } | |
229 | argc--, argv++; | |
230 | } | |
2a126a85 | 231 | |
e79c327e PA |
232 | if (metadata && vni_set) { |
233 | fprintf(stderr, "vxlan: both 'external' and vni cannot be specified\n"); | |
234 | return -1; | |
235 | } | |
236 | ||
237 | if (!metadata && !vni_set) { | |
a5494df2 SH |
238 | fprintf(stderr, "vxlan: missing virtual network identifier\n"); |
239 | return -1; | |
240 | } | |
514cdfb4 | 241 | |
aa574cd6 WC |
242 | if ((gaddr && daddr) || |
243 | (memcmp(&gaddr6, &in6addr_any, sizeof(gaddr6)) && | |
244 | memcmp(&daddr6, &in6addr_any, sizeof(daddr6)))) { | |
7cfa3802 AW |
245 | fprintf(stderr, "vxlan: both group and remote cannot be specified\n"); |
246 | return -1; | |
247 | } | |
514cdfb4 SH |
248 | |
249 | if (!dst_port_set) { | |
250 | fprintf(stderr, "vxlan: destination port not specified\n" | |
251 | "Will use Linux kernel default (non-standard value)\n"); | |
0612519e | 252 | fprintf(stderr, |
514cdfb4 SH |
253 | "Use 'dstport 4789' to get the IANA assigned value\n" |
254 | "Use 'dstport 0' to get default and quiet this message\n"); | |
255 | } | |
256 | ||
a5494df2 | 257 | addattr32(n, 1024, IFLA_VXLAN_ID, vni); |
b64da5a5 SH |
258 | if (gaddr) |
259 | addattr_l(n, 1024, IFLA_VXLAN_GROUP, &gaddr, 4); | |
7cfa3802 AW |
260 | else if (daddr) |
261 | addattr_l(n, 1024, IFLA_VXLAN_GROUP, &daddr, 4); | |
aa574cd6 WC |
262 | if (memcmp(&gaddr6, &in6addr_any, sizeof(gaddr6)) != 0) |
263 | addattr_l(n, 1024, IFLA_VXLAN_GROUP6, &gaddr6, sizeof(struct in6_addr)); | |
264 | else if (memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) != 0) | |
265 | addattr_l(n, 1024, IFLA_VXLAN_GROUP6, &daddr6, sizeof(struct in6_addr)); | |
266 | ||
b64da5a5 SH |
267 | if (saddr) |
268 | addattr_l(n, 1024, IFLA_VXLAN_LOCAL, &saddr, 4); | |
aa574cd6 WC |
269 | else if (memcmp(&saddr6, &in6addr_any, sizeof(saddr6)) != 0) |
270 | addattr_l(n, 1024, IFLA_VXLAN_LOCAL6, &saddr6, sizeof(struct in6_addr)); | |
271 | ||
a5494df2 SH |
272 | if (link) |
273 | addattr32(n, 1024, IFLA_VXLAN_LINK, link); | |
274 | addattr8(n, 1024, IFLA_VXLAN_TTL, ttl); | |
275 | addattr8(n, 1024, IFLA_VXLAN_TOS, tos); | |
276 | addattr8(n, 1024, IFLA_VXLAN_LEARNING, learning); | |
1556e29d DS |
277 | addattr8(n, 1024, IFLA_VXLAN_PROXY, proxy); |
278 | addattr8(n, 1024, IFLA_VXLAN_RSC, rsc); | |
279 | addattr8(n, 1024, IFLA_VXLAN_L2MISS, l2miss); | |
280 | addattr8(n, 1024, IFLA_VXLAN_L3MISS, l3miss); | |
666cdc50 TH |
281 | addattr8(n, 1024, IFLA_VXLAN_UDP_CSUM, udpcsum); |
282 | addattr8(n, 1024, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, udp6zerocsumtx); | |
283 | addattr8(n, 1024, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, udp6zerocsumrx); | |
35f59d86 TH |
284 | addattr8(n, 1024, IFLA_VXLAN_REMCSUM_TX, remcsumtx); |
285 | addattr8(n, 1024, IFLA_VXLAN_REMCSUM_RX, remcsumrx); | |
e79c327e | 286 | addattr8(n, 1024, IFLA_VXLAN_COLLECT_METADATA, metadata); |
514cdfb4 | 287 | |
a5494df2 SH |
288 | if (noage) |
289 | addattr32(n, 1024, IFLA_VXLAN_AGEING, 0); | |
290 | else if (age) | |
291 | addattr32(n, 1024, IFLA_VXLAN_AGEING, age); | |
292 | if (maxaddr) | |
293 | addattr32(n, 1024, IFLA_VXLAN_LIMIT, maxaddr); | |
2d596120 SH |
294 | if (range.low || range.high) |
295 | addattr_l(n, 1024, IFLA_VXLAN_PORT_RANGE, | |
296 | &range, sizeof(range)); | |
514cdfb4 SH |
297 | if (dstport) |
298 | addattr16(n, 1024, IFLA_VXLAN_PORT, htons(dstport)); | |
a5494df2 | 299 | |
2eb90dc7 TG |
300 | if (gbp) |
301 | addattr_l(n, 1024, IFLA_VXLAN_GBP, NULL, 0); | |
302 | ||
303 | ||
a5494df2 SH |
304 | return 0; |
305 | } | |
306 | ||
307 | static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) | |
308 | { | |
309 | __u32 vni; | |
56f5daac | 310 | unsigned int link; |
2d596120 SH |
311 | __u8 tos; |
312 | __u32 maxaddr; | |
a5494df2 SH |
313 | char s1[1024]; |
314 | char s2[64]; | |
315 | ||
316 | if (!tb) | |
317 | return; | |
318 | ||
319 | if (!tb[IFLA_VXLAN_ID] || | |
320 | RTA_PAYLOAD(tb[IFLA_VXLAN_ID]) < sizeof(__u32)) | |
321 | return; | |
322 | ||
323 | vni = rta_getattr_u32(tb[IFLA_VXLAN_ID]); | |
324 | fprintf(f, "id %u ", vni); | |
325 | ||
326 | if (tb[IFLA_VXLAN_GROUP]) { | |
b64da5a5 | 327 | __be32 addr = rta_getattr_u32(tb[IFLA_VXLAN_GROUP]); |
56f5daac | 328 | |
7cfa3802 AW |
329 | if (addr) { |
330 | if (IN_MULTICAST(ntohl(addr))) | |
331 | fprintf(f, "group %s ", | |
332 | format_host(AF_INET, 4, &addr, s1, sizeof(s1))); | |
333 | else | |
334 | fprintf(f, "remote %s ", | |
335 | format_host(AF_INET, 4, &addr, s1, sizeof(s1))); | |
336 | } | |
aa574cd6 WC |
337 | } else if (tb[IFLA_VXLAN_GROUP6]) { |
338 | struct in6_addr addr; | |
56f5daac | 339 | |
aa574cd6 WC |
340 | memcpy(&addr, RTA_DATA(tb[IFLA_VXLAN_GROUP6]), sizeof(struct in6_addr)); |
341 | if (memcmp(&addr, &in6addr_any, sizeof(addr)) != 0) { | |
342 | if (IN6_IS_ADDR_MULTICAST(&addr)) | |
343 | fprintf(f, "group %s ", | |
344 | format_host(AF_INET6, sizeof(struct in6_addr), &addr, s1, sizeof(s1))); | |
345 | else | |
346 | fprintf(f, "remote %s ", | |
347 | format_host(AF_INET6, sizeof(struct in6_addr), &addr, s1, sizeof(s1))); | |
348 | } | |
a5494df2 SH |
349 | } |
350 | ||
351 | if (tb[IFLA_VXLAN_LOCAL]) { | |
b64da5a5 | 352 | __be32 addr = rta_getattr_u32(tb[IFLA_VXLAN_LOCAL]); |
56f5daac | 353 | |
a5494df2 | 354 | if (addr) |
1556e29d | 355 | fprintf(f, "local %s ", |
a5494df2 | 356 | format_host(AF_INET, 4, &addr, s1, sizeof(s1))); |
aa574cd6 WC |
357 | } else if (tb[IFLA_VXLAN_LOCAL6]) { |
358 | struct in6_addr addr; | |
56f5daac | 359 | |
aa574cd6 WC |
360 | memcpy(&addr, RTA_DATA(tb[IFLA_VXLAN_LOCAL6]), sizeof(struct in6_addr)); |
361 | if (memcmp(&addr, &in6addr_any, sizeof(addr)) != 0) | |
362 | fprintf(f, "local %s ", | |
363 | format_host(AF_INET6, sizeof(struct in6_addr), &addr, s1, sizeof(s1))); | |
a5494df2 SH |
364 | } |
365 | ||
366 | if (tb[IFLA_VXLAN_LINK] && | |
367 | (link = rta_getattr_u32(tb[IFLA_VXLAN_LINK]))) { | |
368 | const char *n = if_indextoname(link, s2); | |
369 | ||
370 | if (n) | |
371 | fprintf(f, "dev %s ", n); | |
372 | else | |
373 | fprintf(f, "dev %u ", link); | |
374 | } | |
375 | ||
2d596120 SH |
376 | if (tb[IFLA_VXLAN_PORT_RANGE]) { |
377 | const struct ifla_vxlan_port_range *r | |
378 | = RTA_DATA(tb[IFLA_VXLAN_PORT_RANGE]); | |
514cdfb4 | 379 | fprintf(f, "srcport %u %u ", ntohs(r->low), ntohs(r->high)); |
1556e29d | 380 | } |
2d596120 | 381 | |
514cdfb4 SH |
382 | if (tb[IFLA_VXLAN_PORT]) |
383 | fprintf(f, "dstport %u ", | |
384 | ntohs(rta_getattr_u16(tb[IFLA_VXLAN_PORT]))); | |
385 | ||
a5494df2 SH |
386 | if (tb[IFLA_VXLAN_LEARNING] && |
387 | !rta_getattr_u8(tb[IFLA_VXLAN_LEARNING])) | |
388 | fputs("nolearning ", f); | |
1556e29d DS |
389 | |
390 | if (tb[IFLA_VXLAN_PROXY] && rta_getattr_u8(tb[IFLA_VXLAN_PROXY])) | |
391 | fputs("proxy ", f); | |
392 | ||
393 | if (tb[IFLA_VXLAN_RSC] && rta_getattr_u8(tb[IFLA_VXLAN_RSC])) | |
394 | fputs("rsc ", f); | |
395 | ||
396 | if (tb[IFLA_VXLAN_L2MISS] && rta_getattr_u8(tb[IFLA_VXLAN_L2MISS])) | |
397 | fputs("l2miss ", f); | |
398 | ||
399 | if (tb[IFLA_VXLAN_L3MISS] && rta_getattr_u8(tb[IFLA_VXLAN_L3MISS])) | |
400 | fputs("l3miss ", f); | |
401 | ||
2d596120 SH |
402 | if (tb[IFLA_VXLAN_TOS] && |
403 | (tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]))) { | |
a5494df2 SH |
404 | if (tos == 1) |
405 | fprintf(f, "tos inherit "); | |
406 | else | |
407 | fprintf(f, "tos %#x ", tos); | |
408 | } | |
409 | ||
410 | if (tb[IFLA_VXLAN_TTL]) { | |
411 | __u8 ttl = rta_getattr_u8(tb[IFLA_VXLAN_TTL]); | |
56f5daac | 412 | |
a5494df2 SH |
413 | if (ttl) |
414 | fprintf(f, "ttl %d ", ttl); | |
415 | } | |
416 | ||
417 | if (tb[IFLA_VXLAN_AGEING]) { | |
418 | __u32 age = rta_getattr_u32(tb[IFLA_VXLAN_AGEING]); | |
56f5daac | 419 | |
a5494df2 SH |
420 | if (age == 0) |
421 | fprintf(f, "ageing none "); | |
422 | else | |
423 | fprintf(f, "ageing %u ", age); | |
424 | } | |
2d596120 SH |
425 | |
426 | if (tb[IFLA_VXLAN_LIMIT] && | |
6ad5399c | 427 | ((maxaddr = rta_getattr_u32(tb[IFLA_VXLAN_LIMIT])) != 0)) |
2d596120 | 428 | fprintf(f, "maxaddr %u ", maxaddr); |
666cdc50 TH |
429 | |
430 | if (tb[IFLA_VXLAN_UDP_CSUM] && rta_getattr_u8(tb[IFLA_VXLAN_UDP_CSUM])) | |
431 | fputs("udpcsum ", f); | |
432 | ||
433 | if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX] && | |
434 | rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX])) | |
435 | fputs("udp6zerocsumtx ", f); | |
436 | ||
437 | if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX] && | |
438 | rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX])) | |
439 | fputs("udp6zerocsumrx ", f); | |
2eb90dc7 | 440 | |
35f59d86 TH |
441 | if (tb[IFLA_VXLAN_REMCSUM_TX] && |
442 | rta_getattr_u8(tb[IFLA_VXLAN_REMCSUM_TX])) | |
443 | fputs("remcsumtx ", f); | |
444 | ||
445 | if (tb[IFLA_VXLAN_REMCSUM_RX] && | |
446 | rta_getattr_u8(tb[IFLA_VXLAN_REMCSUM_RX])) | |
447 | fputs("remcsumrx ", f); | |
448 | ||
e79c327e PA |
449 | if (tb[IFLA_VXLAN_COLLECT_METADATA] && |
450 | rta_getattr_u8(tb[IFLA_VXLAN_COLLECT_METADATA])) | |
451 | fputs("external ", f); | |
452 | ||
2eb90dc7 TG |
453 | if (tb[IFLA_VXLAN_GBP]) |
454 | fputs("gbp ", f); | |
a5494df2 SH |
455 | } |
456 | ||
561e650e | 457 | static void vxlan_print_help(struct link_util *lu, int argc, char **argv, |
458 | FILE *f) | |
459 | { | |
460 | print_explain(f); | |
461 | } | |
462 | ||
a5494df2 SH |
463 | struct link_util vxlan_link_util = { |
464 | .id = "vxlan", | |
465 | .maxattr = IFLA_VXLAN_MAX, | |
466 | .parse_opt = vxlan_parse_opt, | |
467 | .print_opt = vxlan_print_opt, | |
561e650e | 468 | .print_help = vxlan_print_help, |
a5494df2 | 469 | }; |