From be8cd8fd4d6fd320bf668482fb49c4e0426c9d28 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 11 Oct 2021 23:51:08 +0100 Subject: [PATCH] interface: don't fork() to start jail interface As we got a persistent per-netns-jail instance of netifd now which handles interface configuration we no longer need to fork() the host netifd to bring up jail interfaces. The follow-up commit will deal with stopping jail interfaces. Signed-off-by: Daniel Golle --- interface.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/interface.c b/interface.c index 6cf0d30..f60b545 100644 --- a/interface.c +++ b/interface.c @@ -1181,40 +1181,6 @@ interface_start_jail(const char *jail, const pid_t netns_pid) } close(netns_fd); - - pr = fork(); - if (pr) { - waitpid(pr, &wstatus, WUNTRACED | WCONTINUED); - return; - } - - /* child process */ - netns_fd = system_netns_open(netns_pid); - if (netns_fd < 0) - return; - - system_netns_set(netns_fd); - system_init(); - vlist_for_each_element(&interfaces, iface, node) { - if (!iface->jail || strcmp(iface->jail, jail)) - continue; - - /* - * The interface has already been renamed and is inside target - * namespace, hence overwrite ifname with jail_ifname for - * interface_set_up(). - * We are inside a fork which got it's own copy of the interfaces - * list, so we can mess with it :) - */ - if (iface->jail_ifname) - iface->device = iface->jail_ifname; - - interface_do_reload(iface); - interface_set_up(iface); - } - - close(netns_fd); - _exit(0); } void -- 2.30.2