Commit 64194c31 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

inet: Make tunnel RX/TX byte counters more consistent

This patch makes the RX/TX byte counters for IPIP, GRE and SIT more
consistent.  Previously we included the external IP headers on the
way out but not when the packet is inbound.

The new scheme is to count payload only in both directions.  For
IPIP and SIT this simply means the exclusion of the external IP
header.  For GRE this means that we exclude the GRE header as
well.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e1a80002
...@@ -37,7 +37,7 @@ struct ip_tunnel_prl_entry ...@@ -37,7 +37,7 @@ struct ip_tunnel_prl_entry
#define IPTUNNEL_XMIT() do { \ #define IPTUNNEL_XMIT() do { \
int err; \ int err; \
int pkt_len = skb->len; \ int pkt_len = skb->len - skb_transport_offset(skb); \
\ \
skb->ip_summed = CHECKSUM_NONE; \ skb->ip_summed = CHECKSUM_NONE; \
ip_select_ident(iph, &rt->u.dst, NULL); \ ip_select_ident(iph, &rt->u.dst, NULL); \
......
...@@ -477,6 +477,7 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -477,6 +477,7 @@ static int ipgre_rcv(struct sk_buff *skb)
struct ip_tunnel *tunnel; struct ip_tunnel *tunnel;
int offset = 4; int offset = 4;
__be16 gre_proto; __be16 gre_proto;
unsigned int len;
if (!pskb_may_pull(skb, 16)) if (!pskb_may_pull(skb, 16))
goto drop_nolock; goto drop_nolock;
...@@ -567,6 +568,8 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -567,6 +568,8 @@ static int ipgre_rcv(struct sk_buff *skb)
tunnel->i_seqno = seqno + 1; tunnel->i_seqno = seqno + 1;
} }
len = skb->len;
/* Warning: All skb pointers will be invalidated! */ /* Warning: All skb pointers will be invalidated! */
if (tunnel->dev->type == ARPHRD_ETHER) { if (tunnel->dev->type == ARPHRD_ETHER) {
if (!pskb_may_pull(skb, ETH_HLEN)) { if (!pskb_may_pull(skb, ETH_HLEN)) {
...@@ -581,7 +584,7 @@ static int ipgre_rcv(struct sk_buff *skb) ...@@ -581,7 +584,7 @@ static int ipgre_rcv(struct sk_buff *skb)
} }
stats->rx_packets++; stats->rx_packets++;
stats->rx_bytes += skb->len; stats->rx_bytes += len;
skb->dev = tunnel->dev; skb->dev = tunnel->dev;
dst_release(skb->dst); dst_release(skb->dst);
skb->dst = NULL; skb->dst = NULL;
...@@ -770,7 +773,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -770,7 +773,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
old_iph = ip_hdr(skb); old_iph = ip_hdr(skb);
} }
skb->transport_header = skb->network_header; skb_reset_transport_header(skb);
skb_push(skb, gre_hlen); skb_push(skb, gre_hlen);
skb_reset_network_header(skb); skb_reset_network_header(skb);
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment