diff options
Diffstat (limited to 'net/ipv6/mip6.c')
-rw-r--r-- | net/ipv6/mip6.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c index 0f9bdc5ee9f..43242e6e610 100644 --- a/net/ipv6/mip6.c +++ b/net/ipv6/mip6.c | |||
@@ -22,8 +22,6 @@ | |||
22 | * Masahide NAKAMURA @USAGI | 22 | * Masahide NAKAMURA @USAGI |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
26 | |||
27 | #include <linux/module.h> | 25 | #include <linux/module.h> |
28 | #include <linux/skbuff.h> | 26 | #include <linux/skbuff.h> |
29 | #include <linux/time.h> | 27 | #include <linux/time.h> |
@@ -46,7 +44,7 @@ static inline void *mip6_padn(__u8 *data, __u8 padlen) | |||
46 | if (!data) | 44 | if (!data) |
47 | return NULL; | 45 | return NULL; |
48 | if (padlen == 1) { | 46 | if (padlen == 1) { |
49 | data[0] = IPV6_TLV_PAD1; | 47 | data[0] = IPV6_TLV_PAD0; |
50 | } else if (padlen > 1) { | 48 | } else if (padlen > 1) { |
51 | data[0] = IPV6_TLV_PADN; | 49 | data[0] = IPV6_TLV_PADN; |
52 | data[1] = padlen - 2; | 50 | data[1] = padlen - 2; |
@@ -86,30 +84,28 @@ static int mip6_mh_len(int type) | |||
86 | 84 | ||
87 | static int mip6_mh_filter(struct sock *sk, struct sk_buff *skb) | 85 | static int mip6_mh_filter(struct sock *sk, struct sk_buff *skb) |
88 | { | 86 | { |
89 | struct ip6_mh _hdr; | 87 | struct ip6_mh *mh; |
90 | const struct ip6_mh *mh; | ||
91 | 88 | ||
92 | mh = skb_header_pointer(skb, skb_transport_offset(skb), | 89 | if (!pskb_may_pull(skb, (skb_transport_offset(skb)) + 8) || |
93 | sizeof(_hdr), &_hdr); | 90 | !pskb_may_pull(skb, (skb_transport_offset(skb) + |
94 | if (!mh) | 91 | ((skb_transport_header(skb)[1] + 1) << 3)))) |
95 | return -1; | 92 | return -1; |
96 | 93 | ||
97 | if (((mh->ip6mh_hdrlen + 1) << 3) > skb->len) | 94 | mh = (struct ip6_mh *)skb_transport_header(skb); |
98 | return -1; | ||
99 | 95 | ||
100 | if (mh->ip6mh_hdrlen < mip6_mh_len(mh->ip6mh_type)) { | 96 | if (mh->ip6mh_hdrlen < mip6_mh_len(mh->ip6mh_type)) { |
101 | LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH message too short: %d vs >=%d\n", | 97 | LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH message too short: %d vs >=%d\n", |
102 | mh->ip6mh_hdrlen, mip6_mh_len(mh->ip6mh_type)); | 98 | mh->ip6mh_hdrlen, mip6_mh_len(mh->ip6mh_type)); |
103 | mip6_param_prob(skb, 0, offsetof(struct ip6_mh, ip6mh_hdrlen) + | 99 | mip6_param_prob(skb, 0, ((&mh->ip6mh_hdrlen) - |
104 | skb_network_header_len(skb)); | 100 | skb_network_header(skb))); |
105 | return -1; | 101 | return -1; |
106 | } | 102 | } |
107 | 103 | ||
108 | if (mh->ip6mh_proto != IPPROTO_NONE) { | 104 | if (mh->ip6mh_proto != IPPROTO_NONE) { |
109 | LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n", | 105 | LIMIT_NETDEBUG(KERN_DEBUG "mip6: MH invalid payload proto = %d\n", |
110 | mh->ip6mh_proto); | 106 | mh->ip6mh_proto); |
111 | mip6_param_prob(skb, 0, offsetof(struct ip6_mh, ip6mh_proto) + | 107 | mip6_param_prob(skb, 0, ((&mh->ip6mh_proto) - |
112 | skb_network_header_len(skb)); | 108 | skb_network_header(skb))); |
113 | return -1; | 109 | return -1; |
114 | } | 110 | } |
115 | 111 | ||
@@ -199,8 +195,8 @@ static inline int mip6_report_rl_allow(struct timeval *stamp, | |||
199 | mip6_report_rl.stamp.tv_sec = stamp->tv_sec; | 195 | mip6_report_rl.stamp.tv_sec = stamp->tv_sec; |
200 | mip6_report_rl.stamp.tv_usec = stamp->tv_usec; | 196 | mip6_report_rl.stamp.tv_usec = stamp->tv_usec; |
201 | mip6_report_rl.iif = iif; | 197 | mip6_report_rl.iif = iif; |
202 | mip6_report_rl.src = *src; | 198 | ipv6_addr_copy(&mip6_report_rl.src, src); |
203 | mip6_report_rl.dst = *dst; | 199 | ipv6_addr_copy(&mip6_report_rl.dst, dst); |
204 | allow = 1; | 200 | allow = 1; |
205 | } | 201 | } |
206 | spin_unlock_bh(&mip6_report_rl.lock); | 202 | spin_unlock_bh(&mip6_report_rl.lock); |
@@ -311,12 +307,13 @@ static int mip6_destopt_offset(struct xfrm_state *x, struct sk_buff *skb, | |||
311 | static int mip6_destopt_init_state(struct xfrm_state *x) | 307 | static int mip6_destopt_init_state(struct xfrm_state *x) |
312 | { | 308 | { |
313 | if (x->id.spi) { | 309 | if (x->id.spi) { |
314 | pr_info("%s: spi is not 0: %u\n", __func__, x->id.spi); | 310 | printk(KERN_INFO "%s: spi is not 0: %u\n", __func__, |
311 | x->id.spi); | ||
315 | return -EINVAL; | 312 | return -EINVAL; |
316 | } | 313 | } |
317 | if (x->props.mode != XFRM_MODE_ROUTEOPTIMIZATION) { | 314 | if (x->props.mode != XFRM_MODE_ROUTEOPTIMIZATION) { |
318 | pr_info("%s: state's mode is not %u: %u\n", | 315 | printk(KERN_INFO "%s: state's mode is not %u: %u\n", |
319 | __func__, XFRM_MODE_ROUTEOPTIMIZATION, x->props.mode); | 316 | __func__, XFRM_MODE_ROUTEOPTIMIZATION, x->props.mode); |
320 | return -EINVAL; | 317 | return -EINVAL; |
321 | } | 318 | } |
322 | 319 | ||
@@ -446,12 +443,13 @@ static int mip6_rthdr_offset(struct xfrm_state *x, struct sk_buff *skb, | |||
446 | static int mip6_rthdr_init_state(struct xfrm_state *x) | 443 | static int mip6_rthdr_init_state(struct xfrm_state *x) |
447 | { | 444 | { |
448 | if (x->id.spi) { | 445 | if (x->id.spi) { |
449 | pr_info("%s: spi is not 0: %u\n", __func__, x->id.spi); | 446 | printk(KERN_INFO "%s: spi is not 0: %u\n", __func__, |
447 | x->id.spi); | ||
450 | return -EINVAL; | 448 | return -EINVAL; |
451 | } | 449 | } |
452 | if (x->props.mode != XFRM_MODE_ROUTEOPTIMIZATION) { | 450 | if (x->props.mode != XFRM_MODE_ROUTEOPTIMIZATION) { |
453 | pr_info("%s: state's mode is not %u: %u\n", | 451 | printk(KERN_INFO "%s: state's mode is not %u: %u\n", |
454 | __func__, XFRM_MODE_ROUTEOPTIMIZATION, x->props.mode); | 452 | __func__, XFRM_MODE_ROUTEOPTIMIZATION, x->props.mode); |
455 | return -EINVAL; | 453 | return -EINVAL; |
456 | } | 454 | } |
457 | 455 | ||
@@ -483,18 +481,18 @@ static const struct xfrm_type mip6_rthdr_type = | |||
483 | 481 | ||
484 | static int __init mip6_init(void) | 482 | static int __init mip6_init(void) |
485 | { | 483 | { |
486 | pr_info("Mobile IPv6\n"); | 484 | printk(KERN_INFO "Mobile IPv6\n"); |
487 | 485 | ||
488 | if (xfrm_register_type(&mip6_destopt_type, AF_INET6) < 0) { | 486 | if (xfrm_register_type(&mip6_destopt_type, AF_INET6) < 0) { |
489 | pr_info("%s: can't add xfrm type(destopt)\n", __func__); | 487 | printk(KERN_INFO "%s: can't add xfrm type(destopt)\n", __func__); |
490 | goto mip6_destopt_xfrm_fail; | 488 | goto mip6_destopt_xfrm_fail; |
491 | } | 489 | } |
492 | if (xfrm_register_type(&mip6_rthdr_type, AF_INET6) < 0) { | 490 | if (xfrm_register_type(&mip6_rthdr_type, AF_INET6) < 0) { |
493 | pr_info("%s: can't add xfrm type(rthdr)\n", __func__); | 491 | printk(KERN_INFO "%s: can't add xfrm type(rthdr)\n", __func__); |
494 | goto mip6_rthdr_xfrm_fail; | 492 | goto mip6_rthdr_xfrm_fail; |
495 | } | 493 | } |
496 | if (rawv6_mh_filter_register(mip6_mh_filter) < 0) { | 494 | if (rawv6_mh_filter_register(mip6_mh_filter) < 0) { |
497 | pr_info("%s: can't add rawv6 mh filter\n", __func__); | 495 | printk(KERN_INFO "%s: can't add rawv6 mh filter\n", __func__); |
498 | goto mip6_rawv6_mh_fail; | 496 | goto mip6_rawv6_mh_fail; |
499 | } | 497 | } |
500 | 498 | ||
@@ -512,11 +510,11 @@ static int __init mip6_init(void) | |||
512 | static void __exit mip6_fini(void) | 510 | static void __exit mip6_fini(void) |
513 | { | 511 | { |
514 | if (rawv6_mh_filter_unregister(mip6_mh_filter) < 0) | 512 | if (rawv6_mh_filter_unregister(mip6_mh_filter) < 0) |
515 | pr_info("%s: can't remove rawv6 mh filter\n", __func__); | 513 | printk(KERN_INFO "%s: can't remove rawv6 mh filter\n", __func__); |
516 | if (xfrm_unregister_type(&mip6_rthdr_type, AF_INET6) < 0) | 514 | if (xfrm_unregister_type(&mip6_rthdr_type, AF_INET6) < 0) |
517 | pr_info("%s: can't remove xfrm type(rthdr)\n", __func__); | 515 | printk(KERN_INFO "%s: can't remove xfrm type(rthdr)\n", __func__); |
518 | if (xfrm_unregister_type(&mip6_destopt_type, AF_INET6) < 0) | 516 | if (xfrm_unregister_type(&mip6_destopt_type, AF_INET6) < 0) |
519 | pr_info("%s: can't remove xfrm type(destopt)\n", __func__); | 517 | printk(KERN_INFO "%s: can't remove xfrm type(destopt)\n", __func__); |
520 | } | 518 | } |
521 | 519 | ||
522 | module_init(mip6_init); | 520 | module_init(mip6_init); |