diff --git a/repos/os/src/server/nic_router/dhcp_server.cc b/repos/os/src/server/nic_router/dhcp_server.cc index 7c6d93a2a7..f46c27e20a 100644 --- a/repos/os/src/server/nic_router/dhcp_server.cc +++ b/repos/os/src/server/nic_router/dhcp_server.cc @@ -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, diff --git a/repos/os/src/server/nic_router/dhcp_server.h b/repos/os/src/server/nic_router/dhcp_server.h index 36e7a0006a..a3e43d537e 100644 --- a/repos/os/src/server/nic_router/dhcp_server.h +++ b/repos/os/src/server/nic_router/dhcp_server.h @@ -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()) { diff --git a/repos/os/src/server/nic_router/interface.cc b/repos/os/src/server/nic_router/interface.cc index f7a6282b52..c471a30653 100644 --- a/repos/os/src/server/nic_router/interface.cc +++ b/repos/os/src/server/nic_router/interface.cc @@ -687,11 +687,18 @@ void Interface::_send_dhcp_reply(Dhcp_server const &dhcp_srv, dhcp_opts.append_option(local_intf.subnet_mask()); dhcp_opts.append_option(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) { - data.append_address(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) { diff --git a/repos/os/src/server/nic_router/ipv4_config.h b/repos/os/src/server/nic_router/ipv4_config.h index af9602a744..a505b11356 100644 --- a/repos/os/src/server/nic_router/ipv4_config.h +++ b/repos/os/src/server/nic_router/ipv4_config.h @@ -91,11 +91,12 @@ class Net::Ipv4_config ** Accessors ** ***************/ - bool valid() const { return _valid; } - Ipv4_address_prefix const &interface() const { return _interface; } - 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 valid() const { return _valid; } + Ipv4_address_prefix const &interface() const { return _interface; } + 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_ */