aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAmerigo Wang <amwang@redhat.com>2012-11-11 16:52:33 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-14 18:49:50 -0500
commitaa0010f880ab542da3ad0e72992f2dc518ac68a0 (patch)
treefe030d13bb1fcbf6071b268f06c068e2a7a50b0e /net
parentbf0098f22ca7b59e8844ac6882bbae230d34b98d (diff)
net: convert __IPTUNNEL_XMIT() to an inline function
__IPTUNNEL_XMIT() is an ugly macro, convert it to a static inline function, so make it more readable. IPTUNNEL_XMIT() is unused, just remove it. Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <amwang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ip_gre.c14
-rw-r--r--net/ipv4/ip_vti.c9
-rw-r--r--net/ipv4/ipip.c14
-rw-r--r--net/ipv6/ip6_gre.c9
-rw-r--r--net/ipv6/ip6_tunnel.c8
-rw-r--r--net/ipv6/sit.c14
6 files changed, 3 insertions, 65 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 7240f8e2dd45..37000ae24c55 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -171,15 +171,6 @@ struct ipgre_net {
171#define for_each_ip_tunnel_rcu(start) \ 171#define for_each_ip_tunnel_rcu(start) \
172 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) 172 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))
173 173
174/* often modified stats are per cpu, other are shared (netdev->stats) */
175struct pcpu_tstats {
176 u64 rx_packets;
177 u64 rx_bytes;
178 u64 tx_packets;
179 u64 tx_bytes;
180 struct u64_stats_sync syncp;
181};
182
183static struct rtnl_link_stats64 *ipgre_get_stats64(struct net_device *dev, 174static struct rtnl_link_stats64 *ipgre_get_stats64(struct net_device *dev,
184 struct rtnl_link_stats64 *tot) 175 struct rtnl_link_stats64 *tot)
185{ 176{
@@ -753,7 +744,6 @@ drop:
753static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) 744static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
754{ 745{
755 struct ip_tunnel *tunnel = netdev_priv(dev); 746 struct ip_tunnel *tunnel = netdev_priv(dev);
756 struct pcpu_tstats *tstats;
757 const struct iphdr *old_iph = ip_hdr(skb); 747 const struct iphdr *old_iph = ip_hdr(skb);
758 const struct iphdr *tiph; 748 const struct iphdr *tiph;
759 struct flowi4 fl4; 749 struct flowi4 fl4;
@@ -977,9 +967,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev
977 } 967 }
978 } 968 }
979 969
980 nf_reset(skb); 970 iptunnel_xmit(skb, dev);
981 tstats = this_cpu_ptr(dev->tstats);
982 __IPTUNNEL_XMIT(tstats, &dev->stats);
983 return NETDEV_TX_OK; 971 return NETDEV_TX_OK;
984 972
985#if IS_ENABLED(CONFIG_IPV6) 973#if IS_ENABLED(CONFIG_IPV6)
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 1831092f999f..e0f2c88f03c1 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -71,15 +71,6 @@ static int vti_tunnel_bind_dev(struct net_device *dev);
71#define for_each_ip_tunnel_rcu(start) \ 71#define for_each_ip_tunnel_rcu(start) \
72 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) 72 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))
73 73
74/* often modified stats are per cpu, other are shared (netdev->stats) */
75struct pcpu_tstats {
76 u64 rx_packets;
77 u64 rx_bytes;
78 u64 tx_packets;
79 u64 tx_bytes;
80 struct u64_stats_sync syncp;
81};
82
83#define VTI_XMIT(stats1, stats2) do { \ 74#define VTI_XMIT(stats1, stats2) do { \
84 int err; \ 75 int err; \
85 int pkt_len = skb->len; \ 76 int pkt_len = skb->len; \
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 720855e41100..3a4ad7d82f67 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -147,15 +147,6 @@ static struct rtnl_link_ops ipip_link_ops __read_mostly;
147#define for_each_ip_tunnel_rcu(start) \ 147#define for_each_ip_tunnel_rcu(start) \
148 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) 148 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))
149 149
150/* often modified stats are per cpu, other are shared (netdev->stats) */
151struct pcpu_tstats {
152 u64 rx_packets;
153 u64 rx_bytes;
154 u64 tx_packets;
155 u64 tx_bytes;
156 struct u64_stats_sync syncp;
157};
158
159static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev, 150static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
160 struct rtnl_link_stats64 *tot) 151 struct rtnl_link_stats64 *tot)
161{ 152{
@@ -465,7 +456,6 @@ drop:
465static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) 456static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
466{ 457{
467 struct ip_tunnel *tunnel = netdev_priv(dev); 458 struct ip_tunnel *tunnel = netdev_priv(dev);
468 struct pcpu_tstats *tstats;
469 const struct iphdr *tiph = &tunnel->parms.iph; 459 const struct iphdr *tiph = &tunnel->parms.iph;
470 u8 tos = tunnel->parms.iph.tos; 460 u8 tos = tunnel->parms.iph.tos;
471 __be16 df = tiph->frag_off; 461 __be16 df = tiph->frag_off;
@@ -592,9 +582,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
592 if ((iph->ttl = tiph->ttl) == 0) 582 if ((iph->ttl = tiph->ttl) == 0)
593 iph->ttl = old_iph->ttl; 583 iph->ttl = old_iph->ttl;
594 584
595 nf_reset(skb); 585 iptunnel_xmit(skb, dev);
596 tstats = this_cpu_ptr(dev->tstats);
597 __IPTUNNEL_XMIT(tstats, &dev->stats);
598 return NETDEV_TX_OK; 586 return NETDEV_TX_OK;
599 587
600tx_error_icmp: 588tx_error_icmp:
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 12aa473e9793..672101db71ee 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -116,15 +116,6 @@ static u32 HASH_ADDR(const struct in6_addr *addr)
116#define for_each_ip_tunnel_rcu(start) \ 116#define for_each_ip_tunnel_rcu(start) \
117 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) 117 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))
118 118
119/* often modified stats are per cpu, other are shared (netdev->stats) */
120struct pcpu_tstats {
121 u64 rx_packets;
122 u64 rx_bytes;
123 u64 tx_packets;
124 u64 tx_bytes;
125 struct u64_stats_sync syncp;
126};
127
128static struct rtnl_link_stats64 *ip6gre_get_stats64(struct net_device *dev, 119static struct rtnl_link_stats64 *ip6gre_get_stats64(struct net_device *dev,
129 struct rtnl_link_stats64 *tot) 120 struct rtnl_link_stats64 *tot)
130{ 121{
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 424ed45ef122..8db4d9b7ab14 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -95,14 +95,6 @@ struct ip6_tnl_net {
95 struct ip6_tnl __rcu **tnls[2]; 95 struct ip6_tnl __rcu **tnls[2];
96}; 96};
97 97
98/* often modified stats are per cpu, other are shared (netdev->stats) */
99struct pcpu_tstats {
100 unsigned long rx_packets;
101 unsigned long rx_bytes;
102 unsigned long tx_packets;
103 unsigned long tx_bytes;
104} __attribute__((aligned(4*sizeof(unsigned long))));
105
106static struct net_device_stats *ip6_get_stats(struct net_device *dev) 98static struct net_device_stats *ip6_get_stats(struct net_device *dev)
107{ 99{
108 struct pcpu_tstats sum = { 0 }; 100 struct pcpu_tstats sum = { 0 };
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index b543c56cad28..ffe83ef70cf7 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -88,15 +88,6 @@ struct sit_net {
88#define for_each_ip_tunnel_rcu(start) \ 88#define for_each_ip_tunnel_rcu(start) \
89 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next)) 89 for (t = rcu_dereference(start); t; t = rcu_dereference(t->next))
90 90
91/* often modified stats are per cpu, other are shared (netdev->stats) */
92struct pcpu_tstats {
93 u64 rx_packets;
94 u64 rx_bytes;
95 u64 tx_packets;
96 u64 tx_bytes;
97 struct u64_stats_sync syncp;
98};
99
100static struct rtnl_link_stats64 *ipip6_get_stats64(struct net_device *dev, 91static struct rtnl_link_stats64 *ipip6_get_stats64(struct net_device *dev,
101 struct rtnl_link_stats64 *tot) 92 struct rtnl_link_stats64 *tot)
102{ 93{
@@ -685,7 +676,6 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
685 struct net_device *dev) 676 struct net_device *dev)
686{ 677{
687 struct ip_tunnel *tunnel = netdev_priv(dev); 678 struct ip_tunnel *tunnel = netdev_priv(dev);
688 struct pcpu_tstats *tstats;
689 const struct iphdr *tiph = &tunnel->parms.iph; 679 const struct iphdr *tiph = &tunnel->parms.iph;
690 const struct ipv6hdr *iph6 = ipv6_hdr(skb); 680 const struct ipv6hdr *iph6 = ipv6_hdr(skb);
691 u8 tos = tunnel->parms.iph.tos; 681 u8 tos = tunnel->parms.iph.tos;
@@ -866,9 +856,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
866 if ((iph->ttl = tiph->ttl) == 0) 856 if ((iph->ttl = tiph->ttl) == 0)
867 iph->ttl = iph6->hop_limit; 857 iph->ttl = iph6->hop_limit;
868 858
869 nf_reset(skb); 859 iptunnel_xmit(skb, dev);
870 tstats = this_cpu_ptr(dev->tstats);
871 __IPTUNNEL_XMIT(tstats, &dev->stats);
872 return NETDEV_TX_OK; 860 return NETDEV_TX_OK;
873 861
874tx_error_icmp: 862tx_error_icmp: