diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2013-12-20 17:16:14 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2013-12-22 14:28:00 +0100 |
commit | 77e8d29dd2ecfa7f11c31c8d96021d323ab3fe3a (patch) | |
tree | 9e959ade9e1b5078b775b5b389e2d2e2a551dec0 | |
parent | 2ed0375c2db786012842f02b84014a70c4806017 (diff) |
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.
-rw-r--r-- | src/libsystemd-dhcp/dhcp-client.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libsystemd-dhcp/dhcp-client.c b/src/libsystemd-dhcp/dhcp-client.c index 18a6e3c50d..7dc1546128 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; |