]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dhcp-server-request: logs more when received invalid messages
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 10 May 2026 15:25:02 +0000 (00:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 22 May 2026 06:57:06 +0000 (15:57 +0900)
src/libsystemd-network/dhcp-server-request.c

index a914f3ef1d6d306635425f01b0b8ccc2e20f3038..6b6b85bae6028ebb10ac6e17895566283136ddbe 100644 (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);