From bac8958311722c6b5e6dd396bb95bfcfa1ae4169 Mon Sep 17 00:00:00 2001 From: Daniel Lezcano Date: Thu, 22 Jul 2010 15:59:44 +0200 Subject: [PATCH] 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 --- 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 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; -- 2.47.2