diff options
Diffstat (limited to 'net/ipv4/xfrm4_mode_tunnel.c')
-rw-r--r-- | net/ipv4/xfrm4_mode_tunnel.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c index cc8bbb274e37..aa335dba8ffa 100644 --- a/net/ipv4/xfrm4_mode_tunnel.c +++ b/net/ipv4/xfrm4_mode_tunnel.c | |||
@@ -16,19 +16,12 @@ | |||
16 | 16 | ||
17 | static inline void ipip_ecn_decapsulate(struct sk_buff *skb) | 17 | static inline void ipip_ecn_decapsulate(struct sk_buff *skb) |
18 | { | 18 | { |
19 | struct iphdr *outer_iph = ip_hdr(skb); | ||
20 | struct iphdr *inner_iph = ipip_hdr(skb); | 19 | struct iphdr *inner_iph = ipip_hdr(skb); |
21 | 20 | ||
22 | if (INET_ECN_is_ce(outer_iph->tos)) | 21 | if (INET_ECN_is_ce(XFRM_MODE_SKB_CB(skb)->tos)) |
23 | IP_ECN_set_ce(inner_iph); | 22 | IP_ECN_set_ce(inner_iph); |
24 | } | 23 | } |
25 | 24 | ||
26 | static inline void ipip6_ecn_decapsulate(struct iphdr *iph, struct sk_buff *skb) | ||
27 | { | ||
28 | if (INET_ECN_is_ce(iph->tos)) | ||
29 | IP6_ECN_set_ce(ipv6_hdr(skb)); | ||
30 | } | ||
31 | |||
32 | /* Add encapsulation header. | 25 | /* Add encapsulation header. |
33 | * | 26 | * |
34 | * The top IP header will be constructed per RFC 2401. | 27 | * The top IP header will be constructed per RFC 2401. |
@@ -72,20 +65,11 @@ static int xfrm4_tunnel_output(struct xfrm_state *x, struct sk_buff *skb) | |||
72 | 65 | ||
73 | static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) | 66 | static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) |
74 | { | 67 | { |
75 | struct iphdr *iph = ip_hdr(skb); | ||
76 | const unsigned char *old_mac; | 68 | const unsigned char *old_mac; |
77 | int err = -EINVAL; | 69 | int err = -EINVAL; |
78 | 70 | ||
79 | switch (iph->protocol){ | 71 | if (XFRM_MODE_SKB_CB(skb)->protocol != IPPROTO_IPIP) |
80 | case IPPROTO_IPIP: | 72 | goto out; |
81 | break; | ||
82 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | ||
83 | case IPPROTO_IPV6: | ||
84 | break; | ||
85 | #endif | ||
86 | default: | ||
87 | goto out; | ||
88 | } | ||
89 | 73 | ||
90 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) | 74 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) |
91 | goto out; | 75 | goto out; |
@@ -94,20 +78,11 @@ static int xfrm4_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) | |||
94 | (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) | 78 | (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) |
95 | goto out; | 79 | goto out; |
96 | 80 | ||
97 | iph = ip_hdr(skb); | 81 | if (x->props.flags & XFRM_STATE_DECAP_DSCP) |
98 | if (iph->protocol == IPPROTO_IPIP) { | 82 | ipv4_copy_dscp(XFRM_MODE_SKB_CB(skb)->tos, ipip_hdr(skb)); |
99 | if (x->props.flags & XFRM_STATE_DECAP_DSCP) | 83 | if (!(x->props.flags & XFRM_STATE_NOECN)) |
100 | ipv4_copy_dscp(ipv4_get_dsfield(iph), ipip_hdr(skb)); | 84 | ipip_ecn_decapsulate(skb); |
101 | if (!(x->props.flags & XFRM_STATE_NOECN)) | 85 | |
102 | ipip_ecn_decapsulate(skb); | ||
103 | } | ||
104 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | ||
105 | else { | ||
106 | if (!(x->props.flags & XFRM_STATE_NOECN)) | ||
107 | ipip6_ecn_decapsulate(iph, skb); | ||
108 | skb->protocol = htons(ETH_P_IPV6); | ||
109 | } | ||
110 | #endif | ||
111 | old_mac = skb_mac_header(skb); | 86 | old_mac = skb_mac_header(skb); |
112 | skb_set_mac_header(skb, -skb->mac_len); | 87 | skb_set_mac_header(skb, -skb->mac_len); |
113 | memmove(skb_mac_header(skb), old_mac, skb->mac_len); | 88 | memmove(skb_mac_header(skb), old_mac, skb->mac_len); |
@@ -119,7 +94,8 @@ out: | |||
119 | } | 94 | } |
120 | 95 | ||
121 | static struct xfrm_mode xfrm4_tunnel_mode = { | 96 | static struct xfrm_mode xfrm4_tunnel_mode = { |
122 | .input = xfrm4_tunnel_input, | 97 | .input2 = xfrm4_tunnel_input, |
98 | .input = xfrm_prepare_input, | ||
123 | .output2 = xfrm4_tunnel_output, | 99 | .output2 = xfrm4_tunnel_output, |
124 | .output = xfrm4_prepare_output, | 100 | .output = xfrm4_prepare_output, |
125 | .owner = THIS_MODULE, | 101 | .owner = THIS_MODULE, |