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

brauner on Github lxc-bot at linuxcontainers.org
Tue Apr 2 21:28:02 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 381 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190402/ef79af87/attachment.bin>
-------------- next part --------------
From 78ab281c61c97a700dec0071c82c308947591a11 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 2 Apr 2019 23:26:59 +0200
Subject: [PATCH] network: fix network device removal

Closes #2849.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/network.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index fc3a8740d6..d1b4d43ada 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -2574,17 +2574,16 @@ bool lxc_delete_network_priv(struct lxc_handler *handler)
 		 * interface to the network namespace, we have to destroy it.
 		 */
 		ret = lxc_netdev_delete_by_index(netdev->ifindex);
-		if (-ret == ENODEV) {
-			INFO("Interface \"%s\" with index %d already "
-			     "deleted or existing in different network "
-			     "namespace",
-			     netdev->name[0] != '\0' ? netdev->name : "(null)",
-			     netdev->ifindex);
-		} else if (ret < 0) {
-			WARN("Failed to remove interface \"%s\" with index %d",
+		if (ret < 0) {
+			if (errno != ENODEV) {
+				WARN("Failed to remove interface \"%s\" with index %d",
+				     netdev->name[0] != '\0' ? netdev->name : "(null)",
+				     netdev->ifindex);
+				goto clear_ifindices;
+			}
+			INFO("Interface \"%s\" with index %d already deleted or existing in different network namespace",
 			     netdev->name[0] != '\0' ? netdev->name : "(null)",
 			     netdev->ifindex);
-			goto clear_ifindices;
 		}
 		INFO("Removed interface \"%s\" with index %d",
 		     netdev->name[0] != '\0' ? netdev->name : "(null)",


More information about the lxc-devel mailing list