linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / net / ipv4 / ah4.c
index 1366bc6..aed537f 100644 (file)
@@ -1,3 +1,4 @@
+#include <linux/config.h>
 #include <linux/module.h>
 #include <net/ip.h>
 #include <net/xfrm.h>
@@ -96,7 +97,6 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
        ah->reserved = 0;
        ah->spi = x->id.spi;
        ah->seq_no = htonl(++x->replay.oseq);
-       xfrm_aevent_doreplay(x);
        ahp->icv(ahp, skb, ah->auth_data);
 
        top_iph->tos = iph->tos;
@@ -115,10 +115,9 @@ error:
        return err;
 }
 
-static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
+static int ah_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_buff *skb)
 {
        int ah_hlen;
-       int ihl;
        struct iphdr *iph;
        struct ip_auth_hdr *ah;
        struct ah_data *ahp;
@@ -149,14 +148,13 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
        ah = (struct ip_auth_hdr*)skb->data;
        iph = skb->nh.iph;
 
-       ihl = skb->data - skb->nh.raw;
-       memcpy(work_buf, iph, ihl);
+       memcpy(work_buf, iph, iph->ihl*4);
 
        iph->ttl = 0;
        iph->tos = 0;
        iph->frag_off = 0;
        iph->check = 0;
-       if (ihl > sizeof(*iph)) {
+       if (iph->ihl != 5) {
                u32 dummy;
                if (ip_clear_mutable_options(iph, &dummy))
                        goto out;
@@ -165,7 +163,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
                u8 auth_data[MAX_AH_AUTH_LEN];
                
                memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len);
-               skb_push(skb, ihl);
+               skb_push(skb, skb->data - skb->nh.raw);
                ahp->icv(ahp, skb, ah->auth_data);
                if (memcmp(ah->auth_data, auth_data, ahp->icv_trunc_len)) {
                        x->stats.integrity_failed++;
@@ -173,8 +171,11 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
                }
        }
        ((struct iphdr*)work_buf)->protocol = ah->nexthdr;
-       skb->h.raw = memcpy(skb->nh.raw += ah_hlen, work_buf, ihl);
-       __skb_pull(skb, ah_hlen + ihl);
+       skb->nh.raw = skb_pull(skb, ah_hlen);
+       memcpy(skb->nh.raw, work_buf, iph->ihl*4);
+       skb->nh.iph->tot_len = htons(skb->len);
+       skb_pull(skb, skb->nh.iph->ihl*4);
+       skb->h.raw = skb->data;
 
        return 0;
 
@@ -215,10 +216,12 @@ static int ah_init_state(struct xfrm_state *x)
        if (x->encap)
                goto error;
 
-       ahp = kzalloc(sizeof(*ahp), GFP_KERNEL);
+       ahp = kmalloc(sizeof(*ahp), GFP_KERNEL);
        if (ahp == NULL)
                return -ENOMEM;
 
+       memset(ahp, 0, sizeof(*ahp));
+
        ahp->key = x->aalg->alg_key;
        ahp->key_len = (x->aalg->alg_key_len+7)/8;
        ahp->tfm = crypto_alloc_tfm(x->aalg->alg_name, 0);