]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce DHCPv6PrefixDelegation= setting
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 16 Oct 2020 06:50:44 +0000 (15:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 19 Oct 2020 01:09:38 +0000 (10:09 +0900)
Then, the link can configure prefix delegated by DHCPv6 without emitting
RA.

src/network/networkd-dhcp6.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h
src/network/networkd-radv.c
test/fuzz/fuzz-network-parser/directives.network

index c7a6d54c790581d560c2be5a6a3dc6c9e988d753..81cf44b082c183c986388bd3849c965d0e600384 100644 (file)
@@ -31,7 +31,7 @@ bool link_dhcp6_pd_is_enabled(Link *link) {
         if (!link->network)
                 return false;
 
-        return link->network->router_prefix_delegation & RADV_PREFIX_DELEGATION_DHCP6;
+        return link->network->dhcp6_pd;
 }
 
 static bool dhcp6_lease_has_pd_prefix(sd_dhcp6_lease *lease) {
index 6f74bcf4e50851ce3970bb86f75a663e26f79b0c..cdf77391b0f9b4def3316bafe95d8ce00e09269c 100644 (file)
@@ -126,6 +126,8 @@ Network.BindCarrier,                         config_parse_strv,
 Network.ConfigureWithoutCarrier,             config_parse_bool,                                        0,                             offsetof(Network, configure_without_carrier)
 Network.IgnoreCarrierLoss,                   config_parse_tristate,                                    0,                             offsetof(Network, ignore_carrier_loss)
 Network.KeepConfiguration,                   config_parse_keep_configuration,                          0,                             offsetof(Network, keep_configuration)
+Network.IPv6PrefixDelegation,                config_parse_router_prefix_delegation,                    0,                             offsetof(Network, router_prefix_delegation)
+Network.DHCPv6PrefixDelegation,              config_parse_tristate,                                    0,                             offsetof(Network, dhcp6_pd)
 Address.Address,                             config_parse_address,                                     0,                             0
 Address.Peer,                                config_parse_address,                                     0,                             0
 Address.Broadcast,                           config_parse_broadcast,                                   0,                             0
@@ -280,7 +282,6 @@ BridgeMDB.VLANId,                            config_parse_mdb_vlan_id,
 BridgeVLAN.PVID,                             config_parse_brvlan_pvid,                                 0,                             0
 BridgeVLAN.VLAN,                             config_parse_brvlan_vlan,                                 0,                             0
 BridgeVLAN.EgressUntagged,                   config_parse_brvlan_untagged,                             0,                             0
-Network.IPv6PrefixDelegation,                config_parse_router_prefix_delegation,                    0,                             offsetof(Network, router_prefix_delegation)
 DHCPv6PrefixDelegation.SubnetId,             config_parse_dhcp6_pd_subnet_id,                          0,                             offsetof(Network, dhcp6_pd_subnet_id)
 DHCPv6PrefixDelegation.Assign,               config_parse_bool,                                        0,                             offsetof(Network, dhcp6_pd_assign)
 DHCPv6PrefixDelegation.Token,                config_parse_dhcp6_pd_token,                              0,                             offsetof(Network, dhcp6_pd_token)
index 20617932c375460d1bc9c1c125126a415a2c48c5..111a11ee0d848dda02237fd86237c7693a957d69 100644 (file)
@@ -367,6 +367,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
                 .dhcp6_use_ntp = true,
                 .dhcp6_use_dns = true,
 
+                .dhcp6_pd = -1,
                 .dhcp6_pd_subnet_id = -1,
                 .dhcp6_pd_assign = true,
 
index 0f26b3852156b8538dbb826b0782dd539f2c458a..5a8aca31333012fb5b1ccbed1d5c56b737721296 100644 (file)
@@ -201,7 +201,7 @@ struct Network {
         OrderedSet *router_search_domains;
 
         /* DHCPv6 Prefix Delegation support */
-        bool dhcp6_pd;
+        int dhcp6_pd;
         bool dhcp6_pd_assign;
         int64_t dhcp6_pd_subnet_id;
         union in_addr_union dhcp6_pd_token;
index cb9e0262e68cd3121ceb27630831c64ee00ff17d..48c37d74902b45acd704ffcfa59d03be9e8fe05e 100644 (file)
@@ -183,6 +183,12 @@ void network_drop_invalid_route_prefixes(Network *network) {
 void network_adjust_radv(Network *network) {
         assert(network);
 
+        /* After this function is called, network->router_prefix_delegation can be treated as a boolean. */
+
+        if (network->dhcp6_pd < 0)
+                /* For backward compatibility. */
+                network->dhcp6_pd = FLAGS_SET(network->router_prefix_delegation, RADV_PREFIX_DELEGATION_DHCP6);
+
         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. "
@@ -631,7 +637,7 @@ static bool link_radv_enabled(Link *link) {
         if (!link_ipv6ll_enabled(link))
                 return false;
 
-        return link->network->router_prefix_delegation != RADV_PREFIX_DELEGATION_NONE;
+        return link->network->router_prefix_delegation;
 }
 
 int radv_configure(Link *link) {
index 1494daa0c1b0e6854d6cbdb0ecd7d2e73a11d9ac..2a11156dbca2dcdb1e0a7aed2b9e2557c4dc5cdc 100644 (file)
@@ -214,6 +214,7 @@ BindCarrier=
 VRF=
 IgnoreCarrierLoss=
 KeepConfiguration=
+DHCPv6PrefixDelegation=
 [IPv6Prefix]
 Prefix=
 OnLink=