]> git.proxmox.com Git - pve-container.git/blobdiff - src/lxc-pve-poststop-hook
Fix #929: delete veths in the post-stop hook
[pve-container.git] / src / lxc-pve-poststop-hook
index 6f370885fda648603f4aadb52d33ce573ddfb157..a22a2172bf74320744842290f358216a814c0155 100755 (executable)
@@ -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;
     }});