From dbf97b47a53809a6ff812d4466d2082aa4d3efb6 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Tue, 14 Apr 2020 00:36:29 +0100 Subject: [PATCH] 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 --- interface.c | 12 ++++++++++-- 1 file 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); -- 2.25.1