Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / net / ipv6 / ah6.c
index e3ecf62..6778173 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/string.h>
 #include <net/icmp.h>
 #include <net/ipv6.h>
+#include <net/protocol.h>
 #include <net/xfrm.h>
 #include <asm/scatterlist.h>
 
@@ -131,10 +132,10 @@ static int ipv6_clear_mutable_options(struct ipv6hdr *iph, int len)
                case NEXTHDR_HOP:
                case NEXTHDR_DEST:
                        if (!zero_out_mutable_opts(exthdr.opth)) {
-                               LIMIT_NETDEBUG(printk(
+                               LIMIT_NETDEBUG(
                                        KERN_WARNING "overrun %sopts\n",
                                        nexthdr == NEXTHDR_HOP ?
-                                               "hop" : "dest"));
+                                               "hop" : "dest");
                                return -EINVAL;
                        }
                        break;
@@ -212,6 +213,7 @@ static int ah6_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);
 
        err = 0;
@@ -227,7 +229,7 @@ error:
        return err;
 }
 
-static int ah6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_buff *skb)
+static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
 {
        /*
         * Before process AH
@@ -278,7 +280,7 @@ static int ah6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struc
                goto out;
        memcpy(tmp_hdr, skb->nh.raw, hdr_len);
        if (ipv6_clear_mutable_options(skb->nh.ipv6h, hdr_len))
-               goto out;
+               goto free_out;
        skb->nh.ipv6h->priority    = 0;
        skb->nh.ipv6h->flow_lbl[0] = 0;
        skb->nh.ipv6h->flow_lbl[1] = 0;
@@ -293,8 +295,7 @@ static int ah6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struc
                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)) {
-                       LIMIT_NETDEBUG(
-                               printk(KERN_WARNING "ipsec ah authentication error\n"));
+                       LIMIT_NETDEBUG(KERN_WARNING "ipsec ah authentication error\n");
                        x->stats.integrity_failed++;
                        goto free_out;
                }
@@ -332,14 +333,13 @@ static void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        if (!x)
                return;
 
-       NETDEBUG(printk(KERN_DEBUG "pmtu discovery on SA AH/%08x/"
-                       "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
-              ntohl(ah->spi), NIP6(iph->daddr)));
+       NETDEBUG(KERN_DEBUG "pmtu discovery on SA AH/%08x/" NIP6_FMT "\n",
+                ntohl(ah->spi), NIP6(iph->daddr));
 
        xfrm_state_put(x);
 }
 
-static int ah6_init_state(struct xfrm_state *x, void *args)
+static int ah6_init_state(struct xfrm_state *x)
 {
        struct ah_data *ahp = NULL;
        struct xfrm_algo_desc *aalg_desc;
@@ -354,12 +354,10 @@ static int ah6_init_state(struct xfrm_state *x, void *args)
        if (x->encap)
                goto error;
 
-       ahp = kmalloc(sizeof(*ahp), GFP_KERNEL);
+       ahp = kzalloc(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);
@@ -402,10 +400,8 @@ static int ah6_init_state(struct xfrm_state *x, void *args)
 
 error:
        if (ahp) {
-               if (ahp->work_icv)
-                       kfree(ahp->work_icv);
-               if (ahp->tfm)
-                       crypto_free_tfm(ahp->tfm);
+               kfree(ahp->work_icv);
+               crypto_free_tfm(ahp->tfm);
                kfree(ahp);
        }
        return -EINVAL;
@@ -418,14 +414,10 @@ static void ah6_destroy(struct xfrm_state *x)
        if (!ahp)
                return;
 
-       if (ahp->work_icv) {
-               kfree(ahp->work_icv);
-               ahp->work_icv = NULL;
-       }
-       if (ahp->tfm) {
-               crypto_free_tfm(ahp->tfm);
-               ahp->tfm = NULL;
-       }
+       kfree(ahp->work_icv);
+       ahp->work_icv = NULL;
+       crypto_free_tfm(ahp->tfm);
+       ahp->tfm = NULL;
        kfree(ahp);
 }