Skip to contentSkip to conversation

nfsim - netfilter simulation environment

ANNOUNCE Jeremy Kerr 3 participants 5 messages Jan 7, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hi all,

Rusty and I have been working on a simulation enviroment ("nfsim") to facilitate netfilter testing. It provides a simulated kernel enviroment to build and run netfilter code in userspace, and a command-line interface to conduct tests.

nfsim is available from:

http://ozlabs.org/~jk/projects/nfsim/

Have a look through the testsuite directory file for an example of a testing script. Also, inline help is available from the CLI.

Contributions & comments are most welcome.

Jeremy

#1 lore raw

Hello,
A very nice idea & work indeed. But when i tried to
build the only available snapshot, i got these errors:

[zak@zeenix nfsim]$ make
awk 'BEGIN { FS="=" } /[A-Z0-9_]=(.*)/ { print "#define "$1" "$2; }' < .config > kernelenv/include/linux/config.h doc/gen-help core/tui.c > core/tui.c.helped.c
warning: failed to load external entity "doc/link-xhtml/xhtml/docbook.xsl" compilation error: file doc/xhtml.xsl line 8 element import
xsl:import : unable to load doc/link-xhtml/xhtml/docbook.xsl
-:1: error: Document is empty

^
-:1: error: Start tag expected, '<' not found

^
doc/gen-help: line 20: links: command not found
warning: failed to load external entity "doc/link-xhtml/xhtml/docbook.xsl" compilation error: file doc/xhtml.xsl line 8 element import
xsl:import : unable to load doc/link-xhtml/xhtml/docbook.xsl
-:1: error: Document is empty

^
-:1: error: Start tag expected, '<' not found

^
doc/gen-help: line 20: links: command not found gcc -Wstrict-prototypes -Wunused -Wall -g -ggdb -Wa,-W -I. -I/home/zak/downloads/nfsim/core -I/home/zak/downloads/nfsim/kernelenv/include -I/home/zak/downloads/nfsim/netfilter/include -c -o core/tui.o core/tui.c.helped.c core/tui.c.helped.c: In function `tui_help_help':
core/tui.c.helped.c:128: parse error before ')' token core/tui.c.helped.c: In function `tui_exit_help':
core/tui.c.helped.c:148: parse error before ')' token
make: *** [core/tui.o] Error 1

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

#2 lore raw

Hi there,

Quoted 2 lines

xsl:import : unable to load
doc/link-xhtml/xhtml/docbook.xsl

Looks like you don't have the doc/link-xhtml symlink set up correctly (which is required to process the help functions for each file). Depending on which distribution you're using, you'll need to manually create the links. On my system, they are:

doc/link-dtd -> /usr/share/sgml/docbook/xml-dtd-4.2-1.0-17 doc/link-xhtml -> /usr/share/sgml/docbook/xsl-stylesheets

The link-xhtml symlink is the important one, and it needs the xhtml/docbook.xsl file within - which is provided (on Redhat) by the docbook-style-xsl package or (on Debian) docbook-xsl

If you find the proper place for the link, let me know and I'll add autodetection to the Makefile.

Jeremy

#3 lore raw
In reply to Jeremy Kerr
Quoted 6 lines · Jeremy Kerr

Hi all,

Rusty and I have been working on a simulation enviroment ("nfsim") to facilitate netfilter testing. It provides a simulated kernel enviroment to build and run netfilter code in userspace, and a command-line interface to conduct tests.

Wee, this is cool. I've been thinking about building something to run tests in userspace, now I don't have to :)
And this is way more elegant than I would ever have made it.

Quoted 8 lines

nfsim is available from:

http://ozlabs.org/~jk/projects/nfsim/

Have a look through the testsuite directory file for an example of a testing script. Also, inline help is available from the CLI.

Contributions & comments are most welcome.

Will give it a testspin.

Signature · 1 line
/Martin
#4 lore raw
Quoted 3 lines · Martin Josefsson
Quoted 1 line

Contributions & comments are most welcome.

Will give it a testspin.

Hi again, now I've given it a small initial testdrive and I've found a small bug.

Here's a small patch to fix select() handling in
core/message.c:wait_for_message()

The fdset is undefined when select() returns -1.
Rerun select() when that happens and errno is something retryable.

Without this all iptables commands that uses sockets hang the simulator when message_client_connection() is called for sockfd but there isn't any data available.

core/message.c renamed from core/message.c.orig +8 -1
@@ -184,6 +184,7 @@
 void wait_for_message(int extra_fd)
 {
 	fd_set fdset;
+	int retry = 0;
 
 	do {
 		int maxfd, sret;
@@ -194,8 +195,14 @@
 
 		maxfd = max(extra_fd, sockfd);
 		sret = select(maxfd + 1, &fdset, NULL, NULL, NULL);
-		if (sret < 0 && errno != EINTR)
+		if (sret < 0) {
+			if (errno == EINTR || errno == EAGAIN) {
+				if (++retry > 3)
+					barf_perror("too many retries");
+				continue;
+			}
 			barf_perror("select");
+		}
 
 		if (FD_ISSET(sockfd, &fdset))
 			message_client_connection(sockfd);
Signature · 1 line
/Martin