summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2020-04-14 00:36:29 +0100
committerDaniel Golle <daniel@makrotopia.org>2020-04-14 00:42:10 +0100
commitdbf97b47a53809a6ff812d4466d2082aa4d3efb6 (patch)
treebc923b3952e85e3714df2a421e929188a6e167a4
parentd93126d3b91ea9e3831b9fd0b5318989f82daebe (diff)
interface: fix jail ifdown and jails without jail_ifname
Fixes: d93126d ("interface: allow renaming interface when moving to jail netns") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--interface.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/interface.c b/interface.c
index 2c883d8..24d90aa 100644
--- a/interface.c
+++ b/interface.c
@@ -1200,7 +1200,9 @@ interface_start_jail(const char *jail, const pid_t netns_pid)
* We are inside a fork which got it's own copy of the interfaces
* list, so we can mess with it :)
*/
- iface->ifname = iface->jail_ifname;
+ if (iface->jail_ifname)
+ iface->ifname = iface->jail_ifname;
+
interface_do_reload(iface);
interface_set_up(iface);
}
@@ -1217,6 +1219,7 @@ interface_stop_jail(const char *jail, const pid_t netns_pid)
int wstatus;
pid_t parent_pid = getpid();
pid_t pr = 0;
+ const char *orig_ifname;
pr = fork();
if (pr) {
@@ -1239,8 +1242,13 @@ interface_stop_jail(const char *jail, const pid_t netns_pid)
if (!iface->jail || strcmp(iface->jail, jail))
continue;
+ orig_ifname = iface->ifname;
+ if (iface->jail_ifname)
+ iface->ifname = iface->jail_ifname;
+
+ interface_do_reload(iface);
interface_set_down(iface);
- system_link_netns_move(iface->jail_ifname, root_netns, iface->ifname);
+ system_link_netns_move(iface->ifname, root_netns, orig_ifname);
}
close(root_netns);