interface: don't fork() to start jail interface
authorDaniel Golle <daniel@makrotopia.org>
Mon, 11 Oct 2021 22:51:08 +0000 (23:51 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 12 Oct 2021 23:30:13 +0000 (00:30 +0100)
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 <daniel@makrotopia.org>
interface.c

index 6cf0d309d5f53ded71a717c39394bc184be13ca8..f60b545c7f5688b2417ccd865e56ace02daa9889 100644 (file)
@@ -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