Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 15bb718

Browse files
committed
move the general rules cleanup to pod level
Signed-off-by: Xu Wang <[email protected]>
1 parent 040d7c3 commit 15bb718

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ static void hyper_flush_channel()
553553

554554
void hyper_pod_destroyed(struct hyper_pod *pod, int failed)
555555
{
556+
hyper_cleanup_portmapping(pod);
556557
hyper_cleanup_mounts(pod);
557558
hyper_ctl_append_msg(&hyper_epoll.ctl, failed?ERROR:ACK, NULL, 0);
558559
// Todo: this doesn't make sure peer receives the data

src/portmapping.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,15 @@ int hyper_setup_container_portmapping(struct hyper_container *c, struct hyper_po
258258
return 0;
259259
}
260260

261-
void hyper_cleanup_container_portmapping(struct hyper_container *c, struct hyper_pod *pod)
261+
// cleanup pod level portmapping configurations
262+
void hyper_cleanup_portmapping(struct hyper_pod *pod)
262263
{
263264
if (pod->portmap_white_lists == NULL || (pod->portmap_white_lists->i_num == 0 &&
264265
pod->portmap_white_lists->e_num == 0)) {
265266
return;
266267
}
267268

268-
int i = 0, j = 0;
269+
int j = 0;
269270
char rule[128] = {0};
270271
for (j=0; j<pod->portmap_white_lists->i_num; j++) {
271272
sprintf(rule, "-s %s -j ACCEPT",
@@ -280,7 +281,17 @@ void hyper_cleanup_container_portmapping(struct hyper_container *c, struct hyper
280281
fprintf(stderr, "cleanup accept_rule '%s' failed\n", rule);
281282
}
282283
}
284+
}
283285

286+
void hyper_cleanup_container_portmapping(struct hyper_container *c, struct hyper_pod *pod)
287+
{
288+
if (pod->portmap_white_lists == NULL || (pod->portmap_white_lists->i_num == 0 &&
289+
pod->portmap_white_lists->e_num == 0)) {
290+
return;
291+
}
292+
293+
int i = 0, j = 0;
294+
char rule[128] = {0};
284295
if (c->ports_num == 0) {
285296
return;
286297
}

src/portmapping.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct hyper_pod;
1717
struct hyper_container;
1818
int hyper_setup_portmapping(struct hyper_pod *pod);
1919
int hyper_setup_container_portmapping(struct hyper_container *c, struct hyper_pod *pod);
20+
void hyper_cleanup_portmapping(struct hyper_pod *pod);
2021
void hyper_cleanup_container_portmapping(struct hyper_container *c, struct hyper_pod *pod);
2122

2223
#endif

0 commit comments

Comments
 (0)