[pve-devel] [PATCH container] Fix #929: delete veths in the post-stop hook

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Apr 13 10:33:58 CEST 2016


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.
---

I really can't reproduce this, but this patch also shouldn't have any
bad side effects.
I just hope we don't have to upgrade it to a loop
(while (interface exists) { delete }) ...

This was also suggested by sigxcpu back in october, but somehow we
forgot about it.

 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.1.4





More information about the pve-devel mailing list