dhcp-server-request: logs more when received invalid messages

This commit is contained in:
Yu Watanabe
2026-05-22 15:57:06 +09:00
parent c73478d49f
commit 94b39d22dd
+3 -4
View File
@@ -252,7 +252,7 @@ static int dhcp_server_process_discover(sd_dhcp_server *server, DHCPRequest *req
sd_dhcp_server_lease *l = hashmap_get(server->bound_leases_by_address, UINT32_TO_PTR(static_lease->address));
if (l && l != existing_lease)
/* The address is already assigned to another host. Refusing. */
return 0;
return -EADDRINUSE;
/* Found a matching static lease. */
req->static_lease = static_lease;
@@ -286,8 +286,7 @@ static int dhcp_server_process_discover(sd_dhcp_server *server, DHCPRequest *req
}
if (req->address == INADDR_ANY)
/* no free addresses left */
return 0;
return -EADDRNOTAVAIL; /* no free addresses left */
if (server->rapid_commit &&
dhcp_message_get_option_flag(req->message, SD_DHCP_OPTION_RAPID_COMMIT) >= 0)
@@ -319,7 +318,7 @@ static int dhcp_server_process_request(sd_dhcp_server *server, DHCPRequest *req)
return 0; /* The message is not for us. Let's silently ignore the packet. */
if (req->message->header.ciaddr != INADDR_ANY) /* this MUST be zero */
return 0;
return -EBADMSG;
/* this must be filled in with the yiaddr from the chosen OFFER */
r = dhcp_message_get_option_be32(req->message, SD_DHCP_OPTION_REQUESTED_IP_ADDRESS, &address);