Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
networkd: dhcp client should be more lenient
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Timothy J Fontaine authored and dm0- committed Mar 7, 2018
1 parent 9840132 commit 4cd49cc
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/libsystemd-network/sd-dhcp-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 4cd49cc

Please sign in to comment.