networkd: add support to configure route protocol. (#5890)

Closes: #5889
This commit is contained in:
Susant Sahani 2017-05-09 18:01:25 +00:00 committed by Lennart Poettering
parent 2f64b5d043
commit c83ecc04d9
4 changed files with 48 additions and 0 deletions

View File

@ -902,6 +902,15 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Protocol=</varname></term>
<listitem>
<para>The Protocol identifier for the route. Takes a number between 0 and 255 or the special values
<literal>kernel</literal>, <literal>boot</literal> and <literal>static</literal>. Defaults to
<literal>static</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

View File

@ -90,6 +90,7 @@ Route.PreferredSource, config_parse_preferred_src,
Route.Table, config_parse_route_table, 0, 0
Route.GatewayOnlink, config_parse_gateway_onlink, 0, 0
Route.IPv6Preference, config_parse_ipv6_route_preference, 0, 0
Route.Protocol, config_parse_route_protocol, 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)

View File

@ -1012,3 +1012,40 @@ int config_parse_ipv6_route_preference(const char *unit,
return 0;
}
int config_parse_route_protocol(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;
r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
if (streq(rvalue, "kernel"))
n->protocol = RTPROT_KERNEL;
else if (streq(rvalue, "boot"))
n->protocol = RTPROT_BOOT;
else if (streq(rvalue, "static"))
n->protocol = RTPROT_STATIC;
else {
r = safe_atou8(rvalue , &n->protocol);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Could not parse route protocol \"%s\", ignoring assignment: %m", rvalue);
return 0;
}
}
n = NULL;
return 0;
}

View File

@ -77,3 +77,4 @@ int config_parse_route_scope(const char *unit, const char *filename, unsigned li
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);
int config_parse_ipv6_route_preference(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_protocol(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);