From 4cd49cc7a233bcb109427042a087d7c4ecaff6ed Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Tue, 11 Jul 2017 19:33:27 -0500 Subject: [PATCH] networkd: dhcp client should be more lenient The RFC requires the "Server Identifier" option, however in practice most clients that ship with modern distributions are more lenient. This change allows that option to be missing. --- src/libsystemd-network/sd-dhcp-client.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index 33f3469f07862..b8475687e5e7f 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -1250,10 +1250,16 @@ static int client_handle_offer(sd_dhcp_client *client, DHCPMessage *offer, size_ lease->next_server = offer->siaddr; lease->address = offer->yiaddr; + /* + * The RFC requires this "option", but most clients are more lenient + */ + if (lease->server_address == 0) { + log_dhcp_client(client, "Missing server identifier option, non-conforming DHCP"); + } + if (lease->address == 0 || - lease->server_address == 0 || lease->lifetime == 0) { - log_dhcp_client(client, "received lease lacks address, server address or lease lifetime, ignoring"); + log_dhcp_client(client, "received lease lacks address, or lease lifetime, ignoring"); return -ENOMSG; } @@ -1320,11 +1326,17 @@ static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack, size_t le lease->address = ack->yiaddr; + /* + * The RFC requires this "option", but most clients are more lenient + */ + if (lease->server_address == 0) { + log_dhcp_client(client, "Missing server identifier option, non-conforming DHCP"); + } + if (lease->address == INADDR_ANY || - lease->server_address == INADDR_ANY || lease->lifetime == 0) { - log_dhcp_client(client, "received lease lacks address, server " - "address or lease lifetime, ignoring"); + log_dhcp_client(client, "received lease lacks address, " + "or lease lifetime, ignoring"); return -ENOMSG; }