diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2013-03-09 11:38:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-03-10 03:05:44 -0400 |
commit | 6aed0c8bf7d2f389b472834053eb6e3bd6926999 (patch) | |
tree | 0b180bcbbefd6e6e447b8771d50fe5371b75bd29 | |
parent | 4f3ed9209f7f75ff0ee21bc5052d76542dd75b5f (diff) |
tunnel: use iptunnel_xmit() again
With recent patches from Pravin, most tunnels can't use iptunnel_xmit()
any more, due to ip_select_ident() and skb->ip_summed. But we can just
move these operations out of iptunnel_xmit(), so that tunnels can
use it again.
This by the way fixes a bug in vxlan (missing nf_reset()) for net-next.
Cc: Pravin B Shelar <pshelar@nicira.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/vxlan.c | 14 | ||||
-rw-r--r-- | include/net/ipip.h | 3 | ||||
-rw-r--r-- | net/ipv4/ip_gre.c | 16 | ||||
-rw-r--r-- | net/ipv4/ipip.c | 18 | ||||
-rw-r--r-- | net/ipv6/sit.c | 2 |
5 files changed, 5 insertions, 48 deletions
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index f057ec00bba3..f3a135cb50a9 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
@@ -855,7 +855,6 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) | |||
855 | __u16 src_port; | 855 | __u16 src_port; |
856 | __be16 df = 0; | 856 | __be16 df = 0; |
857 | __u8 tos, ttl; | 857 | __u8 tos, ttl; |
858 | int err; | ||
859 | bool did_rsc = false; | 858 | bool did_rsc = false; |
860 | const struct vxlan_fdb *f; | 859 | const struct vxlan_fdb *f; |
861 | 860 | ||
@@ -980,18 +979,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) | |||
980 | if (handle_offloads(skb)) | 979 | if (handle_offloads(skb)) |
981 | goto drop; | 980 | goto drop; |
982 | 981 | ||
983 | err = ip_local_out(skb); | 982 | iptunnel_xmit(skb, dev); |
984 | if (likely(net_xmit_eval(err) == 0)) { | ||
985 | struct vxlan_stats *stats = this_cpu_ptr(vxlan->stats); | ||
986 | |||
987 | u64_stats_update_begin(&stats->syncp); | ||
988 | stats->tx_packets++; | ||
989 | stats->tx_bytes += pkt_len; | ||
990 | u64_stats_update_end(&stats->syncp); | ||
991 | } else { | ||
992 | dev->stats.tx_errors++; | ||
993 | dev->stats.tx_aborted_errors++; | ||
994 | } | ||
995 | return NETDEV_TX_OK; | 983 | return NETDEV_TX_OK; |
996 | 984 | ||
997 | drop: | 985 | drop: |
diff --git a/include/net/ipip.h b/include/net/ipip.h index fd19625ff99d..0c046e3bca05 100644 --- a/include/net/ipip.h +++ b/include/net/ipip.h | |||
@@ -51,13 +51,10 @@ struct ip_tunnel_prl_entry { | |||
51 | static inline void iptunnel_xmit(struct sk_buff *skb, struct net_device *dev) | 51 | static inline void iptunnel_xmit(struct sk_buff *skb, struct net_device *dev) |
52 | { | 52 | { |
53 | int err; | 53 | int err; |
54 | struct iphdr *iph = ip_hdr(skb); | ||
55 | int pkt_len = skb->len - skb_transport_offset(skb); | 54 | int pkt_len = skb->len - skb_transport_offset(skb); |
56 | struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats); | 55 | struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats); |
57 | 56 | ||
58 | nf_reset(skb); | 57 | nf_reset(skb); |
59 | skb->ip_summed = CHECKSUM_NONE; | ||
60 | ip_select_ident(iph, skb_dst(skb), NULL); | ||
61 | 58 | ||
62 | err = ip_local_out(skb); | 59 | err = ip_local_out(skb); |
63 | if (likely(net_xmit_eval(err) == 0)) { | 60 | if (likely(net_xmit_eval(err) == 0)) { |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index d0ef0e674ec5..a13a0972a57f 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -762,7 +762,6 @@ error: | |||
762 | 762 | ||
763 | static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | 763 | static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) |
764 | { | 764 | { |
765 | struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats); | ||
766 | struct ip_tunnel *tunnel = netdev_priv(dev); | 765 | struct ip_tunnel *tunnel = netdev_priv(dev); |
767 | const struct iphdr *old_iph; | 766 | const struct iphdr *old_iph; |
768 | const struct iphdr *tiph; | 767 | const struct iphdr *tiph; |
@@ -778,7 +777,6 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev | |||
778 | int mtu; | 777 | int mtu; |
779 | u8 ttl; | 778 | u8 ttl; |
780 | int err; | 779 | int err; |
781 | int pkt_len; | ||
782 | 780 | ||
783 | skb = handle_offloads(tunnel, skb); | 781 | skb = handle_offloads(tunnel, skb); |
784 | if (IS_ERR(skb)) { | 782 | if (IS_ERR(skb)) { |
@@ -1022,19 +1020,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev | |||
1022 | } | 1020 | } |
1023 | } | 1021 | } |
1024 | 1022 | ||
1025 | nf_reset(skb); | 1023 | iptunnel_xmit(skb, dev); |
1026 | |||
1027 | pkt_len = skb->len - skb_transport_offset(skb); | ||
1028 | err = ip_local_out(skb); | ||
1029 | if (likely(net_xmit_eval(err) == 0)) { | ||
1030 | u64_stats_update_begin(&tstats->syncp); | ||
1031 | tstats->tx_bytes += pkt_len; | ||
1032 | tstats->tx_packets++; | ||
1033 | u64_stats_update_end(&tstats->syncp); | ||
1034 | } else { | ||
1035 | dev->stats.tx_errors++; | ||
1036 | dev->stats.tx_aborted_errors++; | ||
1037 | } | ||
1038 | return NETDEV_TX_OK; | 1024 | return NETDEV_TX_OK; |
1039 | 1025 | ||
1040 | #if IS_ENABLED(CONFIG_IPV6) | 1026 | #if IS_ENABLED(CONFIG_IPV6) |
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index b50435ba0ce5..34e006fe2d87 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
@@ -478,8 +478,6 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
478 | __be32 dst = tiph->daddr; | 478 | __be32 dst = tiph->daddr; |
479 | struct flowi4 fl4; | 479 | struct flowi4 fl4; |
480 | int mtu; | 480 | int mtu; |
481 | int err; | ||
482 | int pkt_len; | ||
483 | 481 | ||
484 | if (skb->protocol != htons(ETH_P_IP)) | 482 | if (skb->protocol != htons(ETH_P_IP)) |
485 | goto tx_error; | 483 | goto tx_error; |
@@ -600,21 +598,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
600 | if ((iph->ttl = tiph->ttl) == 0) | 598 | if ((iph->ttl = tiph->ttl) == 0) |
601 | iph->ttl = old_iph->ttl; | 599 | iph->ttl = old_iph->ttl; |
602 | 600 | ||
603 | nf_reset(skb); | 601 | iptunnel_xmit(skb, dev); |
604 | |||
605 | pkt_len = skb->len - skb_transport_offset(skb); | ||
606 | err = ip_local_out(skb); | ||
607 | if (likely(net_xmit_eval(err) == 0)) { | ||
608 | struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats); | ||
609 | |||
610 | u64_stats_update_begin(&tstats->syncp); | ||
611 | tstats->tx_bytes += pkt_len; | ||
612 | tstats->tx_packets++; | ||
613 | u64_stats_update_end(&tstats->syncp); | ||
614 | } else { | ||
615 | dev->stats.tx_errors++; | ||
616 | dev->stats.tx_aborted_errors++; | ||
617 | } | ||
618 | 602 | ||
619 | return NETDEV_TX_OK; | 603 | return NETDEV_TX_OK; |
620 | 604 | ||
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 02f96dcbcf02..898e671a526b 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -899,6 +899,8 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb, | |||
899 | if ((iph->ttl = tiph->ttl) == 0) | 899 | if ((iph->ttl = tiph->ttl) == 0) |
900 | iph->ttl = iph6->hop_limit; | 900 | iph->ttl = iph6->hop_limit; |
901 | 901 | ||
902 | skb->ip_summed = CHECKSUM_NONE; | ||
903 | ip_select_ident(iph, skb_dst(skb), NULL); | ||
902 | iptunnel_xmit(skb, dev); | 904 | iptunnel_xmit(skb, dev); |
903 | return NETDEV_TX_OK; | 905 | return NETDEV_TX_OK; |
904 | 906 | ||