summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-12-21 12:19:29 +0100
committerThomas Haller <thaller@redhat.com>2019-02-20 10:02:30 +0100
commitc2b3b9b95582696c044d3d580e40570b6e96a0df (patch)
tree27ac1494a14ec88e84ad8bac9833202915fe36c1
parentf3e1dea1fef80d8a65142ccae7b008f4936bf063 (diff)
downloadNetworkManager-c2b3b9b95582696c044d3d580e40570b6e96a0df.tar.gz
dhcp/internal: handle localhost and 0.0.0.0 DNS/NTP servers specially
- regarding the DHCP options, we should not suppress them. If the lease contains such bogus(?) addresses, we still want to expose them on D-Bus without modification. - regrading using the DNS server, ignore localhost addresses like done for systemd-networkd ([1], [2]). Until recently, the DHCP library would internally suppress such addresses ([3]). That is no longer the case, and we should handle them specially. [1] https://github.com/systemd/systemd/issues/4524 [2] https://github.com/systemd/systemd/commit/d9ec2e632df4905201facf76d6a205edc952116a [3] 334d5682ae3f1eb89a98c69db3d23140e1552cbd
-rw-r--r--src/dhcp/nm-dhcp-systemd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
index 49c478a504..70ed871503 100644
--- a/src/dhcp/nm-dhcp-systemd.c
+++ b/src/dhcp/nm-dhcp-systemd.c
@@ -326,17 +326,19 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
if (num > 0) {
nm_gstring_prepare (&str);
for (i = 0; i < num; i++) {
- if (addr_list[i].s_addr == 0)
- continue;
-
nm_utils_inet4_ntop (addr_list[i].s_addr, addr_str);
g_string_append (nm_gstring_add_space_delimiter (str), addr_str);
+
+ if ( addr_list[i].s_addr == 0
+ || nm_ip4_addr_is_localhost (addr_list[i].s_addr)) {
+ /* Skip localhost addresses, like also networkd does.
+ * See https://github.com/systemd/systemd/issues/4524. */
+ continue;
+ }
nm_ip4_config_add_nameserver (ip4_config, addr_list[i].s_addr);
}
- if (str->len) {
- LOG_LEASE (LOGD_DHCP4, "nameserver '%s'", str->str);
- add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_NAME_SERVER, str->str);
- }
+ LOG_LEASE (LOGD_DHCP4, "nameserver '%s'", str->str);
+ add_option (options, dhcp4_requests, SD_DHCP_OPTION_DOMAIN_NAME_SERVER, str->str);
}
num = sd_dhcp_lease_get_search_domains (lease, (char ***) &search_domains);