diff --git a/man/systemd.network.xml b/man/systemd.network.xml index ad0e0cf48a..74ee8e56ff 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -902,6 +902,15 @@ + + Protocol= + + The Protocol identifier for the route. Takes a number between 0 and 255 or the special values + kernel, boot and static. Defaults to + static. + + + diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index ee8bd6faf7..ef53b528a8 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -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) diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index ff93fe4a04..c5ee08a77a 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -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; +} diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index 47ff6f28a0..efd1e53d2a 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -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);