summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-05-17 13:29:24 +0200
committerThomas Haller <thaller@redhat.com>2022-05-31 18:32:34 +0200
commit479562815c8c226d302af2e627af3e3f67f42d1a (patch)
tree5626f9f7f9d565a69ee058147830fa4ffaaaec78
parent9abcf3a53cce71fb9c1150750b301598c9a7413f (diff)
downloadNetworkManager-479562815c8c226d302af2e627af3e3f67f42d1a.tar.gz
dhcp: ensure a valid DHCPv4 lease has an address for dhclient
The same check is also for nettools' n-dhcp4 client. It's useful to being able to rely on certain things, like that an DHCPv4 lease always has exactly one address (not equal to 0.0.0.0).
-rw-r--r--src/core/dhcp/nm-dhcp-utils.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core/dhcp/nm-dhcp-utils.c b/src/core/dhcp/nm-dhcp-utils.c
index 79310dc5cc..71813594a0 100644
--- a/src/core/dhcp/nm-dhcp-utils.c
+++ b/src/core/dhcp/nm-dhcp-utils.c
@@ -416,6 +416,8 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
str = g_hash_table_lookup(options, "ip_address");
if (!str || !nm_utils_parse_inaddr_bin(AF_INET, str, NULL, &addr))
return NULL;
+ if (addr == INADDR_ANY)
+ return NULL;
_LOG2I(LOGD_DHCP4, iface, " address %s", str);
@@ -428,6 +430,7 @@ nm_dhcp_utils_ip4_config_from_options(NMDedupMultiIndex *multi_idx,
plen = _nm_utils_ip4_get_default_prefix(addr);
_LOG2I(LOGD_DHCP4, iface, " plen %d (default)", plen);
}
+
nm_platform_ip4_address_set_addr(&address, addr, plen);
/* Routes: if the server returns classless static routes, we MUST ignore