DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Randy Tice <rtice@cisco.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH] eal/linux: harden uevent recv error handling
Date: Thu, 13 Aug 2026 15:57:04 -0700	[thread overview]
Message-ID: <20260813155704.1af0c707@phoenix.local> (raw)
In-Reply-To: <20260813201656.65649-1-rtice@cisco.com>

On Thu, 13 Aug 2026 16:16:56 -0400
Randy Tice <rtice@cisco.com> wrote:

> The Linux uevent handler is harded for non-blocking receive behavior
> 
> Signed-off-by: Randy Tice <rtice@cisco.com>
> ---

Good idea, but the code needs to unregister the uevent fd on error.
Also, fix spelling error, decode error message, and handle odd
case where recv() got interrupted.

Something like (untested):

diff --git a/lib/eal/linux/eal_dev.c b/lib/eal/linux/eal_dev.c
index ec408649d0..1985d5e122 100644
--- a/lib/eal/linux/eal_dev.c
+++ b/lib/eal/linux/eal_dev.c
@@ -241,11 +241,17 @@ dev_uev_handler(__rte_unused void *param)
 
 	ret = recv(rte_intr_fd_get(intr_handle), buf, EAL_UEV_MSG_LEN,
 		   MSG_DONTWAIT);
-	if (ret < 0 && errno == EAGAIN)
-		return;
-	else if (ret <= 0) {
-		/* connection is closed or broken, can not up again. */
-		EAL_LOG(ERR, "uevent socket connection is broken.");
+	if (ret <= 0) {
+		if (ret < 0) {
+			/* non blocking or interrupted */
+			if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
+				return;
+			EAL_ERR(ERR, "unexpected error on uevent: %s",
+				strerror(errno));
+		} else {
+			/* zero length recv is end of file */
+			EAL_LOG(ERR, "uevent socket connection is broken.");
+		}
 		rte_eal_alarm_set(1, dev_delayed_unregister, NULL);
 		return;
 	}

      reply	other threads:[~2026-08-13 22:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 20:16 [PATCH] eal/linux: harden uevent recv error handling Randy Tice
2026-08-13 22:57 ` Stephen Hemminger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260813155704.1af0c707@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=rtice@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox