]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: warn if dynamic gateway is specified but corresponding protocol is disabled
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 12 Oct 2020 08:04:04 +0000 (17:04 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Oct 2020 22:07:46 +0000 (07:07 +0900)
src/network/networkd-route.c

index 83a3b35e2c020bccdb9917a814b3f7781b63c1bc..707660df3c0d4ee280f9c3de82fc3244a2418bc6 100644 (file)
@@ -2382,7 +2382,7 @@ static int route_section_verify(Route *route, Network *network) {
         if (section_is_invalid(route->section))
                 return -EINVAL;
 
-        if (route->gateway_from_dhcp_or_ra)
+        if (route->gateway_from_dhcp_or_ra) {
                 if (route->gw_family == AF_UNSPEC) {
                         /* When deprecated Gateway=_dhcp is set, then assume gateway family based on other settings. */
                         switch (route->family) {
@@ -2406,6 +2406,19 @@ static int route_section_verify(Route *route, Network *network) {
                         route->gw_family = route->family;
                 }
 
+                if (route->gw_family == AF_INET && !FLAGS_SET(network->dhcp, ADDRESS_FAMILY_IPV4))
+                        return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                 "%s: Gateway=\"_dhcp4\" is specified but DHCPv4 client is disabled. "
+                                                 "Ignoring [Route] section from line %u.",
+                                                 route->section->filename, route->section->line);
+
+                if (route->gw_family == AF_INET6 && !network->ipv6_accept_ra)
+                        return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
+                                                 "%s: Gateway=\"_ipv6ra\" is specified but IPv6AcceptRA= is disabled. "
+                                                 "Ignoring [Route] section from line %u.",
+                                                 route->section->filename, route->section->line);
+        }
+
         /* When only Gateway= is specified, assume the route family based on the Gateway address. */
         if (route->family == AF_UNSPEC)
                 route->family = route->gw_family;