]> git.proxmox.com Git - pve-container.git/commitdiff
Fix #929: delete veths in the post-stop hook
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 13 Apr 2016 08:33:58 +0000 (10:33 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 13 Apr 2016 08:44:58 +0000 (10:44 +0200)
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

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;
     }});