From: Yu Watanabe Date: Sat, 17 Apr 2021 17:31:13 +0000 (+0900) Subject: network: move RouteMetric= from [DHCPv6] to [IPv6AcceptRA] X-Git-Tag: v249-rc1~375^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ebafba9f987c21aa5787c8767f2e390b4ec0bc5;p=thirdparty%2Fsystemd.git network: move RouteMetric= from [DHCPv6] to [IPv6AcceptRA] As the value is used in the routes in RA. --- diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 38123508206..c119c716ac6 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1986,13 +1986,6 @@ IPv6Token=prefixstable:2002:da8:1:: - - RouteMetric= - - Set the routing metric for routes specified by the DHCP server. Defaults to 1024. - - - RapidCommit= @@ -2216,6 +2209,14 @@ IPv6Token=prefixstable:2002:da8:1:: + + RouteMetric= + + Set the routing metric for the routes received in the Router Advertisement. Takes an + unsigned integer in the range 0…4294967295. Defaults to 1024. + + + UseAutonomousPrefix= diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c index f09f0ee50e4..bb0b2044677 100644 --- a/src/network/networkd-dhcp-common.c +++ b/src/network/networkd-dhcp-common.c @@ -332,14 +332,14 @@ int config_parse_dhcp_route_metric( if (streq_ptr(section, "DHCPv4")) { network->dhcp_route_metric = metric; network->dhcp_route_metric_set = true; - } else if (streq_ptr(section, "DHCPv6")) { - network->dhcp6_route_metric = metric; - network->dhcp6_route_metric_set = true; + } else if (STRPTR_IN_SET(section, "DHCPv6", "IPv6AcceptRA")) { + network->ipv6_accept_ra_route_metric = metric; + network->ipv6_accept_ra_route_metric_set = true; } else { /* [DHCP] section */ if (!network->dhcp_route_metric_set) network->dhcp_route_metric = metric; - if (!network->dhcp6_route_metric_set) - network->dhcp6_route_metric = metric; + if (!network->ipv6_accept_ra_route_metric_set) + network->ipv6_accept_ra_route_metric = metric; } return 0; diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 7a975f3a916..b02f67c7708 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -530,7 +530,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { route->family = AF_INET6; route->table = table; - route->priority = link->network->dhcp6_route_metric; + route->priority = link->network->ipv6_accept_ra_route_metric; route->protocol = RTPROT_RA; route->pref = preference; route->gw_family = AF_INET6; @@ -554,7 +554,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { if (!route_gw->table_set) route_gw->table = table; if (!route_gw->priority_set) - route_gw->priority = link->network->dhcp6_route_metric; + route_gw->priority = link->network->ipv6_accept_ra_route_metric; if (!route_gw->protocol_set) route_gw->protocol = RTPROT_RA; if (!route_gw->pref_set) @@ -814,7 +814,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->dhcp6_route_metric; + route->priority = link->network->ipv6_accept_ra_route_metric; route->protocol = RTPROT_RA; route->flags = RTM_F_PREFIX; route->dst_prefixlen = prefixlen; @@ -899,7 +899,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->priority = link->network->ipv6_accept_ra_route_metric; route->protocol = RTPROT_RA; route->pref = preference; route->gw = gateway; diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index 0e3361b052b..43e4d30bea5 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -244,13 +244,13 @@ DHCPv6.ForceDHCPv6PDOtherInformation, config_parse_bool, DHCPv6.PrefixDelegationHint, config_parse_dhcp6_pd_hint, 0, 0 DHCPv6.WithoutRA, config_parse_dhcp6_client_start_mode, 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_dhcp_route_metric, 0, 0 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) IPv6AcceptRA.UseDomains, config_parse_ipv6_accept_ra_use_domains, 0, offsetof(Network, ipv6_accept_ra_use_domains) IPv6AcceptRA.DHCPv6Client, config_parse_ipv6_accept_ra_start_dhcp6_client, 0, offsetof(Network, ipv6_accept_ra_start_dhcp6_client) IPv6AcceptRA.RouteTable, config_parse_section_route_table, 0, 0 +IPv6AcceptRA.RouteMetric, config_parse_dhcp_route_metric, 0, 0 IPv6AcceptRA.RouterAllowList, config_parse_ndisc_address_filter, 0, offsetof(Network, ndisc_allow_listed_router) IPv6AcceptRA.RouterDenyList, config_parse_ndisc_address_filter, 0, offsetof(Network, ndisc_deny_listed_router) IPv6AcceptRA.PrefixAllowList, config_parse_ndisc_address_filter, 0, offsetof(Network, ndisc_allow_listed_prefix) @@ -492,6 +492,7 @@ DHCP.RapidCommit, config_parse_bool, DHCP.ForceDHCPv6PDOtherInformation, config_parse_bool, 0, offsetof(Network, dhcp6_force_pd_other_information) DHCPv4.UseDomainName, config_parse_dhcp_use_domains, 0, 0 DHCPv4.CriticalConnection, config_parse_tristate, 0, offsetof(Network, dhcp_critical) +DHCPv6.RouteMetric, config_parse_dhcp_route_metric, 0, 0 IPv6AcceptRA.DenyList, config_parse_ndisc_address_filter, 0, offsetof(Network, ndisc_deny_listed_prefix) IPv6AcceptRA.BlackList, config_parse_ndisc_address_filter, 0, offsetof(Network, ndisc_deny_listed_prefix) TrafficControlQueueingDiscipline.Parent, config_parse_qdisc_parent, _QDISC_KIND_INVALID, 0 diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 320d33645e4..6c81f2cca7b 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -321,7 +321,6 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi .dhcp6_use_hostname = true, .dhcp6_use_ntp = true, .dhcp6_rapid_commit = true, - .dhcp6_route_metric = DHCP_ROUTE_METRIC, .dhcp6_pd = -1, .dhcp6_pd_announce = true, @@ -379,6 +378,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi .ipv6_accept_ra_use_autonomous_prefix = true, .ipv6_accept_ra_use_onlink_prefix = true, .ipv6_accept_ra_route_table = RT_TABLE_MAIN, + .ipv6_accept_ra_route_metric = DHCP_ROUTE_METRIC, .ipv6_accept_ra_start_dhcp6_client = IPV6_ACCEPT_RA_START_DHCP6_CLIENT_YES, .can_triple_sampling = -1, diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 16a445982c6..e36dada3446 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -170,8 +170,6 @@ struct Network { DHCPUseDomains dhcp6_use_domains; bool dhcp6_use_domains_set; uint8_t dhcp6_pd_length; - uint32_t dhcp6_route_metric; - bool dhcp6_route_metric_set; char *dhcp6_mudurl; char **dhcp6_user_class; char **dhcp6_vendor_class; @@ -277,10 +275,12 @@ struct Network { bool ipv6_accept_ra_use_onlink_prefix; bool active_slave; bool primary_slave; - bool ipv6_accept_ra_route_table_set; DHCPUseDomains ipv6_accept_ra_use_domains; IPv6AcceptRAStartDHCP6Client ipv6_accept_ra_start_dhcp6_client; uint32_t ipv6_accept_ra_route_table; + bool ipv6_accept_ra_route_table_set; + uint32_t ipv6_accept_ra_route_metric; + bool ipv6_accept_ra_route_metric_set; Set *ndisc_deny_listed_router; Set *ndisc_allow_listed_router; Set *ndisc_deny_listed_prefix; diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network index dbb6effa958..a938394bab9 100644 --- a/test/fuzz/fuzz-network-parser/directives.network +++ b/test/fuzz/fuzz-network-parser/directives.network @@ -318,6 +318,7 @@ Prefix= [IPv6AcceptRA] UseDomains= RouteTable= +RouteMetric= UseDNS= DHCPv6Client= UseAutonomousPrefix=