diff options
author | Susant Sahani <ssahani@users.noreply.github.com> | 2017-04-21 14:52:30 +0530 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-04-21 11:22:30 +0200 |
commit | 28959f7d3e8922cfb9f4c7c6b9ecfa11f3e32e05 (patch) | |
tree | c221484f46dc1909e6b262e9b7631c8a6f5ac2ec | |
parent | 3e06055500755053050620a45236ef606507e1bd (diff) |
networkd: route - support 'onlink' routes (#5734)
This work based on Tom's original patch
teg@1312172
By setting GatewayOnlink=yes, the kernel will assume that the gateway is onlink
even if there is no route to it.
Resolves issue #1283.
-rw-r--r-- | man/systemd.network.xml | 10 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 1 | ||||
-rw-r--r-- | src/network/networkd-route.c | 41 | ||||
-rw-r--r-- | src/network/networkd-route.h | 1 |
4 files changed, 53 insertions, 0 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 971dee338f..be9af9759f 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -809,6 +809,16 @@ <para>As in the <literal>[Network]</literal> section.</para> </listitem> </varlistentry> + <varlistentry> + <term><varname>GatewayOnlink=</varname></term> + <listitem> + <para>The <literal>GatewayOnlink</literal> option tells the kernel that the it does not have + to check if the gateway is reachable directly by the current machine (i.e., the kernel does + not need to check if the gateway is attached to the local network), so that we can insert the + route in the kernel table without it being complained about. A boolean, defaults to <literal>no</literal>. + </para> + </listitem> + </varlistentry> <varlistentry> <term><varname>Destination=</varname></term> <listitem> diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 9658978651..abd921ee1a 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -86,6 +86,7 @@ Route.Metric, config_parse_route_priority, Route.Scope, config_parse_route_scope, 0, 0 Route.PreferredSource, config_parse_preferred_src, 0, 0 Route.Table, config_parse_route_table, 0, 0 +Route.GatewayOnlink, config_parse_gateway_onlink, 0, 0 DHCP.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier) DHCP.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns) DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp) diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 570083f180..e2a5c77ed1 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -939,3 +939,44 @@ int config_parse_route_table(const char *unit, return 0; } + +int config_parse_gateway_onlink(const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + Network *network = userdata; + _cleanup_route_free_ Route *n = NULL; + int r; + + assert(filename); + assert(section); + assert(lvalue); + assert(rvalue); + assert(data); + + r = route_new_static(network, filename, section_line, &n); + if (r < 0) + return r; + + r = parse_boolean(rvalue); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, + "Could not parse gateway onlink \"%s\", ignoring assignment: %m", rvalue); + return 0; + } + + if (r) + n->flags |= RTNH_F_ONLINK; + else + n->flags &= ~RTNH_F_ONLINK; + + n = NULL; + + return 0; +} diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index 4ebfa0f0bd..e2446b3e92 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -75,3 +75,4 @@ int config_parse_destination(const char *unit, const char *filename, unsigned li int config_parse_route_priority(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_route_scope(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_route_table(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); +int config_parse_gateway_onlink(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); |