From: Patrik Flykt Date: Fri, 20 Dec 2013 15:16:14 +0000 (+0200) Subject: libsystemd-dhcp: Fix receiving of other message when expecting Ack X-Git-Tag: v209~728 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=77e8d29dd2ecfa7f11c31c8d96021d323ab3fe3a 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. --- diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.c index 18a6e3c50..7dc154612 100644 --- a/src/libsystemd-dhcp/dhcp-client.c +++ b/src/libsystemd-dhcp/dhcp-client.c @@ -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;