summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-network.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-02-27 10:41:49 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-02-28 02:34:21 +0100
commit4912ab7774ccc1eed07bfbbc6b87e8a23b1f5495 (patch)
tree0531b5d2cf00ffed9aa735fff91a246e8d7ff3d1 /src/network/networkd-network.c
parentnetwork: save GatewayOnLink= value as tristate in Route (diff)
downloadsystemd-4912ab7774ccc1eed07bfbbc6b87e8a23b1f5495.tar.xz
systemd-4912ab7774ccc1eed07bfbbc6b87e8a23b1f5495.zip
network: enable GatewayOnLink= if Gateway= without static address configured
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.
Diffstat (limited to '')
-rw-r--r--src/network/networkd-network.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 0eda5b1373..ab4e90543c 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -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;
}