aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorPravin B Shelar <pshelar@nicira.com>2013-06-17 20:49:56 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-19 21:07:41 -0400
commit0e6fbc5b6c6218987c93b8c7ca60cf786062899d (patch)
tree5b1241cdd4e43148cd09bc2f6b33d92990680909 /net/ipv6
parent45f2e9976cb6fc3f1cc533fd53fe74da5a9dbce4 (diff)
ip_tunnels: extend iptunnel_xmit()
Refactor various ip tunnels xmit functions and extend iptunnel_xmit() so that there is more code sharing. Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/sit.c39
1 files changed, 10 insertions, 29 deletions
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 6b9c1f128eaf..76bb8de435b2 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -723,13 +723,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
723 __be16 df = tiph->frag_off; 723 __be16 df = tiph->frag_off;
724 struct rtable *rt; /* Route to the other host */ 724 struct rtable *rt; /* Route to the other host */
725 struct net_device *tdev; /* Device to other host */ 725 struct net_device *tdev; /* Device to other host */
726 struct iphdr *iph; /* Our new IP header */
727 unsigned int max_headroom; /* The extra header space needed */ 726 unsigned int max_headroom; /* The extra header space needed */
728 __be32 dst = tiph->daddr; 727 __be32 dst = tiph->daddr;
729 struct flowi4 fl4; 728 struct flowi4 fl4;
730 int mtu; 729 int mtu;
731 const struct in6_addr *addr6; 730 const struct in6_addr *addr6;
732 int addr_type; 731 int addr_type;
732 u8 ttl;
733 int err;
733 734
734 if (skb->protocol != htons(ETH_P_IPV6)) 735 if (skb->protocol != htons(ETH_P_IPV6))
735 goto tx_error; 736 goto tx_error;
@@ -872,34 +873,14 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
872 skb = new_skb; 873 skb = new_skb;
873 iph6 = ipv6_hdr(skb); 874 iph6 = ipv6_hdr(skb);
874 } 875 }
875 876 ttl = tiph->ttl;
876 skb->transport_header = skb->network_header; 877 if (ttl == 0)
877 skb_push(skb, sizeof(struct iphdr)); 878 ttl = iph6->hop_limit;
878 skb_reset_network_header(skb); 879 tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6));
879 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); 880
880 IPCB(skb)->flags = 0; 881 err = iptunnel_xmit(dev_net(dev), rt, skb, fl4.saddr, fl4.daddr,
881 skb_dst_drop(skb); 882 IPPROTO_IPV6, tos, ttl, df);
882 skb_dst_set(skb, &rt->dst); 883 iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
883
884 /*
885 * Push down and install the IPIP header.
886 */
887
888 iph = ip_hdr(skb);
889 iph->version = 4;
890 iph->ihl = sizeof(struct iphdr)>>2;
891 iph->frag_off = df;
892 iph->protocol = IPPROTO_IPV6;
893 iph->tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6));
894 iph->daddr = fl4.daddr;
895 iph->saddr = fl4.saddr;
896
897 if ((iph->ttl = tiph->ttl) == 0)
898 iph->ttl = iph6->hop_limit;
899
900 skb->ip_summed = CHECKSUM_NONE;
901 ip_select_ident(iph, skb_dst(skb), NULL);
902 iptunnel_xmit(skb, dev);
903 return NETDEV_TX_OK; 884 return NETDEV_TX_OK;
904 885
905tx_error_icmp: 886tx_error_icmp: