Netfilter: Multiport revision with port ranges (replaces "mport")
Subsystems (2)
PATCH 13/18 Netfilter: Multiport revision with port ranges (replaces "mport")
Name: Multiport revision with port ranges (replaces "mport")
Status: Tested under nfsim
The multiport match doesn't support ranges of ports, so a new match called "mport" was written. Now we have versioning of matches and targets, we can simply put this extension in multiport revision 1.
Also, removes gratuitous checking in match: we basically trust iptables userspace these days.
===== net/ipv4/netfilter/ipt_multiport.c 1.8 vs edited =====
include/linux/netfilter_ipv4/ipt_multiport.h +8 -0
@@ -18,4 +18,12 @@u_int8_t count;/* Number of ports */ u_int16_t ports[IPT_MULTI_PORTS]; /* Ports */ }; + +struct ipt_multiport_v1 +{ +u_int8_t flags;/* Type of comparison */ +u_int8_t count;/* Number of ports */ +u_int16_t ports[IPT_MULTI_PORTS ];/* Ports */ +u_int8_t pflags[IPT_MULTI_PORTS ];/* Port flags */ +};#endif /*_IPT_MULTIPORT_H*/
net/ipv4/netfilter/ipt_multiport.c +104 -17
166 lines not on this page · raw message
Quoted 3 lines · Rusty Russell
The multiport match doesn't support ranges of ports, so a new match called "mport" was written. Now we have versioning of matches and targets, we can simply put this extension in multiport revision 1.
While I agree the above is a useful change, why not also add inversion to multiport in the process -- as long as you're making a new revision? Or should that be done in revision 2?
Phil
Quoted 7 lines · Phil Oester
Quoted 3 lines · Rusty Russell
The multiport match doesn't support ranges of ports, so a new match called "mport" was written. Now we have versioning of matches and targets, we can simply put this extension in multiport revision 1.
Quoted 6 lines
While I agree the above is a useful change, why not also add inversion to multiport in the process -- as long as you're making a new revision? Or should that be done in revision 2?
Phil
AFAIK iptables already support ranges of ports.
iptables -A INPUT -p tcp --sport 10:40
Cheers :)
-acidfu
Quoted 8 lines · Phil Oester
Quoted 3 lines · Rusty Russell
The multiport match doesn't support ranges of ports, so a new match called "mport" was written. Now we have versioning of matches and targets, we can simply put this extension in multiport revision 1.
While I agree the above is a useful change, why not also add inversion to multiport in the process -- as long as you're making a new revision? Or should that be done in revision 2?
If you put it in before 2.6.11 is released, it can go in the current revision, otherwise we want a new one (where do we put the invert flags?).
Cheers,
Rusty.
Signature · 1 line
A bad analogy is like a leaky screwdriver -- Richard Braakman
Quoted 6 lines · Rusty Russell
Quoted 5 lines · Phil Oester
Quoted 3 lines · Rusty Russell
The multiport match doesn't support ranges of ports, so a new match called "mport" was written. Now we have versioning of matches and targets, we can simply put this extension in multiport revision 1.
Quoted 7 lines
Quoted 3 lines
While I agree the above is a useful change, why not also add inversion to multiport in the process -- as long as you're making a new revision? Or should that be done in revision 2?
If you put it in before 2.6.11 is released, it can go in the current revision, otherwise we want a new one (where do we put the invert flags?).
OK, how about the below which adds inversion?
(note: didn't update manpage, but then again, wasn't updated with previous changes)
Phil
extensions/libipt_multiport.c +7 -5
@@ -31,13 +31,13 @@ {printf ("multiport v%s options:\n" -" --source-ports port[,port:port,port...]\n" +" --source-ports [!] port[,port:port,port...]\n" " --sports ...\n" " match source port(s)\n" -" --destination-ports port[,port:port,port...]\n" +" --destination-ports [!] port[,port:port,port...]\n" " --dports ...\n" " match destination port(s)\n" -" --ports port[,port:port,port]\n" +" --ports [!] port[,port:port,port]\n" " match both source and destination port(s)\n" ,IPTABLES_VERSION ); }
@@ -255,8 +255,7 @@ }if (invert) -exit_error (PARAMETER_PROBLEM , -"multiport does not support invert" ); + multiinfo->invert =1 ;if (*flags) exit_error(PARAMETER_PROBLEM,
@@ -362,6 +361,9 @@break ; } +if (multiinfo->invert) +printf ("! " ); +for (i=0 ; i < multiinfo->count; i++) {printf ("%s" , i ?"," :"" );print_port (multiinfo->ports[i], ip->proto, numeric);
include/linux/netfilter_ipv4/ipt_multiport.h +1 -0
@@ -24,5 +24,6 @@u_int8_t count;/* Number of ports */ u_int16_t ports[IPT_MULTI_PORTS ];/* Ports */ u_int8_t pflags[IPT_MULTI_PORTS ];/* Port flags */ + u_int8_t invert; /* Invert flag */ };#endif /*_IPT_MULTIPORT_H*/
include/linux/netfilter_ipv4/ipt_multiport.h +1 -0
@@ -25,5 +25,6 @@u_int8_t count;/* Number of ports */ u_int16_t ports[IPT_MULTI_PORTS ];/* Ports */ u_int8_t pflags[IPT_MULTI_PORTS ];/* Port flags */ + u_int8_t invert; /* Invert flag */ };#endif /*_IPT_MULTIPORT_H*/
net/ipv4/netfilter/ipt_multiport.c +8 -7
@@ -64,30 +64,31 @@if (minfo->flags ==IPT_MULTIPORT_SOURCE && src >= s && src <= e) -return 1 ; +return 1 ^ minfo->invert;if (minfo->flags ==IPT_MULTIPORT_DESTINATION && dst >= s && dst <= e) -return 1 ; +return 1 ^ minfo->invert;if (minfo->flags ==IPT_MULTIPORT_EITHER && ((dst >= s && dst <= e) || (src >= s && src <= e))) -return 1 ; +return 1 ^ minfo->invert; }else {/* exact port matching */ duprintf ("src or dst matches with %d?\n" , s); +if (minfo->flags ==IPT_MULTIPORT_SOURCE && src == s) -return 1 ; +return 1 ^ minfo->invert;if (minfo->flags ==IPT_MULTIPORT_DESTINATION && dst == s) -return 1 ; +return 1 ^ minfo->invert;if (minfo->flags ==IPT_MULTIPORT_EITHER && (src == s || dst == s)) -return 1 ; +return 1 ^ minfo->invert; } } -return 0 ; +return minfo->invert; } static int
Quoted 6 lines · Phil Oester
Quoted 3 lines · Rusty Russell
Quoted 3 lines
While I agree the above is a useful change, why not also add inversion to multiport in the process -- as long as you're making a new revision? Or should that be done in revision 2?
Quoted 8 lines
Quoted 3 lines
If you put it in before 2.6.11 is released, it can go in the current revision, otherwise we want a new one (where do we put the invert flags?).
OK, how about the below which adds inversion?
(note: didn't update manpage, but then again, wasn't updated with previous changes)
Maybe because no one stated what the manpage policy regarding the new revision system would be?...
When adding every successive revision documentation of every match/target to the manpage, wouldn't it become severly bloated in the end?
Herve
Signature · 4 lines
_ (°= Hervé Eychenne //) v_/_ WallFire project: http://www.wallfire.org/
bonjour,
Quoted 5 lines · Herve Eychenne
Quoted 4 lines
(note: didn't update manpage, but then again, wasn't updated with previous changes)
Quoted 7 lines
Maybe because no one stated what the manpage policy regarding the new revision system would be?...
When adding every successive revision documentation of every match/target to the manpage, wouldn't it become severly bloated in the end?
Hm, I think that the revision infrastructure gives the possibility of extending a target/match with some kind of interesting features, something that we couldn't do so far. However, I don't encourage the release of a new revision every month or something like that.
So, I think that people must have a good reason to extend a target/match, and in case that this new revision is considered worthy. I would hold it for quite some time in the SVN repository and after that push it forward.
If we follow a policy similar to this, the manpages shouldn't get bloated so much I guess.
--
Pablo
Quoted 14 lines · Pablo Neira
bonjour,
Quoted 10 lines · Herve Eychenne
Quoted 4 lines
(note: didn't update manpage, but then again, wasn't updated with previous changes)
Maybe because no one stated what the manpage policy regarding the new revision system would be?...
When adding every successive revision documentation of every match/target to the manpage, wouldn't it become severly bloated in the end?
You should add the new feature to the manpage. The extension should then fail with an appropriate message if the version of the kernel does not support the option used.
eg. libipt_MARK.c's "parse_v0" accepts --and-mark (introduced in rev1) like so:
case '2': exit_error(PARAMETER_PROBLEM, "MARK target: kernel too old for --and-mark");
Cheers,
Rusty.
Signature · 1 line
A bad analogy is like a leaky screwdriver -- Richard Braakman
Quoted 10 lines · Rusty Russell
Quoted 9 lines · Pablo Neira
bonjour,
Quoted 5 lines · Herve Eychenne
Quoted 4 lines
(note: didn't update manpage, but then again, wasn't updated with previous changes)
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Maybe because no one stated what the manpage policy regarding the new revision system would be?...
When adding every successive revision documentation of every match/target to the manpage, wouldn't it become severly bloated in the end?You should add the new feature to the manpage.
Yes, let's just hope there won't be too many revisions over time, because that would certainly confuse the users. So, we shouln't add revisions too often as Pablo said, or at least think before doing so.
Quoted 3 lines
The extension should
then fail with an appropriate message if the version of the kernel does not support the option used.
Yes, and add a mecanism in iptables command enabling to know in advance (before actually trying) if a given revision will work (for third party software), as well as the list of usable revisions (for third party again) _and_ available (whether they would actually work with current kernel or not) revisions (for the user, this time), ideally.
Herve
Signature · 4 lines
_ (°= Hervé Eychenne //) v_/_ WallFire project: http://www.wallfire.org/