From 69e0f833a3bb9b4b283b5a410bdd4a8327a96139 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 15 Oct 2020 16:06:47 +0900 Subject: [PATCH] network: introduce network_adjust_radv() --- src/network/networkd-network.c | 9 +-------- src/network/networkd-radv.c | 20 ++++++++++++++++++++ src/network/networkd-radv.h | 1 + 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index d31b7bca4c1..2a433f96def 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -214,14 +214,6 @@ int network_verify(Network *network) { if (network->link_local < 0) network->link_local = network->bridge ? ADDRESS_FAMILY_NO : ADDRESS_FAMILY_IPV6; - if (!FLAGS_SET(network->link_local, ADDRESS_FAMILY_IPV6)) { - if (network->router_prefix_delegation != RADV_PREFIX_DELEGATION_NONE) { - log_warning("%s: IPv6PrefixDelegation= is enabled but IPv6 link local addressing is disabled. " - "Disabling IPv6PrefixDelegation=.", network->filename); - network->router_prefix_delegation = RADV_PREFIX_DELEGATION_NONE; - } - } - if (FLAGS_SET(network->link_local, ADDRESS_FAMILY_FALLBACK_IPV4) && !FLAGS_SET(network->dhcp, ADDRESS_FAMILY_IPV4)) { log_warning("%s: fallback assignment of IPv4 link local address is enabled but DHCPv4 is disabled. " @@ -235,6 +227,7 @@ int network_verify(Network *network) { network_adjust_ipv6_accept_ra(network); network_adjust_dhcp(network); + network_adjust_radv(network); if (network->mtu > 0 && network->dhcp_use_mtu) { log_warning("%s: MTUBytes= in [Link] section and UseMTU= in [DHCP] section are set. " diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index fca6fa2c97e..4fc207dce58 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -180,6 +180,26 @@ void network_drop_invalid_route_prefixes(Network *network) { route_prefix_free(prefix); } +void network_adjust_radv(Network *network) { + assert(network); + + if (!FLAGS_SET(network->link_local, ADDRESS_FAMILY_IPV6)) { + if (network->router_prefix_delegation != RADV_PREFIX_DELEGATION_NONE) + log_warning("%s: IPv6PrefixDelegation= is enabled but IPv6 link local addressing is disabled. " + "Disabling IPv6PrefixDelegation=.", network->filename); + + network->router_prefix_delegation = RADV_PREFIX_DELEGATION_NONE; + } + + if (network->router_prefix_delegation == RADV_PREFIX_DELEGATION_NONE) { + network->n_router_dns = 0; + network->router_dns = mfree(network->router_dns); + network->router_search_domains = ordered_set_free(network->router_search_domains); + network->prefixes_by_section = hashmap_free_with_destructor(network->prefixes_by_section, prefix_free); + network->route_prefixes_by_section = hashmap_free_with_destructor(network->route_prefixes_by_section, route_prefix_free); + } +} + int config_parse_prefix( const char *unit, const char *filename, diff --git a/src/network/networkd-radv.h b/src/network/networkd-radv.h index fbb93a9accc..75c606d15e2 100644 --- a/src/network/networkd-radv.h +++ b/src/network/networkd-radv.h @@ -47,6 +47,7 @@ RoutePrefix *route_prefix_free(RoutePrefix *prefix); void network_drop_invalid_prefixes(Network *network); void network_drop_invalid_route_prefixes(Network *network); +void network_adjust_radv(Network *network); int radv_emit_dns(Link *link); int radv_configure(Link *link);