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-19 16:18:59 +0100
commit07badc70eaf037f69ef3066d65a58037e200dade (patch)
tree27ac1494a14ec88e84ad8bac9833202915fe36c1
parenta89451626902c7d8875528c39fc070987b8f5fff (diff)
downloadNetworkManager-th/dhcp-internal-mulitple-routers.tar.gz
dhcp/internal: handle localhost and 0.0.0.0 DNS/NTP servers speciallyth/dhcp-internal-mulitple-routers
- 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] Systemd-pull-requst #4524 [2] https://github.com/systemd/systemd/commit/d9ec2e632df4905201facf76d6a205edc952116a [3] Systemd-pull-request #11208
-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);