From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 13AFE5A026D for ; Wed, 2 Aug 2023 11:51:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690969867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M8tBDORL5j0C53nWMb6ORvmxsWjW34U9keMfB8cfawk=; b=LdMJnTXjQ/KvyLGj6XDXMLokSXj/w8wfXLlO2euApfW1bSIMzN1XJ9aABIrJcTpDkvdcih E7tDFmtdgws1KZiR96nyK9tbP93x8S8Z4oGv0L+d4LYfDOs3lnSfyRwsAwjMI9QRngkHeh 5+QZsNXNl4E63+LrhUQC1DjawJRQPM8= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-100-x_YI8zYyOWmnjO0ms8jJ-w-1; Wed, 02 Aug 2023 05:51:05 -0400 X-MC-Unique: x_YI8zYyOWmnjO0ms8jJ-w-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5219ceead33so4719270a12.2 for ; Wed, 02 Aug 2023 02:51:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690969864; x=1691574664; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=M8tBDORL5j0C53nWMb6ORvmxsWjW34U9keMfB8cfawk=; b=TcSsWX/YEd+Rs9e9oMK4bF2uIJP5eLlJq/XaV8lH1ddfM1S2mcOBom+lZZsCAyAx1/ s8OmDRMCGFeYqmqCzby4FWbOG0CeMbxyWr1LkHGz2LqD/98ccF+DbGNY/Mr/47ZUcd8O DFg5mvtbz9RXcQdezlD+INQSoCWYD2Ku4GhWolDjkc5i7/K2srbSyXYcBh1u2SjllIvq 4ztuTAvquBnEzv8vtnDKjrLcuFGqsvyQjw+q5ty2YPIxS4KJCxST4xR4u6V620cckg3S zBBqTTS03PjLQxmvhbxiAm4jXuc46kIkwoK5SYWsyACJoSV2SLbHEX1/eYHRzj769xtt DUow== X-Gm-Message-State: ABy/qLatR3DkY/R4f+JaHI3Tf9OhQWw4KGfBJUFa8oCUL3VRhXjTx0G/ 8jN89gU8Ea7qD69kCNKq3OuishCXOz/CGLbcdsr+5YLoHyZA105NHv5XNvbyIA8BBIPNy8mno+B AOo7dQYYmkBxlSCIrv6nU X-Received: by 2002:aa7:d511:0:b0:522:3849:48d8 with SMTP id y17-20020aa7d511000000b00522384948d8mr4555325edq.9.1690969864559; Wed, 02 Aug 2023 02:51:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlEsU5iJC6vk0/u7goMLOcZNqrgVrLGBLAUFIkInwSvtKDqwVmyKMFFsAuUlDd43AOgtKPLEEg== X-Received: by 2002:aa7:d511:0:b0:522:3849:48d8 with SMTP id y17-20020aa7d511000000b00522384948d8mr4555310edq.9.1690969864136; Wed, 02 Aug 2023 02:51:04 -0700 (PDT) Received: from [192.168.188.25] ([80.243.52.134]) by smtp.gmail.com with ESMTPSA id e12-20020a50ec8c000000b0051e0eba608bsm8107017edr.19.2023.08.02.02.51.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Aug 2023 02:51:03 -0700 (PDT) Message-ID: <7ddb3b35-58fe-a376-f839-d9fc6de9ffc5@redhat.com> Date: Wed, 2 Aug 2023 11:51:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] tap: include errno in error when tap_ns_tun() fails To: David Gibson References: <20230801115016.37118-2-pholzing@redhat.com> From: Paul Holzinger In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: 4J5N6XDA7S3YUCNPFHTIOCEIKEV5STJM X-Message-ID-Hash: 4J5N6XDA7S3YUCNPFHTIOCEIKEV5STJM X-MailFrom: pholzing@redhat.com 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: 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 know >> 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. > >> This change was inspiered by a podman issue[1]. >> >> [1] https://github.com/containers/podman/issues/19428 >> >> Signed-off-by: Paul Holzinger >> --- >> 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); > NS_CALL means we're running the function in an ephemeral > thread/process/thingy.. > >> if (tun_ns_fd == -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. > > I'll have a crack at a more robust approach today. Thanks, I only did a quick test with chmod 600 /dev/net/tun and got the expected EACCES so I assumed it worked fine but anyway your series looks much better. > > >> >> pasta_ns_conf(c); >>