Skip to content

Commit 4912ab7

Browse files
committed
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.
1 parent 54901fd commit 4912ab7

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/network/networkd-network.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,27 @@ static int network_verify(Network *network) {
293293
address_free(address);
294294
}
295295

296-
LIST_FOREACH_SAFE(routes, route, route_next, network->static_routes)
296+
LIST_FOREACH_SAFE(routes, route, route_next, network->static_routes) {
297297
if (route->family == AF_UNSPEC) {
298298
log_warning("%s: Route section without Gateway=, Destination=, Source=, "
299299
"or PreferredSource= field configured. "
300300
"Ignoring [Route] section from line %u.",
301301
network->filename, route->section->line);
302302

303303
route_free(route);
304+
continue;
304305
}
305306

307+
if (network->n_static_addresses == 0 &&
308+
in_addr_is_null(route->family, &route->gw) == 0 &&
309+
route->gateway_onlink < 0) {
310+
log_warning("%s: Gateway= without static address configured. "
311+
"Enabling GatewayOnLink= option.",
312+
network->filename);
313+
route->gateway_onlink = true;
314+
}
315+
}
316+
306317
return 0;
307318
}
308319

0 commit comments

Comments
 (0)