nic_router: no empty DNS servers opt in DHCP reply

The NIC router used to add the DNS servers field to DHCP replies regardless of
whether there were DNS servers or not. As reported by a Genode user, the empty
DNS server field irritated at least Windows 10 guests (Vbox 6) that connected
to the NIC router. This resulted in Windows 10 ignoring DHCP offers from the
router with such characteristic.

With this commit adding the DNS server DHCP option is skipped if there are no
DNS servers at the corresponding DHCP server or the domain IP config the server
shall fetch its DNS servers from.

Fixes #4581
This commit is contained in:
Martin Stein 2022-08-01 10:18:11 +02:00 committed by Christian Helmuth
parent 1dd69eeb6c
commit a4ec06a3b7
4 changed files with 30 additions and 10 deletions

View File

@ -78,6 +78,16 @@ void Dhcp_server_base::_invalid(Domain const &domain,
** Dhcp_server **
*****************/
bool Dhcp_server::dns_servers_empty() const
{
if (_dns_config_from.valid()) {
return _resolve_dns_config_from().dns_servers_empty();
}
return _dns_servers.empty();
}
Dhcp_server::Dhcp_server(Xml_node const node,
Domain &domain,
Allocator &alloc,

View File

@ -125,6 +125,8 @@ class Net::Dhcp_server : private Genode::Noncopyable,
}
}
bool dns_servers_empty() const;
Dns_domain_name const &dns_domain_name() const
{
if (_dns_config_from.valid()) {

View File

@ -687,11 +687,18 @@ void Interface::_send_dhcp_reply(Dhcp_server const &dhcp_srv,
dhcp_opts.append_option<Dhcp_packet::Subnet_mask>(local_intf.subnet_mask());
dhcp_opts.append_option<Dhcp_packet::Router_ipv4>(local_intf.address);
dhcp_opts.append_dns_server([&] (Dhcp_options::Dns_server_data &data) {
dhcp_srv.for_each_dns_server_ip([&] (Ipv4_address const &addr) {
if (not dhcp_srv.dns_servers_empty()) {
dhcp_opts.append_dns_server(
[&] (Dhcp_options::Dns_server_data &data)
{
dhcp_srv.for_each_dns_server_ip(
[&] (Ipv4_address const &addr)
{
data.append_address(addr);
});
});
}
dhcp_srv.dns_domain_name().with_string(
[&] (Dns_domain_name::String const &str)
{

View File

@ -96,6 +96,7 @@ class Net::Ipv4_config
Ipv4_address const &gateway() const { return _gateway; }
bool gateway_valid() const { return _gateway_valid; }
Dns_domain_name const &dns_domain_name() const { return _dns_domain_name; }
bool dns_servers_empty() const { return _dns_servers.empty(); }
};
#endif /* _IPV4_CONFIG_H_ */