]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Fixed mismatch on ipvX gateway
authorSergio Jimenez <tripledes@gmail.com>
Sat, 4 Oct 2014 18:51:27 +0000 (20:51 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 27 Oct 2014 21:42:11 +0000 (17:42 -0400)
Signed-off-by: Sergio Jimenez <tripledes@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/conf.c
src/lxc/confile.c
src/tests/get_item.c

index 8273e6ee2eab26faa8e6aa716bae2a5dbf0f5eef..5938c3ec301cd8b3adefe9801d2f6f30f76ce190 100644 (file)
@@ -4318,12 +4318,12 @@ int lxc_clear_nic(struct lxc_conf *c, const char *key)
                        free(netdev->mtu);
                        netdev->mtu = NULL;
                }
-       } else if (strcmp(p1, ".ipv4_gateway") == 0) {
+       } else if (strcmp(p1, ".ipv4.gateway") == 0) {
                if (netdev->ipv4_gateway) {
                        free(netdev->ipv4_gateway);
                        netdev->ipv4_gateway = NULL;
                }
-       } else if (strcmp(p1, ".ipv6_gateway") == 0) {
+       } else if (strcmp(p1, ".ipv6.gateway") == 0) {
                if (netdev->ipv6_gateway) {
                        free(netdev->ipv6_gateway);
                        netdev->ipv6_gateway = NULL;
index 09eb94dbc6963de5f10212bc7c45c7b715d0900e..886f8a1130014dffd929f0d98b0f83e3452f2b43 100644 (file)
@@ -452,9 +452,9 @@ extern int lxc_list_nicconfigs(struct lxc_conf *c, const char *key,
                strprint(retv, inlen, "hwaddr\n");
                strprint(retv, inlen, "mtu\n");
                strprint(retv, inlen, "ipv6\n");
-               strprint(retv, inlen, "ipv6_gateway\n");
+               strprint(retv, inlen, "ipv6.gateway\n");
                strprint(retv, inlen, "ipv4\n");
-               strprint(retv, inlen, "ipv4_gateway\n");
+               strprint(retv, inlen, "ipv4.gateway\n");
        }
        switch(netdev->type) {
        case LXC_NET_VETH:
@@ -2135,7 +2135,7 @@ static int lxc_get_auto_mounts(struct lxc_conf *c, char *retv, int inlen)
 /*
  * lxc.network.0.XXX, where XXX can be: name, type, link, flags, type,
  * macvlan.mode, veth.pair, vlan, ipv4, ipv6, script.up, hwaddr, mtu,
- * ipv4_gateway, ipv6_gateway.  ipvX_gateway can return 'auto' instead
+ * ipv4.gateway, ipv6.gateway.  ipvX.gateway can return 'auto' instead
  * of an address.  ipv4 and ipv6 return lists (newline-separated).
  * things like veth.pair return '' if invalid (i.e. if called for vlan
  * type).
@@ -2204,7 +2204,7 @@ static int lxc_get_item_nic(struct lxc_conf *c, char *retv, int inlen,
                if (netdev->type == LXC_NET_VLAN) {
                        strprint(retv, inlen, "%d", netdev->priv.vlan_attr.vid);
                }
-       } else if (strcmp(p1, "ipv4_gateway") == 0) {
+       } else if (strcmp(p1, "ipv4.gateway") == 0) {
                if (netdev->ipv4_gateway_auto) {
                        strprint(retv, inlen, "auto");
                } else if (netdev->ipv4_gateway) {
@@ -2220,7 +2220,7 @@ static int lxc_get_item_nic(struct lxc_conf *c, char *retv, int inlen,
                        inet_ntop(AF_INET, &i->addr, buf, sizeof(buf));
                        strprint(retv, inlen, "%s/%d\n", buf, i->prefix);
                }
-       } else if (strcmp(p1, "ipv6_gateway") == 0) {
+       } else if (strcmp(p1, "ipv6.gateway") == 0) {
                if (netdev->ipv6_gateway_auto) {
                        strprint(retv, inlen, "auto");
                } else if (netdev->ipv6_gateway) {
index d9c5aef57b3d01005dd30dd2663b9bcbd27cbaf8..abf50e8767d59947d03ab1fd1e99c41549b3c66b 100644 (file)
@@ -237,6 +237,30 @@ int main(int argc, char *argv[])
                goto out;
        }
 
+       if (!c->set_config_item(c, "lxc.network.ipv4.gateway", "10.2.3.254")) {
+               fprintf(stderr, "%d: failed to set ipv4.gateway\n", __LINE__);
+               ret = 1;
+               goto out;
+       }
+
+       ret = c->get_config_item(c, "lxc.network.0.ipv4.gateway", v2, 255);
+       if (ret <= 0) {
+               fprintf(stderr, "%d: lxc.network.0.ipv4.gateway returned %d\n", __LINE__, ret);
+               ret = 1;
+               goto out;
+       }
+       if (!c->clear_config_item(c, "lxc.network.0.ipv4.gateway")) {
+               fprintf(stderr, "%d: failed clearing ipv4.gateway\n", __LINE__);
+               ret = 1;
+               goto out;
+       }
+       ret = c->get_config_item(c, "lxc.network.0.ipv4.gateway", v2, 255);
+       if (ret != 0) {
+               fprintf(stderr, "%d: after clearing ipv4.gateway get_item(lxc.network.0.ipv4.gateway returned %d\n", __LINE__, ret);
+               ret = 1;
+               goto out;
+       }
+
        ret = c->get_config_item(c, "lxc.network.0.link", v2, 255);
        if (ret < 0) {
                fprintf(stderr, "%d: get_config_item returned %d\n", __LINE__, ret);