Compare commits
5 Commits
9470b8902f
...
4e8b5f0f2c
Author | SHA1 | Date |
---|---|---|
Yu Watanabe | 4e8b5f0f2c | |
Luca Boccassi | b7eefa1996 | |
Yu Watanabe | ec6a9b2e03 | |
Yu Watanabe | 087e46cc55 | |
Yu Watanabe | 4527f71040 |
|
@ -4397,6 +4397,15 @@ ServerAddress=192.168.0.1/24</programlisting>
|
||||||
<xi:include href="version-info.xml" xpointer="v244"/></listitem>
|
<xi:include href="version-info.xml" xpointer="v244"/></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>Preference=</varname></term>
|
||||||
|
|
||||||
|
<listitem><para>Specifies the preference of the route option. Takes one of <literal>high</literal>,
|
||||||
|
<literal>medium</literal>, or <literal>low</literal>. Defaults to <literal>medium</literal>.</para>
|
||||||
|
|
||||||
|
<xi:include href="version-info.xml" xpointer="v258"/></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
|
|
@ -799,7 +799,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *path = strdup(e + 1);
|
_cleanup_free_ char *path = strdup(e + 1);
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) {
|
||||||
if (e)
|
if (e)
|
||||||
*e = 0;
|
*e = 0;
|
||||||
|
|
||||||
*ret_path = path;
|
*ret_path = TAKE_PTR(path);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,7 +406,7 @@ IPv6SendRA.ReachableTimeSec, config_parse_router_uint32_msec_use
|
||||||
IPv6SendRA.RetransmitSec, config_parse_router_uint32_msec_usec, 0, offsetof(Network, router_retransmit_usec)
|
IPv6SendRA.RetransmitSec, config_parse_router_uint32_msec_usec, 0, offsetof(Network, router_retransmit_usec)
|
||||||
IPv6SendRA.Managed, config_parse_bool, 0, offsetof(Network, router_managed)
|
IPv6SendRA.Managed, config_parse_bool, 0, offsetof(Network, router_managed)
|
||||||
IPv6SendRA.OtherInformation, config_parse_bool, 0, offsetof(Network, router_other_information)
|
IPv6SendRA.OtherInformation, config_parse_bool, 0, offsetof(Network, router_other_information)
|
||||||
IPv6SendRA.RouterPreference, config_parse_router_preference, 0, 0
|
IPv6SendRA.RouterPreference, config_parse_router_preference, 0, offsetof(Network, router_preference)
|
||||||
IPv6SendRA.HopLimit, config_parse_uint8, 0, offsetof(Network, router_hop_limit)
|
IPv6SendRA.HopLimit, config_parse_uint8, 0, offsetof(Network, router_hop_limit)
|
||||||
IPv6SendRA.EmitDNS, config_parse_bool, 0, offsetof(Network, router_emit_dns)
|
IPv6SendRA.EmitDNS, config_parse_bool, 0, offsetof(Network, router_emit_dns)
|
||||||
IPv6SendRA.DNS, config_parse_radv_dns, 0, 0
|
IPv6SendRA.DNS, config_parse_radv_dns, 0, 0
|
||||||
|
@ -427,6 +427,7 @@ IPv6Prefix.RouteMetric, config_parse_prefix_metric,
|
||||||
IPv6Prefix.Token, config_parse_prefix_token, 0, 0
|
IPv6Prefix.Token, config_parse_prefix_token, 0, 0
|
||||||
IPv6RoutePrefix.Route, config_parse_route_prefix, 0, 0
|
IPv6RoutePrefix.Route, config_parse_route_prefix, 0, 0
|
||||||
IPv6RoutePrefix.LifetimeSec, config_parse_route_prefix_lifetime, 0, 0
|
IPv6RoutePrefix.LifetimeSec, config_parse_route_prefix_lifetime, 0, 0
|
||||||
|
IPv6RoutePrefix.Preference, config_parse_route_prefix_preference, 0, 0
|
||||||
IPv6PREF64Prefix.Prefix, config_parse_pref64_prefix, 0, 0
|
IPv6PREF64Prefix.Prefix, config_parse_pref64_prefix, 0, 0
|
||||||
IPv6PREF64Prefix.LifetimeSec, config_parse_pref64_prefix_lifetime, 0, 0
|
IPv6PREF64Prefix.LifetimeSec, config_parse_pref64_prefix_lifetime, 0, 0
|
||||||
LLDP.MUDURL, config_parse_mud_url, 0, offsetof(Network, lldp_mudurl)
|
LLDP.MUDURL, config_parse_mud_url, 0, offsetof(Network, lldp_mudurl)
|
||||||
|
|
|
@ -1134,6 +1134,37 @@ int config_parse_route_prefix_lifetime(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int config_parse_route_prefix_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) {
|
||||||
|
|
||||||
|
_cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
|
||||||
|
Network *network = ASSERT_PTR(userdata);
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(filename);
|
||||||
|
|
||||||
|
r = route_prefix_new_static(network, filename, section_line, &p);
|
||||||
|
if (r < 0)
|
||||||
|
return log_oom();
|
||||||
|
|
||||||
|
r = config_parse_router_preference(unit, filename, line, section, section_line,
|
||||||
|
lvalue, ltype, rvalue, &p->route.preference, NULL);
|
||||||
|
if (r <= 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
TAKE_PTR(p);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int config_parse_pref64_prefix(
|
int config_parse_pref64_prefix(
|
||||||
const char *unit,
|
const char *unit,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
|
@ -1511,25 +1542,18 @@ int config_parse_router_preference(
|
||||||
void *data,
|
void *data,
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
Network *network = userdata;
|
uint8_t *preference = ASSERT_PTR(data);
|
||||||
|
|
||||||
assert(filename);
|
if (isempty(rvalue) || STR_IN_SET(rvalue, "medium", "normal", "default"))
|
||||||
assert(section);
|
*preference = SD_NDISC_PREFERENCE_MEDIUM;
|
||||||
assert(lvalue);
|
else if (streq(rvalue, "high"))
|
||||||
assert(rvalue);
|
*preference = SD_NDISC_PREFERENCE_HIGH;
|
||||||
assert(data);
|
|
||||||
|
|
||||||
if (streq(rvalue, "high"))
|
|
||||||
network->router_preference = SD_NDISC_PREFERENCE_HIGH;
|
|
||||||
else if (STR_IN_SET(rvalue, "medium", "normal", "default"))
|
|
||||||
network->router_preference = SD_NDISC_PREFERENCE_MEDIUM;
|
|
||||||
else if (streq(rvalue, "low"))
|
else if (streq(rvalue, "low"))
|
||||||
network->router_preference = SD_NDISC_PREFERENCE_LOW;
|
*preference = SD_NDISC_PREFERENCE_LOW;
|
||||||
else
|
else
|
||||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
return log_syntax_parse_error(unit, filename, line, 0, lvalue, rvalue);
|
||||||
"Invalid router preference, ignoring assignment: %s", rvalue);
|
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_parse_router_home_agent_lifetime(
|
int config_parse_router_home_agent_lifetime(
|
||||||
|
|
|
@ -86,6 +86,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_radv_dns);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_radv_search_domains);
|
CONFIG_PARSER_PROTOTYPE(config_parse_radv_search_domains);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_route_prefix);
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_prefix);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_route_prefix_lifetime);
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_prefix_lifetime);
|
||||||
|
CONFIG_PARSER_PROTOTYPE(config_parse_route_prefix_preference);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_pref64_prefix);
|
CONFIG_PARSER_PROTOTYPE(config_parse_pref64_prefix);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_pref64_prefix_lifetime);
|
CONFIG_PARSER_PROTOTYPE(config_parse_pref64_prefix_lifetime);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_router_home_agent_lifetime);
|
CONFIG_PARSER_PROTOTYPE(config_parse_router_home_agent_lifetime);
|
||||||
|
|
|
@ -6472,6 +6472,22 @@ class NetworkdRATests(unittest.TestCase, Utilities):
|
||||||
networkctl_reload()
|
networkctl_reload()
|
||||||
self.check_router_preference('01', 100, 'high', 300, 'low')
|
self.check_router_preference('01', 100, 'high', 300, 'low')
|
||||||
|
|
||||||
|
# Use route options with preference to configure default routes.
|
||||||
|
with open(os.path.join(network_unit_dir, '25-veth-router-high.network'), mode='a', encoding='utf-8') as f:
|
||||||
|
f.write('LifetimeSec=1200\nPreference=low\n')
|
||||||
|
with open(os.path.join(network_unit_dir, '25-veth-router-low.network'), mode='a', encoding='utf-8') as f:
|
||||||
|
f.write('LifetimeSec=1200\nPreference=high\n')
|
||||||
|
networkctl_reload()
|
||||||
|
self.check_router_preference('01', 300, 'low', 100, 'high')
|
||||||
|
|
||||||
|
# Set zero lifetime again to the route options.
|
||||||
|
with open(os.path.join(network_unit_dir, '25-veth-router-high.network'), mode='a', encoding='utf-8') as f:
|
||||||
|
f.write('LifetimeSec=0\n')
|
||||||
|
with open(os.path.join(network_unit_dir, '25-veth-router-low.network'), mode='a', encoding='utf-8') as f:
|
||||||
|
f.write('LifetimeSec=0\n')
|
||||||
|
networkctl_reload()
|
||||||
|
self.check_router_preference('01', 100, 'high', 300, 'low')
|
||||||
|
|
||||||
def _test_ndisc_vs_static_route(self, manage_foreign_nexthops):
|
def _test_ndisc_vs_static_route(self, manage_foreign_nexthops):
|
||||||
if not manage_foreign_nexthops:
|
if not manage_foreign_nexthops:
|
||||||
copy_networkd_conf_dropin('networkd-manage-foreign-nexthops-no.conf')
|
copy_networkd_conf_dropin('networkd-manage-foreign-nexthops-no.conf')
|
||||||
|
|
Loading…
Reference in New Issue