From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=Io4dOQfH; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 092FE5A0623 for ; Wed, 13 May 2026 06:14:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1778645665; bh=89IGnveo05p4EnBKv7H4fKvXCCJ/cf4AqHBys4mPByE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Io4dOQfHv6sajx2yH1duQghvCL+hD4SCmx/rPwrGoUlCuMins+rIPrhtS6njpJ9Rj Zl8OSK2rKYG7wyAEbkvjY48srCmScxy3Krp2l1op1k1NZm4e5k9buFSyctVPFb2eM1 wZjruLV9SW1W6LIz0R0W/YNSohmYe5Qw1qkgmW0/ca5eUBflJMv6jbkvyJCLVXI6WS jV6F+BtUtYjVJrhJTsvBUZk/IZfiO1V5z0us5jwnz2++GPvENck3CKvW+toIEv41LR HtjzscOL0bx4HIrOgwIPCDgtp6AwP9m02V6yKprQQ/lYILmtqEzXKOVMgGN20tws3N DjfXKPLpx1NxQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gFg8K0WL8z4wG9; Wed, 13 May 2026 14:14:25 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 3/3] conf, repair, tap: More caution about blocking flag on Unix sockets Date: Wed, 13 May 2026 14:14:23 +1000 Message-ID: <20260513041423.2446716-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260513041423.2446716-1-david@gibson.dropbear.id.au> References: <20260513041423.2446716-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 565TXJ4GQRZ7UDAULANFD7AQ432DHFMW X-Message-ID-Hash: 565TXJ4GQRZ7UDAULANFD7AQ432DHFMW X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Most of our operation is asynchronous, based on non-blocking fds handled in our epoll loop. However, our several Unix sockets (tap client, repair helper, control client) are all blocking fds after accept(). That's correct for the repair helper, and (for now) correct for the control client. However, the reasons for that might not be obvious, so add some extra comments giving the rationale. I don't believe it's correct for the tap client; having this socket be blocking means we could potentially block the main loop if we ever got a a spurious EPOLL{IN,OUT} event on the tap socket. Switch the tap socket to non-blocking for better robustness, and consistency with nearly every other fd we track. Signed-off-by: David Gibson --- conf.c | 6 ++++++ repair.c | 4 ++++ tap.c | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index dec43fca..dc85f0f8 100644 --- a/conf.c +++ b/conf.c @@ -2082,6 +2082,12 @@ static void conf_accept(struct ctx *c) int fd, rc; retry: + /* Currently we perform the configuration transaction more-or-less + * synchronously, so we want the accepted socket to be blocking. + * + * FIXME: We should make the configuration update asynchronous, like + * most of our operation, so a misbehaving configuration client can't + * block the main forwarding loop */ fd = accept4(c->fd_control_listen, NULL, NULL, SOCK_CLOEXEC); if (fd < 0) { if (errno != EAGAIN) diff --git a/repair.c b/repair.c index 42c4ae97..8a2d119d 100644 --- a/repair.c +++ b/repair.c @@ -99,6 +99,10 @@ int repair_listen_handler(struct ctx *c, uint32_t events) return EEXIST; } + /* We want accepted socket to be blocking; we use it during migration + * which is a synchronous interruption to our normal non-blocking + * behaviour. + */ if ((c->fd_repair = accept4(c->fd_repair_listen, NULL, NULL, SOCK_CLOEXEC)) < 0) { if ((rc = errno) != EAGAIN) diff --git a/tap.c b/tap.c index fda2da9b..3b8a3f3d 100644 --- a/tap.c +++ b/tap.c @@ -1490,7 +1490,8 @@ void tap_listen_handler(struct ctx *c, uint32_t events) return; } - c->fd_tap = accept4(c->fd_tap_listen, NULL, NULL, SOCK_CLOEXEC); + c->fd_tap = accept4(c->fd_tap_listen, NULL, NULL, + SOCK_NONBLOCK | SOCK_CLOEXEC); if (c->fd_tap < 0) { if (errno != EAGAIN) warn_perror("Error accepting tap client"); -- 2.54.0