public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 2/5] tap: Support for detection of existing sockets on ramfs
Date: Mon, 31 Oct 2022 10:58:55 +0100	[thread overview]
Message-ID: <20221031095858.117012-3-sbrivio@redhat.com> (raw)
In-Reply-To: <20221031095858.117012-1-sbrivio@redhat.com>

On ramfs, connecting to a non-existent UNIX domain socket yields
EACCESS, instead of ENOENT. This is visible if we use passt directly
on rootfs (a ramfs instance) from an initramfs image.

It's probably wrong for ramfs to return EACCES, but given the
simplicity of the filesystem, I doubt we should try to fix it there
at the possible cost of added complexity.

Also, this whole beauty should go away once qrap-less usage is
established, so just accept EACCES as indication that a conflicting
socket does not, in fact, exist.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 tap.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tap.c b/tap.c
index 4dcff4f..0a3ccce 100644
--- a/tap.c
+++ b/tap.c
@@ -912,7 +912,8 @@ static void tap_sock_unix_init(struct ctx *c)
 		}
 
 		ret = connect(ex, (const struct sockaddr *)&addr, sizeof(addr));
-		if (!ret || (errno != ENOENT && errno != ECONNREFUSED)) {
+		if (!ret || (errno != ENOENT && errno != ECONNREFUSED &&
+			     errno != EACCES)) {
 			if (*c->sock_path) {
 				err("Socket path %s already in use", path);
 				exit(EXIT_FAILURE);
-- 
@@ -912,7 +912,8 @@ static void tap_sock_unix_init(struct ctx *c)
 		}
 
 		ret = connect(ex, (const struct sockaddr *)&addr, sizeof(addr));
-		if (!ret || (errno != ENOENT && errno != ECONNREFUSED)) {
+		if (!ret || (errno != ENOENT && errno != ECONNREFUSED &&
+			     errno != EACCES)) {
 			if (*c->sock_path) {
 				err("Socket path %s already in use", path);
 				exit(EXIT_FAILURE);
-- 
2.35.1


  parent reply	other threads:[~2022-10-31  9:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31  9:58 [PATCH 0/5] Test cases to display memory usage in kernel and userspace Stefano Brivio
2022-10-31  9:58 ` [PATCH 1/5] test/lib: Move screen-scraping setup and layout functions to _ugly files Stefano Brivio
2022-10-31  9:58 ` Stefano Brivio [this message]
2022-10-31  9:58 ` [PATCH 3/5] test/lib/perf_report: Use own flag to track initialisation Stefano Brivio
2022-10-31  9:58 ` [PATCH 4/5] test/lib: Add "td" directive, handled by table_value() Stefano Brivio
2022-10-31  9:58 ` [PATCH 5/5] test: Add memory/passt test cases Stefano Brivio
2022-10-31 11:10   ` Stefano Brivio

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=20221031095858.117012-3-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).