Skip to content

Commit e731c24

Browse files
yoshfujiDavid S. Miller
authored andcommitted
[IPV6] MIP6: Several obvious clean-ups.
- Remove redundant code. Pointed out by Brian Haley <[email protected]>. - Unify code paths with/without CONFIG_IPV6_MIP. - Use NIP6_FMT for IPv6 address textual presentation. - Fold long line. Pointed out by David Miller <[email protected]>. Signed-off-by: YOSHIFUJI Hideaki <[email protected]>
1 parent e4bec82 commit e731c24

File tree

3 files changed

+10
-42
lines changed

3 files changed

+10
-42
lines changed

net/ipv6/ah6.c

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -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 */
134132
bad:
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
179176
static 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;

net/ipv6/exthdrs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ int ipv6_find_tlv(struct sk_buff *skb, int offset, int type)
8787
len -= optlen;
8888
}
8989
/* not_found */
90-
return -1;
9190
bad:
9291
return -1;
9392
}

net/ipv6/mip6.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
121121
&skb->nh.ipv6h->daddr,
122122
mhlen, IPPROTO_MH,
123123
skb_checksum(skb, 0, mhlen, 0))) {
124-
LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH checksum failed [%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x > %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]\n",
124+
LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH checksum failed "
125+
"[" NIP6_FMT " > " NIP6_FMT "]\n",
125126
NIP6(skb->nh.ipv6h->saddr),
126127
NIP6(skb->nh.ipv6h->daddr));
127128
return -1;
@@ -234,7 +235,8 @@ static int mip6_destopt_reject(struct xfrm_state *x, struct sk_buff *skb, struct
234235
struct timeval stamp;
235236
int err = 0;
236237

237-
if (unlikely(fl->proto == IPPROTO_MH && fl->fl_mh_type <= IP6_MH_TYPE_MAX))
238+
if (unlikely(fl->proto == IPPROTO_MH &&
239+
fl->fl_mh_type <= IP6_MH_TYPE_MAX))
238240
goto out;
239241

240242
if (likely(opt->dsthao)) {

0 commit comments

Comments
 (0)