]> err.no Git - linux-2.6/blobdiff - net/ipv6/ipcomp6.c
[IPSEC] proto: Move transport mode input path into xfrm_mode_transport
[linux-2.6] / net / ipv6 / ipcomp6.c
index d4cfec3f414e32bbd7c981437b1666c393369f4b..cec3be544b69b23431fec2bbfb8981f95d75dc05 100644 (file)
@@ -63,13 +63,11 @@ static void **ipcomp6_scratches;
 static int ipcomp6_scratch_users;
 static LIST_HEAD(ipcomp6_tfms_list);
 
-static int ipcomp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_buff *skb)
+static int ipcomp6_input(struct xfrm_state *x, struct sk_buff *skb)
 {
        int err = 0;
-       u8 nexthdr = 0;
-       int hdr_len = skb->h.raw - skb->nh.raw;
-       unsigned char *tmp_hdr = NULL;
        struct ipv6hdr *iph;
+       struct ipv6_comp_hdr *ipch;
        int plen, dlen;
        struct ipcomp_data *ipcd = x->data;
        u8 *start, *scratch;
@@ -86,17 +84,9 @@ static int ipcomp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, s
 
        /* Remove ipcomp header and decompress original payload */
        iph = skb->nh.ipv6h;
-       tmp_hdr = kmalloc(hdr_len, GFP_ATOMIC);
-       if (!tmp_hdr)
-               goto out;
-       memcpy(tmp_hdr, iph, hdr_len);
-       nexthdr = *(u8 *)skb->data;
-       skb_pull(skb, sizeof(struct ipv6_comp_hdr)); 
-       skb->nh.raw += sizeof(struct ipv6_comp_hdr);
-       memcpy(skb->nh.raw, tmp_hdr, hdr_len);
-       iph = skb->nh.ipv6h;
-       iph->payload_len = htons(ntohs(iph->payload_len) - sizeof(struct ipv6_comp_hdr));
-       skb->h.raw = skb->data;
+       ipch = (void *)skb->data;
+       skb->h.raw = skb->nh.raw + sizeof(*ipch);
+       __skb_pull(skb, sizeof(*ipch));
 
        /* decompression */
        plen = skb->len;
@@ -125,18 +115,11 @@ static int ipcomp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, s
 
        skb_put(skb, dlen - plen);
        memcpy(skb->data, scratch, dlen);
+       err = ipch->nexthdr;
 
-       iph = skb->nh.ipv6h;
-       iph->payload_len = htons(skb->len);
-       
 out_put_cpu:
        put_cpu();
 out:
-       kfree(tmp_hdr);
-       if (err)
-               goto error_out;
-       return nexthdr;
-error_out:
        return err;
 }
 
@@ -208,7 +191,7 @@ static void ipcomp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        if (type != ICMPV6_DEST_UNREACH && type != ICMPV6_PKT_TOOBIG)
                return;
 
-       spi = ntohl(ntohs(ipcomph->cpi));
+       spi = htonl(ntohs(ipcomph->cpi));
        x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi, IPPROTO_COMP, AF_INET6);
        if (!x)
                return;
@@ -290,7 +273,7 @@ static void ipcomp6_free_scratches(void)
        if (!scratches)
                return;
 
-       for_each_cpu(i) {
+       for_each_possible_cpu(i) {
                void *scratch = *per_cpu_ptr(scratches, i);
 
                vfree(scratch);
@@ -313,7 +296,7 @@ static void **ipcomp6_alloc_scratches(void)
 
        ipcomp6_scratches = scratches;
 
-       for_each_cpu(i) {
+       for_each_possible_cpu(i) {
                void *scratch = vmalloc(IPCOMP_SCRATCH_SIZE);
                if (!scratch)
                        return NULL;
@@ -344,7 +327,7 @@ static void ipcomp6_free_tfms(struct crypto_tfm **tfms)
        if (!tfms)
                return;
 
-       for_each_cpu(cpu) {
+       for_each_possible_cpu(cpu) {
                struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu);
                crypto_free_tfm(tfm);
        }
@@ -384,7 +367,7 @@ static struct crypto_tfm **ipcomp6_alloc_tfms(const char *alg_name)
        if (!tfms)
                goto error;
 
-       for_each_cpu(cpu) {
+       for_each_possible_cpu(cpu) {
                struct crypto_tfm *tfm = crypto_alloc_tfm(alg_name, 0);
                if (!tfm)
                        goto error;