Commit 42165243 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

test: check that contracks are dumped and restored

This tests sets filters which drops all packets which don't
belongs to current tcp connections and creates one tcp connection.
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent afde3659
...@@ -64,6 +64,7 @@ TST_NOFILE = \ ...@@ -64,6 +64,7 @@ TST_NOFILE = \
socket-tcp \ socket-tcp \
socket-tcp6 \ socket-tcp6 \
socket-tcp-local \ socket-tcp-local \
socket-tcp-nfconntrack \
socket-tcp6-local \ socket-tcp6-local \
socket-tcpbuf \ socket-tcpbuf \
socket-tcpbuf-local \ socket-tcpbuf-local \
...@@ -359,6 +360,7 @@ socket-tcpbuf-local: override CFLAGS += -D ZDTM_TCP_LOCAL ...@@ -359,6 +360,7 @@ socket-tcpbuf-local: override CFLAGS += -D ZDTM_TCP_LOCAL
socket-tcpbuf6-local: override CFLAGS += -D ZDTM_TCP_LOCAL -D ZDTM_IPV6 socket-tcpbuf6-local: override CFLAGS += -D ZDTM_TCP_LOCAL -D ZDTM_IPV6
socket-tcp6-local: override CFLAGS += -D ZDTM_TCP_LOCAL -D ZDTM_IPV6 socket-tcp6-local: override CFLAGS += -D ZDTM_TCP_LOCAL -D ZDTM_IPV6
socket-tcp-local: override CFLAGS += -D ZDTM_TCP_LOCAL socket-tcp-local: override CFLAGS += -D ZDTM_TCP_LOCAL
socket-tcp-nfconntrack: override CFLAGS += -D ZDTM_TCP_LOCAL -DZDTM_CONNTRACK
socket_listen6: override CFLAGS += -D ZDTM_IPV6 socket_listen6: override CFLAGS += -D ZDTM_IPV6
sigpending: override LDLIBS += -lrt sigpending: override LDLIBS += -lrt
vdso01: override LDLIBS += -lrt vdso01: override LDLIBS += -lrt
......
socket-tcp.c
\ No newline at end of file
{'flavor': 'h', 'opts': '--tcp-established', 'flags': 'suid'}
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "zdtmtst.h" #include "zdtmtst.h"
#ifdef ZDTM_IPV6 #ifdef ZDTM_IPV6
...@@ -16,6 +19,7 @@ const char *test_author = "Andrey Vagin <avagin@parallels.com"; ...@@ -16,6 +19,7 @@ const char *test_author = "Andrey Vagin <avagin@parallels.com";
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
#include <sched.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
static int port = 8880; static int port = 8880;
...@@ -61,6 +65,15 @@ int main(int argc, char **argv) ...@@ -61,6 +65,15 @@ int main(int argc, char **argv)
int val; int val;
socklen_t optlen; socklen_t optlen;
#ifdef ZDTM_CONNTRACK
unshare(CLONE_NEWNET);
if (system("ip link set up dev lo"))
return 1;
if (system("iptables -A INPUT -i lo -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT"))
return 1;
system("iptables -A INPUT -j DROP");
#endif
#ifdef ZDTM_TCP_LOCAL #ifdef ZDTM_TCP_LOCAL
test_init(argc, argv); test_init(argc, argv);
#endif #endif
......
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