aboutgitcodebugslistschat
path: root/passt.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-02-18 16:12:11 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-02-21 13:41:13 +0100
commit745a9ba4284cbe055aac3fadb57efe531c4e3a96 (patch)
tree6283140095f6652d119fbf619890269b3d1d869d /passt.c
parent6c931118643c8fa35935ddbd920cb669dec10021 (diff)
downloadpasst-745a9ba4284cbe055aac3fadb57efe531c4e3a96.tar
passt-745a9ba4284cbe055aac3fadb57efe531c4e3a96.tar.gz
passt-745a9ba4284cbe055aac3fadb57efe531c4e3a96.tar.bz2
passt-745a9ba4284cbe055aac3fadb57efe531c4e3a96.tar.lz
passt-745a9ba4284cbe055aac3fadb57efe531c4e3a96.tar.xz
passt-745a9ba4284cbe055aac3fadb57efe531c4e3a96.tar.zst
passt-745a9ba4284cbe055aac3fadb57efe531c4e3a96.zip
pasta: By default, quit if filesystem-bound net namespace goes away
This should be convenient for users managing filesystem-bound network namespaces: monitor the base directory of the namespace and exit if the namespace given as PATH or NAME target is deleted. We can't add an inotify watch directly on the namespace directory, that won't work with nsfs. Add an option to disable this behaviour, --no-netns-quit. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'passt.c')
-rw-r--r--passt.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/passt.c b/passt.c
index 67ad1c7..36f0161 100644
--- a/passt.c
+++ b/passt.c
@@ -301,7 +301,7 @@ void exit_handler(int signal)
*/
int main(int argc, char **argv)
{
- int nfds, i, devnull_fd = -1, pidfile_fd = -1;
+ int nfds, i, devnull_fd = -1, pidfile_fd = -1, quit_fd;
struct epoll_event events[EPOLL_EVENTS];
struct ctx c = { 0 };
struct rlimit limit;
@@ -357,6 +357,8 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
+ quit_fd = pasta_netns_quit_init(&c);
+
if (getrlimit(RLIMIT_NOFILE, &limit)) {
perror("getrlimit");
exit(EXIT_FAILURE);
@@ -416,6 +418,7 @@ int main(int argc, char **argv)
seccomp(&c);
timer_init(&c, &now);
+
loop:
nfds = epoll_wait(c.epollfd, events, EPOLL_EVENTS, TIMER_INTERVAL);
if (nfds == -1 && errno != EINTR) {
@@ -431,6 +434,8 @@ loop:
if (fd == c.fd_tap || fd == c.fd_tap_listen)
tap_handler(&c, fd, events[i].events, &now);
+ else if (fd == quit_fd)
+ pasta_netns_quit_handler(&c, fd);
else
sock_handler(&c, ref, events[i].events, &now);
}