Patchwork xfrm: do not check x->km.state

login
register
mail settings
Submitter roy.qing.li@gmail.com
Date Dec. 13, 2012, 9:06 a.m.
Message ID <1355389560-7705-1-git-send-email-roy.qing.li@gmail.com>
Download mbox | patch
Permalink /patch/205784/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

roy.qing.li@gmail.com - Dec. 13, 2012, 9:06 a.m.
From: Li RongQing <roy.qing.li@gmail.com>

do not check x->km.state, it will be checked by succedent
xfrm_state_check_expire()

Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
 net/ipv6/xfrm6_input.c |    1 -
 net/xfrm/xfrm_input.c  |    4 ----
 2 files changed, 0 insertions(+), 5 deletions(-)
Steffen Klassert - Dec. 13, 2012, 10:19 a.m.
On Thu, Dec 13, 2012 at 05:06:00PM +0800, roy.qing.li@gmail.com wrote:
> From: Li RongQing <roy.qing.li@gmail.com>
> 
> do not check x->km.state, it will be checked by succedent
> xfrm_state_check_expire()
> 
> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> ---
>  net/ipv6/xfrm6_input.c |    1 -
>  net/xfrm/xfrm_input.c  |    4 ----
>  2 files changed, 0 insertions(+), 5 deletions(-)
> 
> diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
> index f8c3cf8..de4babd 100644
> --- a/net/ipv6/xfrm6_input.c
> +++ b/net/ipv6/xfrm6_input.c
> @@ -108,7 +108,6 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
>  		spin_lock(&x->lock);
>  
>  		if ((!i || (x->props.flags & XFRM_STATE_WILDRECV)) &&
> -		    likely(x->km.state == XFRM_STATE_VALID) &&
>  		    !xfrm_state_check_expire(x)) {
>  			spin_unlock(&x->lock);
>  			if (x->type->input(x, skb) > 0) {
> diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
> index ab2bb42..a8fbb09 100644
> --- a/net/xfrm/xfrm_input.c
> +++ b/net/xfrm/xfrm_input.c
> @@ -163,10 +163,6 @@ 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_VALID)) {
> -			XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEINVALID);
> -			goto drop_unlock;
> -		}


This would remove the only place where the LINUX_MIB_XFRMINSTATEINVALID
statistics counter is incremented. I think it would be better to ensure
a valid state before we call xfrm_state_check_expire(). This would make
the statistics more accurate and we can remove the x->km.state check
from xfrm_state_check_expire().

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Dec. 13, 2012, 7:19 p.m.
From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Thu, 13 Dec 2012 11:19:48 +0100

> On Thu, Dec 13, 2012 at 05:06:00PM +0800, roy.qing.li@gmail.com wrote:
>> From: Li RongQing <roy.qing.li@gmail.com>
>> 
>> do not check x->km.state, it will be checked by succedent
>> xfrm_state_check_expire()
>> 
>> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
 ...
> This would remove the only place where the LINUX_MIB_XFRMINSTATEINVALID
> statistics counter is incremented. I think it would be better to ensure
> a valid state before we call xfrm_state_check_expire(). This would make
> the statistics more accurate and we can remove the x->km.state check
> from xfrm_state_check_expire().

Agreed.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/ipv6/xfrm6_input.c b/net/ipv6/xfrm6_input.c
index f8c3cf8..de4babd 100644
--- a/net/ipv6/xfrm6_input.c
+++ b/net/ipv6/xfrm6_input.c
@@ -108,7 +108,6 @@  int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
 		spin_lock(&x->lock);
 
 		if ((!i || (x->props.flags & XFRM_STATE_WILDRECV)) &&
-		    likely(x->km.state == XFRM_STATE_VALID) &&
 		    !xfrm_state_check_expire(x)) {
 			spin_unlock(&x->lock);
 			if (x->type->input(x, skb) > 0) {
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index ab2bb42..a8fbb09 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -163,10 +163,6 @@  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_VALID)) {
-			XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEINVALID);
-			goto drop_unlock;
-		}
 
 		if ((x->encap ? x->encap->encap_type : 0) != encap_type) {
 			XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMISMATCH);