aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-09-26 20:33:35 -0400
committerDavid S. Miller <davem@davemloft.net>2010-09-28 00:30:42 -0400
commit290b895e0ba4552dfcfc4bd35759c192345b934a (patch)
tree439ffccea9fa87b28b6af2a06e562cc5a0c01f80 /include
parentaf5ef241133b602a77b682009f112e7c3f7604e5 (diff)
tunnels: prepare percpu accounting
Tunnels are going to use percpu for their accounting. They are going to use a new tstats field in net_device. skb_tunnel_rx() is changed to be a wrapper around __skb_tunnel_rx() IPTUNNEL_XMIT() is changed to be a wrapper around __IPTUNNEL_XMIT() Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/netdevice.h1
-rw-r--r--include/net/dst.h24
-rw-r--r--include/net/ipip.h12
3 files changed, 27 insertions, 10 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 01bd4c82d982..83de0eb7a071 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1053,6 +1053,7 @@ struct net_device {
1053 union { 1053 union {
1054 void *ml_priv; 1054 void *ml_priv;
1055 struct pcpu_lstats __percpu *lstats; /* loopback stats */ 1055 struct pcpu_lstats __percpu *lstats; /* loopback stats */
1056 struct pcpu_tstats __percpu *tstats; /* tunnel stats */
1056 }; 1057 };
1057 /* GARP */ 1058 /* GARP */
1058 struct garp_port *garp_port; 1059 struct garp_port *garp_port;
diff --git a/include/net/dst.h b/include/net/dst.h
index 02386505033d..aa53fbc34b2b 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -228,23 +228,37 @@ static inline void skb_dst_force(struct sk_buff *skb)
228 228
229 229
230/** 230/**
231 * __skb_tunnel_rx - prepare skb for rx reinsert
232 * @skb: buffer
233 * @dev: tunnel device
234 *
235 * After decapsulation, packet is going to re-enter (netif_rx()) our stack,
236 * so make some cleanups. (no accounting done)
237 */
238static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
239{
240 skb->dev = dev;
241 skb->rxhash = 0;
242 skb_set_queue_mapping(skb, 0);
243 skb_dst_drop(skb);
244 nf_reset(skb);
245}
246
247/**
231 * skb_tunnel_rx - prepare skb for rx reinsert 248 * skb_tunnel_rx - prepare skb for rx reinsert
232 * @skb: buffer 249 * @skb: buffer
233 * @dev: tunnel device 250 * @dev: tunnel device
234 * 251 *
235 * After decapsulation, packet is going to re-enter (netif_rx()) our stack, 252 * After decapsulation, packet is going to re-enter (netif_rx()) our stack,
236 * so make some cleanups, and perform accounting. 253 * so make some cleanups, and perform accounting.
254 * Note: this accounting is not SMP safe.
237 */ 255 */
238static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) 256static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev)
239{ 257{
240 skb->dev = dev;
241 /* TODO : stats should be SMP safe */ 258 /* TODO : stats should be SMP safe */
242 dev->stats.rx_packets++; 259 dev->stats.rx_packets++;
243 dev->stats.rx_bytes += skb->len; 260 dev->stats.rx_bytes += skb->len;
244 skb->rxhash = 0; 261 __skb_tunnel_rx(skb, dev);
245 skb_set_queue_mapping(skb, 0);
246 skb_dst_drop(skb);
247 nf_reset(skb);
248} 262}
249 263
250/* Children define the path of the packet through the 264/* Children define the path of the packet through the
diff --git a/include/net/ipip.h b/include/net/ipip.h
index 65caea8b414f..58abbf966b0c 100644
--- a/include/net/ipip.h
+++ b/include/net/ipip.h
@@ -45,7 +45,7 @@ struct ip_tunnel_prl_entry {
45 struct rcu_head rcu_head; 45 struct rcu_head rcu_head;
46}; 46};
47 47
48#define IPTUNNEL_XMIT() do { \ 48#define __IPTUNNEL_XMIT(stats1, stats2) do { \
49 int err; \ 49 int err; \
50 int pkt_len = skb->len - skb_transport_offset(skb); \ 50 int pkt_len = skb->len - skb_transport_offset(skb); \
51 \ 51 \
@@ -54,12 +54,14 @@ struct ip_tunnel_prl_entry {
54 \ 54 \
55 err = ip_local_out(skb); \ 55 err = ip_local_out(skb); \
56 if (likely(net_xmit_eval(err) == 0)) { \ 56 if (likely(net_xmit_eval(err) == 0)) { \
57 txq->tx_bytes += pkt_len; \ 57 (stats1)->tx_bytes += pkt_len; \
58 txq->tx_packets++; \ 58 (stats1)->tx_packets++; \
59 } else { \ 59 } else { \
60 stats->tx_errors++; \ 60 (stats2)->tx_errors++; \
61 stats->tx_aborted_errors++; \ 61 (stats2)->tx_aborted_errors++; \
62 } \ 62 } \
63} while (0) 63} while (0)
64 64
65#define IPTUNNEL_XMIT() __IPTUNNEL_XMIT(txq, stats)
66
65#endif 67#endif