Skip to contentSkip to conversation

the same options for different kinds of matches don't work

IPTABLES Changli Gao 4 participants 19 messages Aug 15, 2008 – Aug 16, 2008 netfilter

lore
Share & tools
lore
#0 lore raw

When using iptables to extent the firewall of Linux, I found that: if there are more than one kinds of iptables matches, only the former options are parsed correctly, but the later options will be treated wrongly.

For example:

iptables -t mangle -A PREROUTING -m a --mac-source 00:11:22:33:44:55 -m b --mac-source 00:11:22:33:44:55 -j ACCEPT

the above command will fail due to the later match.

Then I checked the source code of iptables. It seems that the extra options for each match are global for each individual command. It is out of my exception. I used to think that options are only available for that match. So I "fixed" this issues quickly. After patching, the command options contain the default global options and the last match or the target extra options.

The following is the patch for this issue against iptables-1.3.8. Yea, it is only for iptables, but not for ip6tables, as I don't know if I am right or not.

include/iptables.h +0 -4
diff -ur iptables-1.3.8/include/iptables.h iptables-1.3.8.new/include/iptables.h
@@ -35,10 +35,6 @@
 	struct iptables_rule_match *next;
 
 	struct iptables_match *match;
-
-	/* Multiple matches of the same type: the ones before
-	   the current one are completed from parsing point of view */	
-	unsigned int completed;
 };
 
 /* Include file for additions: new matches and targets. */
iptables.c +10 -17
diff -ur iptables-1.3.8/iptables.c iptables-1.3.8.new/iptables.c
@@ -793,12 +793,9 @@
 
 		newentry = fw_malloc(sizeof(struct iptables_rule_match));
 
-		for (i = matches; *i; i = &(*i)->next) {
-			if (strcmp(name, (*i)->match->name) == 0)
-				(*i)->completed = 1;
-		}
+		for (i = matches; *i; i = &(*i)->next)
+			/* do nothing */;
 		newentry->match = ptr;
-		newentry->completed = 0;
 		newentry->next = NULL;
 		*i = newentry;
 	}
@@ -2182,6 +2179,7 @@
 					     target->revision);
 				if (target->init != NULL)
 					target->init(target->t, &fw.nfcache);
+				free_opts(1);
 				opts = merge_options(opts, target->extra_opts, &target->option_offset);
 			}
 			break;
@@ -2234,9 +2232,8 @@
 			set_revision(m->m->u.user.name, m->revision);
 			if (m->init != NULL)
 				m->init(m->m, &fw.nfcache);
-			if (m != m->next)
-				/* Merge options for non-cloned matches */
-				opts = merge_options(opts, m->extra_opts, &m->option_offset);
+			free_opts(1);
+			opts = merge_options(opts, m->extra_opts, &m->option_offset);
 		}
 		break;
 
@@ -2319,18 +2316,13 @@
 					       argv, invert,
 					       &target->tflags,
 					       &fw, &target->t))) {
-				for (matchp = matches; matchp; matchp = matchp->next) {
-					if (matchp->completed)
-						continue;
-					if (matchp->match->parse(c - matchp->match->option_offset,
+				if (m && !m->parse(c - m->option_offset,
 						     argv, invert,
-						     &matchp->match->mflags,
+						     &m->mflags,
 						     &fw,
 						     &fw.nfcache,
-						     &matchp->match->m))
-						break;
-				}
-				m = matchp ? matchp->match : NULL;
+						     &m->m))
+					m = NULL;
 
 				/* If you listen carefully, you can
 				   actually hear this code suck. */
@@ -2381,6 +2373,7 @@
 					if (m->init != NULL)
 						m->init(m->m, &fw.nfcache);
 
+					free_opts(1);
 					opts = merge_options(opts,
 					    m->extra_opts, &m->option_offset);
 
Signature · 2 lines
Regards,
Changli Gao([email protected])
#1 lore raw

Hi,

Quoted 11 lines · Changli Gao

When using iptables to extent the firewall of Linux, I found that: if there are more than one kinds of iptables matches, only the former options are parsed correctly, but the later options will be treated wrongly.

For example:

iptables -t mangle -A PREROUTING -m a --mac-source 00:11:22:33:44:55 -m b --mac-source 00:11:22:33:44:55 -j ACCEPT

the above command will fail due to the later match.

Yes: you should use match-specific options, like

iptables -t mangle -A PREROUTING -m a --a-mac-source 00:11:22:33:44:55 -m b --b-mac-source 00:11:22:33:44:55 -j ACCEPT

Quoted 6 lines

Then I checked the source code of iptables. It seems that the extra options for each match are global for each individual command. It is out of my exception. I used to think that options are only available for that match. So I "fixed" this issues quickly. After patching, the command options contain the default global options and the last match or the target extra options.

With your patch applied we'd loose supporting multiple matches of the same type.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#2 lore raw
Quoted 11 lines · Jozsef Kadlecsik
Quoted 6 lines

For example:

iptables -t mangle -A PREROUTING -m a --mac-source 00:11:22:33:44:55 -m b --mac-source 00:11:22:33:44:55 -j ACCEPT

the above command will fail due to the later match.

Yes: you should use match-specific options, like

iptables -t mangle -A PREROUTING -m a --a-mac-source 00:11:22:33:44:55 -m b --b-mac-source 00:11:22:33:44:55 -j ACCEPT

I disagree. If you chain multiple matches, e.g.

-m condition --name FOO -m conidtion --name BAR

you can't choose a different option name naturally. Hence I am of the opinion that different matches should also support this syntax.

#3 lore raw
Quoted 10 lines · Jan Engelhardt
Quoted 9 lines · Jozsef Kadlecsik
Quoted 6 lines

For example:

iptables -t mangle -A PREROUTING -m a --mac-source 00:11:22:33:44:55 -m b --mac-source 00:11:22:33:44:55 -j ACCEPT

the above command will fail due to the later match.

Yes: you should use match-specific options, like

Quoted 8 lines
Quoted 2 lines

iptables -t mangle -A PREROUTING -m a --a-mac-source 00:11:22:33:44:55 -m b --b-mac-source 00:11:22:33:44:55 -j ACCEPT

I disagree. If you chain multiple matches, e.g.

-m condition --name FOO -m conidtion --name BAR

you can't choose a different option name naturally.

And you don't choose - why should you? The (not-mistyped) example above *is* supported by iptables. With the suggested patch we'd loose it. And currently we do not enforce that match options let be strictly packed together, i.e. you can type

-m foo -m bar --foo-option --bar-option

Quoted 2 lines

Hence I am of the opinion that different matches should also support this syntax.

Why should different matches use the same syntax? Would it make the rules more readable and less error prone if the same option names could be used at different kind of matches? Of course not. So in my opinion the feature would not buy us anything but could lead to confusion, not to mention loosing a valuable feature and breaking backward compatibility. Therefore I'm against it.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#4 lore raw
In reply to Jozsef Kadlecsik
Quoted 10 lines · Jozsef Kadlecsik
Quoted 6 lines

Then I checked the source code of iptables. It seems that the extra options for each match are global for each individual command. It is out of my exception. I used to think that options are only available for that match. So I "fixed" this issues quickly. After patching, the command options contain the default global options and the last match or the target extra options.

With your patch applied we'd loose supporting multiple matches of the same type.

No we don't loose that function. Look at this example:

iptables -t mangle -A PREROUTING --match a --mac-source
00:11:22:33:44:55 --match a --mac-source 00:11:22:33:44:55 -j ACCEPT
a: 0x60e5e0
a: 0x60eb10

a and b are both the modified match mac. To identify them, I output their name and option address in their match function. As you see, it works well without any error.

        switch (c) {
        case '1':
                printf("a: %p\n", macinfo);
Signature · 2 lines
Regards,
Changli Gao([email protected])
#5 lore raw
Quoted 6 lines · Changli Gao

On Sat, Aug 16, 2008 at 3:31 AM, Jozsef Kadlecsik

Quoted 3 lines

With your patch applied we'd loose supporting multiple matches of the same type.

No we don't loose that function. Look at this example:

Yes, you are right: it seems it was too late yesterday for mental patching, compiling and testing ;-).

Still, with your patch we'd break backward compatibility by making mandatory for match options to strictly follow '-m matchname'.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#6 lore raw
Quoted 7 lines · Jozsef Kadlecsik
Quoted 5 lines · Changli Gao

On Sat, Aug 16, 2008 at 3:31 AM, Jozsef Kadlecsik

Quoted 3 lines

With your patch applied we'd loose supporting multiple matches of the same type.

Quoted 8 lines
Quoted 1 line

No we don't loose that function. Look at this example:

Yes, you are right: it seems it was too late yesterday for mental patching, compiling and testing ;-).

Still, with your patch we'd break backward compatibility by making mandatory for match options to strictly follow '-m matchname'.

Yea, but the question is is there anyone know and relay this feature? And is using this feature is encouraged?

BTW: how about this idea to avoid calling the function parse for the options not for it:

iptables.c 2008-08-16 19:44:11.000000000 +0800 renamed from iptables.c 2007-04-30 07:03:30.000000000 +0800 +0 -0
@@ -2322,6 +2322,10 @@
                                for (matchp = matches; matchp; matchp
= matchp->next) {
                                        if (matchp->completed)
                                                continue;
+                                       if (c < matchp->match->option_offset ||
+                                           c >= matchp->match->option_offset +
+                                                OPTION_OFFSET)
+                                               continue;
                                        if (matchp->match->parse(c -
matchp->match->option_offset,
                                                     argv, invert,
                                                     &matchp->match->mflags,
Signature · 2 lines
Regards,
Changli Gao([email protected])
#7 lore raw
In reply to Changli Gao
Quoted 10 lines · Changli Gao

When using iptables to extent the firewall of Linux, I found that: if there are more than one kinds of iptables matches, only the former options are parsed correctly, but the later options will be treated wrongly.

For example:

iptables -t mangle -A PREROUTING -m a --mac-source 00:11:22:33:44:55 -m b --mac-source 00:11:22:33:44:55 -j ACCEPT

Quoted 8 lines

the above command will fail due to the later match.

Then I checked the source code of iptables. It seems that the extra options for each match are global for each individual command. It is out of my exception. I used to think that options are only available for that match. So I "fixed" this issues quickly. After patching, the command options contain the default global options and the last match or the target extra options.

I see, it's worth to know this issue. However, my main objection with this patch is: is there any match in iptables mainline that actually uses two options with clashing names?

Signature · 1 line
"Los honestos son inadaptados sociales" -- Les Luthiers
#8 lore raw
Quoted 3 lines · Pablo Neira Ayuso

I see, it's worth to know this issue. However, my main objection with this patch is: is there any match in iptables mainline that actually uses two options with clashing names?

In mainline, no. Otherwise - as far as I know - there's a single clash between '-m recent --set' and '-m set --set'. The latter should definitely be '-m set --match-set' and is my fault.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#9 lore raw
In reply to Pablo Neira Ayuso
Quoted 20 lines · Pablo Neira Ayuso
Quoted 10 lines · Changli Gao

When using iptables to extent the firewall of Linux, I found that: if there are more than one kinds of iptables matches, only the former options are parsed correctly, but the later options will be treated wrongly.

For example:

iptables -t mangle -A PREROUTING -m a --mac-source 00:11:22:33:44:55 -m b --mac-source 00:11:22:33:44:55 -j ACCEPT

Quoted 8 lines

the above command will fail due to the later match.

Then I checked the source code of iptables. It seems that the extra options for each match are global for each individual command. It is out of my exception. I used to think that options are only available for that match. So I "fixed" this issues quickly. After patching, the command options contain the default global options and the last match or the target extra options.

Quoted 3 lines

I see, it's worth to know this issue. However, my main objection with this patch is: is there any match in iptables mainline that actually uses two options with clashing names?

- mark, connmark, realm
- ecn and ECN
- multiport and tcp/udp/sctp/dccp.

(There was a reason to my post after all ;-)

#10 lore raw
Quoted 6 lines · Jan Engelhardt
Quoted 3 lines · Pablo Neira Ayuso

I see, it's worth to know this issue. However, my main objection with this patch is: is there any match in iptables mainline that actually uses two options with clashing names?

- mark, connmark, realm

mark and connmark do clash, so I was wrong in my previous reply about non-clashing in mainline. There might be cases when one would want to check the mark value of a packet and a conntrack entry, which is currently not possible in a single rule due to the clashing option name.

Reading the manpage, realm does not clash with either mark or connmark.

Quoted 1 line

- ecn and ECN

The options of the ecn match and the ECN target are not clashing.

Quoted 1 line

- multiport and tcp/udp/sctp/dccp.

They are ortogonal.

Quoted 1 line

(There was a reason to my post after all ;-)

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#11 lore raw
Quoted 2 lines · Jozsef Kadlecsik

Reading the manpage, realm does not clash with either mark or connmark.

Right you are. My grep-fu turned up wrong comments! (See libxt_realm.c for --mark!)

Quoted 3 lines
Quoted 1 line

- ecn and ECN

The options of the ecn match and the ECN target are not clashing.

They do. Both libipt_ecn.c and libipt_ECN.c have --ecn-ip-ect, --ecn-tcp-cwr and --ecn-tcp-ece even if they are not documented (what, more of these? Patch follows).

#12 lore raw
Quoted 9 lines · Jan Engelhardt
Quoted 3 lines · Jozsef Kadlecsik
Quoted 1 line

- ecn and ECN

The options of the ecn match and the ECN target are not clashing.

They do. Both libipt_ecn.c and libipt_ECN.c have --ecn-ip-ect, --ecn-tcp-cwr and --ecn-tcp-ece even if they are not documented (what, more of these? Patch follows).

Non-documented options do not exist ;-) - so updates are highly welcomed.

But as the ECN options has not been documented so far, I think it'd be better to rename them at the same time to something like

--ecn-tcp-cwr-remove
--ecn-tcp-ece-remove
--ecn-ip-ect-set

and clashing with the ecn options were resolved.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
#13 lore raw
Quoted 14 lines · Jozsef Kadlecsik
Quoted 9 lines · Jan Engelhardt
Quoted 3 lines · Jozsef Kadlecsik
Quoted 1 line

- ecn and ECN

The options of the ecn match and the ECN target are not clashing.

They do. Both libipt_ecn.c and libipt_ECN.c have --ecn-ip-ect, --ecn-tcp-cwr and --ecn-tcp-ece even if they are not documented (what, more of these? Patch follows).

Non-documented options do not exist ;-) - so updates are highly welcomed.

Quoted 8 lines

But as the ECN options has not been documented so far, I think it'd be better to rename them at the same time to something like

--ecn-tcp-cwr-remove
--ecn-tcp-ece-remove
--ecn-ip-ect-set

and clashing with the ecn options were resolved.

It sounds a good idae. But in order to avoid clashing, we'd better change all the options for all matches in this way:

match: foo
match-options: --foo-bar

I don't mean that some maches share the same options is encouraged, but I don't think it lose readable, as I think most of people will think the long options after a "-m" option until another match appears with the leading "-m" are all for this corresponding match. Global option naming space allow commands like this:

iptables ... -m a --a-option-1 -m b --b-option-1 --a-option-2

Oh, I think it make the command unreadable, and we should not allow it happen.

I encountered this issue when I debugging a match. Its parse function is like this:

parse(...)

{
        if (*flags)
                error...;
        switch (c) {
        case 'a':
                ....
                break;
        default:
                return 0;
        }
       *flags = 1;

        return 1;
}

it will fail if there is another kinds of match after it, as all the options not belong to it are parsed to its parse function. I think it is the reason why default branch in switch exists. I make things a little different from my original thought.

When writting this, I get another idea to solve this. Before calling the parse function, we should check if c is in the option range with one line code:

c > m->option_offset && c < m->option_offset + OPTION_OFFSET

Signature · 2 lines
Regards,
Changli Gao([email protected])
#14 lore raw
Quoted 16 lines · Changli Gao
Quoted 2 lines · Jozsef Kadlecsik

On Fri, 15 Aug 2008, Jan Engelhardt wrote:

It sounds a good idae. But in order to avoid clashing, we'd better change all the options for all matches in this way:

match: foo
match-options: --foo-bar

I don't mean that some maches share the same options is encouraged, but I don't think it lose readable, as I think most of people will think the long options after a "-m" option until another match appears with the leading "-m" are all for this corresponding match. Global option naming space allow commands like this:

Quoted 3 lines

iptables ... -m a --a-option-1 -m b --b-option-1 --a-option-2

Oh, I think it make the command unreadable, and we should not allow it happen.

As I see it, -m enables a new set of options and brings them in top priority, possibly overriding older ones. And because matches don't get printed in whacky option order when running iptables-save or similar, I see nothing wrong with keeping it that way and go on sometimes having same --names for different -m. It's kinda redundant to give --set-mark with -j MARK, because eh well obviously it will set the mark in some way, it could have just been -j MARK --mark 17.

Quoted 19 lines

I encountered this issue when I debugging a match. Its parse function is like this:

parse(...)

{
       if (*flags)
               error...;
       switch (c) {
       case 'a':
               ....
               break;
       default:
               return 0;
       }
      *flags = 1;

       return 1;
}
Quoted 4 lines

it will fail if there is another kinds of match after it, as all the options not belong to it are parsed to its parse function. I think it is the reason why default branch in switch exists. I make things a little different from my original thought.

Why should it fail?
Once you gave -m secondmatch, you OBVIOUSLY want options from the second one, and rarely from the first.

Quoted 5 lines

When writting this, I get another idea to solve this. Before calling the parse function, we should check if c is in the option range with one line code:

c > m->option_offset && c < m->option_offset + OPTION_OFFSET

Just how the hell is that supposed to work.

#15 lore raw
Quoted 20 lines · Jan Engelhardt
Quoted 20 lines

I encountered this issue when I debugging a match. Its parse function is like this:

parse(...)

{
       if (*flags)
               error...;
       switch (c) {
       case 'a':
               ....
               break;
       default:
               return 0;
       }
      *flags = 1;

       return 1;
}
Quoted 9 lines
Quoted 4 lines

it will fail if there is another kinds of match after it, as all the options not belong to it are parsed to its parse function. I think it is the reason why default branch in switch exists. I make things a little different from my original thought.

Why should it fail?
Once you gave -m secondmatch, you OBVIOUSLY want options from the second one, and rarely from the first.

The match mentioned above applies one option only. When the option is got, *flags will be set to 1, to avoid being set second time. Before checking c, I check the value of *flags first, if it is set, report an error and exit directly. However, if there is another kind of match after it, iptables will pass the new options to every matches one by one until one eats it. When the parse function gets a option doesn't belong to it, it finds *flags is set, then error is reported.

                                for (matchp = matches; matchp; matchp = matchp->
next) {
                                        if (matchp->completed)
                                                continue;
                                        if (matchp->match->parse(c - matchp->mat
ch->option_offset,
                                                     argv, invert,
                                                     &matchp->match->mflags,
                                                     &fw,
                                                     &fw.nfcache,
                                                     &matchp->match->m))
                                                break;
                                }
Signature · 2 lines
Regards,
Changli Gao([email protected])
#16 lore raw
In reply to Changli Gao
Quoted 7 lines · Changli Gao
Quoted 7 lines

But as the ECN options has not been documented so far, I think it'd be better to rename them at the same time to something like

--ecn-tcp-cwr-remove
--ecn-tcp-ece-remove
--ecn-ip-ect-set

Quoted 7 lines
Quoted 1 line

and clashing with the ecn options were resolved.

It sounds a good idae. But in order to avoid clashing, we'd better change all the options for all matches in this way:

match: foo
match-options: --foo-bar

I think changing the existing clashing option names (with keeping the old ones for backward compatibility) is just enough - we can use the "rule" above for future new matches.

The patch below implements what I suggest:

---
 extensions/libipt_ECN.c       |   24 ++++++++++++------------
 extensions/libipt_realm.c     |    2 +-
 extensions/libipt_set.c       |   19 +++++++++++--------
 extensions/libipt_set.man     |    3 ++-
 extensions/libxt_connmark.c   |   27 ++++++++++++++++-----------
 extensions/libxt_connmark.man |    3 ++-
 6 files changed, 44 insertions(+), 34 deletions(-)
extensions/libipt_ECN.c +12 -12
index 9526c37..b455b1d 100644
@@ -26,17 +26,17 @@ static void ECN_help(void)
 
 #if 0
 "ECN target v%s EXPERIMENTAL options (use with extreme care!)\n"
-"  --ecn-ip-ect			Set the IPv4 ECT codepoint (0 to 3)\n"
-"  --ecn-tcp-cwr		Set the IPv4 CWR bit (0 or 1)\n"
-"  --ecn-tcp-ece		Set the IPv4 ECE bit (0 or 1)\n",
+"  --ecn-ip-ect-set		Set the IPv4 ECT codepoint (0 to 3)\n"
+"  --ecn-tcp-cwr-set		Set the IPv4 CWR bit (0 or 1)\n"
+"  --ecn-tcp-ece-set		Set the IPv4 ECE bit (0 or 1)\n",
 #endif
 
 
 static const struct option ECN_opts[] = {
 	{ "ecn-tcp-remove", 0, NULL, 'F' },
-	{ "ecn-tcp-cwr", 1, NULL, 'G' },
-	{ "ecn-tcp-ece", 1, NULL, 'H' },
-	{ "ecn-ip-ect", 1, NULL, '9' },
+	{ "ecn-tcp-cwr-set", 1, NULL, 'G' },
+	{ "ecn-tcp-ece-set", 1, NULL, 'H' },
+	{ "ecn-ip-ect-set", 1, NULL, '9' },
 	{ .name = NULL }
 };
 
@@ -60,7 +60,7 @@ static int ECN_parse(int c, char **argv, int invert, unsigned int *flags,
 	case 'G':
 		if (*flags & IPT_ECN_OP_SET_CWR)
 			exit_error(PARAMETER_PROBLEM,
-				"ECN target: Only use --ecn-tcp-cwr ONCE!");
+				"ECN target: Only use --ecn-tcp-cwr-set ONCE!");
 		if (string_to_number(optarg, 0, 1, &result))
 			exit_error(PARAMETER_PROBLEM,
 				   "ECN target: Value out of range");
@@ -71,7 +71,7 @@ static int ECN_parse(int c, char **argv, int invert, unsigned int *flags,
 	case 'H':
 		if (*flags & IPT_ECN_OP_SET_ECE)
 			exit_error(PARAMETER_PROBLEM,
-				"ECN target: Only use --ecn-tcp-ece ONCE!");
+				"ECN target: Only use --ecn-tcp-ece-set ONCE!");
 		if (string_to_number(optarg, 0, 1, &result))
 			exit_error(PARAMETER_PROBLEM,
 				   "ECN target: Value out of range");
@@ -82,7 +82,7 @@ static int ECN_parse(int c, char **argv, int invert, unsigned int *flags,
 	case '9':
 		if (*flags & IPT_ECN_OP_SET_IP)
 			exit_error(PARAMETER_PROBLEM,
-				"ECN target: Only use --ecn-ip-ect ONCE!");
+				"ECN target: Only use --ecn-ip-ect-set ONCE!");
 		if (string_to_number(optarg, 0, 3, &result))
 			exit_error(PARAMETER_PROBLEM,
 				   "ECN target: Value out of range");
@@ -142,13 +142,13 @@ static void ECN_save(const void *ip, const struct xt_entry_target *target)
 	else {
 
 		if (einfo->operation & IPT_ECN_OP_SET_ECE)
-			printf("--ecn-tcp-ece %d ", einfo->proto.tcp.ece);
+			printf("--ecn-tcp-ece-set %d ", einfo->proto.tcp.ece);
 
 		if (einfo->operation & IPT_ECN_OP_SET_CWR)
-			printf("--ecn-tcp-cwr %d ", einfo->proto.tcp.cwr);
+			printf("--ecn-tcp-cwr-set %d ", einfo->proto.tcp.cwr);
 
 		if (einfo->operation & IPT_ECN_OP_SET_IP)
-			printf("--ecn-ip-ect %d ", einfo->ip_ect);
+			printf("--ecn-ip-ect-set %d ", einfo->ip_ect);
 	}
 }
 
extensions/libipt_realm.c +1 -1
index 1e7f690..e7ce065 100644
@@ -234,7 +234,7 @@ static void realm_save(const void *ip, const struct xt_entry_match *match)
 	print_realm(ri->id, ri->mask, 0);
 }
 
-/* Final check; must have specified --mark. */
+/* Final check; must have specified --realm. */
 static void realm_check(unsigned int flags)
 {
 	if (!flags)
extensions/libipt_set.c +11 -8
index 759bca3..d90b3a7 100644
@@ -25,14 +25,15 @@
 static void set_help(void)
 {
 	printf("set match options:\n"
-	       " [!] --set     name flags\n"
+	       " [!] --match-set name flags\n"
 	       "		'name' is the set name from to match,\n" 
 	       "		'flags' are the comma separated list of\n"
 	       "		'src' and 'dst'.\n");
 }
 
 static const struct option set_opts[] = {
-	{"set", 1, NULL, '1'},
+	{"match-set", 1, NULL, '1'},
+	{"set", 1, NULL, '2'}, /* Backward compatibility */
 	{ }
 };
 
@@ -56,10 +57,12 @@ static int set_parse(int c, char **argv, int invert, unsigned int *flags,
 	struct ipt_set_info *info = &myinfo->match_set;
 
 	switch (c) {
-	case '1':		/* --set <set> <flag>[,<flag> */
+	case '2': /* --set <set> <flag>[,<flag> */
+		fprintf(stderr, "Option name changed from --set to --match-set. Update your command to suppress this warning!\n");
+	case '1':		/* --match-set <set> <flag>[,<flag> */
 		if (info->flags[0])
 			exit_error(PARAMETER_PROBLEM,
-				   "--set can be specified only once");
+				   "--match-set can be specified only once");
 
 		check_inverse(optarg, &invert, &optind, 0);
 		if (invert)
@@ -69,7 +72,7 @@ static int set_parse(int c, char **argv, int invert, unsigned int *flags,
 		    || argv[optind][0] == '-'
 		    || argv[optind][0] == '!')
 			exit_error(PARAMETER_PROBLEM,
-				   "--set requires two args.");
+				   "--match-set requires two args.");
 
 		if (strlen(argv[optind-1]) > IP_SET_MAXNAMELEN - 1)
 			exit_error(PARAMETER_PROBLEM,
@@ -91,12 +94,12 @@ static int set_parse(int c, char **argv, int invert, unsigned int *flags,
 	return 1;
 }
 
-/* Final check; must have specified --set. */
+/* Final check; must have specified --match-set. */
 static void set_check(unsigned int flags)
 {
 	if (!flags)
 		exit_error(PARAMETER_PROBLEM,
-			   "You must specify `--set' with proper arguments");
+			   "You must specify `--match-set' with proper arguments");
 	DEBUGP("final check OK\n");
 }
 
@@ -137,7 +140,7 @@ static void set_save(const void *ip, const struct xt_entry_match *match)
 	struct ipt_set_info_match *info = 
 		(struct ipt_set_info_match *) match->data;
 
-	print_match("--set", &info->match_set);
+	print_match("--match-set", &info->match_set);
 }
 
 static struct xtables_match set_mt_reg = {
extensions/libipt_set.man +2 -1
index c8ff601..7833930 100644
@@ -1,6 +1,6 @@
 This modules macthes IP sets which can be defined by ipset(8).
 .TP
-[\fB!\fP] \fB--set\fP \fIsetname\fP \fIflag\fP[\fB,\fP\fIflag\fP]...
+[\fB!\fP] \fB--match-set\fP \fIsetname\fP \fIflag\fP[\fB,\fP\fIflag\fP]...
 where flags are
 .BR "src"
 and/or
@@ -15,3 +15,4 @@ there is a binding belonging to the mached set element or there is a default
 binding for the given set, then the rule will match the packet only if 
 additionally (depending on the type of the set) the destination address or 
 port number of the packet can be found in the set according to the binding.
+(Old option name \fB--set\fR is still supported.)
extensions/libxt_connmark.c +16 -11
index eb4060e..2bbc3ef 100644
@@ -36,11 +36,12 @@ static void connmark_mt_help(void)
 {
 	printf(
 "connmark match options:\n"
-"[!] --mark value[/mask]    Match ctmark value with optional mask\n");
+"[!] --connmark value[/mask]    Match ctmark value with optional mask\n");
 }
 
 static const struct option connmark_mt_opts[] = {
-	{.name = "mark", .has_arg = true, .val = '1'},
+	{.name = "connmark", .has_arg = true, .val = '1'},
+	{.name = "mark", .has_arg = true, .val = '2'}, /* Backward compatibility */
 	{ .name = NULL }
 };
 
@@ -53,15 +54,17 @@ connmark_mt_parse(int c, char **argv, int invert, unsigned int *flags,
 	char *end;
 
 	switch (c) {
-	case '1': /* --mark */
-		param_act(P_ONLY_ONCE, "connmark", "--mark", *flags & F_MARK);
+	case '2': /* --mark */
+		fprintf(stderr, "Option name changed from --mark to --connmark. Update your command to suppress this warning!\n");
+	case '1': /* --connmark */
+		param_act(P_ONLY_ONCE, "connmark", "--connmark", *flags & F_MARK);
 		if (!strtonum(optarg, &end, &mark, 0, ~0U))
-			param_act(P_BAD_VALUE, "connmark", "--mark", optarg);
+			param_act(P_BAD_VALUE, "connmark", "--connmark", optarg);
 		if (*end == '/')
 			if (!strtonum(end + 1, &end, &mask, 0, ~0U))
-				param_act(P_BAD_VALUE, "connmark", "--mark", optarg);
+				param_act(P_BAD_VALUE, "connmark", "--connmark", optarg);
 		if (*end != '\0')
-			param_act(P_BAD_VALUE, "connmark", "--mark", optarg);
+			param_act(P_BAD_VALUE, "connmark", "--connmark", optarg);
 
 		if (invert)
 			info->invert = true;
@@ -83,6 +86,8 @@ connmark_parse(int c, char **argv, int invert, unsigned int *flags,
 
 	switch (c) {
 		char *end;
+	case '2':
+		fprintf(stderr, "Option name changed from --mark to --connmark. Update your command to suppress this warning!\n");
 	case '1':
 		check_inverse(optarg, &invert, &optind, 0);
 
@@ -93,7 +98,7 @@ connmark_parse(int c, char **argv, int invert, unsigned int *flags,
 			markinfo->mask = strtoul(end+1, &end, 0);
 
 		if (*end != '\0' || end == optarg)
-			exit_error(PARAMETER_PROBLEM, "Bad MARK value `%s'", optarg);
+			exit_error(PARAMETER_PROBLEM, "Bad CONNMARK value `%s'", optarg);
 		if (invert)
 			markinfo->invert = 1;
 		*flags = 1;
@@ -117,7 +122,7 @@ static void connmark_mt_check(unsigned int flags)
 {
 	if (flags == 0)
 		exit_error(PARAMETER_PROBLEM,
-		           "connmark: The --mark option is required");
+		           "connmark: The --connmark option is required");
 }
 
 /* Prints out the matchinfo. */
@@ -151,7 +156,7 @@ static void connmark_save(const void *ip, const struct xt_entry_match *match)
 	if (info->invert)
 		printf("! ");
 
-	printf("--mark ");
+	printf("--connmark ");
 	print_mark(info->mark, info->mask);
 }
 
@@ -163,7 +168,7 @@ connmark_mt_save(const void *ip, const struct xt_entry_match *match)
 	if (info->invert)
 		printf("! ");
 
-	printf("--mark ");
+	printf("--connmark ");
 	print_mark(info->mark, info->mask);
 }
 
extensions/libxt_connmark.man +2 -1
index a50c537..9e10e97 100644
@@ -1,6 +1,7 @@
 This module matches the netfilter mark field associated with a connection
 (which can be set using the \fBCONNMARK\fR target below).
 .TP
-[\fB!\fP] \fB--mark\fR \fIvalue\fR[\fB/\fR\fImask\fR]
+[\fB!\fP] \fB--connmark\fR \fIvalue\fR[\fB/\fR\fImask\fR]
 Matches packets in connections with the given mark value (if a mask is
 specified, this is logically ANDed with the mark before the comparison).
+(Old option name \fB--mark\fR is still supported.)
Signature · 9 lines
1.5.3.4

Best regards,
Jozsef
-
E-mail  : [email protected], [email protected]
PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
          H-1525 Budapest 114, POB. 49, Hungary
#17 lore raw
Quoted 14 lines · Jozsef Kadlecsik
Quoted 12 lines · Changli Gao
Quoted 8 lines

But as the ECN options has not been documented so far, I think it'd be better to rename them at the same time to something like

--ecn-tcp-cwr-remove
--ecn-tcp-ece-remove
--ecn-ip-ect-set

and clashing with the ecn options were resolved.

It sounds a good idae. But in order to avoid clashing, we'd better change all the options for all matches in this way:

Quoted 7 lines
Quoted 2 lines

match: foo
match-options: --foo-bar

I think changing the existing clashing option names (with keeping the old ones for backward compatibility) is just enough - we can use the "rule" above for future new matches.

Well, If so, we'd better make this rule well documented to let more people know the issue we talked here if they don't obey it.

Signature · 2 lines
Regards,
Changli Gao([email protected])
#18 lore raw
Quoted 16 lines · Changli Gao
Quoted 16 lines
Quoted 15 lines
Quoted 9 lines

But as the ECN options has not been documented so far, I think it'd be better to rename them at the same time to something like

--ecn-tcp-cwr-remove
--ecn-tcp-ece-remove
--ecn-ip-ect-set

and clashing with the ecn options were resolved.

It sounds a good idae. But in order to avoid clashing, we'd better change all the options for all matches in this way:

match: foo
match-options: --foo-bar

Quoted 6 lines
Quoted 3 lines

I think changing the existing clashing option names (with keeping the old ones for backward compatibility) is just enough - we can use the "rule" above for future new matches.

Well, If so, we'd better make this rule well documented to let more people know the issue we talked here if they don't obey it.

I would not make this a hard requirement. (NAKing the NAK.)