Skip to content

Commit 5dbe573

Browse files
authored
[posix] DHCPv6-PD client handling of sendto() failure (openthread#13100)
If the PD client sendto() fails, e.g. because of an unroutable IPv6 destination, currently the message remains in the queue. Then the subsequent retries cause a 100% CPU use (without end). This fixes the issue by dropping the message in case of an unresolvable sendto() failure.
1 parent 64c4124 commit 5dbe573

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/posix/platform/dhcp6_pd_socket.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,21 @@ void Dhcp6PdSocket::SendQueuedMessages(void)
255255
CopyIp6AddressTo(metadata.mAddress, &addr6.sin6_addr);
256256

257257
bytesSent = sendto(mFd6, buffer, length, 0, reinterpret_cast<struct sockaddr *>(&addr6), sizeof(addr6));
258-
VerifyOrExit(bytesSent == length);
258+
259+
if (bytesSent != static_cast<int>(length))
260+
{
261+
if (errno == EAGAIN || errno == EWOULDBLOCK)
262+
{
263+
// Socket send buffer full - retry when writable
264+
ExitNow();
265+
}
266+
267+
// Fatal send error - drop message; OT core retransmit timer will re-send after backoff
268+
LogWarn("sendto() failed errno:%s - dropping message", strerror(errno));
269+
otMessageQueueDequeue(&mTxQueue, message);
270+
otMessageFree(message);
271+
continue;
272+
}
259273

260274
otMessageQueueDequeue(&mTxQueue, message);
261275
otMessageFree(message);

0 commit comments

Comments
 (0)