Commit f61dd388 authored by Pravin B Shelar's avatar Pravin B Shelar Committed by David S. Miller

Tunneling: use IP Tunnel stats APIs.

Use common function get calculate rtnl_link_stats64 stats.
Signed-off-by: default avatarPravin B Shelar <pshelar@nicira.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 206aaafc
...@@ -319,6 +319,7 @@ config SYN_COOKIES ...@@ -319,6 +319,7 @@ config SYN_COOKIES
config NET_IPVTI config NET_IPVTI
tristate "Virtual (secure) IP: tunneling" tristate "Virtual (secure) IP: tunneling"
select INET_TUNNEL select INET_TUNNEL
select NET_IP_TUNNEL
depends on INET_XFRM_MODE_TUNNEL depends on INET_XFRM_MODE_TUNNEL
---help--- ---help---
Tunneling means encapsulating data of one protocol type within Tunneling means encapsulating data of one protocol type within
......
...@@ -82,44 +82,6 @@ static int vti_tunnel_bind_dev(struct net_device *dev); ...@@ -82,44 +82,6 @@ static int vti_tunnel_bind_dev(struct net_device *dev);
} while (0) } while (0)
static struct rtnl_link_stats64 *vti_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *tot)
{
int i;
for_each_possible_cpu(i) {
const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
unsigned int start;
do {
start = u64_stats_fetch_begin_bh(&tstats->syncp);
rx_packets = tstats->rx_packets;
tx_packets = tstats->tx_packets;
rx_bytes = tstats->rx_bytes;
tx_bytes = tstats->tx_bytes;
} while (u64_stats_fetch_retry_bh(&tstats->syncp, start));
tot->rx_packets += rx_packets;
tot->tx_packets += tx_packets;
tot->rx_bytes += rx_bytes;
tot->tx_bytes += tx_bytes;
}
tot->multicast = dev->stats.multicast;
tot->rx_crc_errors = dev->stats.rx_crc_errors;
tot->rx_fifo_errors = dev->stats.rx_fifo_errors;
tot->rx_length_errors = dev->stats.rx_length_errors;
tot->rx_errors = dev->stats.rx_errors;
tot->tx_fifo_errors = dev->stats.tx_fifo_errors;
tot->tx_carrier_errors = dev->stats.tx_carrier_errors;
tot->tx_dropped = dev->stats.tx_dropped;
tot->tx_aborted_errors = dev->stats.tx_aborted_errors;
tot->tx_errors = dev->stats.tx_errors;
return tot;
}
static struct ip_tunnel *vti_tunnel_lookup(struct net *net, static struct ip_tunnel *vti_tunnel_lookup(struct net *net,
__be32 remote, __be32 local) __be32 remote, __be32 local)
{ {
...@@ -597,7 +559,7 @@ static const struct net_device_ops vti_netdev_ops = { ...@@ -597,7 +559,7 @@ static const struct net_device_ops vti_netdev_ops = {
.ndo_start_xmit = vti_tunnel_xmit, .ndo_start_xmit = vti_tunnel_xmit,
.ndo_do_ioctl = vti_tunnel_ioctl, .ndo_do_ioctl = vti_tunnel_ioctl,
.ndo_change_mtu = vti_tunnel_change_mtu, .ndo_change_mtu = vti_tunnel_change_mtu,
.ndo_get_stats64 = vti_get_stats64, .ndo_get_stats64 = ip_tunnel_get_stats64,
}; };
static void vti_dev_free(struct net_device *dev) static void vti_dev_free(struct net_device *dev)
......
...@@ -156,6 +156,7 @@ config INET6_XFRM_MODE_ROUTEOPTIMIZATION ...@@ -156,6 +156,7 @@ config INET6_XFRM_MODE_ROUTEOPTIMIZATION
config IPV6_SIT config IPV6_SIT
tristate "IPv6: IPv6-in-IPv4 tunnel (SIT driver)" tristate "IPv6: IPv6-in-IPv4 tunnel (SIT driver)"
select INET_TUNNEL select INET_TUNNEL
select NET_IP_TUNNEL
select IPV6_NDISC_NODETYPE select IPV6_NDISC_NODETYPE
default y default y
---help--- ---help---
...@@ -201,6 +202,7 @@ config IPV6_TUNNEL ...@@ -201,6 +202,7 @@ config IPV6_TUNNEL
config IPV6_GRE config IPV6_GRE
tristate "IPv6: GRE tunnel" tristate "IPv6: GRE tunnel"
select IPV6_TUNNEL select IPV6_TUNNEL
select NET_IP_TUNNEL
---help--- ---help---
Tunneling means encapsulating data of one protocol type within Tunneling means encapsulating data of one protocol type within
another protocol and sending it over a channel that understands the another protocol and sending it over a channel that understands the
......
...@@ -111,46 +111,6 @@ static u32 HASH_ADDR(const struct in6_addr *addr) ...@@ -111,46 +111,6 @@ static u32 HASH_ADDR(const struct in6_addr *addr)
#define tunnels_l tunnels[1] #define tunnels_l tunnels[1]
#define tunnels_wc tunnels[0] #define tunnels_wc tunnels[0]
static struct rtnl_link_stats64 *ip6gre_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *tot)
{
int i;
for_each_possible_cpu(i) {
const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
unsigned int start;
do {
start = u64_stats_fetch_begin_bh(&tstats->syncp);
rx_packets = tstats->rx_packets;
tx_packets = tstats->tx_packets;
rx_bytes = tstats->rx_bytes;
tx_bytes = tstats->tx_bytes;
} while (u64_stats_fetch_retry_bh(&tstats->syncp, start));
tot->rx_packets += rx_packets;
tot->tx_packets += tx_packets;
tot->rx_bytes += rx_bytes;
tot->tx_bytes += tx_bytes;
}
tot->multicast = dev->stats.multicast;
tot->rx_crc_errors = dev->stats.rx_crc_errors;
tot->rx_fifo_errors = dev->stats.rx_fifo_errors;
tot->rx_length_errors = dev->stats.rx_length_errors;
tot->rx_frame_errors = dev->stats.rx_frame_errors;
tot->rx_errors = dev->stats.rx_errors;
tot->tx_fifo_errors = dev->stats.tx_fifo_errors;
tot->tx_carrier_errors = dev->stats.tx_carrier_errors;
tot->tx_dropped = dev->stats.tx_dropped;
tot->tx_aborted_errors = dev->stats.tx_aborted_errors;
tot->tx_errors = dev->stats.tx_errors;
return tot;
}
/* Given src, dst and key, find appropriate for input tunnel. */ /* Given src, dst and key, find appropriate for input tunnel. */
static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev,
...@@ -1257,7 +1217,7 @@ static const struct net_device_ops ip6gre_netdev_ops = { ...@@ -1257,7 +1217,7 @@ static const struct net_device_ops ip6gre_netdev_ops = {
.ndo_start_xmit = ip6gre_tunnel_xmit, .ndo_start_xmit = ip6gre_tunnel_xmit,
.ndo_do_ioctl = ip6gre_tunnel_ioctl, .ndo_do_ioctl = ip6gre_tunnel_ioctl,
.ndo_change_mtu = ip6gre_tunnel_change_mtu, .ndo_change_mtu = ip6gre_tunnel_change_mtu,
.ndo_get_stats64 = ip6gre_get_stats64, .ndo_get_stats64 = ip_tunnel_get_stats64,
}; };
static void ip6gre_dev_free(struct net_device *dev) static void ip6gre_dev_free(struct net_device *dev)
...@@ -1506,7 +1466,7 @@ static const struct net_device_ops ip6gre_tap_netdev_ops = { ...@@ -1506,7 +1466,7 @@ static const struct net_device_ops ip6gre_tap_netdev_ops = {
.ndo_set_mac_address = eth_mac_addr, .ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_change_mtu = ip6gre_tunnel_change_mtu, .ndo_change_mtu = ip6gre_tunnel_change_mtu,
.ndo_get_stats64 = ip6gre_get_stats64, .ndo_get_stats64 = ip_tunnel_get_stats64,
}; };
static void ip6gre_tap_setup(struct net_device *dev) static void ip6gre_tap_setup(struct net_device *dev)
......
...@@ -87,41 +87,6 @@ struct sit_net { ...@@ -87,41 +87,6 @@ struct sit_net {
struct net_device *fb_tunnel_dev; struct net_device *fb_tunnel_dev;
}; };
static struct rtnl_link_stats64 *ipip6_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *tot)
{
int i;
for_each_possible_cpu(i) {
const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
u64 rx_packets, rx_bytes, tx_packets, tx_bytes;
unsigned int start;
do {
start = u64_stats_fetch_begin_bh(&tstats->syncp);
rx_packets = tstats->rx_packets;
tx_packets = tstats->tx_packets;
rx_bytes = tstats->rx_bytes;
tx_bytes = tstats->tx_bytes;
} while (u64_stats_fetch_retry_bh(&tstats->syncp, start));
tot->rx_packets += rx_packets;
tot->tx_packets += tx_packets;
tot->rx_bytes += rx_bytes;
tot->tx_bytes += tx_bytes;
}
tot->rx_errors = dev->stats.rx_errors;
tot->rx_frame_errors = dev->stats.rx_frame_errors;
tot->tx_fifo_errors = dev->stats.tx_fifo_errors;
tot->tx_carrier_errors = dev->stats.tx_carrier_errors;
tot->tx_dropped = dev->stats.tx_dropped;
tot->tx_aborted_errors = dev->stats.tx_aborted_errors;
tot->tx_errors = dev->stats.tx_errors;
return tot;
}
/* /*
* Must be invoked with rcu_read_lock * Must be invoked with rcu_read_lock
*/ */
...@@ -1202,7 +1167,7 @@ static const struct net_device_ops ipip6_netdev_ops = { ...@@ -1202,7 +1167,7 @@ static const struct net_device_ops ipip6_netdev_ops = {
.ndo_start_xmit = ipip6_tunnel_xmit, .ndo_start_xmit = ipip6_tunnel_xmit,
.ndo_do_ioctl = ipip6_tunnel_ioctl, .ndo_do_ioctl = ipip6_tunnel_ioctl,
.ndo_change_mtu = ipip6_tunnel_change_mtu, .ndo_change_mtu = ipip6_tunnel_change_mtu,
.ndo_get_stats64= ipip6_get_stats64, .ndo_get_stats64 = ip_tunnel_get_stats64,
}; };
static void ipip6_dev_free(struct net_device *dev) static void ipip6_dev_free(struct net_device *dev)
......
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