]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: enable GatewayOnLink= if Gateway= without static address configured
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 27 Feb 2019 09:41:49 +0000 (18:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 28 Feb 2019 01:34:21 +0000 (10:34 +0900)
And warn about that.

But this only done if GatewayOnLink= is not specified. When it is
explicitly disabled, then the flag will not be set.

src/network/networkd-network.c

index 0eda5b1373a63a91afafafb3c1e61212edb2a3c7..ab4e90543c3a67e3101a9693db5f6c9b190e2f40 100644 (file)
@@ -293,7 +293,7 @@ static int network_verify(Network *network) {
                         address_free(address);
                 }
 
-        LIST_FOREACH_SAFE(routes, route, route_next, network->static_routes)
+        LIST_FOREACH_SAFE(routes, route, route_next, network->static_routes) {
                 if (route->family == AF_UNSPEC) {
                         log_warning("%s: Route section without Gateway=, Destination=, Source=, "
                                     "or PreferredSource= field configured. "
@@ -301,8 +301,19 @@ static int network_verify(Network *network) {
                                     network->filename, route->section->line);
 
                         route_free(route);
+                        continue;
                 }
 
+                if (network->n_static_addresses == 0 &&
+                    in_addr_is_null(route->family, &route->gw) == 0 &&
+                    route->gateway_onlink < 0) {
+                        log_warning("%s: Gateway= without static address configured. "
+                                    "Enabling GatewayOnLink= option.",
+                                    network->filename);
+                        route->gateway_onlink = true;
+                }
+        }
+
         return 0;
 }