[lxc-devel] [PATCH] conf: Save lxc.network.ipv4 broadcast address

Stéphane Graber stgraber at ubuntu.com
Tue Feb 11 22:25:21 UTC 2014


Reported-by: Robert Vogelgesang <vogel at users.sourceforge.net>
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 src/lxc/confile.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 546df53..fa263ef 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -2274,11 +2274,19 @@ void write_config(FILE *fout, struct lxc_conf *c)
 			struct lxc_inetdev *i = it2->elem;
 			char buf[INET_ADDRSTRLEN];
 			inet_ntop(AF_INET, &i->addr, buf, sizeof(buf));
+			fprintf(fout, "lxc.network.ipv4 = %s", buf);
+
 			if (i->prefix)
-				fprintf(fout, "lxc.network.ipv4 = %s/%d\n",
-					buf, i->prefix);
+				fprintf(fout, "/%d", i->prefix);
+
+			if (i->bcast.s_addr != (i->addr.s_addr |
+			    htonl(INADDR_BROADCAST >>  i->prefix))) {
+
+				inet_ntop(AF_INET, &i->bcast, buf, sizeof(buf));
+				fprintf(fout, " %s\n", buf);
+			}
 			else
-				fprintf(fout, "lxc.network.ipv4 = %s\n", buf);
+				fprintf(fout, "\n");
 		}
 		if (n->ipv6_gateway_auto)
 			fprintf(fout, "lxc.network.ipv6.gateway = auto\n");
-- 
1.9.rc1



More information about the lxc-devel mailing list