netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Volkov <pva@gentoo.org>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Netfilter Developer Mailing List <netfilter-devel@vger.kernel.org>
Subject: [patch] iptables-1.4.3.1: unabled to restore proto and iface negated matches
Date: Sat, 04 Apr 2009 14:11:12 +0400	[thread overview]
Message-ID: <1238839872.31963.621.camel@localhost> (raw)
In-Reply-To: <49C8DB3B.909@netfilter.org>


[-- Attachment #1.1: Type: text/plain, Size: 186 bytes --]

Hi. After previous fix I've reviewed sources a bit and found that
protocol and iface negated matches are broken in the same regard. Patch
in attachment fixes them too.

-- 
Peter.

[-- Attachment #1.2: iptables-1.4.3.1-proto-iface-save-restore.patch --]
[-- Type: text/x-patch, Size: 1603 bytes --]

commit a08db349d0be99a8ae8b4ab271489b42735f4404
Author: Peter Volkov <pva@gentoo.org>
Date:   Sat Apr 4 14:07:31 2009 +0400

    Fix restore of negated iface and proto matches
    
    Attemt to restore ruleset with ! -i iface or ! -p proto matches fail
    with the following error:
    
    Using intrapositioned negation (`--option ! this`) is deprecated in
    favor of extrapositioned (`! --option this`).
    
    This patch fixes this issue.

diff --git a/iptables.c b/iptables.c
index fe43ab0..392981f 100644
--- a/iptables.c
+++ b/iptables.c
@@ -1002,22 +1002,22 @@ static void print_proto(u_int16_t proto, int invert)
 {
 	if (proto) {
 		unsigned int i;
-		const char *invertstr = invert ? "! " : "";
+		const char *invertstr = invert ? "!" : "";
 
 		struct protoent *pent = getprotobynumber(proto);
 		if (pent) {
-			printf("-p %s%s ", invertstr, pent->p_name);
+			printf("%s -p %s ", invertstr, pent->p_name);
 			return;
 		}
 
 		for (i = 0; xtables_chain_protos[i].name != NULL; ++i)
 			if (xtables_chain_protos[i].num == proto) {
-				printf("-p %s%s ",
+				printf("%s -p %s ",
 				       invertstr, xtables_chain_protos[i].name);
 				return;
 			}
 
-		printf("-p %s%u ", invertstr, proto);
+		printf("%s -p %u ", invertstr, proto);
 	}
 }
 
@@ -1039,7 +1039,7 @@ print_iface(char letter, const char *iface, const unsigned char *mask,
 	if (mask[0] == 0)
 		return;
 
-	printf("-%c %s", letter, invert ? "! " : "");
+	printf("%s -%c ", invert ? "!" : "", letter);
 
 	for (i = 0; i < IFNAMSIZ; i++) {
 		if (mask[i] != 0) {

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  parent reply	other threads:[~2009-04-04 10:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-24 13:08 [ANNOUNCE]: Release of iptables-1.4.3.1 Pablo Neira Ayuso
2009-03-24 21:12 ` Steven Jan Springl
2009-03-24 21:32   ` Jan Engelhardt
2009-03-25 12:50     ` Pablo Neira Ayuso
2009-03-28 14:17 ` Gabor Z. Papp
2009-04-04  9:50 ` [patch] iptables-1.4.3.1: unabled to restore ! -s 192.168.1.0/24 match Peter Volkov
2009-04-04 11:40   ` Jan Engelhardt
2009-04-05 10:23     ` Pablo Neira Ayuso
2009-04-05 11:41       ` Jan Engelhardt
2009-04-04 10:11 ` Peter Volkov [this message]
2009-04-04 20:00 ` Negation bug Steven Jan Springl
2009-04-04 22:08   ` Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1238839872.31963.621.camel@localhost \
    --to=pva@gentoo.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).