Fix syntax errors

This commit is contained in:
Pengfei Ni
2016-06-03 16:32:04 +08:00
parent 01a958b209
commit 6aa71c3bd9
2 changed files with 12 additions and 17 deletions
+4 -9
View File
@@ -1068,7 +1068,7 @@ static int hyper_parse_portmapping_external_networks(struct portmapping_white_li
static int hyper_parse_portmapping_whitelist(struct hyper_pod *pod, char *json, jsmntok_t *toks)
{
int i = 0, j, toks_size, next, ret = 0;
int i = 0, j, toks_size, next;
if (toks[i].type != JSMN_OBJECT) {
fprintf(stdout, "PortmappingWhiteLists format incorrect\n");
@@ -1095,7 +1095,6 @@ static int hyper_parse_portmapping_whitelist(struct hyper_pod *pod, char *json,
if (json_token_streq(json, t, "internalNetworks") && t->size == 1) {
next = hyper_parse_portmapping_internal_networks(pod->portmap_white_lists, json, &toks[++i]);
if (next < -1) {
ret = -1;
goto out;
}
@@ -1103,27 +1102,23 @@ static int hyper_parse_portmapping_whitelist(struct hyper_pod *pod, char *json,
} else if (json_token_streq(json, t, "externalNetworks") && t->size == 1) {
next = hyper_parse_portmapping_external_networks(pod->portmap_white_lists, json, &toks[++i]);
if (next < -1) {
ret = -1;
goto out;
}
i += next;
} else {
fprintf(stdout, "get unknown section %s in portmap_white_lists\n", json_token_str(json, t));
ret = -1;
goto out;
}
}
out:
if (ret != -1) {
return i;
}
return i;
out:
free(pod->portmap_white_lists->internal_networks);
free(pod->portmap_white_lists->external_networks);
free(pod->portmap_white_lists);
pod->portmap_white_lists = NULL;
return ret;
return -1;
}
int hyper_parse_pod(struct hyper_pod *pod, char *json, int length)
+8 -8
View File
@@ -278,14 +278,14 @@ int hyper_setup_container_portmapping(struct hyper_container *c, struct hyper_po
c->ports[i].protocol,
c->ports[i].host_port,
c->ports[i].container_port);
struct ipt_rule rediect_rule = {
struct ipt_rule redirect_rule = {
.table = "nat",
.op = "-I",
.chain = "hyperstart-PREROUTING",
.rule = rule,
};
if (hyper_setup_iptables_rule(rediect_rule)<0) {
fprintf(stderr, "setup rediect_rule '%s' failed\n", rule);
if (hyper_setup_iptables_rule(redirect_rule)<0) {
fprintf(stderr, "setup redirect_rule '%s' failed\n", rule);
return -1;
}
@@ -358,14 +358,14 @@ void hyper_cleanup_container_portmapping(struct hyper_container *c, struct hyper
c->ports[i].protocol,
c->ports[i].host_port,
c->ports[i].container_port);
struct ipt_rule rediect_rule = {
struct ipt_rule redirect_rule = {
.table = "nat",
.op = "-D",
.chain = "hyperstart-PREROUTING",
.rule = rule,
};
if (hyper_setup_iptables_rule(rediect_rule)<0) {
fprintf(stderr, "setup rediect_rule '%s' failed\n", rule);
if (hyper_setup_iptables_rule(redirect_rule)<0) {
fprintf(stderr, "cleanup redirect '%s' failed\n", rule);
}
// open container_port to external network
@@ -381,7 +381,7 @@ void hyper_cleanup_container_portmapping(struct hyper_container *c, struct hyper
.rule = rule,
};
if (hyper_setup_iptables_rule(accept_rule)<0) {
fprintf(stderr, "setup accept_rule '%s' failed\n", rule);
fprintf(stderr, "cleanup accept_rule '%s' failed\n", rule);
}
}
}
@@ -399,7 +399,7 @@ void hyper_cleanup_container_portmapping(struct hyper_container *c, struct hyper
.rule = rule,
};
if (hyper_setup_iptables_rule(accept_rule)<0) {
fprintf(stderr, "setup accept_rule '%s' failed\n", rule);
fprintf(stderr, "cleanup accept_rule '%s' failed\n", rule);
}
}
}