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 <dlezcano@fr.ibm.com>
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;
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);
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;