[CRIU] [PATCHv2 2/2] zdtm: sysctl net.unix.max_dgram_qlen value preservation test
Alexander Mikhalitsyn
alexander.mikhalitsyn at virtuozzo.com
Thu Oct 31 18:31:07 MSK 2019
Test checks that if the /proc/sys/net/unix/max_dgram_qlen value has
been changed in process net namespace, then it is saved after c/r.
Based-on-patch-by: Cyrill Gorcunov <gorcunov at gmail.com>
Signed-off-by: Alexander Mikhalitsyn <alexander at mihalicyn.com>
---
test/zdtm/static/Makefile | 1 +
test/zdtm/static/netns_sub_sysctl.c | 52 ++++++++++++++++++++++++++
test/zdtm/static/netns_sub_sysctl.desc | 5 +++
3 files changed, 58 insertions(+)
create mode 100644 test/zdtm/static/netns_sub_sysctl.c
create mode 100644 test/zdtm/static/netns_sub_sysctl.desc
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index a38482f4..887bf4ac 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -207,6 +207,7 @@ TST_NOFILE := \
pipe03 \
netns_sub \
netns_sub_veth \
+ netns_sub_sysctl \
unlink_multiple_largefiles \
config_inotify_irmap \
thp_disable \
diff --git a/test/zdtm/static/netns_sub_sysctl.c b/test/zdtm/static/netns_sub_sysctl.c
new file mode 100644
index 00000000..6a816c53
--- /dev/null
+++ b/test/zdtm/static/netns_sub_sysctl.c
@@ -0,0 +1,52 @@
+#include <sched.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc = "Check dump and restore a net.unix.max_dgram_qlen sysctl parameter in subns";
+
+#define CONF_UNIX_PARAM "/proc/sys/net/unix/max_dgram_qlen"
+
+int main(int argc, char **argv)
+{
+ char cmd[128];
+ FILE *fp;
+ int ret, test_max_dgram_qlen = 321, max_dgram_qlen = 0;
+ test_init(argc, argv);
+
+ if (unshare(CLONE_NEWNET)) {
+ perror("unshare");
+ return 1;
+ }
+
+ sprintf(cmd, "echo %d > %s", test_max_dgram_qlen, CONF_UNIX_PARAM);
+ if (system(cmd)) {
+ pr_perror("Can't change %s", CONF_UNIX_PARAM);
+ return -1;
+ }
+
+ test_daemon();
+ test_waitsig();
+
+ fp = fopen(CONF_UNIX_PARAM, "r+");
+ if (fp == NULL) {
+ pr_perror("fopen");
+ return -1;
+ }
+
+ ret = fscanf(fp, "%d", &max_dgram_qlen);
+ if (ret != 1) {
+ pr_perror("fscanf");
+ fclose(fp);
+ return -1;
+ }
+
+ if (test_max_dgram_qlen != max_dgram_qlen) {
+ fail();
+ return 1;
+ }
+
+ pass();
+ return 0;
+}
diff --git a/test/zdtm/static/netns_sub_sysctl.desc b/test/zdtm/static/netns_sub_sysctl.desc
new file mode 100644
index 00000000..e13a65b6
--- /dev/null
+++ b/test/zdtm/static/netns_sub_sysctl.desc
@@ -0,0 +1,5 @@
+{
+ 'deps': ['/bin/sh', '/sbin/ip|/bin/ip'],
+ 'flavor': 'ns',
+ 'flags': 'suid'
+}
--
2.17.1
More information about the CRIU
mailing list