blob: 7ec377791d88b15e3fd5e9398d50d043c6d340a8 [file] [log] [blame]
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +01001/*
2 * link_iptnl.c ipip and sit 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: Nicolas Dichtel <nicolas.dichtel@6wind.com>
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
vadimk561e6502014-09-30 08:17:31 +030026static void print_usage(FILE *f, int sit)
27{
28 fprintf(f, "Usage: ip link { add | set | change | replace | del } NAME\n");
29 fprintf(f, " type { ipip | sit } [ remote ADDR ] [ local ADDR ]\n");
30 fprintf(f, " [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n");
31 fprintf(f, " [ 6rd-prefix ADDR ] [ 6rd-relay_prefix ADDR ] [ 6rd-reset ]\n");
Tom Herbertc1159152014-11-05 10:06:25 -080032 fprintf(f, " [ noencap ] [ encap { fou | gue | none } ]\n");
33 fprintf(f, " [ encap-sport PORT ] [ encap-dport PORT ]\n");
Tom Herbert858dbb22015-01-29 08:51:58 -080034 fprintf(f, " [ [no]encap-csum ] [ [no]encap-csum6 ] [ [no]encap-remcsum ]\n");
vadimk561e6502014-09-30 08:17:31 +030035 if (sit) {
36 fprintf(f, " [ mode { ip6ip | ipip | any } ]\n");
37 fprintf(f, " [ isatap ]\n");
38 }
39 fprintf(f, "\n");
40 fprintf(f, "Where: NAME := STRING\n");
41 fprintf(f, " ADDR := { IP_ADDRESS | any }\n");
42 fprintf(f, " TOS := { NUMBER | inherit }\n");
43 fprintf(f, " TTL := { 1..255 | inherit }\n");
44}
45
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +010046static void usage(int sit) __attribute__((noreturn));
47static void usage(int sit)
48{
vadimk561e6502014-09-30 08:17:31 +030049 print_usage(stderr, sit);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +010050 exit(-1);
51}
52
53static int iptunnel_parse_opt(struct link_util *lu, int argc, char **argv,
54 struct nlmsghdr *n)
55{
Phil Sutterd17b1362016-07-18 16:48:42 +020056 struct ifinfomsg *ifi = (struct ifinfomsg *)(n + 1);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +010057 struct {
58 struct nlmsghdr n;
59 struct ifinfomsg i;
60 char buf[2048];
Phil Sutterd17b1362016-07-18 16:48:42 +020061 } req = {
62 .n.nlmsg_len = NLMSG_LENGTH(sizeof(*ifi)),
63 .n.nlmsg_flags = NLM_F_REQUEST,
64 .n.nlmsg_type = RTM_GETLINK,
65 .i.ifi_family = preferred_family,
66 .i.ifi_index = ifi->ifi_index,
67 };
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +010068 struct rtattr *tb[IFLA_MAX + 1];
69 struct rtattr *linkinfo[IFLA_INFO_MAX+1];
70 struct rtattr *iptuninfo[IFLA_IPTUN_MAX + 1];
71 int len;
72 __u32 link = 0;
73 __u32 laddr = 0;
74 __u32 raddr = 0;
75 __u8 ttl = 0;
76 __u8 tos = 0;
77 __u8 pmtudisc = 1;
78 __u16 iflags = 0;
Nicolas Dichtel77620be2013-07-16 22:54:14 +020079 __u8 proto = 0;
Phil Sutterd17b1362016-07-18 16:48:42 +020080 struct in6_addr ip6rdprefix = {};
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +010081 __u16 ip6rdprefixlen = 0;
82 __u32 ip6rdrelayprefix = 0;
83 __u16 ip6rdrelayprefixlen = 0;
Tom Herbertc1159152014-11-05 10:06:25 -080084 __u16 encaptype = 0;
85 __u16 encapflags = 0;
86 __u16 encapsport = 0;
87 __u16 encapdport = 0;
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +010088
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +010089 if (!(n->nlmsg_flags & NLM_F_CREATE)) {
Stephen Hemmingerc079e122015-05-27 12:26:14 -070090 if (rtnl_talk(&rth, &req.n, &req.n, sizeof(req)) < 0) {
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +010091get_failed:
92 fprintf(stderr,
93 "Failed to get existing tunnel info.\n");
94 return -1;
95 }
96
97 len = req.n.nlmsg_len;
98 len -= NLMSG_LENGTH(sizeof(*ifi));
99 if (len < 0)
100 goto get_failed;
101
102 parse_rtattr(tb, IFLA_MAX, IFLA_RTA(&req.i), len);
103
104 if (!tb[IFLA_LINKINFO])
105 goto get_failed;
106
107 parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb[IFLA_LINKINFO]);
108
109 if (!linkinfo[IFLA_INFO_DATA])
110 goto get_failed;
111
112 parse_rtattr_nested(iptuninfo, IFLA_IPTUN_MAX,
113 linkinfo[IFLA_INFO_DATA]);
114
115 if (iptuninfo[IFLA_IPTUN_LOCAL])
116 laddr = rta_getattr_u32(iptuninfo[IFLA_IPTUN_LOCAL]);
117
118 if (iptuninfo[IFLA_IPTUN_REMOTE])
119 raddr = rta_getattr_u32(iptuninfo[IFLA_IPTUN_REMOTE]);
120
121 if (iptuninfo[IFLA_IPTUN_TTL])
122 ttl = rta_getattr_u8(iptuninfo[IFLA_IPTUN_TTL]);
123
124 if (iptuninfo[IFLA_IPTUN_TOS])
125 tos = rta_getattr_u8(iptuninfo[IFLA_IPTUN_TOS]);
126
127 if (iptuninfo[IFLA_IPTUN_PMTUDISC])
128 pmtudisc =
129 rta_getattr_u8(iptuninfo[IFLA_IPTUN_PMTUDISC]);
130
131 if (iptuninfo[IFLA_IPTUN_FLAGS])
132 iflags = rta_getattr_u16(iptuninfo[IFLA_IPTUN_FLAGS]);
133
134 if (iptuninfo[IFLA_IPTUN_LINK])
135 link = rta_getattr_u32(iptuninfo[IFLA_IPTUN_LINK]);
136
Nicolas Dichtel77620be2013-07-16 22:54:14 +0200137 if (iptuninfo[IFLA_IPTUN_PROTO])
138 proto = rta_getattr_u8(iptuninfo[IFLA_IPTUN_PROTO]);
139
Tom Herbertc1159152014-11-05 10:06:25 -0800140 if (iptuninfo[IFLA_IPTUN_ENCAP_TYPE])
141 encaptype = rta_getattr_u16(iptuninfo[IFLA_IPTUN_ENCAP_TYPE]);
142 if (iptuninfo[IFLA_IPTUN_ENCAP_FLAGS])
143 encapflags = rta_getattr_u16(iptuninfo[IFLA_IPTUN_ENCAP_FLAGS]);
144 if (iptuninfo[IFLA_IPTUN_ENCAP_SPORT])
145 encapsport = rta_getattr_u16(iptuninfo[IFLA_IPTUN_ENCAP_SPORT]);
146 if (iptuninfo[IFLA_IPTUN_ENCAP_DPORT])
147 encapdport = rta_getattr_u16(iptuninfo[IFLA_IPTUN_ENCAP_DPORT]);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100148 if (iptuninfo[IFLA_IPTUN_6RD_PREFIX])
149 memcpy(&ip6rdprefix,
150 RTA_DATA(iptuninfo[IFLA_IPTUN_6RD_PREFIX]),
151 sizeof(laddr));
152
153 if (iptuninfo[IFLA_IPTUN_6RD_PREFIXLEN])
154 ip6rdprefixlen =
155 rta_getattr_u16(iptuninfo[IFLA_IPTUN_6RD_PREFIXLEN]);
156
157 if (iptuninfo[IFLA_IPTUN_6RD_RELAY_PREFIX])
158 ip6rdrelayprefix =
159 rta_getattr_u32(iptuninfo[IFLA_IPTUN_6RD_RELAY_PREFIX]);
160
161 if (iptuninfo[IFLA_IPTUN_6RD_RELAY_PREFIXLEN])
162 ip6rdrelayprefixlen =
163 rta_getattr_u16(iptuninfo[IFLA_IPTUN_6RD_RELAY_PREFIXLEN]);
164 }
165
166 while (argc > 0) {
167 if (strcmp(*argv, "remote") == 0) {
168 NEXT_ARG();
169 if (strcmp(*argv, "any"))
170 raddr = get_addr32(*argv);
171 else
172 raddr = 0;
173 } else if (strcmp(*argv, "local") == 0) {
174 NEXT_ARG();
175 if (strcmp(*argv, "any"))
176 laddr = get_addr32(*argv);
177 else
178 laddr = 0;
179 } else if (matches(*argv, "dev") == 0) {
180 NEXT_ARG();
181 link = if_nametoindex(*argv);
182 if (link == 0)
183 invarg("\"dev\" is invalid", *argv);
184 } else if (strcmp(*argv, "ttl") == 0 ||
185 strcmp(*argv, "hoplimit") == 0) {
186 NEXT_ARG();
187 if (strcmp(*argv, "inherit") != 0) {
188 if (get_u8(&ttl, *argv, 0))
189 invarg("invalid TTL\n", *argv);
190 } else
191 ttl = 0;
192 } else if (strcmp(*argv, "tos") == 0 ||
193 strcmp(*argv, "tclass") == 0 ||
194 matches(*argv, "dsfield") == 0) {
195 __u32 uval;
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700196
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100197 NEXT_ARG();
198 if (strcmp(*argv, "inherit") != 0) {
199 if (rtnl_dsfield_a2n(&uval, *argv))
200 invarg("bad TOS value", *argv);
201 tos = uval;
202 } else
203 tos = 1;
204 } else if (strcmp(*argv, "nopmtudisc") == 0) {
205 pmtudisc = 0;
206 } else if (strcmp(*argv, "pmtudisc") == 0) {
207 pmtudisc = 1;
208 } else if (strcmp(lu->id, "sit") == 0 &&
209 strcmp(*argv, "isatap") == 0) {
210 iflags |= SIT_ISATAP;
Nicolas Dichtel77620be2013-07-16 22:54:14 +0200211 } else if (strcmp(lu->id, "sit") == 0 &&
212 strcmp(*argv, "mode") == 0) {
213 NEXT_ARG();
214 if (strcmp(*argv, "ipv6/ipv4") == 0 ||
215 strcmp(*argv, "ip6ip") == 0)
216 proto = IPPROTO_IPV6;
217 else if (strcmp(*argv, "ipv4/ipv4") == 0 ||
218 strcmp(*argv, "ipip") == 0 ||
219 strcmp(*argv, "ip4ip4") == 0)
220 proto = IPPROTO_IPIP;
221 else if (strcmp(*argv, "any/ipv4") == 0 ||
222 strcmp(*argv, "any") == 0)
223 proto = 0;
224 else
225 invarg("Cannot guess tunnel mode.", *argv);
Tom Herbertc1159152014-11-05 10:06:25 -0800226 } else if (strcmp(*argv, "noencap") == 0) {
227 encaptype = TUNNEL_ENCAP_NONE;
228 } else if (strcmp(*argv, "encap") == 0) {
229 NEXT_ARG();
230 if (strcmp(*argv, "fou") == 0)
231 encaptype = TUNNEL_ENCAP_FOU;
232 else if (strcmp(*argv, "gue") == 0)
233 encaptype = TUNNEL_ENCAP_GUE;
234 else if (strcmp(*argv, "none") == 0)
235 encaptype = TUNNEL_ENCAP_NONE;
236 else
237 invarg("Invalid encap type.", *argv);
238 } else if (strcmp(*argv, "encap-sport") == 0) {
239 NEXT_ARG();
240 if (strcmp(*argv, "auto") == 0)
241 encapsport = 0;
242 else if (get_u16(&encapsport, *argv, 0))
243 invarg("Invalid source port.", *argv);
244 } else if (strcmp(*argv, "encap-dport") == 0) {
245 NEXT_ARG();
246 if (get_u16(&encapdport, *argv, 0))
247 invarg("Invalid destination port.", *argv);
248 } else if (strcmp(*argv, "encap-csum") == 0) {
249 encapflags |= TUNNEL_ENCAP_FLAG_CSUM;
250 } else if (strcmp(*argv, "noencap-csum") == 0) {
251 encapflags &= ~TUNNEL_ENCAP_FLAG_CSUM;
252 } else if (strcmp(*argv, "encap-udp6-csum") == 0) {
253 encapflags |= TUNNEL_ENCAP_FLAG_CSUM6;
254 } else if (strcmp(*argv, "noencap-udp6-csum") == 0) {
255 encapflags &= ~TUNNEL_ENCAP_FLAG_CSUM6;
Tom Herbert858dbb22015-01-29 08:51:58 -0800256 } else if (strcmp(*argv, "encap-remcsum") == 0) {
257 encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM;
258 } else if (strcmp(*argv, "noencap-remcsum") == 0) {
259 encapflags &= ~TUNNEL_ENCAP_FLAG_REMCSUM;
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100260 } else if (strcmp(*argv, "6rd-prefix") == 0) {
261 inet_prefix prefix;
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700262
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100263 NEXT_ARG();
264 if (get_prefix(&prefix, *argv, AF_INET6))
265 invarg("invalid 6rd_prefix\n", *argv);
266 memcpy(&ip6rdprefix, prefix.data, 16);
267 ip6rdprefixlen = prefix.bitlen;
268 } else if (strcmp(*argv, "6rd-relay_prefix") == 0) {
269 inet_prefix prefix;
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700270
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100271 NEXT_ARG();
272 if (get_prefix(&prefix, *argv, AF_INET))
273 invarg("invalid 6rd-relay_prefix\n", *argv);
274 memcpy(&ip6rdrelayprefix, prefix.data, 4);
275 ip6rdrelayprefixlen = prefix.bitlen;
276 } else if (strcmp(*argv, "6rd-reset") == 0) {
277 inet_prefix prefix;
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700278
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100279 get_prefix(&prefix, "2002::", AF_INET6);
280 memcpy(&ip6rdprefix, prefix.data, 16);
281 ip6rdprefixlen = 16;
282 ip6rdrelayprefix = 0;
283 ip6rdrelayprefixlen = 0;
284 } else
285 usage(strcmp(lu->id, "sit") == 0);
286 argc--, argv++;
287 }
288
289 if (ttl && pmtudisc == 0) {
Richard Godbee30d07e92013-08-25 22:40:18 -0400290 fprintf(stderr, "ttl != 0 and nopmtudisc are incompatible\n");
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100291 exit(-1);
292 }
293
294 addattr32(n, 1024, IFLA_IPTUN_LINK, link);
295 addattr32(n, 1024, IFLA_IPTUN_LOCAL, laddr);
296 addattr32(n, 1024, IFLA_IPTUN_REMOTE, raddr);
297 addattr8(n, 1024, IFLA_IPTUN_TTL, ttl);
298 addattr8(n, 1024, IFLA_IPTUN_TOS, tos);
299 addattr8(n, 1024, IFLA_IPTUN_PMTUDISC, pmtudisc);
Tom Herbertc1159152014-11-05 10:06:25 -0800300
301 addattr16(n, 1024, IFLA_IPTUN_ENCAP_TYPE, encaptype);
302 addattr16(n, 1024, IFLA_IPTUN_ENCAP_FLAGS, encapflags);
303 addattr16(n, 1024, IFLA_IPTUN_ENCAP_SPORT, htons(encapsport));
304 addattr16(n, 1024, IFLA_IPTUN_ENCAP_DPORT, htons(encapdport));
305
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100306 if (strcmp(lu->id, "sit") == 0) {
307 addattr16(n, 1024, IFLA_IPTUN_FLAGS, iflags);
Nicolas Dichtel77620be2013-07-16 22:54:14 +0200308 addattr8(n, 1024, IFLA_IPTUN_PROTO, proto);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100309 if (ip6rdprefixlen) {
310 addattr_l(n, 1024, IFLA_IPTUN_6RD_PREFIX,
311 &ip6rdprefix, sizeof(ip6rdprefix));
312 addattr16(n, 1024, IFLA_IPTUN_6RD_PREFIXLEN,
313 ip6rdprefixlen);
314 addattr32(n, 1024, IFLA_IPTUN_6RD_RELAY_PREFIX,
315 ip6rdrelayprefix);
316 addattr16(n, 1024, IFLA_IPTUN_6RD_RELAY_PREFIXLEN,
317 ip6rdrelayprefixlen);
318 }
319 }
320
321 return 0;
322}
323
324static void iptunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
325{
326 char s1[1024];
327 char s2[64];
328 const char *local = "any";
329 const char *remote = "any";
330
331 if (!tb)
332 return;
333
334 if (tb[IFLA_IPTUN_REMOTE]) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700335 unsigned int addr = rta_getattr_u32(tb[IFLA_IPTUN_REMOTE]);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100336
337 if (addr)
Phil Suttera418e452016-03-22 19:35:15 +0100338 remote = format_host(AF_INET, 4, &addr);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100339 }
340
341 fprintf(f, "remote %s ", remote);
342
343 if (tb[IFLA_IPTUN_LOCAL]) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700344 unsigned int addr = rta_getattr_u32(tb[IFLA_IPTUN_LOCAL]);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100345
346 if (addr)
Phil Suttera418e452016-03-22 19:35:15 +0100347 local = format_host(AF_INET, 4, &addr);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100348 }
349
350 fprintf(f, "local %s ", local);
351
352 if (tb[IFLA_IPTUN_LINK] && rta_getattr_u32(tb[IFLA_IPTUN_LINK])) {
Stephen Hemminger56f5daa2016-03-21 11:52:19 -0700353 unsigned int link = rta_getattr_u32(tb[IFLA_IPTUN_LINK]);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100354 const char *n = if_indextoname(link, s2);
355
356 if (n)
357 fprintf(f, "dev %s ", n);
358 else
359 fprintf(f, "dev %u ", link);
360 }
361
362 if (tb[IFLA_IPTUN_TTL] && rta_getattr_u8(tb[IFLA_IPTUN_TTL]))
363 fprintf(f, "ttl %d ", rta_getattr_u8(tb[IFLA_IPTUN_TTL]));
364 else
365 fprintf(f, "ttl inherit ");
366
367 if (tb[IFLA_IPTUN_TOS] && rta_getattr_u8(tb[IFLA_IPTUN_TOS])) {
368 int tos = rta_getattr_u8(tb[IFLA_IPTUN_TOS]);
369
370 fputs("tos ", f);
371 if (tos == 1)
372 fputs("inherit ", f);
373 else
374 fprintf(f, "0x%x ", tos);
375 }
376
377 if (tb[IFLA_IPTUN_PMTUDISC] && rta_getattr_u8(tb[IFLA_IPTUN_PMTUDISC]))
378 fprintf(f, "pmtudisc ");
379 else
380 fprintf(f, "nopmtudisc ");
381
382 if (tb[IFLA_IPTUN_FLAGS]) {
Nicolas Dichtel195f0f62012-12-14 09:50:33 -0800383 __u16 iflags = rta_getattr_u16(tb[IFLA_IPTUN_FLAGS]);
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100384
Nicolas Dichtel195f0f62012-12-14 09:50:33 -0800385 if (iflags & SIT_ISATAP)
386 fprintf(f, "isatap ");
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100387 }
388
389 if (tb[IFLA_IPTUN_6RD_PREFIXLEN] &&
390 *(__u16 *)RTA_DATA(tb[IFLA_IPTUN_6RD_PREFIXLEN])) {
391 __u16 prefixlen = rta_getattr_u16(tb[IFLA_IPTUN_6RD_PREFIXLEN]);
392 __u16 relayprefixlen =
393 rta_getattr_u16(tb[IFLA_IPTUN_6RD_RELAY_PREFIXLEN]);
394 __u32 relayprefix =
395 rta_getattr_u32(tb[IFLA_IPTUN_6RD_RELAY_PREFIX]);
396
397 printf("6rd-prefix %s/%u ",
398 inet_ntop(AF_INET6, RTA_DATA(tb[IFLA_IPTUN_6RD_PREFIX]),
Nicolas Dichtel195f0f62012-12-14 09:50:33 -0800399 s1, sizeof(s1)),
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100400 prefixlen);
401 if (relayprefix) {
402 printf("6rd-relay_prefix %s/%u ",
Phil Suttera418e452016-03-22 19:35:15 +0100403 format_host(AF_INET, 4, &relayprefix),
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100404 relayprefixlen);
405 }
406 }
Tom Herbertc1159152014-11-05 10:06:25 -0800407
408 if (tb[IFLA_IPTUN_ENCAP_TYPE] &&
409 *(__u16 *)RTA_DATA(tb[IFLA_IPTUN_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
410 __u16 type = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_TYPE]);
411 __u16 flags = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_FLAGS]);
412 __u16 sport = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_SPORT]);
413 __u16 dport = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_DPORT]);
414
415 fputs("encap ", f);
416 switch (type) {
417 case TUNNEL_ENCAP_FOU:
418 fputs("fou ", f);
419 break;
420 case TUNNEL_ENCAP_GUE:
421 fputs("gue ", f);
422 break;
423 default:
424 fputs("unknown ", f);
425 break;
426 }
427
428 if (sport == 0)
429 fputs("encap-sport auto ", f);
430 else
431 fprintf(f, "encap-sport %u", ntohs(sport));
432
433 fprintf(f, "encap-dport %u ", ntohs(dport));
434
435 if (flags & TUNNEL_ENCAP_FLAG_CSUM)
436 fputs("encap-csum ", f);
437 else
438 fputs("noencap-csum ", f);
439
440 if (flags & TUNNEL_ENCAP_FLAG_CSUM6)
441 fputs("encap-csum6 ", f);
442 else
443 fputs("noencap-csum6 ", f);
Tom Herbert858dbb22015-01-29 08:51:58 -0800444
445 if (flags & TUNNEL_ENCAP_FLAG_REMCSUM)
446 fputs("encap-remcsum ", f);
447 else
448 fputs("noencap-remcsum ", f);
Tom Herbertc1159152014-11-05 10:06:25 -0800449 }
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100450}
451
vadimk561e6502014-09-30 08:17:31 +0300452static void iptunnel_print_help(struct link_util *lu, int argc, char **argv,
453 FILE *f)
454{
455 print_usage(f, strcmp(lu->id, "sit") == 0);
456}
457
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100458struct link_util ipip_link_util = {
459 .id = "ipip",
460 .maxattr = IFLA_IPTUN_MAX,
461 .parse_opt = iptunnel_parse_opt,
462 .print_opt = iptunnel_print_opt,
vadimk561e6502014-09-30 08:17:31 +0300463 .print_help = iptunnel_print_help,
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100464};
465
466struct link_util sit_link_util = {
467 .id = "sit",
468 .maxattr = IFLA_IPTUN_MAX,
469 .parse_opt = iptunnel_parse_opt,
470 .print_opt = iptunnel_print_opt,
vadimk561e6502014-09-30 08:17:31 +0300471 .print_help = iptunnel_print_help,
Nicolas Dichtel1ce2de92012-12-12 10:51:47 +0100472};