Please do not apply the previous version of this patch, it is wrong. I
didn't take into account that priv is a union, so priv.veth_attr.pair
is only a pointer when netdev type is VETH. The following patch works
when non-veth nics are also present.

--

Signed-off-by: Dwight Engen <dwight.en...@oracle.com>
---
 src/lxc/conf.c    |  2 ++
 src/lxc/confile.c | 14 +-------------
 2 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 2a47e77..c131259 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -3308,6 +3308,8 @@ static void lxc_remove_nic(struct lxc_list *it)
                free(netdev->link);
        if (netdev->name)
                free(netdev->name);
+       if (netdev->type == LXC_NET_VETH && netdev->priv.veth_attr.pair)
+               free(netdev->priv.veth_attr.pair);
        if (netdev->upscript)
                free(netdev->upscript);
        if (netdev->hwaddr)
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 680d260..0e0b7e8 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -453,19 +453,7 @@ static struct lxc_netdev *network_netdev(const char *key, 
const char *value,
 
 static int network_ifname(char **valuep, const char *value)
 {
-       if (strlen(value) >= IFNAMSIZ) {
-               ERROR("interface name '%s' too long (>%d)\n",
-               value, IFNAMSIZ - 1);
-               return -1;
-       }
-
-       *valuep = strdup(value);
-       if (!*valuep) {
-               ERROR("failed to dup string '%s'", value);
-               return -1;
-       }
-
-       return 0;
+       return config_string_item_max(valuep, value, IFNAMSIZ);
 }
 
 #ifndef MACVLAN_MODE_PRIVATE
-- 
1.8.3.1


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to