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.129.124]) by passt.top (Postfix) with ESMTP id 5D8485A028F for ; Tue, 23 May 2023 15:47:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684849648; 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=p9ZMaE27Wi6e88vDXpTfyrqlKvJwWJ8Gu988v6eUiQ8=; b=AWPD5S+MsAJ71s4eIEQcK/5Y/nC03FKC7zSauim0H+OsWCkXUzxVjKA0GMFvqWRYmXtKRe vOW9UX99bVx86ywiT66ukouz8PsJITYui01ZJMOkIH/7nLPOo1P1+I3a7kMzdebsN2M+23 dIt4nUgNi8pUD4bH4khnYOpPEIQic7o= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-395-UIoq3ANTNdChuOeVTwiZUg-1; Tue, 23 May 2023 09:47:24 -0400 X-MC-Unique: UIoq3ANTNdChuOeVTwiZUg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E32EE1C07559; Tue, 23 May 2023 13:47:23 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53C8A2166B25; Tue, 23 May 2023 13:47:21 +0000 (UTC) Date: Tue, 23 May 2023 15:47:15 +0200 From: Stefano Brivio To: passt-dev@passt.top Subject: Re: [PATCH v3 02/10] pasta: Improve error handling on failure to join network namespace Message-ID: <20230523154715.6432bdbb@elisabeth> In-Reply-To: <20230522174607.2824220-3-sbrivio@redhat.com> References: <20230522174607.2824220-1-sbrivio@redhat.com> <20230522174607.2824220-3-sbrivio@redhat.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: KG4IN5RIHRGYCBRZJ6TPNIIQS4DC4WYA X-Message-ID-Hash: KG4IN5RIHRGYCBRZJ6TPNIIQS4DC4WYA X-MailFrom: sbrivio@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: Callum Parsey , me@yawnt.com, David Gibson , lemmi@nerd2nerd.org, Andrea Arcangeli 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 Mon, 22 May 2023 19:45:59 +0200 Stefano Brivio wrote: > In pasta_wait_for_ns(), open() failing with ENOENT is expected: we're > busy-looping until the network namespace appears. But any other > failure is not something we're going to recover from: return right > away if we don't get either success or ENOENT. > > Now that pasta_wait_for_ns() can actually fail, handle that in > pasta_start_ns() by reporting the issue and exiting. > > Looping on EPERM, when pasta doesn't actually have the permissions to > join a given namespace, isn't exactly a productive thing to do. > > Signed-off-by: Stefano Brivio > Reviewed-by: David Gibson > --- > pasta.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/pasta.c b/pasta.c > index b30ce70..2a6fb60 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -95,8 +95,11 @@ static int pasta_wait_for_ns(void *arg) > char ns[PATH_MAX]; > > snprintf(ns, PATH_MAX, "/proc/%i/ns/net", pasta_child_pid); > - do > - while ((c->pasta_netns_fd = open(ns, flags)) < 0); > + while ((c->pasta_netns_fd = open(ns, flags)) < 0) { > + if (errno != ENOENT) > + return 0; > + } > + > while (setns(c->pasta_netns_fd, CLONE_NEWNET) && > !close(c->pasta_netns_fd)); Oops, what did I do here... :( On a failed setns(), we need (in most cases) to close and reopen the file. The fix and intention are quite obvious so I'm just fixing this up now as I'm applying it. -- Stefano