From: Daniel Lezcano Date: Thu, 22 Jul 2010 13:59:44 +0000 (+0200) Subject: fix inverted network interface creation X-Git-Tag: lxc-0.7.2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bac8958311722c6b5e6dd396bb95bfcfa1ae4169;p=thirdparty%2Flxc.git fix inverted network interface creation 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 --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 127fb3700..e2c015d7c 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 eb4fd1346..5213e8085 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;