summary refs log tree commit diff
path: root/src/core/dhcp/nm-dhcp-systemd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/dhcp/nm-dhcp-systemd.c')
-rw-r--r--src/core/dhcp/nm-dhcp-systemd.c74
1 files changed, 40 insertions, 34 deletions
diff --git a/src/core/dhcp/nm-dhcp-systemd.c b/src/core/dhcp/nm-dhcp-systemd.c
index 14a121e7..4a718de9 100644
--- a/src/core/dhcp/nm-dhcp-systemd.c
+++ b/src/core/dhcp/nm-dhcp-systemd.c
@@ -751,14 +751,12 @@ lease_to_ip6_config(NMDedupMultiIndex *multi_idx,
     gs_unref_hashtable GHashTable          *options = NULL;
     struct in6_addr                         tmp_addr;
     const struct in6_addr                  *dns;
-    uint32_t                                lft_pref, lft_valid;
     char                                    addr_str[NM_UTILS_INET_ADDRSTRLEN];
     char                                  **domains;
     char                                  **ntp_fqdns;
     const struct in6_addr                  *ntp_addrs;
     const char                             *s;
-    nm_auto_free_gstring GString           *str               = NULL;
-    gboolean                                has_any_addresses = FALSE;
+    nm_auto_free_gstring GString           *str = NULL;
     int                                     num, i;
 
     nm_assert(lease);
@@ -767,36 +765,45 @@ lease_to_ip6_config(NMDedupMultiIndex *multi_idx,
 
     options = nm_dhcp_option_create_options_dict();
 
-    sd_dhcp6_lease_reset_address_iter(lease);
-    nm_gstring_prepare(&str);
-    while (sd_dhcp6_lease_get_address(lease, &tmp_addr, &lft_pref, &lft_valid) >= 0) {
-        const NMPlatformIP6Address address = {
-            .plen        = 128,
-            .address     = tmp_addr,
-            .timestamp   = ts,
-            .lifetime    = lft_valid,
-            .preferred   = lft_pref,
-            .addr_source = NM_IP_CONFIG_SOURCE_DHCP,
-        };
-
-        nm_l3_config_data_add_address_6(l3cd, &address);
+    if (!info_only) {
+        gboolean has_any_addresses = FALSE;
+        uint32_t lft_pref;
+        uint32_t lft_valid;
 
-        _nm_utils_inet6_ntop(&tmp_addr, addr_str);
-        g_string_append(nm_gstring_add_space_delimiter(str), addr_str);
+        sd_dhcp6_lease_reset_address_iter(lease);
+        nm_gstring_prepare(&str);
+        while (sd_dhcp6_lease_get_address(lease, &tmp_addr, &lft_pref, &lft_valid) >= 0) {
+            const NMPlatformIP6Address address = {
+                .plen        = 128,
+                .address     = tmp_addr,
+                .timestamp   = ts,
+                .lifetime    = lft_valid,
+                .preferred   = lft_pref,
+                .addr_source = NM_IP_CONFIG_SOURCE_DHCP,
+            };
+
+            nm_l3_config_data_add_address_6(l3cd, &address);
+
+            _nm_utils_inet6_ntop(&tmp_addr, addr_str);
+            g_string_append(nm_gstring_add_space_delimiter(str), addr_str);
 
-        has_any_addresses = TRUE;
-    }
+            has_any_addresses = TRUE;
+        }
 
-    if (str->len) {
-        nm_dhcp_option_add_option(options, AF_INET6, NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS, str->str);
-    }
+        if (str->len) {
+            nm_dhcp_option_add_option(options,
+                                      AF_INET6,
+                                      NM_DHCP_OPTION_DHCP6_NM_IP_ADDRESS,
+                                      str->str);
+        }
 
-    if (!info_only && !has_any_addresses) {
-        g_set_error_literal(error,
-                            NM_MANAGER_ERROR,
-                            NM_MANAGER_ERROR_FAILED,
-                            "no address received in managed mode");
-        return NULL;
+        if (!has_any_addresses) {
+            g_set_error_literal(error,
+                                NM_MANAGER_ERROR,
+                                NM_MANAGER_ERROR_FAILED,
+                                "no address received in managed mode");
+            return NULL;
+        }
     }
 
     num = sd_dhcp6_lease_get_dns(lease, &dns);
@@ -966,11 +973,10 @@ ip6_start(NMDhcpClient *client, const struct in6_addr *ll_addr, GError **error)
 
     _LOGT("dhcp-client6: set %p", sd_client);
 
-    if (client_config->v6.info_only) {
-        sd_dhcp6_client_set_address_request(sd_client, 0);
-        if (client_config->v6.needed_prefixes == 0)
-            sd_dhcp6_client_set_information_request(sd_client, 1);
-    }
+    sd_dhcp6_client_set_address_request(sd_client, !client_config->v6.info_only);
+    sd_dhcp6_client_set_information_request(sd_client,
+                                            client_config->v6.info_only
+                                                && client_config->v6.needed_prefixes == 0);
 
     r = sd_dhcp6_client_set_iaid(sd_client, client_config->v6.iaid);
     if (r < 0) {