]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
xfrm: Move the test on replay window size into the replay check functions
authorSteffen Klassert <steffen.klassert@secunet.com>
Mon, 28 Mar 2011 19:45:52 +0000 (19:45 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 29 Mar 2011 06:34:51 +0000 (23:34 -0700)
As it is, the replay check is just performed if the replay window of the
legacy implementation is nonzero. So we move the test on a nonzero replay
window inside the replay check functions to be sure we are testing for the
right implementation.

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>
net/xfrm/xfrm_input.c
net/xfrm/xfrm_replay.c

index 341cd1189f8a5b7aa90093707825f7cdac3b05b2..a026b0ef2443ce3150417059691434a4926ba108 100644 (file)
@@ -173,7 +173,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
                        goto drop_unlock;
                }
 
-               if (x->props.replay_window && x->repl->check(x, skb, seq)) {
+               if (x->repl->check(x, skb, seq)) {
                        XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATESEQERROR);
                        goto drop_unlock;
                }
index 2f5be5b15740507fac23201330899faf949055a0..f218385950ca06a3a8b6830c51c29ac370ca2ea0 100644 (file)
@@ -118,6 +118,9 @@ static int xfrm_replay_check(struct xfrm_state *x,
        u32 diff;
        u32 seq = ntohl(net_seq);
 
+       if (!x->props.replay_window)
+               return 0;
+
        if (unlikely(seq == 0))
                goto err;
 
@@ -193,9 +196,14 @@ static int xfrm_replay_check_bmp(struct xfrm_state *x,
 {
        unsigned int bitnr, nr;
        struct xfrm_replay_state_esn *replay_esn = x->replay_esn;
+       u32 pos;
        u32 seq = ntohl(net_seq);
        u32 diff =  replay_esn->seq - seq;
-       u32 pos = (replay_esn->seq - 1) % replay_esn->replay_window;
+
+       if (!replay_esn->replay_window)
+               return 0;
+
+       pos = (replay_esn->seq - 1) % replay_esn->replay_window;
 
        if (unlikely(seq == 0))
                goto err;
@@ -373,12 +381,17 @@ static int xfrm_replay_check_esn(struct xfrm_state *x,
        unsigned int bitnr, nr;
        u32 diff;
        struct xfrm_replay_state_esn *replay_esn = x->replay_esn;
+       u32 pos;
        u32 seq = ntohl(net_seq);
-       u32 pos = (replay_esn->seq - 1) % replay_esn->replay_window;
        u32 wsize = replay_esn->replay_window;
        u32 top = replay_esn->seq;
        u32 bottom = top - wsize + 1;
 
+       if (!wsize)
+               return 0;
+
+       pos = (replay_esn->seq - 1) % replay_esn->replay_window;
+
        if (unlikely(seq == 0 && replay_esn->seq_hi == 0 &&
                     (replay_esn->seq < replay_esn->replay_window - 1)))
                goto err;