Skip to contentSkip to conversation

iptables: use skb->len for accounting

PATCH Applied Changli Gao 3 participants 7 messages Jul 23, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iptables: use skb->len for accounting

iptables: use skb->len for accounting

use skb->len for accounting as xt_quota does.

----

 net/ipv4/netfilter/ip_tables.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/netfilter/ip_tables.c +1 -1
index b38c118..3c584a6 100644
@@ -364,7 +364,7 @@ ipt_do_table(struct sk_buff *skb,
 				goto no_match;
 		}
 
-		ADD_COUNTER(e->counters, ntohs(ip->tot_len), 1);
+		ADD_COUNTER(e->counters, skb->len, 1);
 
 		t = ipt_get_target(e);
 		IP_NF_ASSERT(t->u.kernel.target);
#1 lore raw
Quoted 4 lines · Changli Gao

iptables: use skb->len for accounting

use skb->len for accounting as xt_quota does.

Why ?

This is a gratuitous change, unless you have very strong arguments.

xt_quota is an exception, dont change all others because of it !

It is about actual data on wire, including overhead (excess bytes after IP frame if any).

But IP tables accounting is about IP only.

Quoted 9 lines

----

 net/ipv4/netfilter/ip_tables.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/netfilter/ip_tables.c +0 -0
index b38c118..3c584a6 100644

net/ipv4/netfilter/ip_tables.c ipt_do_table(struct sk_buff *skb,

Quoted 9 lines
net/ipv4/netfilter/ip_tables.c +1 -2
@@ -364,7 +364,7 @@ ipt_do_table(struct sk_buff *skb,
 				goto no_match;
 		}
 
-		ADD_COUNTER(e->counters, ntohs(ip->tot_len), 1);
+		ADD_COUNTER(e->counters, skb->len, 1);
 
 		t = ipt_get_target(e);
 		IP_NF_ASSERT(t->u.kernel.target);
--

--
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

#2 lore raw
Quoted 11 lines · Eric Dumazet
Quoted 4 lines · Changli Gao

iptables: use skb->len for accounting

use skb->len for accounting as xt_quota does.

Why ?

This is a gratuitous change, unless you have very strong arguments.

xt_quota is an exception, dont change all others because of it !

exception ? Why ?

Quoted 6 lines

It is about actual data on wire, including overhead (excess bytes after IP frame if any).

But IP tables accounting is about IP only.

Is the assumption that: the packets in netfilter have the padding bytes removed, and skb->data points to the network header? Thanks.

Signature · 6 lines
Regards,
Changli Gao([email protected])
--
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
#3 lore raw
Quoted 7 lines · Changli Gao
Quoted 6 lines · Eric Dumazet
Quoted 4 lines · Changli Gao

iptables: use skb->len for accounting

use skb->len for accounting as xt_quota does.

Quoted 7 lines
Quoted 5 lines

Why ?

This is a gratuitous change, unless you have very strong arguments.

xt_quota is an exception, dont change all others because of it !

exception ? Why ?

Because it handles all protocols...

So skb->len is a shortcut, an approximation if you want.

At IPV4 level, ip->tot_len is an exact value.

#4 lore raw
Quoted 14 lines · Eric Dumazet
Quoted 13 lines · Changli Gao
Quoted 11 lines · Eric Dumazet
Quoted 4 lines · Changli Gao

iptables: use skb->len for accounting

use skb->len for accounting as xt_quota does.

Why ?

This is a gratuitous change, unless you have very strong arguments.

xt_quota is an exception, dont change all others because of it !

Quoted 7 lines
Quoted 1 line

exception ? Why ?

Because it handles all protocols...

So skb->len is a shortcut, an approximation if you want.

At IPV4 level, ip->tot_len is an exact value.

Actually skb->len is also exact at the IPv4 level. I'm inclined to apply this patch for consistency with ip6_tables, where using skb->len fixes jumbo frame accounting.

#5 lore raw
Quoted 4 lines · Patrick McHardy

Actually skb->len is also exact at the IPv4 level. I'm inclined to apply this patch for consistency with ip6_tables, where using skb->len fixes jumbo frame accounting.

Thats right.

I was confused by recent problem raised with UDP checksums.

But pskb_trim_rcsum() is indeed called from ip_rcv() so skb->len == ntohs(iph->tot_len)

Thanks

--
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