[lxc-devel] [patch -lxc 1/2] fix inverted network interface creation

2010-07-22 Thread Daniel Lezcano
From: Daniel Lezcano daniel.lezc...@free.fr

The list is 'lifo', so when we create the network interfaces, we
do this in the reverse order of the expected one. That is confusing.

Signed-off-by: Daniel Lezcano dlezc...@fr.ibm.com
---
 src/lxc/confile.c |4 ++--
 src/lxc/list.h|5 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 127fb37..e2c015d 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -136,7 +136,7 @@ static int config_network_type(const char *key, char *value,
lxc_list_init(list);
list-elem = netdev;
 
-   lxc_list_add(network, list);
+   lxc_list_add_tail(network, list);
 
if (!strcmp(value, veth))
netdev-type = LXC_NET_VETH;
@@ -178,7 +178,7 @@ static struct lxc_netdev *network_netdev(const char *key, 
const char *value,
return NULL;
}
 
-   netdev = lxc_list_first_elem(network);
+   netdev = lxc_list_last_elem(network);
if (!netdev) {
ERROR(no network device defined for '%s' = '%s' option,
  key, value);
diff --git a/src/lxc/list.h b/src/lxc/list.h
index eb4fd13..5213e80 100644
--- a/src/lxc/list.h
+++ b/src/lxc/list.h
@@ -30,6 +30,11 @@ static inline void *lxc_list_first_elem(struct lxc_list 
*list)
return list-next-elem;
 }
 
+static inline void *lxc_list_last_elem(struct lxc_list *list)
+{
+   return list-prev-elem;
+}
+
 static inline int lxc_list_empty(struct lxc_list *list)
 {
return list == list-next;
-- 
1.7.0.4


--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel


[lxc-devel] segfault with insufficient network config

2010-07-22 Thread Ferenc Wagner
Hi,

$ lxc-execute --name net -s lxc.network.type=phys bash
Segmentation fault (core dumped)

The problem is that the netdev structure is mostly uninitialized (only
its type is set to LXC_NET_PHYS), so if_nametoindex() is invoked with a
NULL argument:

static int instanciate_phys(struct lxc_netdev *netdev)
{
netdev-ifindex = if_nametoindex(netdev-link);

That would be easy to fix by starting with

if (!netdev-link) {
ERROR(no link specified for phy netdev);
return -1;
}

or similar, but there's something else, too:

# lxc-execute --name net -s lxc.network.type=phys -s lxc.network.link=eth0 bash
lxc-execute: failed to move 'eth0' to the container : Message too long

It might as well have some sense, but I definitely don't get it this
late. :)  I give up now.
-- 
Regards,
Feri.

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel