From 9d8b1f8c3f5a3fd0be2479de5b6fe76206389f96 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 13 Apr 2016 10:33:58 +0200 Subject: [PATCH] Fix #929: delete veths in the post-stop hook Unfortunately it can still happen that LXC's network link deletion netlink messages get dropped/ignored. This is the same issue as initially reported on the forums by sigxcpu in October, however, it seems that some users hit this problem more reliably currently. --- src/lxc-pve-poststop-hook | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lxc-pve-poststop-hook b/src/lxc-pve-poststop-hook index 6f37088..a22a217 100755 --- a/src/lxc-pve-poststop-hook +++ b/src/lxc-pve-poststop-hook @@ -60,7 +60,19 @@ __PACKAGE__->register_method ({ my $rootfs = $ENV{LXC_ROOTFS_PATH}; die "Missing container root directory!\n" if !$rootfs; PVE::Tools::run_command(['umount', '--recursive', $rootfs]); - + + # Because netlink is not a reliable protocol it can happen that lxc's + # link-deletion messages get lost (or end up being too early?) + for my $k (keys %$conf) { + next if $k !~ /^net(\d+)/; + my $ind = $1; + my $net = PVE::LXC::Config->parse_lxc_network($conf->{$k}); + next if $net->{type} ne 'veth'; + my $name = "veth${vmid}i${ind}"; + # veth_delete tests with '-d /sys/class/net/$name' before running the command + PVE::Network::veth_delete("veth${vmid}i$ind"); + } + return undef; }}); -- 2.39.2