[netfilter-cvslog] r3484 - in trunk: nfsim/core nfsim-testsuite/03NAT

rusty at netfilter.org rusty at netfilter.org
Wed Dec 22 03:47:13 CET 2004


Author: rusty at netfilter.org
Date: 2004-12-22 03:47:13 +0100 (Wed, 22 Dec 2004)
New Revision: 3484

Modified:
   trunk/nfsim-testsuite/03NAT/02natcontrol.sim
   trunk/nfsim/core/message.c
Log:
Add more meaningful errors to strace output.
Use strace output to have more finegrained expectations in 02natcontrol.sim: without it, test never terminates with --failtest because of too many paths.


Modified: trunk/nfsim/core/message.c
===================================================================
--- trunk/nfsim/core/message.c	2004-12-22 02:09:37 UTC (rev 3483)
+++ trunk/nfsim/core/message.c	2004-12-22 02:47:13 UTC (rev 3484)
@@ -202,6 +202,55 @@
 	barf("Unknown %ssocket opt %i", get ? "get" : "set", opt);
 }
 
+static const char *err(int err)
+{
+	static char errstr[50];
+
+	if (err >= 0)
+		sprintf(errstr, "%i", err);
+	else {
+		switch (err) {
+		case -EPERM: strcpy(errstr, "-EPERM"); break;
+		case -ENOENT: strcpy(errstr, "-ENOENT"); break;
+		case -ESRCH: strcpy(errstr, "-ESRCH"); break;
+		case -EINTR: strcpy(errstr, "-EINTR"); break;
+		case -EIO: strcpy(errstr, "-EIO"); break;
+		case -ENXIO: strcpy(errstr, "-ENXIO"); break;
+		case -E2BIG: strcpy(errstr, "-E2BIG"); break;
+		case -ENOEXEC: strcpy(errstr, "-ENOEXEC"); break;
+		case -EBADF: strcpy(errstr, "-EBADF"); break;
+		case -ECHILD: strcpy(errstr, "-ECHILD"); break;
+		case -EAGAIN: strcpy(errstr, "-EAGAIN"); break;
+		case -ENOMEM: strcpy(errstr, "-ENOMEM"); break;
+		case -EACCES: strcpy(errstr, "-EACCES"); break;
+		case -EFAULT: strcpy(errstr, "-EFAULT"); break;
+		case -ENOTBLK: strcpy(errstr, "-ENOTBLK"); break;
+		case -EBUSY: strcpy(errstr, "-EBUSY"); break;
+		case -EEXIST: strcpy(errstr, "-EEXIST"); break;
+		case -EXDEV: strcpy(errstr, "-EXDEV"); break;
+		case -ENODEV: strcpy(errstr, "-ENODEV"); break;
+		case -ENOTDIR: strcpy(errstr, "-ENOTDIR"); break;
+		case -EISDIR: strcpy(errstr, "-EISDIR"); break;
+		case -EINVAL: strcpy(errstr, "-EINVAL"); break;
+		case -ENFILE: strcpy(errstr, "-ENFILE"); break;
+		case -EMFILE: strcpy(errstr, "-EMFILE"); break;
+		case -ENOTTY: strcpy(errstr, "-ENOTTY"); break;
+		case -ETXTBSY: strcpy(errstr, "-ETXTBSY"); break;
+		case -EFBIG: strcpy(errstr, "-EFBIG"); break;
+		case -ENOSPC: strcpy(errstr, "-ENOSPC"); break;
+		case -ESPIPE: strcpy(errstr, "-ESPIPE"); break;
+		case -EROFS: strcpy(errstr, "-EROFS"); break;
+		case -EMLINK: strcpy(errstr, "-EMLINK"); break;
+		case -EPIPE: strcpy(errstr, "-EPIPE"); break;
+		case -EDOM: strcpy(errstr, "-EDOM"); break;
+		case -ERANGE: strcpy(errstr, "-ERANGE"); break;
+		default:
+			barf("Unknown error %i!\n", -err);
+		}
+	}
+	return errstr;
+}
+
 void handle_userspace_message(void)
 {
 	int len;
@@ -230,8 +279,8 @@
 					&msg.args[3]);
 			if (strace)
 				nfsim_log(LOG_ALWAYS,
-					  "    -> %i (len %i)",
-					  msg.retval, msg.args[3]);
+					  "    getsockopt -> %s (len %i)",
+					  err(msg.retval), msg.args[3]);
 			write(sock[0], &msg, sizeof(msg));
 			add_message(true, &msg, 0, NULL);
 			break;
@@ -248,8 +297,8 @@
 					msg.args[1], (char *)msg.args[2],
 					msg.args[3]);
 			if (strace)
-				nfsim_log(LOG_ALWAYS, "    -> %i\n",
-					  msg.retval);
+				nfsim_log(LOG_ALWAYS, "    setsockopt -> %s",
+					  err(msg.retval));
 			write(sock[0], &msg, sizeof(msg));
 			add_message(true, &msg, 0, NULL);
 			break;

Modified: trunk/nfsim-testsuite/03NAT/02natcontrol.sim
===================================================================
--- trunk/nfsim-testsuite/03NAT/02natcontrol.sim	2004-12-22 02:09:37 UTC (rev 3483)
+++ trunk/nfsim-testsuite/03NAT/02natcontrol.sim	2004-12-22 02:47:13 UTC (rev 3484)
@@ -2,42 +2,50 @@
 
 # Test various NAT admin things.
 
+# NAT table only has PREROUTING, OUTPUT and POSTROUTING chains
+iptables -t nat -A PREROUTING -j ACCEPT
+iptables -t nat -A OUTPUT -j ACCEPT
+iptables -t nat -A POSTROUTING -j ACCEPT
+expect iptables iptables: command failed
+expect iptables iptables: No chain/target/match by that name
+iptables -t nat -A FORWARD -j ACCEPT
+expect iptables iptables: command failed
+expect iptables iptables: No chain/target/match by that name
+iptables -t nat -A INPUT -j ACCEPT
+iptables -t nat -F
+
 # DNAT only on PREROUTING or OUTPUT
-iptables -t nat -A PREROUTING -i eth0 -j DNAT --to-dest 192.168.1.3
-iptables -t nat -A OUTPUT -o eth0 -j DNAT --to-dest 192.168.1.3
+iptables -t nat -A PREROUTING -j DNAT --to-dest 192.168.1.3
+iptables -t nat -A OUTPUT -j DNAT --to-dest 192.168.1.3
 
+# Expect -EINVAL from DNAT checkentry.
+strace
+expect iptables setsockopt -> -EINVAL
 expect iptables iptables: command failed
-iptables -t nat -A INPUT -i eth0 -j DNAT --to-dest 192.168.1.3
-expect iptables iptables: command failed
-iptables -t nat -A FORWARD -i eth0 -j DNAT --to-dest 192.168.1.3
-expect iptables iptables: command failed
-iptables -t nat -A POSTROUTING -o eth0 -j DNAT --to-dest 192.168.1.3
+iptables -t nat -A POSTROUTING -j DNAT --to-dest 192.168.1.3
+strace off
 
 # No DNAT without --to-destination arg.
 expect iptables iptables: command failed
-iptables -t nat -A PREROUTING -i eth0 -j DNAT
+expect iptables *--to-destination*
+iptables -t nat -A PREROUTING -j DNAT
 
-# No -o for PREROUTING
-expect iptables iptables: command failed
-iptables -t nat -A PREROUTING -o eth0 -j DNAT
+# SNAT only on POSTROUTING
+iptables -t nat -A POSTROUTING -j SNAT --to-source 192.168.1.3
 
-# SNAT only on POSTROUTING
-iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 192.168.1.3
+# Expect -EINVAL from SNAT checkentry.
+strace
+expect iptables setsockopt -> -EINVAL
 expect iptables iptables: command failed
-iptables -t nat -A OUTPUT -i eth0 -j SNAT --to-source 192.168.1.3
+iptables -t nat -A PREROUTING -j SNAT --to-source 192.168.1.3
+expect iptables setsockopt -> -EINVAL
 expect iptables iptables: command failed
-iptables -t nat -A INPUT -i eth0 -j SNAT --to-source 192.168.1.3
-expect iptables iptables: command failed
-iptables -t nat -A FORWARD -i eth0 -j SNAT --to-source 192.168.1.3
-expect iptables iptables: command failed
-iptables -t nat -A PREROUTING -i eth0 -j SNAT --to-source 192.168.1.3
+iptables -t nat -A OUTPUT -j SNAT --to-source 192.168.1.3
+strace off
 
 # No SNAT without --to-source arg.
 expect iptables iptables: command failed
-iptables -t nat -A PREROUTING -i eth0 -j SNAT
+expect iptables *--to-source*
+iptables -t nat -A POSTROUTING -j SNAT
 
-# No -i for POSTROUTING.
-expect iptables iptables: command failed
-iptables -t nat -A POSTROUTING -i eth0 -j SNAT --to-source 192.168.0.3
-
 iptables -t nat -F




More information about the netfilter-cvslog mailing list