[lxc-devel] [PATCH 3/4] check if lxc.netdev.link is set for macvlan

Michael Tokarev mjt at tls.msk.ru
Thu Nov 19 14:59:28 UTC 2009


Ensure that lxc.netdev.link is specified for macvlan interfaces,
since it's required.

While at it, simplify logic in instanciate_macvlan():
remove unnecessary-complicating goto statements (we only
need to perform a cleanup in one place)

Signed-off-by: Michael Tokarev <mjt at tls.msk.ru>
---
 src/lxc/conf.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 1b9817a..9274920 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -898,10 +898,15 @@ out_delete:
 	lxc_device_delete(veth1);
 	goto out;
 }
+
 static int instanciate_macvlan(struct lxc_netdev *netdev)
 {
 	char peer[IFNAMSIZ];
-	int ret = -1;
+
+	if (!netdev->link) {
+		ERROR("no link specified for macvlan netdev");
+		return -1;
+	}
 
 	snprintf(peer, sizeof(peer), "mcXXXXXX");
 
@@ -915,24 +920,19 @@ static int instanciate_macvlan(struct lxc_netdev *netdev)
 	if (lxc_macvlan_create(netdev->link, peer)) {
 		ERROR("failed to create macvlan interface '%s' on '%s'",
 		      peer, netdev->link);
-		goto out;
+		return -1;
 	}
 
 	netdev->ifindex = if_nametoindex(peer);
 	if (!netdev->ifindex) {
 		ERROR("failed to retrieve the index for %s", peer);
-		goto out_delete;
+		lxc_device_delete(peer);
+		return -1;
 	}
 
 	DEBUG("instanciated macvlan '%s', index is '%d'", peer, netdev->ifindex);
 
-	ret = 0;
-out:
-	return ret;
-
-out_delete:
-	lxc_device_delete(peer);
-	goto out;
+	return 0;
 }
 
 static int instanciate_phys(struct lxc_netdev *netdev)
-- 
1.6.3.3





More information about the lxc-devel mailing list