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

Commit 79b81bb

Browse files
committed
setup iptables rules passed by runv
the iptables rules stores in sharedir, the name format is containerid-iptables. Signed-off-by: Gao feng <omarapazanadi@gmail.com>
1 parent 68942fb commit 79b81bb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/portmapping.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,21 @@ int hyper_setup_portmapping(struct hyper_pod *pod)
166166

167167
int hyper_setup_container_portmapping(struct hyper_container *c, struct hyper_pod *pod)
168168
{
169+
// only allow network request from internal white list
170+
int i = 0, j = 0;
171+
char rule[128] = {0};
172+
char iptables_restore[512];
173+
174+
// restore iptables rules
175+
if (sprintf(iptables_restore, "iptables-restore /tmp/hyper/shared/%s-iptables", c->id) > 0) {
176+
hyper_cmd(iptables_restore);
177+
}
178+
169179
if (pod->portmap_white_lists == NULL || (pod->portmap_white_lists->i_num == 0 &&
170180
pod->portmap_white_lists->e_num == 0)) {
171181
return 0;
172182
}
173183

174-
// only allow network request from internal white list
175-
int i = 0, j = 0;
176-
char rule[128] = {0};
177184
for (j=0; j<pod->portmap_white_lists->i_num; j++) {
178185
sprintf(rule, "-s %s -j ACCEPT",
179186
pod->portmap_white_lists->internal_networks[j]);

0 commit comments

Comments
 (0)