networkd: make IPv6 route preference configurable (#5700)
The work supports route preference configurable. i.e. able to set low, medium and high.
This commit is contained in:
parent
19fe49f62c
commit
b5bf6f645e
|
@ -841,6 +841,16 @@
|
||||||
<para>The metric of the route (an unsigned integer).</para>
|
<para>The metric of the route (an unsigned integer).</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>IPv6Preference=</varname></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Specifies the route preference as defined in <ulink
|
||||||
|
url="https://tools.ietf.org/html/rfc4191">RFC4191</ulink> for Router Discovery messages.
|
||||||
|
Which can be one of <literal>low</literal> the route has a lowest priority,
|
||||||
|
<literal>medium</literal> the route has a default priority or
|
||||||
|
<literal>high</literal> the route has a highest priority.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><varname>Scope=</varname></term>
|
<term><varname>Scope=</varname></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
|
|
@ -87,6 +87,7 @@ Route.Scope, config_parse_route_scope,
|
||||||
Route.PreferredSource, config_parse_preferred_src, 0, 0
|
Route.PreferredSource, config_parse_preferred_src, 0, 0
|
||||||
Route.Table, config_parse_route_table, 0, 0
|
Route.Table, config_parse_route_table, 0, 0
|
||||||
Route.GatewayOnlink, config_parse_gateway_onlink, 0, 0
|
Route.GatewayOnlink, config_parse_gateway_onlink, 0, 0
|
||||||
|
Route.IPv6Preference, config_parse_ipv6_route_preference, 0, 0
|
||||||
DHCP.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier)
|
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.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns)
|
||||||
DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp)
|
DHCP.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp)
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
#include <linux/icmpv6.h>
|
||||||
|
|
||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "conf-parser.h"
|
#include "conf-parser.h"
|
||||||
#include "in-addr-util.h"
|
#include "in-addr-util.h"
|
||||||
|
@ -975,6 +977,35 @@ int config_parse_gateway_onlink(const char *unit,
|
||||||
n->flags |= RTNH_F_ONLINK;
|
n->flags |= RTNH_F_ONLINK;
|
||||||
else
|
else
|
||||||
n->flags &= ~RTNH_F_ONLINK;
|
n->flags &= ~RTNH_F_ONLINK;
|
||||||
|
n = NULL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
Network *network = userdata;
|
||||||
|
_cleanup_route_free_ Route *n = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if (streq(rvalue, "low"))
|
||||||
|
n->pref = ICMPV6_ROUTER_PREF_LOW;
|
||||||
|
else if (streq(rvalue, "medium"))
|
||||||
|
n->pref = ICMPV6_ROUTER_PREF_MEDIUM;
|
||||||
|
else if (streq(rvalue, "high"))
|
||||||
|
n->pref = ICMPV6_ROUTER_PREF_HIGH;
|
||||||
|
else {
|
||||||
|
log_syntax(unit, LOG_ERR, filename, line, 0, "Unknown route preference: %s", rvalue);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
n = NULL;
|
n = NULL;
|
||||||
|
|
||||||
|
|
|
@ -76,3 +76,4 @@ int config_parse_route_priority(const char *unit, const char *filename, unsigned
|
||||||
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_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_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_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);
|
||||||
|
|
Loading…
Reference in a new issue