]> git.proxmox.com Git - mirror_iproute2.git/blob - ip/link_gre.c
lib/libnetlink: update rtnl_talk to support malloc buff at run time
[mirror_iproute2.git] / ip / link_gre.c
1 /*
2 * link_gre.c gre driver module
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: Herbert Xu <herbert@gondor.apana.org.au>
10 *
11 */
12
13 #include <string.h>
14 #include <net/if.h>
15 #include <sys/types.h>
16 #include <sys/socket.h>
17 #include <arpa/inet.h>
18
19 #include <linux/ip.h>
20 #include <linux/if_tunnel.h>
21 #include "rt_names.h"
22 #include "utils.h"
23 #include "ip_common.h"
24 #include "tunnel.h"
25
26 static void print_usage(FILE *f)
27 {
28 fprintf(f,
29 "Usage: ... { gre | gretap | erspan } [ remote ADDR ]\n"
30 " [ local ADDR ]\n"
31 " [ [i|o]seq ]\n"
32 " [ [i|o]key KEY ]\n"
33 " [ [i|o]csum ]\n"
34 " [ ttl TTL ]\n"
35 " [ tos TOS ]\n"
36 " [ [no]pmtudisc ]\n"
37 " [ [no]ignore-df ]\n"
38 " [ dev PHYS_DEV ]\n"
39 " [ noencap ]\n"
40 " [ encap { fou | gue | none } ]\n"
41 " [ encap-sport PORT ]\n"
42 " [ encap-dport PORT ]\n"
43 " [ [no]encap-csum ]\n"
44 " [ [no]encap-csum6 ]\n"
45 " [ [no]encap-remcsum ]\n"
46 " [ fwmark MARK ]\n"
47 " [ erspan IDX ]\n"
48 "\n"
49 "Where: ADDR := { IP_ADDRESS | any }\n"
50 " TOS := { NUMBER | inherit }\n"
51 " TTL := { 1..255 | inherit }\n"
52 " KEY := { DOTTED_QUAD | NUMBER }\n"
53 " MARK := { 0x0..0xffffffff }\n"
54 );
55 }
56
57 static void usage(void) __attribute__((noreturn));
58 static void usage(void)
59 {
60 print_usage(stderr);
61 exit(-1);
62 }
63
64 static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
65 struct nlmsghdr *n)
66 {
67 struct ifinfomsg *ifi = (struct ifinfomsg *)(n + 1);
68 struct {
69 struct nlmsghdr n;
70 struct ifinfomsg i;
71 } req = {
72 .n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
73 .n.nlmsg_flags = NLM_F_REQUEST,
74 .n.nlmsg_type = RTM_GETLINK,
75 .i.ifi_family = preferred_family,
76 .i.ifi_index = ifi->ifi_index,
77 };
78 struct nlmsghdr *answer = NULL;
79 struct rtattr *tb[IFLA_MAX + 1];
80 struct rtattr *linkinfo[IFLA_INFO_MAX+1];
81 struct rtattr *greinfo[IFLA_GRE_MAX + 1];
82 __u16 iflags = 0;
83 __u16 oflags = 0;
84 unsigned int ikey = 0;
85 unsigned int okey = 0;
86 unsigned int saddr = 0;
87 unsigned int daddr = 0;
88 unsigned int link = 0;
89 __u8 pmtudisc = 1;
90 __u8 ttl = 0;
91 __u8 tos = 0;
92 int len;
93 __u16 encaptype = 0;
94 __u16 encapflags = 0;
95 __u16 encapsport = 0;
96 __u16 encapdport = 0;
97 __u8 metadata = 0;
98 __u8 ignore_df = 0;
99 __u32 fwmark = 0;
100 __u32 erspan_idx = 0;
101
102 if (!(n->nlmsg_flags & NLM_F_CREATE)) {
103 if (rtnl_talk(&rth, &req.n, &answer) < 0) {
104 get_failed:
105 fprintf(stderr,
106 "Failed to get existing tunnel info.\n");
107 free(answer);
108 return -1;
109 }
110
111 len = answer->nlmsg_len;
112 len -= NLMSG_LENGTH(sizeof(*ifi));
113 if (len < 0)
114 goto get_failed;
115
116 parse_rtattr(tb, IFLA_MAX, IFLA_RTA(NLMSG_DATA(answer)), len);
117
118 if (!tb[IFLA_LINKINFO])
119 goto get_failed;
120
121 parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb[IFLA_LINKINFO]);
122
123 if (!linkinfo[IFLA_INFO_DATA])
124 goto get_failed;
125
126 parse_rtattr_nested(greinfo, IFLA_GRE_MAX,
127 linkinfo[IFLA_INFO_DATA]);
128
129 if (greinfo[IFLA_GRE_IKEY])
130 ikey = rta_getattr_u32(greinfo[IFLA_GRE_IKEY]);
131
132 if (greinfo[IFLA_GRE_OKEY])
133 okey = rta_getattr_u32(greinfo[IFLA_GRE_OKEY]);
134
135 if (greinfo[IFLA_GRE_IFLAGS])
136 iflags = rta_getattr_u16(greinfo[IFLA_GRE_IFLAGS]);
137
138 if (greinfo[IFLA_GRE_OFLAGS])
139 oflags = rta_getattr_u16(greinfo[IFLA_GRE_OFLAGS]);
140
141 if (greinfo[IFLA_GRE_LOCAL])
142 saddr = rta_getattr_u32(greinfo[IFLA_GRE_LOCAL]);
143
144 if (greinfo[IFLA_GRE_REMOTE])
145 daddr = rta_getattr_u32(greinfo[IFLA_GRE_REMOTE]);
146
147 if (greinfo[IFLA_GRE_PMTUDISC])
148 pmtudisc = rta_getattr_u8(
149 greinfo[IFLA_GRE_PMTUDISC]);
150
151 if (greinfo[IFLA_GRE_TTL])
152 ttl = rta_getattr_u8(greinfo[IFLA_GRE_TTL]);
153
154 if (greinfo[IFLA_GRE_TOS])
155 tos = rta_getattr_u8(greinfo[IFLA_GRE_TOS]);
156
157 if (greinfo[IFLA_GRE_LINK])
158 link = rta_getattr_u8(greinfo[IFLA_GRE_LINK]);
159
160 if (greinfo[IFLA_GRE_ENCAP_TYPE])
161 encaptype = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_TYPE]);
162 if (greinfo[IFLA_GRE_ENCAP_FLAGS])
163 encapflags = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_FLAGS]);
164 if (greinfo[IFLA_GRE_ENCAP_SPORT])
165 encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
166 if (greinfo[IFLA_GRE_ENCAP_DPORT])
167 encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
168
169 if (greinfo[IFLA_GRE_COLLECT_METADATA])
170 metadata = 1;
171
172 if (greinfo[IFLA_GRE_IGNORE_DF])
173 ignore_df =
174 !!rta_getattr_u8(greinfo[IFLA_GRE_IGNORE_DF]);
175
176 if (greinfo[IFLA_GRE_FWMARK])
177 fwmark = rta_getattr_u32(greinfo[IFLA_GRE_FWMARK]);
178
179 if (greinfo[IFLA_GRE_ERSPAN_INDEX])
180 erspan_idx = rta_getattr_u32(greinfo[IFLA_GRE_ERSPAN_INDEX]);
181
182 free(answer);
183 }
184
185 while (argc > 0) {
186 if (!matches(*argv, "key")) {
187 unsigned int uval;
188
189 NEXT_ARG();
190 iflags |= GRE_KEY;
191 oflags |= GRE_KEY;
192 if (strchr(*argv, '.'))
193 uval = get_addr32(*argv);
194 else {
195 if (get_unsigned(&uval, *argv, 0) < 0) {
196 fprintf(stderr,
197 "Invalid value for \"key\": \"%s\"; it should be an unsigned integer\n", *argv);
198 exit(-1);
199 }
200 uval = htonl(uval);
201 }
202
203 ikey = okey = uval;
204 } else if (!matches(*argv, "ikey")) {
205 unsigned int uval;
206
207 NEXT_ARG();
208 iflags |= GRE_KEY;
209 if (strchr(*argv, '.'))
210 uval = get_addr32(*argv);
211 else {
212 if (get_unsigned(&uval, *argv, 0) < 0) {
213 fprintf(stderr, "invalid value for \"ikey\": \"%s\"; it should be an unsigned integer\n", *argv);
214 exit(-1);
215 }
216 uval = htonl(uval);
217 }
218 ikey = uval;
219 } else if (!matches(*argv, "okey")) {
220 unsigned int uval;
221
222 NEXT_ARG();
223 oflags |= GRE_KEY;
224 if (strchr(*argv, '.'))
225 uval = get_addr32(*argv);
226 else {
227 if (get_unsigned(&uval, *argv, 0) < 0) {
228 fprintf(stderr, "invalid value for \"okey\": \"%s\"; it should be an unsigned integer\n", *argv);
229 exit(-1);
230 }
231 uval = htonl(uval);
232 }
233 okey = uval;
234 } else if (!matches(*argv, "seq")) {
235 iflags |= GRE_SEQ;
236 oflags |= GRE_SEQ;
237 } else if (!matches(*argv, "iseq")) {
238 iflags |= GRE_SEQ;
239 } else if (!matches(*argv, "oseq")) {
240 oflags |= GRE_SEQ;
241 } else if (!matches(*argv, "csum")) {
242 iflags |= GRE_CSUM;
243 oflags |= GRE_CSUM;
244 } else if (!matches(*argv, "icsum")) {
245 iflags |= GRE_CSUM;
246 } else if (!matches(*argv, "ocsum")) {
247 oflags |= GRE_CSUM;
248 } else if (!matches(*argv, "nopmtudisc")) {
249 pmtudisc = 0;
250 } else if (!matches(*argv, "pmtudisc")) {
251 pmtudisc = 1;
252 } else if (!matches(*argv, "remote")) {
253 NEXT_ARG();
254 if (strcmp(*argv, "any"))
255 daddr = get_addr32(*argv);
256 } else if (!matches(*argv, "local")) {
257 NEXT_ARG();
258 if (strcmp(*argv, "any"))
259 saddr = get_addr32(*argv);
260 } else if (!matches(*argv, "dev")) {
261 NEXT_ARG();
262 link = if_nametoindex(*argv);
263 if (link == 0) {
264 fprintf(stderr, "Cannot find device \"%s\"\n",
265 *argv);
266 exit(-1);
267 }
268 } else if (!matches(*argv, "ttl") ||
269 !matches(*argv, "hoplimit")) {
270 unsigned int uval;
271
272 NEXT_ARG();
273 if (strcmp(*argv, "inherit") != 0) {
274 if (get_unsigned(&uval, *argv, 0))
275 invarg("invalid TTL\n", *argv);
276 if (uval > 255)
277 invarg("TTL must be <= 255\n", *argv);
278 ttl = uval;
279 }
280 } else if (!matches(*argv, "tos") ||
281 !matches(*argv, "tclass") ||
282 !matches(*argv, "dsfield")) {
283 __u32 uval;
284
285 NEXT_ARG();
286 if (strcmp(*argv, "inherit") != 0) {
287 if (rtnl_dsfield_a2n(&uval, *argv))
288 invarg("bad TOS value", *argv);
289 tos = uval;
290 } else
291 tos = 1;
292 } else if (strcmp(*argv, "noencap") == 0) {
293 encaptype = TUNNEL_ENCAP_NONE;
294 } else if (strcmp(*argv, "encap") == 0) {
295 NEXT_ARG();
296 if (strcmp(*argv, "fou") == 0)
297 encaptype = TUNNEL_ENCAP_FOU;
298 else if (strcmp(*argv, "gue") == 0)
299 encaptype = TUNNEL_ENCAP_GUE;
300 else if (strcmp(*argv, "none") == 0)
301 encaptype = TUNNEL_ENCAP_NONE;
302 else
303 invarg("Invalid encap type.", *argv);
304 } else if (strcmp(*argv, "encap-sport") == 0) {
305 NEXT_ARG();
306 if (strcmp(*argv, "auto") == 0)
307 encapsport = 0;
308 else if (get_u16(&encapsport, *argv, 0))
309 invarg("Invalid source port.", *argv);
310 } else if (strcmp(*argv, "encap-dport") == 0) {
311 NEXT_ARG();
312 if (get_u16(&encapdport, *argv, 0))
313 invarg("Invalid destination port.", *argv);
314 } else if (strcmp(*argv, "encap-csum") == 0) {
315 encapflags |= TUNNEL_ENCAP_FLAG_CSUM;
316 } else if (strcmp(*argv, "noencap-csum") == 0) {
317 encapflags &= ~TUNNEL_ENCAP_FLAG_CSUM;
318 } else if (strcmp(*argv, "encap-udp6-csum") == 0) {
319 encapflags |= TUNNEL_ENCAP_FLAG_CSUM6;
320 } else if (strcmp(*argv, "noencap-udp6-csum") == 0) {
321 encapflags |= ~TUNNEL_ENCAP_FLAG_CSUM6;
322 } else if (strcmp(*argv, "encap-remcsum") == 0) {
323 encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM;
324 } else if (strcmp(*argv, "noencap-remcsum") == 0) {
325 encapflags |= ~TUNNEL_ENCAP_FLAG_REMCSUM;
326 } else if (strcmp(*argv, "external") == 0) {
327 metadata = 1;
328 } else if (strcmp(*argv, "ignore-df") == 0) {
329 ignore_df = 1;
330 } else if (strcmp(*argv, "noignore-df") == 0) {
331 /*
332 *only the lsb is significant, use 2 for presence
333 */
334 ignore_df = 2;
335 } else if (strcmp(*argv, "fwmark") == 0) {
336 NEXT_ARG();
337 if (get_u32(&fwmark, *argv, 0))
338 invarg("invalid fwmark\n", *argv);
339 } else if (strcmp(*argv, "erspan") == 0) {
340 NEXT_ARG();
341 if (get_u32(&erspan_idx, *argv, 0))
342 invarg("invalid erspan index\n", *argv);
343 if (erspan_idx & ~((1<<20) - 1) || erspan_idx == 0)
344 invarg("erspan index must be > 0 and <= 20-bit\n", *argv);
345 } else
346 usage();
347 argc--; argv++;
348 }
349
350 if (!ikey && IN_MULTICAST(ntohl(daddr))) {
351 ikey = daddr;
352 iflags |= GRE_KEY;
353 }
354 if (!okey && IN_MULTICAST(ntohl(daddr))) {
355 okey = daddr;
356 oflags |= GRE_KEY;
357 }
358 if (IN_MULTICAST(ntohl(daddr)) && !saddr) {
359 fprintf(stderr, "A broadcast tunnel requires a source address.\n");
360 return -1;
361 }
362
363 if (!metadata) {
364 addattr32(n, 1024, IFLA_GRE_IKEY, ikey);
365 addattr32(n, 1024, IFLA_GRE_OKEY, okey);
366 addattr_l(n, 1024, IFLA_GRE_IFLAGS, &iflags, 2);
367 addattr_l(n, 1024, IFLA_GRE_OFLAGS, &oflags, 2);
368 addattr_l(n, 1024, IFLA_GRE_LOCAL, &saddr, 4);
369 addattr_l(n, 1024, IFLA_GRE_REMOTE, &daddr, 4);
370 addattr_l(n, 1024, IFLA_GRE_PMTUDISC, &pmtudisc, 1);
371 if (link)
372 addattr32(n, 1024, IFLA_GRE_LINK, link);
373 addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
374 addattr_l(n, 1024, IFLA_GRE_TOS, &tos, 1);
375 addattr32(n, 1024, IFLA_GRE_FWMARK, fwmark);
376 if (erspan_idx != 0)
377 addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
378 } else {
379 addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
380 }
381
382 addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
383 addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
384 addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
385 addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
386
387 if (ignore_df)
388 addattr8(n, 1024, IFLA_GRE_IGNORE_DF, ignore_df & 1);
389
390 return 0;
391 }
392
393 static void gre_print_direct_opt(FILE *f, struct rtattr *tb[])
394 {
395 char s2[64];
396 const char *local = "any";
397 const char *remote = "any";
398 unsigned int iflags = 0;
399 unsigned int oflags = 0;
400
401 if (tb[IFLA_GRE_REMOTE]) {
402 unsigned int addr = rta_getattr_u32(tb[IFLA_GRE_REMOTE]);
403
404 if (addr)
405 remote = format_host(AF_INET, 4, &addr);
406 }
407
408 print_string(PRINT_ANY, "remote", "remote %s ", remote);
409
410 if (tb[IFLA_GRE_LOCAL]) {
411 unsigned int addr = rta_getattr_u32(tb[IFLA_GRE_LOCAL]);
412
413 if (addr)
414 local = format_host(AF_INET, 4, &addr);
415 }
416
417 print_string(PRINT_ANY, "local", "local %s ", local);
418
419 if (tb[IFLA_GRE_LINK] && rta_getattr_u32(tb[IFLA_GRE_LINK])) {
420 unsigned int link = rta_getattr_u32(tb[IFLA_GRE_LINK]);
421 const char *n = if_indextoname(link, s2);
422
423 if (n)
424 print_string(PRINT_ANY, "link", "dev %s ", n);
425 else
426 print_uint(PRINT_ANY, "link_index", "dev %u ", link);
427 }
428
429 if (tb[IFLA_GRE_TTL]) {
430 __u8 ttl = rta_getattr_u8(tb[IFLA_GRE_TTL]);
431
432 if (ttl)
433 print_int(PRINT_ANY, "ttl", "ttl %d ", ttl);
434 else
435 print_int(PRINT_JSON, "ttl", NULL, ttl);
436 } else {
437 print_string(PRINT_FP, NULL, "ttl %s ", "inherit");
438 }
439
440 if (tb[IFLA_GRE_TOS] && rta_getattr_u8(tb[IFLA_GRE_TOS])) {
441 int tos = rta_getattr_u8(tb[IFLA_GRE_TOS]);
442
443 if (is_json_context()) {
444 SPRINT_BUF(b1);
445
446 snprintf(b1, sizeof(b1), "0x%x", tos);
447 print_string(PRINT_JSON, "tos", NULL, b1);
448 } else {
449 fputs("tos ", f);
450 if (tos == 1)
451 fputs("inherit ", f);
452 else
453 fprintf(f, "0x%x ", tos);
454 }
455 }
456
457 if (tb[IFLA_GRE_PMTUDISC]) {
458 if (!rta_getattr_u8(tb[IFLA_GRE_PMTUDISC]))
459 print_bool(PRINT_ANY, "pmtudisc", "nopmtudisc ", false);
460 else
461 print_bool(PRINT_JSON, "pmtudisc", NULL, true);
462 }
463
464 if (tb[IFLA_GRE_IFLAGS])
465 iflags = rta_getattr_u16(tb[IFLA_GRE_IFLAGS]);
466
467 if (tb[IFLA_GRE_OFLAGS])
468 oflags = rta_getattr_u16(tb[IFLA_GRE_OFLAGS]);
469
470 if ((iflags & GRE_KEY) && tb[IFLA_GRE_IKEY]) {
471 inet_ntop(AF_INET, RTA_DATA(tb[IFLA_GRE_IKEY]), s2, sizeof(s2));
472 print_string(PRINT_ANY, "ikey", "ikey %s ", s2);
473 }
474
475 if ((oflags & GRE_KEY) && tb[IFLA_GRE_OKEY]) {
476 inet_ntop(AF_INET, RTA_DATA(tb[IFLA_GRE_OKEY]), s2, sizeof(s2));
477 print_string(PRINT_ANY, "okey", "okey %s ", s2);
478 }
479
480 if (iflags & GRE_SEQ)
481 print_bool(PRINT_ANY, "iseq", "iseq ", true);
482 if (oflags & GRE_SEQ)
483 print_bool(PRINT_ANY, "oseq", "oseq ", true);
484 if (iflags & GRE_CSUM)
485 print_bool(PRINT_ANY, "icsum", "icsum ", true);
486 if (oflags & GRE_CSUM)
487 print_bool(PRINT_ANY, "ocsum", "ocsum ", true);
488
489 if (tb[IFLA_GRE_FWMARK]) {
490 __u32 fwmark = rta_getattr_u32(tb[IFLA_GRE_FWMARK]);
491
492 if (fwmark) {
493 snprintf(s2, sizeof(s2), "0x%x", fwmark);
494
495 print_string(PRINT_ANY, "fwmark", "fwmark %s ", s2);
496 }
497 }
498 }
499
500 static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
501 {
502 if (!tb)
503 return;
504
505 if (!tb[IFLA_GRE_COLLECT_METADATA])
506 gre_print_direct_opt(f, tb);
507 else
508 print_bool(PRINT_ANY, "external", "external ", true);
509
510 if (tb[IFLA_GRE_IGNORE_DF] && rta_getattr_u8(tb[IFLA_GRE_IGNORE_DF]))
511 print_bool(PRINT_ANY, "ignore_df", "ignore-df ", true);
512
513 if (tb[IFLA_GRE_ERSPAN_INDEX]) {
514 __u32 erspan_idx = rta_getattr_u32(tb[IFLA_GRE_ERSPAN_INDEX]);
515
516 fprintf(f, "erspan_index %u ", erspan_idx);
517 }
518
519 if (tb[IFLA_GRE_ENCAP_TYPE] &&
520 rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
521 __u16 type = rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]);
522 __u16 flags = rta_getattr_u16(tb[IFLA_GRE_ENCAP_FLAGS]);
523 __u16 sport = rta_getattr_u16(tb[IFLA_GRE_ENCAP_SPORT]);
524 __u16 dport = rta_getattr_u16(tb[IFLA_GRE_ENCAP_DPORT]);
525
526
527 open_json_object("encap");
528 print_string(PRINT_FP, NULL, "encap ", NULL);
529
530 switch (type) {
531 case TUNNEL_ENCAP_FOU:
532 print_string(PRINT_ANY, "type", "%s ", "fou");
533 break;
534 case TUNNEL_ENCAP_GUE:
535 print_string(PRINT_ANY, "type", "%s ", "gue");
536 break;
537 default:
538 print_null(PRINT_ANY, "type", "%s ", "unknown");
539 break;
540 }
541
542 if (is_json_context()) {
543 print_uint(PRINT_JSON,
544 "sport",
545 NULL,
546 sport ? ntohs(sport) : 0);
547 print_uint(PRINT_JSON, "dport", NULL, ntohs(dport));
548
549 print_bool(PRINT_JSON,
550 "csum",
551 NULL,
552 flags & TUNNEL_ENCAP_FLAG_CSUM);
553
554 print_bool(PRINT_JSON,
555 "csum6",
556 NULL,
557 flags & TUNNEL_ENCAP_FLAG_CSUM6);
558
559 print_bool(PRINT_JSON,
560 "remcsum",
561 NULL,
562 flags & TUNNEL_ENCAP_FLAG_REMCSUM);
563
564 close_json_object();
565 } else {
566 if (sport == 0)
567 fputs("encap-sport auto ", f);
568 else
569 fprintf(f, "encap-sport %u", ntohs(sport));
570
571 fprintf(f, "encap-dport %u ", ntohs(dport));
572
573 if (flags & TUNNEL_ENCAP_FLAG_CSUM)
574 fputs("encap-csum ", f);
575 else
576 fputs("noencap-csum ", f);
577
578 if (flags & TUNNEL_ENCAP_FLAG_CSUM6)
579 fputs("encap-csum6 ", f);
580 else
581 fputs("noencap-csum6 ", f);
582
583 if (flags & TUNNEL_ENCAP_FLAG_REMCSUM)
584 fputs("encap-remcsum ", f);
585 else
586 fputs("noencap-remcsum ", f);
587 }
588 }
589 }
590
591 static void gre_print_help(struct link_util *lu, int argc, char **argv,
592 FILE *f)
593 {
594 print_usage(f);
595 }
596
597 struct link_util gre_link_util = {
598 .id = "gre",
599 .maxattr = IFLA_GRE_MAX,
600 .parse_opt = gre_parse_opt,
601 .print_opt = gre_print_opt,
602 .print_help = gre_print_help,
603 };
604
605 struct link_util gretap_link_util = {
606 .id = "gretap",
607 .maxattr = IFLA_GRE_MAX,
608 .parse_opt = gre_parse_opt,
609 .print_opt = gre_print_opt,
610 .print_help = gre_print_help,
611 };
612
613 struct link_util erspan_link_util = {
614 .id = "erspan",
615 .maxattr = IFLA_GRE_MAX,
616 .parse_opt = gre_parse_opt,
617 .print_opt = gre_print_opt,
618 .print_help = gre_print_help,
619 };