Skip to contentSkip to conversation

veth: Fix the byte counters

PATCH Applied Eric W. Biederman 2 participants 2 messages Mar 21, 2011 – Mar 22, 2011

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

PATCH 1/1 veth: Fix the byte counters

Commit 44540960 "veth: move loopback logic to common location" introduced a bug in the packet counters. I don't understand why that happened as it is not explained in the comments and the mut check in dev_forward_skb retains the assumption that skb->len is the total length of the packet.

I just measured this emperically by setting up a veth pair between two noop network namespaces setting and attempting a telnet connection between the two. I saw three packets in each direction and the byte counters were exactly 14*3 = 42 bytes high in each direction. I got the actual packet lengths with tcpdump.

So remove the extra ETH_HLEN from the veth byte count totals.

---
 drivers/net/veth.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/veth.c +1 -1
index 105d7f0..2de9b90 100644
@@ -171,7 +171,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
 	if (skb->ip_summed == CHECKSUM_NONE)
 		skb->ip_summed = rcv_priv->ip_summed;
 
-	length = skb->len + ETH_HLEN;
+	length = skb->len;
 	if (dev_forward_skb(rcv, skb) != NET_RX_SUCCESS)
 		goto rx_drop;
 
Signature · 1 line
1.7.4
maintainer Applied
#1 lore raw

From: [email protected] (Eric W. Biederman)
Date: Mon, 21 Mar 2011 14:40:29 -0700

Quoted 12 lines

Commit 44540960 "veth: move loopback logic to common location" introduced a bug in the packet counters. I don't understand why that happened as it is not explained in the comments and the mut check in dev_forward_skb retains the assumption that skb->len is the total length of the packet.

I just measured this emperically by setting up a veth pair between two noop network namespaces setting and attempting a telnet connection between the two. I saw three packets in each direction and the byte counters were exactly 14*3 = 42 bytes high in each direction. I got the actual packet lengths with tcpdump.

Quoted 3 lines

So remove the extra ETH_HLEN from the veth byte count totals.

Applied, thanks.