diff options
author | Alexandre Peixoto Ferreira <alexandref75@gmail.com> | 2023-09-25 04:46:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-25 04:46:41 +0200 |
commit | 13abd00685664ada99159adcfe0c4af9c889e96f (patch) | |
tree | 14dfc2c40ac7317dafd4952cfde45c2d2800cbf9 | |
parent | hwdb: ieee1394-unit-function: add Miglia Technology Harmony Audio (HA02) (diff) | |
download | systemd-13abd00685664ada99159adcfe0c4af9c889e96f.tar.xz systemd-13abd00685664ada99159adcfe0c4af9c889e96f.zip |
sd-dhcp-client: reject NAKs from servers that we did not send an offer to (#29290)
To support multiple DHCP servers in a network.
-rw-r--r-- | src/libsystemd-network/sd-dhcp-client.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index cfdee5d6b4..79f308f652 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -1591,9 +1591,14 @@ static int client_parse_message( case DHCP_STATE_REQUESTING: case DHCP_STATE_RENEWING: case DHCP_STATE_REBINDING: - if (r == DHCP_NAK) + if (r == DHCP_NAK) { + if (client->lease && client->lease->server_address != lease->server_address) + return log_dhcp_client_errno(client, SYNTHETIC_ERRNO(ENOMSG), + "NAK from unexpected server, ignoring: %s", + strna(error_message)); return log_dhcp_client_errno(client, SYNTHETIC_ERRNO(EADDRNOTAVAIL), "NAK: %s", strna(error_message)); + } if (r != DHCP_ACK) return log_dhcp_client_errno(client, SYNTHETIC_ERRNO(ENOMSG), "received message was not an ACK, ignoring."); |