Skip to content

Commit

Permalink
zdtm: add alternative socket filter
Browse files Browse the repository at this point in the history
A little rework of sock_filter test to be able to use it with different
filters

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
  • Loading branch information
azhadchenko committed Oct 5, 2020
1 parent a3d2371 commit 7b246dc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/zdtm/static/Makefile
Expand Up @@ -44,7 +44,8 @@ TST_NOFILE := \
packet_sock \
packet_sock_mmap \
packet_sock_spkt \
sock_filter \
sock_filter00 \
sock_filter01 \
msgque \
inotify_system \
inotify_system_nodel \
Expand Down Expand Up @@ -515,6 +516,7 @@ msgque: CFLAGS += -DNEW_IPC_NS
sem: CFLAGS += -DNEW_IPC_NS
posix_timers: LDLIBS += -lrt -pthread
remap_dead_pid_root: CFLAGS += -DREMAP_PID_ROOT
sock_filter01: CFLAGS += -DSOCK_FILTER01
socket-tcp6: CFLAGS += -D ZDTM_IPV6
socket-tcp4v6: CFLAGS += -D ZDTM_IPV4V6
socket-tcpbuf6: CFLAGS += -D ZDTM_IPV6
Expand Down
Expand Up @@ -15,12 +15,24 @@ const char *test_author = "Pavel Emelyanov <xemul@parallels.com>";
#define SO_GET_FILTER SO_ATTACH_FILTER
#endif

#ifdef SOCK_FILTER01
#define SFLEN 4
#else
#define SFLEN 14
#endif

int main(int argc, char **argv)
{
int sk;
struct sock_fprog p;
#ifdef SOCK_FILTER01
struct sock_filter f[SFLEN] = {
{ 0x6, 0, 0, 0x0000ffff },
{ 0x6, 0, 0, 0x0000ffff },
{ 0x6, 0, 0, 0x0000ffff },
{ 0x6, 0, 0, 0x0000ffff },
};
#else
struct sock_filter f[SFLEN] = {
{ 0x28, 0, 0, 0x0000000c },
{ 0x15, 0, 4, 0x00000800 },
Expand All @@ -37,6 +49,7 @@ int main(int argc, char **argv)
{ 0x6, 0, 0, 0x0000ffff },
{ 0x6, 0, 0, 0x00000000 },
};
#endif
struct sock_filter f2[SFLEN], f3[SFLEN];
socklen_t len;

Expand Down
1 change: 1 addition & 0 deletions test/zdtm/static/sock_filter01.c

0 comments on commit 7b246dc

Please sign in to comment.