Skip to content

Commit

Permalink
dhcp/internal: handle localhost and 0.0.0.0 DNS/NTP servers specially
Browse files Browse the repository at this point in the history
- 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] systemd/systemd@d9ec2e6
[3] Systemd-pull-request #11208
  • Loading branch information
thom311 committed Feb 19, 2019
1 parent a894516 commit 07badc7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/dhcp/nm-dhcp-systemd.c
Expand Up @@ -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);
Expand Down

0 comments on commit 07badc7

Please sign in to comment.