[lxc-devel] [PATCH] return lxc generated name for veth pair

Dwight Engen dwight.engen at oracle.com
Fri May 17 22:28:12 UTC 2013


Doing a get_config_item for lxc.network.0.veth.pair only returns the
pair name if explicitly given, but it can be useful to know the name
even if it is the one that lxc autogenerated.

Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
 src/lxc/confile.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index fb851c9..a7db117 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1705,8 +1705,12 @@ static int lxc_get_item_nic(struct lxc_conf *c, char *retv, int inlen,
 			strprint(retv, inlen, "%s", mode);
 		}
 	} else if (strcmp(p1, "veth.pair") == 0) {
-		if (netdev->type == LXC_NET_VETH && netdev->priv.veth_attr.pair)
-			strprint(retv, inlen, "%s", netdev->priv.veth_attr.pair);
+		if (netdev->type == LXC_NET_VETH) {
+			strprint(retv, inlen, "%s",
+				 netdev->priv.veth_attr.pair ?
+				  netdev->priv.veth_attr.pair :
+				  netdev->priv.veth_attr.veth1);
+		}
 	} else if (strcmp(p1, "vlan") == 0) {
 		if (netdev->type == LXC_NET_VLAN) {
 			strprint(retv, inlen, "%d", netdev->priv.vlan_attr.vid);
-- 
1.8.1.4





More information about the lxc-devel mailing list