[lxc-devel] [PATCH] Multiple IP addresses: add them in the correct order

Christian Seiler christian at iwakd.de
Tue Jan 15 13:44:25 UTC 2013


Make sure that when configuring containers that have interfaces containing
multiple IP addresses they are added in the order of the configuration file
(i.e. the first being the primary one) and not the reverse order.

Signed-off-by: Christian Seiler <christian at iwakd.de>
---
 src/lxc/confile.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

This problem hit me when I created a container with multiple IPv4 addresses
and they were added in the reverse order, making the last one in the config
file the primary address from which all outgoing connections were made
unless the program bound source IPs explicitly, which then caused an
IP-based filter on the other end to deny access.

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 034136e..da87088 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -624,7 +624,7 @@ static int config_network_ipv4(const char *key, const char *value,
 			htonl(INADDR_BROADCAST >>  inetdev->prefix);
 	}
 
-	lxc_list_add(&netdev->ipv4, list);
+	lxc_list_add_tail(&netdev->ipv4, list);
 
 	free(addr);
 	return 0;
@@ -716,7 +716,7 @@ static int config_network_ipv6(const char *key, const char *value,
 		return -1;
 	}
 
-	lxc_list_add(&netdev->ipv6, list);
+	lxc_list_add_tail(&netdev->ipv6, list);
 
 	free(valdup);
 	return 0;
-- 
1.7.2.5





More information about the lxc-devel mailing list