Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Tunneling: use IP Tunnel stats APIs.

Use common function get calculate rtnl_link_stats64 stats.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Pravin B Shelar and committed by
David S. Miller
f61dd388 206aaafc

+7 -117
+1
net/ipv4/Kconfig
··· 319 319 config NET_IPVTI 320 320 tristate "Virtual (secure) IP: tunneling" 321 321 select INET_TUNNEL 322 + select NET_IP_TUNNEL 322 323 depends on INET_XFRM_MODE_TUNNEL 323 324 ---help--- 324 325 Tunneling means encapsulating data of one protocol type within
+1 -39
net/ipv4/ip_vti.c
··· 82 82 } while (0) 83 83 84 84 85 - static struct rtnl_link_stats64 *vti_get_stats64(struct net_device *dev, 86 - struct rtnl_link_stats64 *tot) 87 - { 88 - int i; 89 - 90 - for_each_possible_cpu(i) { 91 - const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i); 92 - u64 rx_packets, rx_bytes, tx_packets, tx_bytes; 93 - unsigned int start; 94 - 95 - do { 96 - start = u64_stats_fetch_begin_bh(&tstats->syncp); 97 - rx_packets = tstats->rx_packets; 98 - tx_packets = tstats->tx_packets; 99 - rx_bytes = tstats->rx_bytes; 100 - tx_bytes = tstats->tx_bytes; 101 - } while (u64_stats_fetch_retry_bh(&tstats->syncp, start)); 102 - 103 - tot->rx_packets += rx_packets; 104 - tot->tx_packets += tx_packets; 105 - tot->rx_bytes += rx_bytes; 106 - tot->tx_bytes += tx_bytes; 107 - } 108 - 109 - tot->multicast = dev->stats.multicast; 110 - tot->rx_crc_errors = dev->stats.rx_crc_errors; 111 - tot->rx_fifo_errors = dev->stats.rx_fifo_errors; 112 - tot->rx_length_errors = dev->stats.rx_length_errors; 113 - tot->rx_errors = dev->stats.rx_errors; 114 - tot->tx_fifo_errors = dev->stats.tx_fifo_errors; 115 - tot->tx_carrier_errors = dev->stats.tx_carrier_errors; 116 - tot->tx_dropped = dev->stats.tx_dropped; 117 - tot->tx_aborted_errors = dev->stats.tx_aborted_errors; 118 - tot->tx_errors = dev->stats.tx_errors; 119 - 120 - return tot; 121 - } 122 - 123 85 static struct ip_tunnel *vti_tunnel_lookup(struct net *net, 124 86 __be32 remote, __be32 local) 125 87 { ··· 559 597 .ndo_start_xmit = vti_tunnel_xmit, 560 598 .ndo_do_ioctl = vti_tunnel_ioctl, 561 599 .ndo_change_mtu = vti_tunnel_change_mtu, 562 - .ndo_get_stats64 = vti_get_stats64, 600 + .ndo_get_stats64 = ip_tunnel_get_stats64, 563 601 }; 564 602 565 603 static void vti_dev_free(struct net_device *dev)
+2
net/ipv6/Kconfig
··· 156 156 config IPV6_SIT 157 157 tristate "IPv6: IPv6-in-IPv4 tunnel (SIT driver)" 158 158 select INET_TUNNEL 159 + select NET_IP_TUNNEL 159 160 select IPV6_NDISC_NODETYPE 160 161 default y 161 162 ---help--- ··· 202 201 config IPV6_GRE 203 202 tristate "IPv6: GRE tunnel" 204 203 select IPV6_TUNNEL 204 + select NET_IP_TUNNEL 205 205 ---help--- 206 206 Tunneling means encapsulating data of one protocol type within 207 207 another protocol and sending it over a channel that understands the
+2 -42
net/ipv6/ip6_gre.c
··· 111 111 #define tunnels_l tunnels[1] 112 112 #define tunnels_wc tunnels[0] 113 113 114 - static struct rtnl_link_stats64 *ip6gre_get_stats64(struct net_device *dev, 115 - struct rtnl_link_stats64 *tot) 116 - { 117 - int i; 118 - 119 - for_each_possible_cpu(i) { 120 - const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i); 121 - u64 rx_packets, rx_bytes, tx_packets, tx_bytes; 122 - unsigned int start; 123 - 124 - do { 125 - start = u64_stats_fetch_begin_bh(&tstats->syncp); 126 - rx_packets = tstats->rx_packets; 127 - tx_packets = tstats->tx_packets; 128 - rx_bytes = tstats->rx_bytes; 129 - tx_bytes = tstats->tx_bytes; 130 - } while (u64_stats_fetch_retry_bh(&tstats->syncp, start)); 131 - 132 - tot->rx_packets += rx_packets; 133 - tot->tx_packets += tx_packets; 134 - tot->rx_bytes += rx_bytes; 135 - tot->tx_bytes += tx_bytes; 136 - } 137 - 138 - tot->multicast = dev->stats.multicast; 139 - tot->rx_crc_errors = dev->stats.rx_crc_errors; 140 - tot->rx_fifo_errors = dev->stats.rx_fifo_errors; 141 - tot->rx_length_errors = dev->stats.rx_length_errors; 142 - tot->rx_frame_errors = dev->stats.rx_frame_errors; 143 - tot->rx_errors = dev->stats.rx_errors; 144 - 145 - tot->tx_fifo_errors = dev->stats.tx_fifo_errors; 146 - tot->tx_carrier_errors = dev->stats.tx_carrier_errors; 147 - tot->tx_dropped = dev->stats.tx_dropped; 148 - tot->tx_aborted_errors = dev->stats.tx_aborted_errors; 149 - tot->tx_errors = dev->stats.tx_errors; 150 - 151 - return tot; 152 - } 153 - 154 114 /* Given src, dst and key, find appropriate for input tunnel. */ 155 115 156 116 static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, ··· 1217 1257 .ndo_start_xmit = ip6gre_tunnel_xmit, 1218 1258 .ndo_do_ioctl = ip6gre_tunnel_ioctl, 1219 1259 .ndo_change_mtu = ip6gre_tunnel_change_mtu, 1220 - .ndo_get_stats64 = ip6gre_get_stats64, 1260 + .ndo_get_stats64 = ip_tunnel_get_stats64, 1221 1261 }; 1222 1262 1223 1263 static void ip6gre_dev_free(struct net_device *dev) ··· 1466 1506 .ndo_set_mac_address = eth_mac_addr, 1467 1507 .ndo_validate_addr = eth_validate_addr, 1468 1508 .ndo_change_mtu = ip6gre_tunnel_change_mtu, 1469 - .ndo_get_stats64 = ip6gre_get_stats64, 1509 + .ndo_get_stats64 = ip_tunnel_get_stats64, 1470 1510 }; 1471 1511 1472 1512 static void ip6gre_tap_setup(struct net_device *dev)
+1 -36
net/ipv6/sit.c
··· 87 87 struct net_device *fb_tunnel_dev; 88 88 }; 89 89 90 - static struct rtnl_link_stats64 *ipip6_get_stats64(struct net_device *dev, 91 - struct rtnl_link_stats64 *tot) 92 - { 93 - int i; 94 - 95 - for_each_possible_cpu(i) { 96 - const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i); 97 - u64 rx_packets, rx_bytes, tx_packets, tx_bytes; 98 - unsigned int start; 99 - 100 - do { 101 - start = u64_stats_fetch_begin_bh(&tstats->syncp); 102 - rx_packets = tstats->rx_packets; 103 - tx_packets = tstats->tx_packets; 104 - rx_bytes = tstats->rx_bytes; 105 - tx_bytes = tstats->tx_bytes; 106 - } while (u64_stats_fetch_retry_bh(&tstats->syncp, start)); 107 - 108 - tot->rx_packets += rx_packets; 109 - tot->tx_packets += tx_packets; 110 - tot->rx_bytes += rx_bytes; 111 - tot->tx_bytes += tx_bytes; 112 - } 113 - 114 - tot->rx_errors = dev->stats.rx_errors; 115 - tot->rx_frame_errors = dev->stats.rx_frame_errors; 116 - tot->tx_fifo_errors = dev->stats.tx_fifo_errors; 117 - tot->tx_carrier_errors = dev->stats.tx_carrier_errors; 118 - tot->tx_dropped = dev->stats.tx_dropped; 119 - tot->tx_aborted_errors = dev->stats.tx_aborted_errors; 120 - tot->tx_errors = dev->stats.tx_errors; 121 - 122 - return tot; 123 - } 124 - 125 90 /* 126 91 * Must be invoked with rcu_read_lock 127 92 */ ··· 1167 1202 .ndo_start_xmit = ipip6_tunnel_xmit, 1168 1203 .ndo_do_ioctl = ipip6_tunnel_ioctl, 1169 1204 .ndo_change_mtu = ipip6_tunnel_change_mtu, 1170 - .ndo_get_stats64= ipip6_get_stats64, 1205 + .ndo_get_stats64 = ip_tunnel_get_stats64, 1171 1206 }; 1172 1207 1173 1208 static void ipip6_dev_free(struct net_device *dev)