]> err.no Git - linux-2.6/blobdiff - net/ipv6/mip6.c
[8021Q]: vlan_ioctl_handler: fix return value
[linux-2.6] / net / ipv6 / mip6.c
index f0288e92fb52ef0ac496648d73f74214c57590ca..8a1399ce38ce826ae774a54508382adae905603f 100644 (file)
@@ -30,6 +30,7 @@
 #include <net/sock.h>
 #include <net/ipv6.h>
 #include <net/ip6_checksum.h>
+#include <net/rawv6.h>
 #include <net/xfrm.h>
 #include <net/mip6.h>
 
@@ -86,7 +87,7 @@ static int mip6_mh_len(int type)
        return len;
 }
 
-int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
+static int mip6_mh_filter(struct sock *sk, struct sk_buff *skb)
 {
        struct ip6_mh *mh;
 
@@ -125,7 +126,7 @@ struct mip6_report_rate_limiter {
 };
 
 static struct mip6_report_rate_limiter mip6_report_rl = {
-       .lock = SPIN_LOCK_UNLOCKED
+       .lock = __SPIN_LOCK_UNLOCKED(mip6_report_rl.lock)
 };
 
 static int mip6_destopt_input(struct xfrm_state *x, struct sk_buff *skb)
@@ -260,7 +261,7 @@ static int mip6_destopt_offset(struct xfrm_state *x, struct sk_buff *skb,
        struct ipv6_opt_hdr *exthdr =
                                   (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1);
        const unsigned char *nh = skb_network_header(skb);
-       unsigned int packet_len = skb->tail - nh;
+       unsigned int packet_len = skb->tail - skb->network_header;
        int found_rhdr = 0;
 
        *nexthdr = &ipv6_hdr(skb)->nexthdr;
@@ -392,7 +393,7 @@ static int mip6_rthdr_offset(struct xfrm_state *x, struct sk_buff *skb,
        struct ipv6_opt_hdr *exthdr =
                                   (struct ipv6_opt_hdr *)(ipv6_hdr(skb) + 1);
        const unsigned char *nh = skb_network_header(skb);
-       unsigned int packet_len = skb->tail - nh;
+       unsigned int packet_len = skb->tail - skb->network_header;
        int found_rhdr = 0;
 
        *nexthdr = &ipv6_hdr(skb)->nexthdr;
@@ -471,7 +472,7 @@ static struct xfrm_type mip6_rthdr_type =
        .remote_addr    = mip6_xfrm_addr,
 };
 
-int __init mip6_init(void)
+static int __init mip6_init(void)
 {
        printk(KERN_INFO "Mobile IPv6\n");
 
@@ -483,18 +484,35 @@ int __init mip6_init(void)
                printk(KERN_INFO "%s: can't add xfrm type(rthdr)\n", __FUNCTION__);
                goto mip6_rthdr_xfrm_fail;
        }
+       if (rawv6_mh_filter_register(mip6_mh_filter) < 0) {
+               printk(KERN_INFO "%s: can't add rawv6 mh filter\n", __FUNCTION__);
+               goto mip6_rawv6_mh_fail;
+       }
+
+
        return 0;
 
+ mip6_rawv6_mh_fail:
+       xfrm_unregister_type(&mip6_rthdr_type, AF_INET6);
  mip6_rthdr_xfrm_fail:
        xfrm_unregister_type(&mip6_destopt_type, AF_INET6);
  mip6_destopt_xfrm_fail:
        return -EAGAIN;
 }
 
-void __exit mip6_fini(void)
+static void __exit mip6_fini(void)
 {
+       if (rawv6_mh_filter_unregister(mip6_mh_filter) < 0)
+               printk(KERN_INFO "%s: can't remove rawv6 mh filter\n", __FUNCTION__);
        if (xfrm_unregister_type(&mip6_rthdr_type, AF_INET6) < 0)
                printk(KERN_INFO "%s: can't remove xfrm type(rthdr)\n", __FUNCTION__);
        if (xfrm_unregister_type(&mip6_destopt_type, AF_INET6) < 0)
                printk(KERN_INFO "%s: can't remove xfrm type(destopt)\n", __FUNCTION__);
 }
+
+module_init(mip6_init);
+module_exit(mip6_fini);
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_XFRM_TYPE(AF_INET6, XFRM_PROTO_DSTOPTS);
+MODULE_ALIAS_XFRM_TYPE(AF_INET6, XFRM_PROTO_ROUTING);