dhcp: Only use DHCP server port if explicitly configured

If a DHCP server is running on the same host it isn't necessary to
bind the server port and might even cause conflicts.
This commit is contained in:
Tobias Brunner
2018-07-02 11:39:22 +02:00
parent 50c4c1bb40
commit 707b70725a
2 changed files with 22 additions and 2 deletions
+7 -2
View File
@@ -800,7 +800,10 @@ dhcp_socket_t *dhcp_socket_create()
destroy(this);
return NULL;
}
if (!is_broadcast(this->dst))
if (!is_broadcast(this->dst) &&
lib->settings->get_bool(lib->settings,
"%s.plugins.dhcp.use_server_port", FALSE,
lib->ns))
{
/* when setting giaddr (which we do when we don't broadcast), the server
* should respond to the server port on that IP, according to RFC 2131,
@@ -808,7 +811,9 @@ dhcp_socket_t *dhcp_socket_create()
* kernel will respond with an ICMP port unreachable if there is no
* socket bound to that port, which might be problematic with certain
* DHCP servers. instead of opening an additional socket, that we don't
* actually use, we can also just send our requests from port 67 */
* actually use, we can also just send our requests from port 67.
* we don't do this by default, as it might cause conflicts with DHCP
* servers running on the same host */
src.sin_port = htons(DHCP_SERVER_PORT);
}
if (bind(this->send, (struct sockaddr*)&src, sizeof(src)) == -1)