[lxc-devel] [lxc/master] network: fix ovs removal

brauner on Github lxc-bot at linuxcontainers.org
Thu Mar 19 15:19:46 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 379 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200319/2a726eb6/attachment.bin>
-------------- next part --------------
From ffcc7dd0cb2ecb312c1d73e529d26aef532a73cd Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 19 Mar 2020 16:08:44 +0100
Subject: [PATCH] network: fix ovs removal

Closes #3137.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/network.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index 0e79500f1f..484cdfc16c 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -3492,29 +3492,19 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
 		if (hostveth[0] == '\0')
 			goto clear_ifindices;
 
-		ret = lxc_netdev_delete_by_name(hostveth);
-		if (ret < 0) {
-			WARN("Failed to remove interface \"%s\" from \"%s\"",
-			     hostveth, netdev->link);
-			goto clear_ifindices;
-		}
-		INFO("Removed interface \"%s\" from \"%s\"", hostveth, netdev->link);
+		if (!is_ovs_bridge(netdev->link)) {
+			ret = lxc_netdev_delete_by_name(hostveth);
+			if (ret < 0)
+				WARN("Failed to remove interface \"%s\" from \"%s\"", hostveth, netdev->link);
 
-		if (netdev->link[0] == '\0' || !is_ovs_bridge(netdev->link)) {
-			netdev->priv.veth_attr.veth1[0] = '\0';
-			netdev->ifindex = 0;
-			netdev->priv.veth_attr.ifindex = 0;
-			goto clear_ifindices;
-		}
+			INFO("Removed interface \"%s\" from \"%s\"", hostveth, netdev->link);
+		} else if (!is_empty_string(netdev->link)) {
+			ret = lxc_ovs_delete_port(netdev->link, hostveth);
+			if (ret < 0)
+				WARN("Failed to remove port \"%s\" from openvswitch bridge \"%s\"", hostveth, netdev->link);
 
-		/* Delete the openvswitch port. */
-		ret = lxc_ovs_delete_port(netdev->link, hostveth);
-		if (ret < 0)
-			WARN("Failed to remove port \"%s\" from openvswitch "
-			     "bridge \"%s\"", hostveth, netdev->link);
-		else
-			INFO("Removed port \"%s\" from openvswitch bridge \"%s\"",
-			     hostveth, netdev->link);
+			INFO("Removed port \"%s\" from openvswitch bridge \"%s\"", hostveth, netdev->link);
+		}
 
 clear_ifindices:
 		/* We need to clear any ifindices we recorded so liblxc won't


More information about the lxc-devel mailing list