]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/tunnel: allow Local=/Remote=any for all tunnel types
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Oct 2024 17:51:18 +0000 (02:51 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 13 Nov 2024 19:48:10 +0000 (19:48 +0000)
It seems there is no restriction for local and remote addresses.

Fixes #34930.

(cherry picked from commit 5e48fd0506ed6212c9db2276d5845ab77aa9bce4)

src/network/netdev/tunnel.c

index db84e7cf6eeb8070188ab577224876ffaf29583f..ab3b8fbb5139c582c3a02b729c8e2e5f747257ae 100644 (file)
@@ -681,34 +681,27 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
                 }
         }
 
-        if (IN_SET(netdev->kind, NETDEV_KIND_VTI, NETDEV_KIND_IPIP, NETDEV_KIND_SIT, NETDEV_KIND_GRE) &&
-            !IN_SET(t->family, AF_UNSPEC, AF_INET))
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "vti/ipip/sit/gre tunnel without a local/remote IPv4 address configured in %s. Ignoring", filename);
-
-        if (IN_SET(netdev->kind, NETDEV_KIND_GRETAP, NETDEV_KIND_ERSPAN) &&
-            (t->family != AF_INET || !in_addr_is_set(t->family, &t->remote)))
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "gretap/erspan tunnel without a remote IPv4 address configured in %s. Ignoring", filename);
+        if (IN_SET(netdev->kind, NETDEV_KIND_VTI, NETDEV_KIND_IPIP, NETDEV_KIND_SIT, NETDEV_KIND_GRE, NETDEV_KIND_GRETAP, NETDEV_KIND_ERSPAN)) {
+                if (!IN_SET(t->family, AF_UNSPEC, AF_INET))
+                        return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
+                                                      "%s tunnel without a local/remote IPv4 address configured in %s, ignoring.",
+                                                      netdev_kind_to_string(netdev->kind), filename);
 
-        if ((IN_SET(netdev->kind, NETDEV_KIND_VTI6, NETDEV_KIND_IP6TNL) && t->family != AF_INET6) ||
-            (netdev->kind == NETDEV_KIND_IP6GRE && !IN_SET(t->family, AF_UNSPEC, AF_INET6)))
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "vti6/ip6tnl/ip6gre tunnel without a local/remote IPv6 address configured in %s. Ignoring", filename);
+                t->family = AF_INET; /* For netlink_message_append_in_addr_union(). */
+        }
 
-        if (netdev->kind == NETDEV_KIND_IP6GRETAP &&
-            (t->family != AF_INET6 || !in_addr_is_set(t->family, &t->remote)))
-                return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
-                                              "ip6gretap tunnel without a remote IPv6 address configured in %s. Ignoring", filename);
+        if (IN_SET(netdev->kind, NETDEV_KIND_VTI6, NETDEV_KIND_IP6TNL, NETDEV_KIND_IP6GRE, NETDEV_KIND_IP6GRETAP)) {
+                if (!IN_SET(t->family, AF_UNSPEC, AF_INET6))
+                        return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
+                                                      "%s tunnel without a local/remote IPv6 address configured in %s, ignoring,",
+                                                      netdev_kind_to_string(netdev->kind), filename);
+                t->family = AF_INET6; /* For netlink_message_append_in_addr_union(). */
+        }
 
         if (t->fou_tunnel && t->fou_destination_port <= 0)
                 return log_netdev_error_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
                                               "FooOverUDP missing port configured in %s. Ignoring", filename);
 
-        /* netlink_message_append_in_addr_union() is used for vti/vti6. So, t->family cannot be AF_UNSPEC. */
-        if (netdev->kind == NETDEV_KIND_VTI)
-                t->family = AF_INET;
-
         if (t->assign_to_loopback)
                 t->independent = true;