From 1bf1bfd9589c0c531847b0cf93bc97699617936e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 1 Jun 2020 13:02:16 +0900 Subject: [PATCH] network: add DHCPv6.RouteMetric= Hopefully fixes #15295. --- man/systemd.network.xml | 10 ++++++++-- src/network/networkd-ndisc.c | 5 +++-- src/network/networkd-network-gperf.gperf | 1 + src/network/networkd-network.c | 1 + src/network/networkd-network.h | 1 + test/fuzz/fuzz-network-parser/directives.network | 1 + 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/man/systemd.network.xml b/man/systemd.network.xml index ae82ae7e02b..146401f6c90 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1614,8 +1614,7 @@ RouteMetric= - Set the routing metric for routes specified by the - DHCP server. + Set the routing metric for routes specified by the DHCP server. Defaults to 1024. @@ -1734,6 +1733,13 @@ + + RouteMetric= + + Set the routing metric for routes specified by the DHCP server. Defaults to 1024. + + + RapidCommit= diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 8af7b3c0c3c..6de8428e1e2 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -216,7 +216,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { route->family = AF_INET6; route->table = link_get_ipv6_accept_ra_route_table(link); - route->priority = link->network->dhcp_route_metric; + route->priority = link->network->dhcp6_route_metric; route->protocol = RTPROT_RA; route->pref = preference; route->gw = gateway; @@ -451,7 +451,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) { route->family = AF_INET6; route->table = link_get_ipv6_accept_ra_route_table(link); - route->priority = link->network->dhcp_route_metric; + route->priority = link->network->dhcp6_route_metric; route->protocol = RTPROT_RA; route->flags = RTM_F_PREFIX; route->dst_prefixlen = prefixlen; @@ -512,6 +512,7 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) { route->family = AF_INET6; route->table = link_get_ipv6_accept_ra_route_table(link); + route->priority = link->network->dhcp6_route_metric; route->protocol = RTPROT_RA; route->pref = preference; route->gw.in6 = gateway; diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 2fc513fbadc..4976c62c100 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -204,6 +204,7 @@ DHCPv6.AssignAcquiredDelegatedPrefixAddress, config_parse_bool, DHCPv6.PrefixDelegationHint, config_parse_dhcp6_pd_hint, 0, 0 DHCPv6.WithoutRA, config_parse_bool, 0, offsetof(Network, dhcp6_without_ra) DHCPv6.SendOption, config_parse_dhcp_send_option, AF_INET6, offsetof(Network, dhcp6_client_send_options) +DHCPv6.RouteMetric, config_parse_uint32, 0, offsetof(Network, dhcp6_route_metric) IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix) IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix) IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 2e8cba4ae2e..b928f7585c3 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -410,6 +410,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi .dhcp_use_timezone = false, .rapid_commit = true, + .dhcp6_route_metric = DHCP_ROUTE_METRIC, .dhcp6_use_ntp = true, .dhcp6_use_dns = true, diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index db325d0d3c2..1d4b68d790e 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -132,6 +132,7 @@ struct Network { bool dhcp6_use_ntp; bool dhcp6_without_ra; uint8_t dhcp6_pd_length; + uint32_t dhcp6_route_metric; char *dhcp6_mudurl; char **dhcp6_user_class; char **dhcp6_vendor_class; diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index faa38a1c1e0..0b62420e0a9 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -121,6 +121,7 @@ UserClass= VendorClass= AssignAcquiredDelegatedPrefixAddress= SendVendorOption= +RouteMetric= [Route] Destination= Protocol= -- 2.39.2