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 0EC615A027E for ; Fri, 16 Feb 2024 06:09:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708060159; 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=YoHInITg/yfDBbrjqAh/CsBFZZmgxOO6CXNAfdW1VxQ=; b=dnIZEIukrWmjiWUIEOtP5PvABpeJAn26fXROg5Isee7ekon9AZLGX9Jkxka3z5LiEVKaPH VOD/AuV370r31Sj2QUSkrYN7Tr4y8UYV+NMx+23AWcA5x17kb7SpntuFfQY/AF5SF3XQsX /JY7kQ7P64q/636tNxP9Lj2WITWej4o= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-504-1Az2N1_rOnOTDYM9FEHScg-1; Fri, 16 Feb 2024 00:09:17 -0500 X-MC-Unique: 1Az2N1_rOnOTDYM9FEHScg-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-51288102312so1384559e87.3 for ; Thu, 15 Feb 2024 21:09:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708060156; x=1708664956; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=YoHInITg/yfDBbrjqAh/CsBFZZmgxOO6CXNAfdW1VxQ=; b=PXRUqHTLgpL9JIVyQmO3dx0iSWTvTegIFJA2W6Z2czAsK2G0UCeglVbXYVqOMyARCF 8NALkcarYO+UKfr69WJIU1yMcoyv0Z8cYdOV/oOZETlICRCNqrlyECse6xj1h+sYGQh0 RAjXvsow9u4cZs8wdceH0h6AAJdiqfdOaf3lmZ6HOj+H2BSo0omL2Ef90zR9xatZS+yV rhWAwXVH1PAS6FjxoD3zh3ZRwKAh0Uy0nJO4chqjPmFZahPyeOnkyX/ZTAdBOV8chOce Fx5xvwLAysQDqnnjVNWYAbATMTChkrl+T05hF7XUOzWZoMYWI8Dtq6snRA9MFp3eT+Os edJA== X-Gm-Message-State: AOJu0YzybBldTFai/9CJOn+QSaHLILKZB8EFiTPsH9Qv2iaR4V+1M3Cy XIZMhS0FarfzeBCj3SJgxwPRLkfj5eu4cQ4BF18Zzt/zJd8KX9hoPi/aR19HUiYhni1EVXJPDBc N+CoBzwPYsb4nSfoKiMXIP4ypopd9uVNyW+CKKb3RcqCFflg+ZQ== X-Received: by 2002:a19:e041:0:b0:511:7c27:9655 with SMTP id g1-20020a19e041000000b005117c279655mr2402353lfj.23.1708060155860; Thu, 15 Feb 2024 21:09:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFO9U5UlMpD1o9S7l5MOLbFbYS6+I0u8Fd0B872ORbnB4EF/cLaJS7lseEBMZUESsEoU5EMNg== X-Received: by 2002:a19:e041:0:b0:511:7c27:9655 with SMTP id g1-20020a19e041000000b005117c279655mr2402341lfj.23.1708060155440; Thu, 15 Feb 2024 21:09:15 -0800 (PST) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id vg12-20020a170907d30c00b00a3d6a2d3904sm1200942ejc.146.2024.02.15.21.09.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Feb 2024 21:09:14 -0800 (PST) Date: Fri, 16 Feb 2024 06:08:40 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] pasta: Add fallback timer mechanism to check if namespace is gone Message-ID: <20240216060840.6c03c331@elisabeth> In-Reply-To: References: <20240215223911.486945-1-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 5KGFK75Z4N7T5CYJOOAFBC4RDZ6VLUHR X-Message-ID-Hash: 5KGFK75Z4N7T5CYJOOAFBC4RDZ6VLUHR 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: passt-dev@passt.top, Paul Holzinger 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 Fri, 16 Feb 2024 14:00:41 +1100 David Gibson wrote: > On Thu, Feb 15, 2024 at 11:39:11PM +0100, Stefano Brivio wrote: > > We don't know how frequently this happens, but hitting > > fs.inotify.max_user_watches or similar sysctl limits is definitely > > not out of question, and Paul mentioned that, for example, Podman's > > CI environments hit similar issues in the past. > > > > Introduce a fallback mechanism based on a timer file descriptor: we > > grab the directory handle at startup, and we can then use openat(), > > triggered periodically, to check if the (network) namespace directory > > still exists. If openat() fails at some point, exit. > > > > Link: https://github.com/containers/podman/pull/21563#issuecomment-1943505707 > > Reported-by: Paul Holzinger > > Signed-off-by: Stefano Brivio > > --- > > passt.c | 6 ++-- > > passt.h | 2 ++ > > pasta.c | 85 +++++++++++++++++++++++++++++++++++++++++++++------------ > > pasta.h | 2 +- > > 4 files changed, 73 insertions(+), 22 deletions(-) > > > > diff --git a/passt.c b/passt.c > > index aaa8e58..13670b9 100644 > > --- a/passt.c > > +++ b/passt.c > > @@ -201,7 +201,7 @@ void exit_handler(int signal) > > */ > > int main(int argc, char **argv) > > { > > - int nfds, i, devnull_fd = -1, pidfile_fd = -1, quit_fd; > > + int nfds, i, devnull_fd = -1, pidfile_fd = -1; > > struct epoll_event events[EPOLL_EVENTS]; > > char *log_name, argv0[PATH_MAX], *name; > > struct ctx c = { 0 }; > > @@ -274,7 +274,7 @@ int main(int argc, char **argv) > > if (c.force_stderr || isatty(fileno(stdout))) > > __openlog(log_name, LOG_PERROR, LOG_DAEMON); > > > > - quit_fd = pasta_netns_quit_init(&c); > > + pasta_netns_quit_init(&c); > > > > tap_sock_init(&c); > > > > @@ -371,7 +371,7 @@ loop: > > tap_listen_handler(&c, eventmask); > > break; > > case EPOLL_TYPE_NSQUIT: > > - pasta_netns_quit_handler(&c, quit_fd); > > + pasta_netns_quit_handler(&c, ref); > > Hm. As a rule, I've been trying to use a separate EPOLL_TYPE for each > different handler, rather than having secondary dispatch based on > other details, even if those different handlers are accomplishing > similar purposes (e.g. TAP_PASTA vs. TAP_PASST). Yes, I have to admit that the (ref.nsdir_fd != -1) if clause in the handler is a bit of a hack, and a rather gratuitous one. Changed in v2 to use a new epoll reference type. -- Stefano