Skip to contentSkip to conversation

Add support for --set-counters to iptables -P

PATCH Applied Henrik Nordstrom 3 participants 6 messages May 12, 2008 – May 13, 2008 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 Add support for --set-counters to iptables -P

Adds support for setting the policy counters

iptables -P INPUT -J DROP -c 10 20

Regards
Henrik

iptables.c +2 -2
Index: iptables/iptables.c
===================================================================
@@ -165,7 +165,7 @@ static char commands_v_options[NUMBER_OF
 /*ZERO*/      {'x','x','x','x','x',' ','x','x','x','x','x','x'},
 /*NEW_CHAIN*/ {'x','x','x','x','x',' ','x','x','x','x','x','x'},
 /*DEL_CHAIN*/ {'x','x','x','x','x',' ','x','x','x','x','x','x'},
-/*SET_POLICY*/{'x','x','x','x','x',' ','x','x','x','x','x','x'},
+/*SET_POLICY*/{'x','x','x','x','x',' ','x','x','x','x','x',' '},
 /*RENAME*/    {'x','x','x','x','x',' ','x','x','x','x','x','x'}
 };
 
@@ -1842,7 +1842,7 @@ int do_command(int argc, char *argv[], c
 		ret = iptc_rename_chain(chain, newname,	handle);
 		break;
 	case CMD_SET_POLICY:
-		ret = iptc_set_policy(chain, policy, NULL, handle);
+		ret = iptc_set_policy(chain, policy, options&OPT_COUNTERS ? &fw.counters : NULL, handle);
 		break;
 	default:
 		/* We should never reach this... */
ip6tables.c +2 -2
Index: iptables/ip6tables.c
===================================================================
@@ -165,7 +165,7 @@ static char commands_v_options[NUMBER_OF
 /*ZERO*/      {'x','x','x','x','x',' ','x','x','x','x','x'},
 /*NEW_CHAIN*/ {'x','x','x','x','x',' ','x','x','x','x','x'},
 /*DEL_CHAIN*/ {'x','x','x','x','x',' ','x','x','x','x','x'},
-/*SET_POLICY*/{'x','x','x','x','x',' ','x','x','x','x','x'},
+/*SET_POLICY*/{'x','x','x','x','x',' ','x','x','x','x',' '},
 /*RENAME*/    {'x','x','x','x','x',' ','x','x','x','x','x'}
 };
 
@@ -1802,7 +1802,7 @@ int do_command6(int argc, char *argv[], 
 		ret = ip6tc_rename_chain(chain, newname,	handle);
 		break;
 	case CMD_SET_POLICY:
-		ret = ip6tc_set_policy(chain, policy, NULL, handle);
+		ret = ip6tc_set_policy(chain, policy, options&OPT_COUNTERS ? &fw.counters : NULL, handle);
 		break;
 	default:
 		/* We should never reach this... */
#1 lore raw
Quoted 3 lines · Henrik Nordstrom

Adds support for setting the policy counters

iptables -P INPUT -J DROP -c 10 20

Could this perhaps be changed so that -c only takes one argument? Like -c 10,20. This would ease integration with passthrough argument parsing in 3rd party applications.

#2 lore raw
Quoted 9 lines · Jan Engelhardt
Quoted 3 lines · Henrik Nordstrom

Adds support for setting the policy counters

iptables -P INPUT -J DROP -c 10 20

Could this perhaps be changed so that -c only takes one argument? Like -c 10,20. This would ease integration with passthrough argument parsing in 3rd party applications.

I already applied it, in case you want to change anything, please send a patch on top.

#3 lore raw
Quoted 6 lines · Patrick McHardy
Quoted 3 lines

Could this perhaps be changed so that -c only takes one argument? Like -c 10,20. This would ease integration with passthrough argument parsing in 3rd party applications.

I already applied it, in case you want to change anything, please send a patch on top.

Done, but it is a separate issue not related to these patches.

Regards
Henrik

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Jan Engelhardt
Quoted 9 lines · Jan Engelhardt
Quoted 3 lines · Henrik Nordstrom

Adds support for setting the policy counters

iptables -P INPUT -J DROP -c 10 20

Could this perhaps be changed so that -c only takes one argument? Like -c 10,20. This would ease integration with passthrough argument parsing in 3rd party applications.

That's a different patch. All this patch does is enabling the existing --set-counters (-c) option to be used with --set-policy (-P).

Regards
Henrik

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html