Skip to contentSkip to conversation

netfilter: conntrack: account packets drop by tcp_packet()

PATCH Applied Pablo Neira Ayuso 3 participants 4 messages Feb 23, 2009 – Feb 24, 2009

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: conntrack: account packets drop by tcp_packet()

Since tcp_packet() may return -NF_DROP in two situations, the packet-drop stats must be increased.

---

 net/netfilter/nf_conntrack_core.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/netfilter/nf_conntrack_core.c +2 -0
index 8b9dbb7..4503727 100644
@@ -733,6 +733,8 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
 		nf_conntrack_put(skb->nfct);
 		skb->nfct = NULL;
 		NF_CT_STAT_INC_ATOMIC(net, invalid);
+		if (-ret == NF_DROP)
+			NF_CT_STAT_INC_ATOMIC(net, drop);
 		return -ret;
 	}
 
#1 lore raw

net/netfilter/nf_conntrack_core.c nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, · line 740

Quoted 13 lines · Pablo Neira Ayuso
net/netfilter/nf_conntrack_core.c +2 -0
index 8b9dbb7..4503727 100644
@@ -733,6 +733,8 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
 		nf_conntrack_put(skb->nfct);
 		skb->nfct = NULL;
 		NF_CT_STAT_INC_ATOMIC(net, invalid);
+		if (-ret == NF_DROP)
+			NF_CT_STAT_INC_ATOMIC(net, drop);
 		return -ret;
 	}
 

*boggle* Why not just "ret == -NF_DROP"?
The assumption would be near that "-NF_DROP" is a constant just as "NF_DROP" would be, but "-ret" involves an extra instruction for negating ret.

#2 lore raw
Quoted 11 lines · Jan Engelhardt
Quoted 10 lines · Pablo Neira Ayuso
net/netfilter/nf_conntrack_core.c +2 -0
index 8b9dbb7..4503727 100644
@@ -733,6 +733,8 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
 		nf_conntrack_put(skb->nfct);
 		skb->nfct = NULL;
 		NF_CT_STAT_INC_ATOMIC(net, invalid);
+		if (-ret == NF_DROP)
+			NF_CT_STAT_INC_ATOMIC(net, drop);
Quoted 8 lines

net/netfilter/nf_conntrack_core.c nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum, · line 740

Quoted 3 lines
net/netfilter/nf_conntrack_core.c +0 -0
 		return -ret;
 	}
 

*boggle* Why not just "ret == -NF_DROP"?
The assumption would be near that "-NF_DROP" is a constant just as "NF_DROP" would be, but "-ret" involves an extra instruction for negating ret.

Indeed. No need to resend though, I'll fix it up.