diff options
Diffstat (limited to 'net/ipv6/ipcomp6.c')
-rw-r--r-- | net/ipv6/ipcomp6.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 87e6407ebf97..8f3f32faaf4c 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c | |||
@@ -65,7 +65,7 @@ static LIST_HEAD(ipcomp6_tfms_list); | |||
65 | static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb) | 65 | static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb) |
66 | { | 66 | { |
67 | int err = -ENOMEM; | 67 | int err = -ENOMEM; |
68 | struct ipv6_comp_hdr *ipch; | 68 | struct ip_comp_hdr *ipch; |
69 | int plen, dlen; | 69 | int plen, dlen; |
70 | struct ipcomp_data *ipcd = x->data; | 70 | struct ipcomp_data *ipcd = x->data; |
71 | u8 *start, *scratch; | 71 | u8 *start, *scratch; |
@@ -92,12 +92,10 @@ static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
92 | tfm = *per_cpu_ptr(ipcd->tfms, cpu); | 92 | tfm = *per_cpu_ptr(ipcd->tfms, cpu); |
93 | 93 | ||
94 | err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); | 94 | err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); |
95 | if (err) { | 95 | if (err) |
96 | err = -EINVAL; | ||
97 | goto out_put_cpu; | 96 | goto out_put_cpu; |
98 | } | ||
99 | 97 | ||
100 | if (dlen < (plen + sizeof(struct ipv6_comp_hdr))) { | 98 | if (dlen < (plen + sizeof(*ipch))) { |
101 | err = -EINVAL; | 99 | err = -EINVAL; |
102 | goto out_put_cpu; | 100 | goto out_put_cpu; |
103 | } | 101 | } |
@@ -122,7 +120,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
122 | { | 120 | { |
123 | int err; | 121 | int err; |
124 | struct ipv6hdr *top_iph; | 122 | struct ipv6hdr *top_iph; |
125 | struct ipv6_comp_hdr *ipch; | 123 | struct ip_comp_hdr *ipch; |
126 | struct ipcomp_data *ipcd = x->data; | 124 | struct ipcomp_data *ipcd = x->data; |
127 | int plen, dlen; | 125 | int plen, dlen; |
128 | u8 *start, *scratch; | 126 | u8 *start, *scratch; |
@@ -151,7 +149,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
151 | tfm = *per_cpu_ptr(ipcd->tfms, cpu); | 149 | tfm = *per_cpu_ptr(ipcd->tfms, cpu); |
152 | 150 | ||
153 | err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); | 151 | err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); |
154 | if (err || (dlen + sizeof(struct ipv6_comp_hdr)) >= plen) { | 152 | if (err || (dlen + sizeof(*ipch)) >= plen) { |
155 | put_cpu(); | 153 | put_cpu(); |
156 | goto out_ok; | 154 | goto out_ok; |
157 | } | 155 | } |
@@ -164,7 +162,7 @@ static int ipcomp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
164 | 162 | ||
165 | top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); | 163 | top_iph->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); |
166 | 164 | ||
167 | ipch = (struct ipv6_comp_hdr *)start; | 165 | ipch = ip_comp_hdr(skb); |
168 | ipch->nexthdr = *skb_mac_header(skb); | 166 | ipch->nexthdr = *skb_mac_header(skb); |
169 | ipch->flags = 0; | 167 | ipch->flags = 0; |
170 | ipch->cpi = htons((u16 )ntohl(x->id.spi)); | 168 | ipch->cpi = htons((u16 )ntohl(x->id.spi)); |
@@ -179,7 +177,8 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
179 | { | 177 | { |
180 | __be32 spi; | 178 | __be32 spi; |
181 | struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; | 179 | struct ipv6hdr *iph = (struct ipv6hdr*)skb->data; |
182 | struct ipv6_comp_hdr *ipcomph = (struct ipv6_comp_hdr*)(skb->data+offset); | 180 | struct ip_comp_hdr *ipcomph = |
181 | (struct ip_comp_hdr *)(skb->data + offset); | ||
183 | struct xfrm_state *x; | 182 | struct xfrm_state *x; |
184 | 183 | ||
185 | if (type != ICMPV6_DEST_UNREACH && type != ICMPV6_PKT_TOOBIG) | 184 | if (type != ICMPV6_DEST_UNREACH && type != ICMPV6_PKT_TOOBIG) |