]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: Save lxc.network.ipv4 broadcast address
authorStéphane Graber <stgraber@ubuntu.com>
Tue, 11 Feb 2014 21:31:44 +0000 (16:31 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 11 Feb 2014 23:57:26 +0000 (18:57 -0500)
Reported-by: Robert Vogelgesang <vogel@users.sourceforge.net>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/confile.c

index 546df53909a05cd2b37d15f819f731dcaa14a58f..fa263ef4a45f023aae70bef398c74a6bdfd13b8f 100644 (file)
@@ -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");