public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top, Paul Holzinger <pholzing@redhat.com>
Subject: Re: [PATCH] pasta: Add fallback timer mechanism to check if namespace is gone
Date: Fri, 16 Feb 2024 06:08:40 +0100	[thread overview]
Message-ID: <20240216060840.6c03c331@elisabeth> (raw)
In-Reply-To: <Zc7P2Uz29zaslzz_@zatzit>

On Fri, 16 Feb 2024 14:00:41 +1100
David Gibson <david@gibson.dropbear.id.au> 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 <pholzing@redhat.com>
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> > ---
> >  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


      reply	other threads:[~2024-02-16  5:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 22:39 [PATCH] pasta: Add fallback timer mechanism to check if namespace is gone Stefano Brivio
2024-02-16  3:00 ` David Gibson
2024-02-16  5:08   ` Stefano Brivio [this message]

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=20240216060840.6c03c331@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=pholzing@redhat.com \
    /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).