xfrm: slightly optimise xfrm_input
authorLi RongQing <roy.qing.li@gmail.com>
Fri, 24 Apr 2015 08:49:31 +0000 (16:49 +0800)
committerSteffen Klassert <steffen.klassert@secunet.com>
Fri, 24 Apr 2015 10:17:16 +0000 (12:17 +0200)
Check x->km.state with XFRM_STATE_ACQ only when state is not
XFRM_STAT_VALID, not everytime

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
net/xfrm/xfrm_input.c

index 459796a..1858a45 100644 (file)
@@ -239,13 +239,13 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
                skb->sp->xvec[skb->sp->len++] = x;
 
                spin_lock(&x->lock);
-               if (unlikely(x->km.state == XFRM_STATE_ACQ)) {
-                       XFRM_INC_STATS(net, LINUX_MIB_XFRMACQUIREERROR);
-                       goto drop_unlock;
-               }
 
                if (unlikely(x->km.state != XFRM_STATE_VALID)) {
-                       XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEINVALID);
+                       if (x->km.state == XFRM_STATE_ACQ)
+                               XFRM_INC_STATS(net, LINUX_MIB_XFRMACQUIREERROR);
+                       else
+                               XFRM_INC_STATS(net,
+                                              LINUX_MIB_XFRMINSTATEINVALID);
                        goto drop_unlock;
                }