Commit eb3fc256 authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Basic checks for iptables save and restore

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 28014d7e
...@@ -123,6 +123,7 @@ static/msgque ...@@ -123,6 +123,7 @@ static/msgque
static/sem static/sem
transition/ipc transition/ipc
ns/static/tun ns/static/tun
static/netns-nf
" "
TEST_CR_KERNEL=" TEST_CR_KERNEL="
......
...@@ -135,6 +135,7 @@ TST_FILE = \ ...@@ -135,6 +135,7 @@ TST_FILE = \
sockets_dgram \ sockets_dgram \
file_locks00 \ file_locks00 \
file_locks01 \ file_locks01 \
netns-nf \
TST_DIR = \ TST_DIR = \
cwd00 \ cwd00 \
......
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "zdtmtst.h"
const char *test_doc = "Check that netfilter rules (some) are kept";
const char *test_author = "Pavel Emelianov <xemul@parallels.com>";
char *filename;
TEST_OPTION(filename, string, "file name", 1);
static int test_fn(int argc, char **argv)
{
char cmd[128];
if (system("iptables -A INPUT -t filter --protocol icmp -j DROP")) {
err("Can't set input rule");
return -1;
}
sprintf(cmd, "iptables -L > pre-%s", filename);
if (system(cmd)) {
err("Can't save iptables");
return -1;
}
test_daemon();
test_waitsig();
sprintf(cmd, "iptables -L > post-%s", filename);
if (system(cmd)) {
fail("Can't get iptables");
return -1;
}
sprintf(cmd, "diff pre-%s post-%s", filename, filename);
if (system(cmd)) {
fail("Iptables differ");
return -1;
}
pass();
return 0;
}
#define CLONE_NEWNET 0x40000000
int main(int argc, char **argv)
{
test_init_ns(argc, argv, CLONE_NEWNET, test_fn);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment