@@ -128,9 +128,7 @@ static void ipv6_rearrange_destopt(struct ipv6hdr *iph, struct ipv6_opt_hdr *des
128128 off += optlen ;
129129 len -= optlen ;
130130 }
131- if (len == 0 )
132- return ;
133-
131+ /* Note: ok if len == 0 */
134132bad :
135133 return ;
136134}
@@ -175,11 +173,7 @@ static void ipv6_rearrange_rthdr(struct ipv6hdr *iph, struct ipv6_rt_hdr *rthdr)
175173 ipv6_addr_copy (& iph -> daddr , & final_addr );
176174}
177175
178- #ifdef CONFIG_IPV6_MIP6
179176static int ipv6_clear_mutable_options (struct ipv6hdr * iph , int len , int dir )
180- #else
181- static int ipv6_clear_mutable_options (struct ipv6hdr * iph , int len )
182- #endif
183177{
184178 union {
185179 struct ipv6hdr * iph ;
@@ -194,30 +188,12 @@ static int ipv6_clear_mutable_options(struct ipv6hdr *iph, int len)
194188
195189 while (exthdr .raw < end ) {
196190 switch (nexthdr ) {
197- #ifdef CONFIG_IPV6_MIP6
198- case NEXTHDR_HOP :
199- if (!zero_out_mutable_opts (exthdr .opth )) {
200- LIMIT_NETDEBUG (
201- KERN_WARNING "overrun %sopts\n" ,
202- nexthdr == NEXTHDR_HOP ?
203- "hop" : "dest" );
204- return - EINVAL ;
205- }
206- break ;
207191 case NEXTHDR_DEST :
192+ #ifdef CONFIG_IPV6_MIP6
208193 if (dir == XFRM_POLICY_OUT )
209194 ipv6_rearrange_destopt (iph , exthdr .opth );
210- if (!zero_out_mutable_opts (exthdr .opth )) {
211- LIMIT_NETDEBUG (
212- KERN_WARNING "overrun %sopts\n" ,
213- nexthdr == NEXTHDR_HOP ?
214- "hop" : "dest" );
215- return - EINVAL ;
216- }
217- break ;
218- #else
195+ #endif
219196 case NEXTHDR_HOP :
220- case NEXTHDR_DEST :
221197 if (!zero_out_mutable_opts (exthdr .opth )) {
222198 LIMIT_NETDEBUG (
223199 KERN_WARNING "overrun %sopts\n" ,
@@ -226,7 +202,6 @@ static int ipv6_clear_mutable_options(struct ipv6hdr *iph, int len)
226202 return - EINVAL ;
227203 }
228204 break ;
229- #endif
230205
231206 case NEXTHDR_ROUTING :
232207 ipv6_rearrange_rthdr (iph , exthdr .rth );
@@ -282,16 +257,13 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
282257 }
283258#ifdef CONFIG_IPV6_MIP6
284259 memcpy (tmp_ext , & top_iph -> saddr , extlen );
285- err = ipv6_clear_mutable_options (top_iph ,
286- extlen - sizeof (* tmp_ext ) +
287- sizeof (* top_iph ),
288- XFRM_POLICY_OUT );
289260#else
290261 memcpy (tmp_ext , & top_iph -> daddr , extlen );
262+ #endif
291263 err = ipv6_clear_mutable_options (top_iph ,
292264 extlen - sizeof (* tmp_ext ) +
293- sizeof (* top_iph ));
294- #endif
265+ sizeof (* top_iph ),
266+ XFRM_POLICY_OUT );
295267 if (err )
296268 goto error_free_iph ;
297269 }
@@ -386,13 +358,8 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
386358 if (!tmp_hdr )
387359 goto out ;
388360 memcpy (tmp_hdr , skb -> nh .raw , hdr_len );
389- #ifdef CONFIG_IPV6_MIP6
390361 if (ipv6_clear_mutable_options (skb -> nh .ipv6h , hdr_len , XFRM_POLICY_IN ))
391362 goto free_out ;
392- #else
393- if (ipv6_clear_mutable_options (skb -> nh .ipv6h , hdr_len ))
394- goto free_out ;
395- #endif
396363 skb -> nh .ipv6h -> priority = 0 ;
397364 skb -> nh .ipv6h -> flow_lbl [0 ] = 0 ;
398365 skb -> nh .ipv6h -> flow_lbl [1 ] = 0 ;
0 commit comments