Resend: Add inversion to multiport match
Subsystems (2)
PATCH 1/1 Resend: Add inversion to multiport match
2.6.11 is theoretically around the corner, and I'd like to get inversion added to multiport rev1. Could I get an ack/nack/i'm an idiot regarding the patch below?
Thanks,
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 3 lines · Phil Oester
2.6.11 is theoretically around the corner, and I'd like to get inversion added to multiport rev1. Could I get an ack/nack/i'm an idiot regarding the patch below?
Patrick, could you add the kernelpart to your tree together with the other changes that need to go into 2.6.11 ?
Phil, the userspace part only adds inverted printout to print_v1() not to save_v1()
Either send an updated patch or I'll fix that up when applying it after Patrick has submitted the kernel part.
Signature · 1 line
/Martin
Quoted 4 lines · Martin Josefsson
Phil, the userspace part only adds inverted printout to
print_v1()not tosave_v1()
Either send an updated patch or I'll fix that up when applying it after Patrick has submitted the kernel part.
Indeed -- appologies. Attached is corrected userspace patch.
Phil
extensions/libipt_multiport.c +10 -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);
@@ -422,6 +424,9 @@break ; } +if (multiinfo->invert) +printf ("! " ); +for (i=0 ; i < multiinfo->count; i++) {printf ("%s" , i ?"," :"" );print_port (multiinfo->ports[i], ip->proto,1 );
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*/