aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/xfrm4_mode_tunnel.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/xfrm4_mode_tunnel.c')
-rw-r--r--net/ipv4/xfrm4_mode_tunnel.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c
index 68a9f56ff09f..cc8bbb274e37 100644
--- a/net/ipv4/xfrm4_mode_tunnel.c
+++ b/net/ipv4/xfrm4_mode_tunnel.c
@@ -36,53 +36,37 @@ static inline void ipip6_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb)
36static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb) 36static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
37{ 37{
38 struct dst_entry *dst = skb->dst; 38 struct dst_entry *dst = skb->dst;
39 struct xfrm_dst *xdst = (struct xfrm_dst*)dst; 39 struct iphdr *top_iph;
40 struct iphdr *iph, *top_iph;
41 int flags; 40 int flags;
42 41
43 iph = ip_hdr(skb);
44
45 skb_set_network_header(skb, -x->props.header_len); 42 skb_set_network_header(skb, -x->props.header_len);
46 skb->mac_header = skb->network_header + 43 skb->mac_header = skb->network_header +
47 offsetof(struct iphdr, protocol); 44 offsetof(struct iphdr, protocol);
48 skb->transport_header = skb->network_header + sizeof(*iph); 45 skb->transport_header = skb->network_header + sizeof(*top_iph);
49 top_iph = ip_hdr(skb); 46 top_iph = ip_hdr(skb);
50 47
51 top_iph->ihl = 5; 48 top_iph->ihl = 5;
52 top_iph->version = 4; 49 top_iph->version = 4;
53 50
54 flags = x->props.flags; 51 top_iph->protocol = x->inner_mode->afinfo->proto;
55 52
56 /* DS disclosed */ 53 /* DS disclosed */
57 if (xdst->route->ops->family == AF_INET) { 54 top_iph->tos = INET_ECN_encapsulate(XFRM_MODE_SKB_CB(skb)->tos,
58 top_iph->protocol = IPPROTO_IPIP; 55 XFRM_MODE_SKB_CB(skb)->tos);
59 top_iph->tos = INET_ECN_encapsulate(iph->tos, iph->tos);
60 top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
61 0 : (iph->frag_off & htons(IP_DF));
62 }
63#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
64 else {
65 struct ipv6hdr *ipv6h = (struct ipv6hdr*)iph;
66 top_iph->protocol = IPPROTO_IPV6;
67 top_iph->tos = INET_ECN_encapsulate(iph->tos, ipv6_get_dsfield(ipv6h));
68 top_iph->frag_off = 0;
69 }
70#endif
71 56
57 flags = x->props.flags;
72 if (flags & XFRM_STATE_NOECN) 58 if (flags & XFRM_STATE_NOECN)
73 IP_ECN_clear(top_iph); 59 IP_ECN_clear(top_iph);
74 60
75 if (!top_iph->frag_off) 61 top_iph->frag_off = (flags & XFRM_STATE_NOPMTUDISC) ?
76 __ip_select_ident(top_iph, dst->child, 0); 62 0 : XFRM_MODE_SKB_CB(skb)->frag_off;
63 ip_select_ident(top_iph, dst->child, NULL);
77 64
78 top_iph->ttl = dst_metric(dst->child, RTAX_HOPLIMIT); 65 top_iph->ttl = dst_metric(dst->child, RTAX_HOPLIMIT);
79 66
80 top_iph->saddr = x->props.saddr.a4; 67 top_iph->saddr = x->props.saddr.a4;
81 top_iph->daddr = x->id.daddr.a4; 68 top_iph->daddr = x->id.daddr.a4;
82 69
83 skb->protocol = htons(ETH_P_IP);
84
85 memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
86 return 0; 70 return 0;
87} 71}
88 72
@@ -136,7 +120,8 @@ out:
136 120
137static struct xfrm_mode xfrm4_tunnel_mode = { 121static struct xfrm_mode xfrm4_tunnel_mode = {
138 .input = xfrm4_tunnel_input, 122 .input = xfrm4_tunnel_input,
139 .output = xfrm4_tunnel_output, 123 .output2 = xfrm4_tunnel_output,
124 .output = xfrm4_prepare_output,
140 .owner = THIS_MODULE, 125 .owner = THIS_MODULE,
141 .encap = XFRM_MODE_TUNNEL, 126 .encap = XFRM_MODE_TUNNEL,
142 .flags = XFRM_MODE_FLAG_TUNNEL, 127 .flags = XFRM_MODE_FLAG_TUNNEL,