1 Star 0 Fork 35

hd_zhoujie/criu

forked from src-openEuler/criu 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0018-test-flush-ipt-rules-after-program-exits.patch 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
river 提交于 2022-04-13 15:05 . criu: backport kinds of features/bugfix
From 003edcab5c2dc1a3f00dba7f4b7bcdd017eb34b5 Mon Sep 17 00:00:00 2001
From: "fu.lin" <fulin10@huawei.com>
Date: Thu, 20 Jan 2022 19:45:14 +0800
Subject: [PATCH 18/72] test: flush ipt rules after program exits
Signed-off-by: fu.lin <fulin10@huawei.com>
---
test/zdtm/static/socket-tcp-nfconntrack.desc | 2 +-
test/zdtm/static/socket-tcp.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/test/zdtm/static/socket-tcp-nfconntrack.desc b/test/zdtm/static/socket-tcp-nfconntrack.desc
index add2513..05bdb49 100644
--- a/test/zdtm/static/socket-tcp-nfconntrack.desc
+++ b/test/zdtm/static/socket-tcp-nfconntrack.desc
@@ -1 +1 @@
-{'flavor': 'h', 'opts': '--tcp-established', 'flags': 'suid'}
+{'flavor': 'h', 'opts': '--tcp-established', 'flags': 'suid excl'}
diff --git a/test/zdtm/static/socket-tcp.c b/test/zdtm/static/socket-tcp.c
index f6ef473..29b0fce 100644
--- a/test/zdtm/static/socket-tcp.c
+++ b/test/zdtm/static/socket-tcp.c
@@ -57,6 +57,13 @@ int write_data(int fd, const unsigned char *buf, int size)
return 0;
}
+#ifdef ZDTM_CONNTRACK
+static void ipt_flush(void)
+{
+ system("iptables -w --flush");
+}
+#endif
+
int main(int argc, char **argv)
{
unsigned char buf[BUF_SIZE];
@@ -72,6 +79,12 @@ int main(int argc, char **argv)
pr_perror("unshare");
return 1;
}
+
+ if (atexit(ipt_flush) != 0) {
+ pr_perror("atexit");
+ return 1;
+ }
+
if (system("ip link set up dev lo"))
return 1;
if (system("iptables -w -A INPUT -i lo -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT"))
--
2.34.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hd-zhoujie/criu.git
git@gitee.com:hd-zhoujie/criu.git
hd-zhoujie
criu
criu
master

搜索帮助