Skip to contentSkip to conversation

iptables-save match tos bug-fix

PATCH In review Michael Schwendt 2 participants 2 messages Nov 26, 2002 – Nov 28, 2002 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iptables-save match tos bug-fix

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi everyone!

Here's one more patch for another "missing space in save() function" bug. This time it's the "tos match" userspace extension. An inverted TOS match is not saved correctly, so that iptables-restore would understand it.

The patch is a bit longer because it tidies up save() as used by iptables-save without adding white-space in print() as used by iptables -L.

Michael

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE94txL0iMVcrivHFQRArTjAJ48jzFMAOFDsHU+VIM+J2gF4eawBACghhPi u7pLzmwY1GqFXcfcnxWwxo0=
=6m+o
-----END PGP SIGNATURE-----

Fix save function of tos match.

extensions/libipt_tos.c +11 -8
diff -Naur iptables-1.2.7a-orig/extensions/libipt_tos.c iptables-1.2.7a/extensions/libipt_tos.c
@@ -105,13 +105,10 @@
 }
 
 static void
-print_tos(u_int8_t tos, int invert, int numeric)
+print_tos(u_int8_t tos, int numeric)
 {
 	unsigned int i;
 
-	if (invert)
-		fputc('!', stdout);
-
 	if (!numeric) {
 		for (i = 0; i<sizeof(TOS_values)/sizeof(struct TOS_value); i++)
 			if (TOS_values[i].TOS == tos) {
@@ -137,18 +134,24 @@
       const struct ipt_entry_match *match,
       int numeric)
 {
+	const struct ipt_tos_info *info = (const struct ipt_tos_info *)match->data;
+    
 	printf("TOS match ");
-	print_tos(((struct ipt_tos_info *)match->data)->tos,
-		  ((struct ipt_tos_info *)match->data)->invert, numeric);
+	if (info->invert)
+		printf("!");
+	print_tos(info->tos, numeric);
 }
 
 /* Saves the union ipt_matchinfo in parsable form to stdout. */
 static void
 save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
 {
+	const struct ipt_tos_info *info = (const struct ipt_tos_info *)match->data;
+    
+	if (info->invert)
+		printf("! ");
 	printf("--tos ");
-	print_tos(((struct ipt_tos_info *)match->data)->tos,
-		  ((struct ipt_tos_info *)match->data)->invert, 0);
+	print_tos(info->tos, 0);
 }
 
 static
#1 lore raw
Quoted 9 lines · Michael Schwendt

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi everyone!

Here's one more patch for another "missing space in save() function" bug. This time it's the "tos match" userspace extension. An inverted TOS match is not saved correctly, so that iptables-restore would understand it.

thanks. I'll apply it as soon as I have IP connectivity again.

Quoted 1 line

Michael

Signature · 5 lines
Live long and prosper
- Harald Welte / [email protected]               http://www.gnumonks.org/
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M- 
V-- PS+ PE-- Y+ PGP++ t++ 5-- !X !R tv-- b+++ DI? !D G+ e* h+ r% y+(*)