From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id EF5B65A026D for ; Thu, 3 Aug 2023 04:33:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1691030006; bh=Yby87aSqnWDnYlaW7njlPVjAG8bZMcGs45BDZi5MIAA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TiEqEb2uIcBAv5nqgBwK4j6zs8wK5TZsu+TEpxUrzJLgvS9SkUfK7Kxj5IulgpQj4 bE14+7qkHh/ZxNpYhQmQAb0duEYhrW5sxlY2/n+OTJ0yz+F0mQ6EDvQElNN31URLix Qw0EKJsabJCwhuQFfe6gwH3NA58ToZ3A5t4VzLe0= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RGXvp3Hysz4wb8; Thu, 3 Aug 2023 12:33:26 +1000 (AEST) Date: Thu, 3 Aug 2023 12:28:39 +1000 From: David Gibson To: Paul Holzinger Subject: Re: [PATCH] tap: include errno in error when tap_ns_tun() fails Message-ID: References: <20230801115016.37118-2-pholzing@redhat.com> <7ddb3b35-58fe-a376-f839-d9fc6de9ffc5@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="RX0DXBc6X8sju8nl" Content-Disposition: inline In-Reply-To: <7ddb3b35-58fe-a376-f839-d9fc6de9ffc5@redhat.com> Message-ID-Hash: 5R3Q52COPXUY5ENEWDD6KOKJXXHCI63Q X-Message-ID-Hash: 5R3Q52COPXUY5ENEWDD6KOKJXXHCI63Q 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: passt-dev@passt.top 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: --RX0DXBc6X8sju8nl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 02, 2023 at 11:51:02AM +0200, Paul Holzinger wrote: >=20 > On 02/08/2023 03:39, David Gibson wrote: > > On Tue, Aug 01, 2023 at 01:50:17PM +0200, Paul Holzinger wrote: > > > 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 kn= ow > > > which of functions (open, ioctl, if_nametoindex) failed but it should= at > > > least include more important context. > > Uh.. we certainly want this, but I don't think this implementation > > will quite do it. > >=20 > > > This change was inspiered by a podman issue[1]. > > >=20 > > > [1] https://github.com/containers/podman/issues/19428 > > >=20 > > > Signed-off-by: Paul Holzinger > > > --- > > > tap.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > >=20 > > > 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); > > NS_CALL means we're running the function in an ephemeral > > thread/process/thingy.. > >=20 > > > if (tun_ns_fd =3D=3D -1) > > > - die("Failed to open tun socket in namespace"); > > > + die("Failed to open tun socket in namespace: %s", > > > + strerror(errno)); > > ..which means we can't rely on it actually setting errno in the > > original process. The ephemeral thread does share memory, but modern > > errno is a weird per-thread thingy, so I'm not entirely sure what will > > happen here, but I'm certainly not confident about it working as we'd > > like. > >=20 > > I'll have a crack at a more robust approach today. >=20 > Thanks, I only did a quick test with chmod 600 /dev/net/tun and got the > expected EACCES so I assumed it worked fine Huh, interesting, maybe it does work. Unless some earlier syscall happened to set errno to EACCES. > but anyway your series looks > much better. Yeah, I realized as I was working on it that that approach has the additional advantage of clearly showing which operation failed. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --RX0DXBc6X8sju8nl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmTLENAACgkQzQJF27ox 2GesSw//S1iLFJbKaDMoGn6wxFtIsqJVHdhfYzuMBuhZrRvLwdQK1mIBjF2hpbuA sSk7FZ+8Q0AIflHGKN+yND06uRHKotiyheinBgemdSIJ+1mAkqrrtM/4EJBDj/J6 m0P+HrXfYW/kJDXb5eor1qVDqRg1C8A8ouhBB+fRijun8oT/FOrKk3c0An596eDs SZLZlDN/7n3Ni19YbzUUb9/ezrPsrjKNlO3blxpiiEadeYJbJ9dc1KMiq2w7iqLO PjdvVlTOR6mRqyDTBgPKLAJDDfrtYSaQakRf0U54+pUSippsLGhX+zzoUOkAkU3X dumPOuwRYn6XoFapYBnW3butzJIZ9q1mHSyVtt2fHRzS6P2cvFkVWmFWxonvk0eE HaGW3DkGOIHaO253Jht140MOk4/Ac5Mg8Z9ky8KDZQE8juUXPmZD7GLKVpepCYBr 2quHH/+XXotycu69FWKkkfjizkCIIqwFkvn79Yf44wmbj85xOUd8NT3dfmHgBXbe 8vD4matTBX4MhonDeo//qCvhv/ZJL5PTkvqVXlDiAlNpbDDEg2zL4W8JiArc+CfZ GBt3j+7IlEwC8wJk2Jg1LhTX681gVvO/pTYJX8WAXoeFMOxoUN9ISHBAqhUsXQv6 RcEAx2OxyXfZlEStUxXlhcqRKGA4McNQ+eNrnv2BR2xFNb4a1GE= =dtgs -----END PGP SIGNATURE----- --RX0DXBc6X8sju8nl--