xfrm: Use separate low and high order bits of the sequence numbers in xfrm_skb_cb
authorSteffen Klassert <steffen.klassert@secunet.com>
Tue, 8 Mar 2011 00:06:31 +0000 (00:06 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 14 Mar 2011 03:22:28 +0000 (20:22 -0700)
To support IPsec extended sequence numbers, we split the
output sequence numbers of xfrm_skb_cb in low and high order 32 bits
and we add the high order 32 bits to the input sequence numbers.
All users are updated accordingly.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/xfrm.h
net/ipv4/ah4.c
net/ipv4/esp4.c
net/ipv6/ah6.c
net/ipv6/esp6.c
net/xfrm/xfrm_input.c
net/xfrm/xfrm_output.c

index 7640822bc5154c9e15b6339ae3fe5893b9e4d9bf..cb6d9b3fc55e021875157cbb44233dfe60cdcce4 100644 (file)
@@ -582,8 +582,14 @@ struct xfrm_skb_cb {
 
         /* Sequence number for replay protection. */
        union {
-               u64 output;
-               __be32 input;
+               struct {
+                       __u32 low;
+                       __u32 hi;
+               } output;
+               struct {
+                       __be32 low;
+                       __be32 hi;
+               } input;
        } seq;
 };
 
index 325053df6e705f6a413f73f4abb9db4651ee9bb4..4286fd3cc0e2bce0a09655959d0b7c699b711aaa 100644 (file)
@@ -208,7 +208,7 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
 
        ah->reserved = 0;
        ah->spi = x->id.spi;
-       ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
+       ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low);
 
        sg_init_table(sg, nfrags);
        skb_to_sgvec(skb, sg, 0, skb->len);
index e42a905180f00f93d3113fbdb2922bf5b1bb2217..882dbbb7d799a0047d5f1bef724fc7e27158e3a2 100644 (file)
@@ -215,7 +215,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
        }
 
        esph->spi = x->id.spi;
-       esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
+       esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low);
 
        sg_init_table(sg, nfrags);
        skb_to_sgvec(skb, sg,
@@ -227,7 +227,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
        aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
        aead_givcrypt_set_assoc(req, asg, sizeof(*esph));
        aead_givcrypt_set_giv(req, esph->enc_data,
-                             XFRM_SKB_CB(skb)->seq.output);
+                             XFRM_SKB_CB(skb)->seq.output.low);
 
        ESP_SKB_CB(skb)->tmp = tmp;
        err = crypto_aead_givencrypt(req);
index 1aba54ae53c443481dd2b2d7e0a5f1b2f573bdaa..2195ae651923e0e3242c3e61738fed91d19711ff 100644 (file)
@@ -409,7 +409,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(XFRM_SKB_CB(skb)->seq.output);
+       ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low);
 
        sg_init_table(sg, nfrags);
        skb_to_sgvec(skb, sg, 0, skb->len);
index 1b5c9825743b6dd45731782a254d4e3595a5cb2b..c7b5d5ee0deeac800e59c89bb93cf9ab3d1b22b6 100644 (file)
@@ -204,7 +204,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
        *skb_mac_header(skb) = IPPROTO_ESP;
 
        esph->spi = x->id.spi;
-       esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
+       esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low);
 
        sg_init_table(sg, nfrags);
        skb_to_sgvec(skb, sg,
@@ -216,7 +216,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
        aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
        aead_givcrypt_set_assoc(req, asg, sizeof(*esph));
        aead_givcrypt_set_giv(req, esph->enc_data,
-                             XFRM_SKB_CB(skb)->seq.output);
+                             XFRM_SKB_CB(skb)->seq.output.low);
 
        ESP_SKB_CB(skb)->tmp = tmp;
        err = crypto_aead_givencrypt(req);
index 45f1c98d4fce212bd427b733c9ab304680cf7530..b173b7fdc433de6a313dcfd2c57cf9c728860468 100644 (file)
@@ -118,7 +118,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
        if (encap_type < 0) {
                async = 1;
                x = xfrm_input_state(skb);
-               seq = XFRM_SKB_CB(skb)->seq.input;
+               seq = XFRM_SKB_CB(skb)->seq.input.low;
                goto resume;
        }
 
@@ -184,7 +184,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
 
                spin_unlock(&x->lock);
 
-               XFRM_SKB_CB(skb)->seq.input = seq;
+               XFRM_SKB_CB(skb)->seq.input.low = seq;
 
                nexthdr = x->type->input(x, skb);
 
index 64f2ae1fdc15e2a63a28fc7073fc0e1f957cee44..4b63776a0264bb45255b0eef15778a0d96d9b7fa 100644 (file)
@@ -68,7 +68,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
                }
 
                if (x->type->flags & XFRM_TYPE_REPLAY_PROT) {
-                       XFRM_SKB_CB(skb)->seq.output = ++x->replay.oseq;
+                       XFRM_SKB_CB(skb)->seq.output.low = ++x->replay.oseq;
                        if (unlikely(x->replay.oseq == 0)) {
                                XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATESEQERROR);
                                x->replay.oseq--;