Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 149793
b: refs/heads/master
c: 7eebb0b
h: refs/heads/master
i:
  149791: 6099368
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Apr 20, 2009
1 parent 4e3e4c9 commit 2d62311
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eb62efd287fe6e12d18083287e38e4a811c28256
refs/heads/master: 7eebb0b28f755e297d355a205bb04945b256db6b
21 changes: 15 additions & 6 deletions trunk/drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
struct pcpu_lstats {
unsigned long packets;
unsigned long bytes;
unsigned long drops;
};

/*
Expand All @@ -71,18 +72,22 @@ struct pcpu_lstats {
static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct pcpu_lstats *pcpu_lstats, *lb_stats;
int len;

skb_orphan(skb);

skb->protocol = eth_type_trans(skb,dev);
skb->protocol = eth_type_trans(skb, dev);

/* it's OK to use per_cpu_ptr() because BHs are off */
pcpu_lstats = dev->ml_priv;
lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
lb_stats->bytes += skb->len;
lb_stats->packets++;

netif_rx(skb);
len = skb->len;
if (likely(netif_rx(skb) == NET_RX_SUCCESS)) {
lb_stats->bytes += len;
lb_stats->packets++;
} else
lb_stats->drops++;

return 0;
}
Expand All @@ -93,6 +98,7 @@ static struct net_device_stats *loopback_get_stats(struct net_device *dev)
struct net_device_stats *stats = &dev->stats;
unsigned long bytes = 0;
unsigned long packets = 0;
unsigned long drops = 0;
int i;

pcpu_lstats = dev->ml_priv;
Expand All @@ -102,11 +108,14 @@ static struct net_device_stats *loopback_get_stats(struct net_device *dev)
lb_stats = per_cpu_ptr(pcpu_lstats, i);
bytes += lb_stats->bytes;
packets += lb_stats->packets;
drops += lb_stats->drops;
}
stats->rx_packets = packets;
stats->tx_packets = packets;
stats->rx_bytes = bytes;
stats->tx_bytes = bytes;
stats->rx_dropped = drops;
stats->rx_errors = drops;
stats->rx_bytes = bytes;
stats->tx_bytes = bytes;
return stats;
}

Expand Down

0 comments on commit 2d62311

Please sign in to comment.