public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Paul Holzinger <pholzing@redhat.com>
To: passt-dev@passt.top
Cc: Paul Holzinger <pholzing@redhat.com>
Subject: [PATCH] tap: include errno in error when tap_ns_tun() fails
Date: Tue,  1 Aug 2023 13:50:17 +0200	[thread overview]
Message-ID: <20230801115016.37118-2-pholzing@redhat.com> (raw)

It is important to know why a syscall failed so pasta should include the
errno in the error message. This is still not perfect as we do not know
which of functions (open, ioctl, if_nametoindex) failed but it should at
least include more important context.

This change was inspiered by a podman issue[1].

[1] https://github.com/containers/podman/issues/19428

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

diff --git a/tap.c b/tap.c
index a6a73d3..c212616 100644
--- a/tap.c
+++ b/tap.c
@@ -1205,7 +1205,8 @@ static void tap_sock_tun_init(struct ctx *c)
 
 	NS_CALL(tap_ns_tun, c);
 	if (tun_ns_fd == -1)
-		die("Failed to open tun socket in namespace");
+		die("Failed to open tun socket in namespace: %s",
+		    strerror(errno));
 
 	pasta_ns_conf(c);
 
-- 
@@ -1205,7 +1205,8 @@ static void tap_sock_tun_init(struct ctx *c)
 
 	NS_CALL(tap_ns_tun, c);
 	if (tun_ns_fd == -1)
-		die("Failed to open tun socket in namespace");
+		die("Failed to open tun socket in namespace: %s",
+		    strerror(errno));
 
 	pasta_ns_conf(c);
 
-- 
2.41.0


             reply	other threads:[~2023-08-01 11:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 11:50 Paul Holzinger [this message]
2023-08-02  1:39 ` [PATCH] tap: include errno in error when tap_ns_tun() fails David Gibson
2023-08-02  9:51   ` Paul Holzinger
2023-08-03  2:28     ` David Gibson

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=20230801115016.37118-2-pholzing@redhat.com \
    --to=pholzing@redhat.com \
    --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).