Skip to content

Commit d1f8424

Browse files
yuwatabluca
authored andcommitted
network/tunnel: allow Local=/Remote=any for all tunnel types
It seems there is no restriction for local and remote addresses. Fixes #34930. (cherry picked from commit 5e48fd0) (cherry picked from commit 3093ac0) (cherry picked from commit 81c8433) (cherry picked from commit 6f19e9f) (cherry picked from commit 2e68de2)
1 parent 4f2d422 commit d1f8424

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

src/network/netdev/tunnel.c

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -711,34 +711,27 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
711711
}
712712
}
713713

714-
if (IN_SET(netdev->kind, NETDEV_KIND_VTI, NETDEV_KIND_IPIP, NETDEV_KIND_SIT, NETDEV_KIND_GRE) &&
715-
!IN_SET(t->family, AF_UNSPEC, AF_INET))
716-
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
717-
"vti/ipip/sit/gre tunnel without a local/remote IPv4 address configured in %s. Ignoring", filename);
718-
719-
if (IN_SET(netdev->kind, NETDEV_KIND_GRETAP, NETDEV_KIND_ERSPAN) &&
720-
(t->family != AF_INET || !in_addr_is_set(t->family, &t->remote)))
721-
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
722-
"gretap/erspan tunnel without a remote IPv4 address configured in %s. Ignoring", filename);
714+
if (IN_SET(netdev->kind, NETDEV_KIND_VTI, NETDEV_KIND_IPIP, NETDEV_KIND_SIT, NETDEV_KIND_GRE, NETDEV_KIND_GRETAP, NETDEV_KIND_ERSPAN)) {
715+
if (!IN_SET(t->family, AF_UNSPEC, AF_INET))
716+
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
717+
"%s tunnel without a local/remote IPv4 address configured in %s, ignoring.",
718+
netdev_kind_to_string(netdev->kind), filename);
723719

724-
if ((IN_SET(netdev->kind, NETDEV_KIND_VTI6, NETDEV_KIND_IP6TNL) && t->family != AF_INET6) ||
725-
(netdev->kind == NETDEV_KIND_IP6GRE && !IN_SET(t->family, AF_UNSPEC, AF_INET6)))
726-
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
727-
"vti6/ip6tnl/ip6gre tunnel without a local/remote IPv6 address configured in %s. Ignoring", filename);
720+
t->family = AF_INET; /* For netlink_message_append_in_addr_union(). */
721+
}
728722

729-
if (netdev->kind == NETDEV_KIND_IP6GRETAP &&
730-
(t->family != AF_INET6 || !in_addr_is_set(t->family, &t->remote)))
731-
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
732-
"ip6gretap tunnel without a remote IPv6 address configured in %s. Ignoring", filename);
723+
if (IN_SET(netdev->kind, NETDEV_KIND_VTI6, NETDEV_KIND_IP6TNL, NETDEV_KIND_IP6GRE, NETDEV_KIND_IP6GRETAP)) {
724+
if (!IN_SET(t->family, AF_UNSPEC, AF_INET6))
725+
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
726+
"%s tunnel without a local/remote IPv6 address configured in %s, ignoring,",
727+
netdev_kind_to_string(netdev->kind), filename);
728+
t->family = AF_INET6; /* For netlink_message_append_in_addr_union(). */
729+
}
733730

734731
if (t->fou_tunnel && t->fou_destination_port <= 0)
735732
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
736733
"FooOverUDP missing port configured in %s. Ignoring", filename);
737734

738-
/* netlink_message_append_in_addr_union() is used for vti/vti6. So, t->family cannot be AF_UNSPEC. */
739-
if (netdev->kind == NETDEV_KIND_VTI)
740-
t->family = AF_INET;
741-
742735
if (t->assign_to_loopback)
743736
t->independent = true;
744737

0 commit comments

Comments
 (0)