libsystemd-dhcp: Fix receiving of other message when expecting Ack
When a DHCP Nak is received, return a DHCP_EVENT_NO_LEASE event. If some other DHCP message is received or an error happens when parsing options, return -ENOMSG in order to ignore the packet. There may be more than one server serving the same subnet, each server will send its Offer to the client.
This commit is contained in:
committed by
Tom Gundersen
parent
2ed0375c2d
commit
77e8d29dd2
@@ -731,8 +731,15 @@ static int client_receive_ack(sd_dhcp_client *client, DHCPPacket *offer,
|
||||
len = len - DHCP_IP_UDP_SIZE;
|
||||
r = dhcp_option_parse(&offer->dhcp, len, client_parse_offer, lease);
|
||||
|
||||
if (r != DHCP_ACK)
|
||||
if (r == DHCP_NAK) {
|
||||
r = DHCP_EVENT_NO_LEASE;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (r != DHCP_ACK) {
|
||||
r = -ENOMSG;
|
||||
goto error;
|
||||
}
|
||||
|
||||
lease->address = offer->dhcp.yiaddr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user