Skip to content

Commit 81c8433

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)
1 parent 80efb1d commit 81c8433

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
@@ -681,34 +681,27 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
681681
}
682682
}
683683

684-
if (IN_SET(netdev->kind, NETDEV_KIND_VTI, NETDEV_KIND_IPIP, NETDEV_KIND_SIT, NETDEV_KIND_GRE) &&
685-
!IN_SET(t->family, AF_UNSPEC, AF_INET))
686-
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
687-
"vti/ipip/sit/gre tunnel without a local/remote IPv4 address configured in %s. Ignoring", filename);
688-
689-
if (IN_SET(netdev->kind, NETDEV_KIND_GRETAP, NETDEV_KIND_ERSPAN) &&
690-
(t->family != AF_INET || !in_addr_is_set(t->family, &t->remote)))
691-
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
692-
"gretap/erspan tunnel without a remote IPv4 address configured in %s. Ignoring", filename);
684+
if (IN_SET(netdev->kind, NETDEV_KIND_VTI, NETDEV_KIND_IPIP, NETDEV_KIND_SIT, NETDEV_KIND_GRE, NETDEV_KIND_GRETAP, NETDEV_KIND_ERSPAN)) {
685+
if (!IN_SET(t->family, AF_UNSPEC, AF_INET))
686+
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
687+
"%s tunnel without a local/remote IPv4 address configured in %s, ignoring.",
688+
netdev_kind_to_string(netdev->kind), filename);
693689

694-
if ((IN_SET(netdev->kind, NETDEV_KIND_VTI6, NETDEV_KIND_IP6TNL) && t->family != AF_INET6) ||
695-
(netdev->kind == NETDEV_KIND_IP6GRE && !IN_SET(t->family, AF_UNSPEC, AF_INET6)))
696-
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
697-
"vti6/ip6tnl/ip6gre tunnel without a local/remote IPv6 address configured in %s. Ignoring", filename);
690+
t->family = AF_INET; /* For netlink_message_append_in_addr_union(). */
691+
}
698692

699-
if (netdev->kind == NETDEV_KIND_IP6GRETAP &&
700-
(t->family != AF_INET6 || !in_addr_is_set(t->family, &t->remote)))
701-
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
702-
"ip6gretap tunnel without a remote IPv6 address configured in %s. Ignoring", filename);
693+
if (IN_SET(netdev->kind, NETDEV_KIND_VTI6, NETDEV_KIND_IP6TNL, NETDEV_KIND_IP6GRE, NETDEV_KIND_IP6GRETAP)) {
694+
if (!IN_SET(t->family, AF_UNSPEC, AF_INET6))
695+
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
696+
"%s tunnel without a local/remote IPv6 address configured in %s, ignoring,",
697+
netdev_kind_to_string(netdev->kind), filename);
698+
t->family = AF_INET6; /* For netlink_message_append_in_addr_union(). */
699+
}
703700

704701
if (t->fou_tunnel && t->fou_destination_port <= 0)
705702
return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
706703
"FooOverUDP missing port configured in %s. Ignoring", filename);
707704

708-
/* netlink_message_append_in_addr_union() is used for vti/vti6. So, t->family cannot be AF_UNSPEC. */
709-
if (netdev->kind == NETDEV_KIND_VTI)
710-
t->family = AF_INET;
711-
712705
if (t->assign_to_loopback)
713706
t->independent = true;
714707

0 commit comments

Comments
 (0)