1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 #include <netinet/in.h>
6 #include <linux/if_tunnel.h>
7 #include <linux/ip6_tunnel.h>
9 #include "conf-parser.h"
10 #include "missing_network.h"
11 #include "netlink-util.h"
12 #include "parse-util.h"
13 #include "string-table.h"
14 #include "string-util.h"
18 #define DEFAULT_TNL_HOP_LIMIT 64
19 #define IP6_FLOWINFO_FLOWLABEL htobe32(0x000FFFFF)
20 #define IP6_TNL_F_ALLOW_LOCAL_REMOTE 0x40
22 static const char* const ip6tnl_mode_table
[_NETDEV_IP6_TNL_MODE_MAX
] = {
23 [NETDEV_IP6_TNL_MODE_IP6IP6
] = "ip6ip6",
24 [NETDEV_IP6_TNL_MODE_IPIP6
] = "ipip6",
25 [NETDEV_IP6_TNL_MODE_ANYIP6
] = "any",
28 DEFINE_STRING_TABLE_LOOKUP(ip6tnl_mode
, Ip6TnlMode
);
29 DEFINE_CONFIG_PARSE_ENUM(config_parse_ip6tnl_mode
, ip6tnl_mode
, Ip6TnlMode
, "Failed to parse ip6 tunnel Mode");
31 static int netdev_ipip_sit_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*m
) {
37 if (netdev
->kind
== NETDEV_KIND_IPIP
)
45 if (link
|| t
->assign_to_loopback
) {
46 r
= sd_netlink_message_append_u32(m
, IFLA_IPTUN_LINK
, link
? link
->ifindex
: LOOPBACK_IFINDEX
);
48 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_LINK attribute: %m");
51 r
= sd_netlink_message_append_in_addr(m
, IFLA_IPTUN_LOCAL
, &t
->local
.in
);
53 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_LOCAL attribute: %m");
55 r
= sd_netlink_message_append_in_addr(m
, IFLA_IPTUN_REMOTE
, &t
->remote
.in
);
57 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_REMOTE attribute: %m");
59 r
= sd_netlink_message_append_u8(m
, IFLA_IPTUN_TTL
, t
->ttl
);
61 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_TTL attribute: %m");
63 r
= sd_netlink_message_append_u8(m
, IFLA_IPTUN_PMTUDISC
, t
->pmtudisc
);
65 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_PMTUDISC attribute: %m");
68 r
= sd_netlink_message_append_u16(m
, IFLA_IPTUN_ENCAP_TYPE
, t
->fou_encap_type
);
70 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_ENCAP_TYPE attribute: %m");
72 r
= sd_netlink_message_append_u16(m
, IFLA_IPTUN_ENCAP_SPORT
, htobe16(t
->encap_src_port
));
74 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_ENCAP_SPORT attribute: %m");
76 r
= sd_netlink_message_append_u16(m
, IFLA_IPTUN_ENCAP_DPORT
, htobe16(t
->fou_destination_port
));
78 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_ENCAP_DPORT attribute: %m");
81 if (netdev
->kind
== NETDEV_KIND_SIT
) {
82 if (t
->sixrd_prefixlen
> 0) {
83 r
= sd_netlink_message_append_in6_addr(m
, IFLA_IPTUN_6RD_PREFIX
, &t
->sixrd_prefix
);
85 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_6RD_PREFIX attribute: %m");
87 /* u16 is deliberate here, even though we're passing a netmask that can never be >128. The kernel is
88 * expecting to receive the prefixlen as a u16.
90 r
= sd_netlink_message_append_u16(m
, IFLA_IPTUN_6RD_PREFIXLEN
, t
->sixrd_prefixlen
);
92 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_6RD_PREFIXLEN attribute: %m");
98 SET_FLAG(flags
, SIT_ISATAP
, t
->isatap
);
100 r
= sd_netlink_message_append_u16(m
, IFLA_IPTUN_FLAGS
, flags
);
102 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_FLAGS attribute: %m");
109 static int netdev_gre_erspan_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*m
) {
120 switch (netdev
->kind
) {
121 case NETDEV_KIND_GRE
:
124 case NETDEV_KIND_ERSPAN
:
127 case NETDEV_KIND_GRETAP
:
131 assert_not_reached("invalid netdev kind");
136 if (link
|| t
->assign_to_loopback
) {
137 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_LINK
, link
? link
->ifindex
: LOOPBACK_IFINDEX
);
139 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_LINK attribute: %m");
142 if (netdev
->kind
== NETDEV_KIND_ERSPAN
) {
143 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_ERSPAN_INDEX
, t
->erspan_index
);
145 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_ERSPAN_INDEX attribute: %m");
148 r
= sd_netlink_message_append_in_addr(m
, IFLA_GRE_LOCAL
, &t
->local
.in
);
150 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_LOCAL attribute: %m");
152 r
= sd_netlink_message_append_in_addr(m
, IFLA_GRE_REMOTE
, &t
->remote
.in
);
154 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_REMOTE attribute: %m");
156 r
= sd_netlink_message_append_u8(m
, IFLA_GRE_TTL
, t
->ttl
);
158 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_TTL attribute: %m");
160 r
= sd_netlink_message_append_u8(m
, IFLA_GRE_TOS
, t
->tos
);
162 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_TOS attribute: %m");
164 r
= sd_netlink_message_append_u8(m
, IFLA_GRE_PMTUDISC
, t
->pmtudisc
);
166 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_PMTUDISC attribute: %m");
169 ikey
= okey
= htobe32(t
->key
);
175 ikey
= htobe32(t
->ikey
);
180 okey
= htobe32(t
->okey
);
184 if (t
->gre_erspan_sequence
> 0) {
187 } else if (t
->gre_erspan_sequence
== 0) {
192 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_IKEY
, ikey
);
194 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_IKEY attribute: %m");
196 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_OKEY
, okey
);
198 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_OKEY attribute: %m");
200 r
= sd_netlink_message_append_u16(m
, IFLA_GRE_IFLAGS
, iflags
);
202 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_IFLAGS attribute: %m");
204 r
= sd_netlink_message_append_u16(m
, IFLA_GRE_OFLAGS
, oflags
);
206 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_OFLAGS, attribute: %m");
209 r
= sd_netlink_message_append_u16(m
, IFLA_GRE_ENCAP_TYPE
, t
->fou_encap_type
);
211 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_ENCAP_TYPE attribute: %m");
213 r
= sd_netlink_message_append_u16(m
, IFLA_GRE_ENCAP_SPORT
, htobe16(t
->encap_src_port
));
215 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_ENCAP_SPORT attribute: %m");
217 r
= sd_netlink_message_append_u16(m
, IFLA_GRE_ENCAP_DPORT
, htobe16(t
->fou_destination_port
));
219 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_ENCAP_DPORT attribute: %m");
225 static int netdev_ip6gre_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*m
) {
235 if (netdev
->kind
== NETDEV_KIND_IP6GRE
)
238 t
= IP6GRETAP(netdev
);
243 if (link
|| t
->assign_to_loopback
) {
244 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_LINK
, link
? link
->ifindex
: LOOPBACK_IFINDEX
);
246 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_LINK attribute: %m");
249 r
= sd_netlink_message_append_in6_addr(m
, IFLA_GRE_LOCAL
, &t
->local
.in6
);
251 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_LOCAL attribute: %m");
253 r
= sd_netlink_message_append_in6_addr(m
, IFLA_GRE_REMOTE
, &t
->remote
.in6
);
255 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_REMOTE attribute: %m");
257 r
= sd_netlink_message_append_u8(m
, IFLA_GRE_TTL
, t
->ttl
);
259 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_TTL attribute: %m");
261 if (t
->ipv6_flowlabel
!= _NETDEV_IPV6_FLOWLABEL_INVALID
) {
262 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_FLOWINFO
, t
->ipv6_flowlabel
);
264 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_FLOWINFO attribute: %m");
267 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_FLAGS
, t
->flags
);
269 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_FLAGS attribute: %m");
272 ikey
= okey
= htobe32(t
->key
);
278 ikey
= htobe32(t
->ikey
);
283 okey
= htobe32(t
->okey
);
287 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_IKEY
, ikey
);
289 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_IKEY attribute: %m");
291 r
= sd_netlink_message_append_u32(m
, IFLA_GRE_OKEY
, okey
);
293 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_OKEY attribute: %m");
295 r
= sd_netlink_message_append_u16(m
, IFLA_GRE_IFLAGS
, iflags
);
297 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_IFLAGS attribute: %m");
299 r
= sd_netlink_message_append_u16(m
, IFLA_GRE_OFLAGS
, oflags
);
301 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_GRE_OFLAGS, attribute: %m");
306 static int netdev_vti_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*m
) {
314 if (netdev
->kind
== NETDEV_KIND_VTI
)
321 if (link
|| t
->assign_to_loopback
) {
322 r
= sd_netlink_message_append_u32(m
, IFLA_VTI_LINK
, link
? link
->ifindex
: LOOPBACK_IFINDEX
);
324 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_VTI_LINK attribute: %m");
328 ikey
= okey
= htobe32(t
->key
);
330 ikey
= htobe32(t
->ikey
);
331 okey
= htobe32(t
->okey
);
334 r
= sd_netlink_message_append_u32(m
, IFLA_VTI_IKEY
, ikey
);
336 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_VTI_IKEY attribute: %m");
338 r
= sd_netlink_message_append_u32(m
, IFLA_VTI_OKEY
, okey
);
340 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_VTI_OKEY attribute: %m");
342 r
= netlink_message_append_in_addr_union(m
, IFLA_VTI_LOCAL
, t
->family
, &t
->local
);
344 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_VTI_LOCAL attribute: %m");
346 r
= netlink_message_append_in_addr_union(m
, IFLA_VTI_REMOTE
, t
->family
, &t
->remote
);
348 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_VTI_REMOTE attribute: %m");
353 static int netdev_ip6tnl_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*m
) {
354 Tunnel
*t
= IP6TNL(netdev
);
362 if (link
|| t
->assign_to_loopback
) {
363 r
= sd_netlink_message_append_u32(m
, IFLA_IPTUN_LINK
, link
? link
->ifindex
: LOOPBACK_IFINDEX
);
365 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_LINK attribute: %m");
368 r
= sd_netlink_message_append_in6_addr(m
, IFLA_IPTUN_LOCAL
, &t
->local
.in6
);
370 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_LOCAL attribute: %m");
372 r
= sd_netlink_message_append_in6_addr(m
, IFLA_IPTUN_REMOTE
, &t
->remote
.in6
);
374 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_REMOTE attribute: %m");
376 r
= sd_netlink_message_append_u8(m
, IFLA_IPTUN_TTL
, t
->ttl
);
378 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_TTL attribute: %m");
380 if (t
->ipv6_flowlabel
!= _NETDEV_IPV6_FLOWLABEL_INVALID
) {
381 r
= sd_netlink_message_append_u32(m
, IFLA_IPTUN_FLOWINFO
, t
->ipv6_flowlabel
);
383 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_FLOWINFO attribute: %m");
387 t
->flags
|= IP6_TNL_F_RCV_DSCP_COPY
;
389 if (t
->allow_localremote
>= 0)
390 SET_FLAG(t
->flags
, IP6_TNL_F_ALLOW_LOCAL_REMOTE
, t
->allow_localremote
);
392 if (t
->encap_limit
!= IPV6_DEFAULT_TNL_ENCAP_LIMIT
) {
393 r
= sd_netlink_message_append_u8(m
, IFLA_IPTUN_ENCAP_LIMIT
, t
->encap_limit
);
395 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_ENCAP_LIMIT attribute: %m");
398 r
= sd_netlink_message_append_u32(m
, IFLA_IPTUN_FLAGS
, t
->flags
);
400 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_FLAGS attribute: %m");
402 switch (t
->ip6tnl_mode
) {
403 case NETDEV_IP6_TNL_MODE_IP6IP6
:
404 proto
= IPPROTO_IPV6
;
406 case NETDEV_IP6_TNL_MODE_IPIP6
:
407 proto
= IPPROTO_IPIP
;
409 case NETDEV_IP6_TNL_MODE_ANYIP6
:
415 r
= sd_netlink_message_append_u8(m
, IFLA_IPTUN_PROTO
, proto
);
417 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPTUN_PROTO attribute: %m");
422 static int netdev_tunnel_verify(NetDev
*netdev
, const char *filename
) {
428 switch (netdev
->kind
) {
429 case NETDEV_KIND_IPIP
:
432 case NETDEV_KIND_SIT
:
435 case NETDEV_KIND_GRE
:
438 case NETDEV_KIND_GRETAP
:
441 case NETDEV_KIND_IP6GRE
:
444 case NETDEV_KIND_IP6GRETAP
:
445 t
= IP6GRETAP(netdev
);
447 case NETDEV_KIND_VTI
:
450 case NETDEV_KIND_VTI6
:
453 case NETDEV_KIND_IP6TNL
:
456 case NETDEV_KIND_ERSPAN
:
460 assert_not_reached("Invalid tunnel kind");
465 if (IN_SET(netdev
->kind
, NETDEV_KIND_VTI
, NETDEV_KIND_IPIP
, NETDEV_KIND_SIT
, NETDEV_KIND_GRE
) &&
466 !IN_SET(t
->family
, AF_UNSPEC
, AF_INET
))
467 return log_netdev_error_errno(netdev
, SYNTHETIC_ERRNO(EINVAL
),
468 "vti/ipip/sit/gre tunnel without a local/remote IPv4 address configured in %s. Ignoring", filename
);
470 if (IN_SET(netdev
->kind
, NETDEV_KIND_GRETAP
, NETDEV_KIND_ERSPAN
) &&
471 (t
->family
!= AF_INET
|| in_addr_is_null(t
->family
, &t
->remote
)))
472 return log_netdev_error_errno(netdev
, SYNTHETIC_ERRNO(EINVAL
),
473 "gretap/erspan tunnel without a remote IPv4 address configured in %s. Ignoring", filename
);
475 if ((IN_SET(netdev
->kind
, NETDEV_KIND_VTI6
, NETDEV_KIND_IP6TNL
) && t
->family
!= AF_INET6
) ||
476 (netdev
->kind
== NETDEV_KIND_IP6GRE
&& !IN_SET(t
->family
, AF_UNSPEC
, AF_INET6
)))
477 return log_netdev_error_errno(netdev
, SYNTHETIC_ERRNO(EINVAL
),
478 "vti6/ip6tnl/ip6gre tunnel without a local/remote IPv6 address configured in %s. Ignoring", filename
);
480 if (netdev
->kind
== NETDEV_KIND_IP6GRETAP
&&
481 (t
->family
!= AF_INET6
|| in_addr_is_null(t
->family
, &t
->remote
)))
482 return log_netdev_error_errno(netdev
, SYNTHETIC_ERRNO(EINVAL
),
483 "ip6gretap tunnel without a remote IPv6 address configured in %s. Ignoring", filename
);
485 if (netdev
->kind
== NETDEV_KIND_IP6TNL
&&
486 t
->ip6tnl_mode
== _NETDEV_IP6_TNL_MODE_INVALID
)
487 return log_netdev_error_errno(netdev
, SYNTHETIC_ERRNO(EINVAL
),
488 "ip6tnl without mode configured in %s. Ignoring", filename
);
490 if (t
->fou_tunnel
&& t
->fou_destination_port
<= 0)
491 return log_netdev_error_errno(netdev
, SYNTHETIC_ERRNO(EINVAL
),
492 "FooOverUDP missing port configured in %s. Ignoring", filename
);
494 if (netdev
->kind
== NETDEV_KIND_ERSPAN
&& (t
->erspan_index
>= (1 << 20) || t
->erspan_index
== 0))
495 return log_netdev_error_errno(netdev
, SYNTHETIC_ERRNO(EINVAL
), "Invalid erspan index %d. Ignoring", t
->erspan_index
);
497 /* netlink_message_append_in_addr_union() is used for vti/vti6. So, t->family cannot be AF_UNSPEC. */
498 if (netdev
->kind
== NETDEV_KIND_VTI
)
504 int config_parse_tunnel_address(const char *unit
,
505 const char *filename
,
508 unsigned section_line
,
514 Tunnel
*t
= userdata
;
515 union in_addr_union
*addr
= data
, buffer
;
523 /* This is used to parse addresses on both local and remote ends of the tunnel.
524 * Address families must match.
526 * "any" is a special value which means that the address is unspecified.
529 if (streq(rvalue
, "any")) {
530 *addr
= IN_ADDR_NULL
;
532 /* As a special case, if both the local and remote addresses are
533 * unspecified, also clear the address family.
535 if (t
->family
!= AF_UNSPEC
&&
536 in_addr_is_null(t
->family
, &t
->local
) != 0 &&
537 in_addr_is_null(t
->family
, &t
->remote
) != 0)
538 t
->family
= AF_UNSPEC
;
542 r
= in_addr_from_string_auto(rvalue
, &f
, &buffer
);
544 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
545 "Tunnel address \"%s\" invalid, ignoring assignment: %m", rvalue
);
549 if (t
->family
!= AF_UNSPEC
&& t
->family
!= f
) {
550 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
551 "Tunnel addresses incompatible, ignoring assignment: %s", rvalue
);
560 int config_parse_tunnel_key(const char *unit
,
561 const char *filename
,
564 unsigned section_line
,
570 union in_addr_union buffer
;
571 Tunnel
*t
= userdata
;
580 r
= in_addr_from_string(AF_INET
, rvalue
, &buffer
);
582 r
= safe_atou32(rvalue
, &k
);
584 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0, "Failed to parse tunnel key ignoring assignment: %s", rvalue
);
588 k
= be32toh(buffer
.in
.s_addr
);
590 if (streq(lvalue
, "Key"))
592 else if (streq(lvalue
, "InputKey"))
600 int config_parse_ipv6_flowlabel(const char* unit
,
601 const char *filename
,
604 unsigned section_line
,
610 IPv6FlowLabel
*ipv6_flowlabel
= data
;
611 Tunnel
*t
= userdata
;
618 assert(ipv6_flowlabel
);
620 if (streq(rvalue
, "inherit")) {
621 *ipv6_flowlabel
= IP6_FLOWINFO_FLOWLABEL
;
622 t
->flags
|= IP6_TNL_F_USE_ORIG_FLOWLABEL
;
624 r
= config_parse_int(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, rvalue
, &k
, userdata
);
629 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0, "Failed to parse IPv6 flowlabel option, ignoring: %s", rvalue
);
631 *ipv6_flowlabel
= htobe32(k
) & IP6_FLOWINFO_FLOWLABEL
;
632 t
->flags
&= ~IP6_TNL_F_USE_ORIG_FLOWLABEL
;
639 int config_parse_encap_limit(const char* unit
,
640 const char *filename
,
643 unsigned section_line
,
649 Tunnel
*t
= userdata
;
657 if (streq(rvalue
, "none"))
658 t
->flags
|= IP6_TNL_F_IGN_ENCAP_LIMIT
;
660 r
= safe_atoi(rvalue
, &k
);
662 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
, "Failed to parse Tunnel Encapsulation Limit option, ignoring: %s", rvalue
);
666 if (k
> 255 || k
< 0)
667 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0, "Invalid Tunnel Encapsulation value, ignoring: %d", k
);
670 t
->flags
&= ~IP6_TNL_F_IGN_ENCAP_LIMIT
;
677 int config_parse_6rd_prefix(const char* unit
,
678 const char *filename
,
681 unsigned section_line
,
687 Tunnel
*t
= userdata
;
693 union in_addr_union p
;
697 r
= in_addr_prefix_from_string(rvalue
, AF_INET6
, &p
, &l
);
699 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
, "Failed to parse 6rd prefix \"%s\", ignoring: %m", rvalue
);
703 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0, "6rd prefix length of \"%s\" must be greater than zero, ignoring", rvalue
);
707 t
->sixrd_prefix
= p
.in6
;
708 t
->sixrd_prefixlen
= l
;
713 static void ipip_sit_init(NetDev
*n
) {
719 case NETDEV_KIND_IPIP
:
722 case NETDEV_KIND_SIT
:
726 assert_not_reached("invalid netdev kind");
732 t
->fou_encap_type
= NETDEV_FOO_OVER_UDP_ENCAP_DIRECT
;
736 static void vti_init(NetDev
*n
) {
741 if (n
->kind
== NETDEV_KIND_VTI
)
751 static void gre_erspan_init(NetDev
*n
) {
757 case NETDEV_KIND_GRE
:
760 case NETDEV_KIND_ERSPAN
:
763 case NETDEV_KIND_GRETAP
:
767 assert_not_reached("invalid netdev kind");
773 t
->gre_erspan_sequence
= -1;
774 t
->fou_encap_type
= NETDEV_FOO_OVER_UDP_ENCAP_DIRECT
;
777 static void ip6gre_init(NetDev
*n
) {
782 if (n
->kind
== NETDEV_KIND_IP6GRE
)
789 t
->ttl
= DEFAULT_TNL_HOP_LIMIT
;
792 static void ip6tnl_init(NetDev
*n
) {
793 Tunnel
*t
= IP6TNL(n
);
798 t
->ttl
= DEFAULT_TNL_HOP_LIMIT
;
799 t
->encap_limit
= IPV6_DEFAULT_TNL_ENCAP_LIMIT
;
800 t
->ip6tnl_mode
= _NETDEV_IP6_TNL_MODE_INVALID
;
801 t
->ipv6_flowlabel
= _NETDEV_IPV6_FLOWLABEL_INVALID
;
802 t
->allow_localremote
= -1;
805 const NetDevVTable ipip_vtable
= {
806 .object_size
= sizeof(Tunnel
),
807 .init
= ipip_sit_init
,
808 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
809 .fill_message_create
= netdev_ipip_sit_fill_message_create
,
810 .create_type
= NETDEV_CREATE_STACKED
,
811 .config_verify
= netdev_tunnel_verify
,
812 .generate_mac
= true,
815 const NetDevVTable sit_vtable
= {
816 .object_size
= sizeof(Tunnel
),
817 .init
= ipip_sit_init
,
818 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
819 .fill_message_create
= netdev_ipip_sit_fill_message_create
,
820 .create_type
= NETDEV_CREATE_STACKED
,
821 .config_verify
= netdev_tunnel_verify
,
822 .generate_mac
= true,
825 const NetDevVTable vti_vtable
= {
826 .object_size
= sizeof(Tunnel
),
828 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
829 .fill_message_create
= netdev_vti_fill_message_create
,
830 .create_type
= NETDEV_CREATE_STACKED
,
831 .config_verify
= netdev_tunnel_verify
,
832 .generate_mac
= true,
835 const NetDevVTable vti6_vtable
= {
836 .object_size
= sizeof(Tunnel
),
838 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
839 .fill_message_create
= netdev_vti_fill_message_create
,
840 .create_type
= NETDEV_CREATE_STACKED
,
841 .config_verify
= netdev_tunnel_verify
,
842 .generate_mac
= true,
845 const NetDevVTable gre_vtable
= {
846 .object_size
= sizeof(Tunnel
),
847 .init
= gre_erspan_init
,
848 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
849 .fill_message_create
= netdev_gre_erspan_fill_message_create
,
850 .create_type
= NETDEV_CREATE_STACKED
,
851 .config_verify
= netdev_tunnel_verify
,
852 .generate_mac
= true,
855 const NetDevVTable gretap_vtable
= {
856 .object_size
= sizeof(Tunnel
),
857 .init
= gre_erspan_init
,
858 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
859 .fill_message_create
= netdev_gre_erspan_fill_message_create
,
860 .create_type
= NETDEV_CREATE_STACKED
,
861 .config_verify
= netdev_tunnel_verify
,
862 .generate_mac
= true,
865 const NetDevVTable ip6gre_vtable
= {
866 .object_size
= sizeof(Tunnel
),
868 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
869 .fill_message_create
= netdev_ip6gre_fill_message_create
,
870 .create_type
= NETDEV_CREATE_STACKED
,
871 .config_verify
= netdev_tunnel_verify
,
872 .generate_mac
= true,
875 const NetDevVTable ip6gretap_vtable
= {
876 .object_size
= sizeof(Tunnel
),
878 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
879 .fill_message_create
= netdev_ip6gre_fill_message_create
,
880 .create_type
= NETDEV_CREATE_STACKED
,
881 .config_verify
= netdev_tunnel_verify
,
882 .generate_mac
= true,
885 const NetDevVTable ip6tnl_vtable
= {
886 .object_size
= sizeof(Tunnel
),
888 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
889 .fill_message_create
= netdev_ip6tnl_fill_message_create
,
890 .create_type
= NETDEV_CREATE_STACKED
,
891 .config_verify
= netdev_tunnel_verify
,
892 .generate_mac
= true,
895 const NetDevVTable erspan_vtable
= {
896 .object_size
= sizeof(Tunnel
),
897 .init
= gre_erspan_init
,
898 .sections
= NETDEV_COMMON_SECTIONS
"Tunnel\0",
899 .fill_message_create
= netdev_gre_erspan_fill_message_create
,
900 .create_type
= NETDEV_CREATE_STACKED
,
901 .config_verify
= netdev_tunnel_verify
,
902 .generate_mac
= true,