Skip to contentSkip to conversation

add support for zeroing counters at getting

PATCH In review Pablo Neira 2 participants 2 messages Nov 4, 2005 – Nov 5, 2005

Subsystems (2)
lore
Share & tools
lore

Pablo Neira

author maintainer
#0 lore raw

PATCH 6/7 add support for zeroing counters at getting

Add support to zero counters conntrack at getting. Currently we can zero all the conntracks via zero and dump, but it could be useful more fine grain zeroing.

Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris

Add support to zero counters conntrack at getting. Currently we can zero all the conntracks via zero and dump, but it could be useful more fine grain zeroing.

Signed-by-off: Pablo Neira Ayuso <[email protected]>

net/ipv4/netfilter/ip_conntrack_netlink.c +6 -0
Index: net-2.6.git/net/ipv4/netfilter/ip_conntrack_netlink.c
===================================================================
@@ -788,6 +788,12 @@ ctnetlink_get_conntrack(struct sock *ctn
 
 	err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, 
 				  IPCTNL_MSG_CT_NEW, 1, ct);
+
+#ifdef CONFIG_IP_NF_CT_ACCT
+	if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO) 
+		memset(&ct->counters, 0, sizeof(ct->counters));
+#endif
+	
 	ip_conntrack_put(ct);
 	if (err <= 0)
 		goto free;
#1 lore raw
Quoted 3 lines · Pablo Neira

Add support to zero counters conntrack at getting. Currently we can zero all the conntracks via zero and dump, but it could be useful more fine grain zeroing.

This misses proper write locking, so we can get corruption with packets trying to increment the counter meanwhile.

Please try adding write locking, test it, and re-submit.

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie