* [PATCH] xfrm: do not check x->km.state @ 2012-12-13 9:06 roy.qing.li 2012-12-13 10:19 ` Steffen Klassert 0 siblings, 1 reply; 6+ messages in thread From: roy.qing.li @ 2012-12-13 9:06 UTC (permalink / raw) To: netdev 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; - } if ((x->encap ? x->encap->encap_type : 0) != encap_type) { XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMISMATCH); -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] xfrm: do not check x->km.state 2012-12-13 9:06 [PATCH] xfrm: do not check x->km.state roy.qing.li @ 2012-12-13 10:19 ` Steffen Klassert 2012-12-13 19:19 ` David Miller 0 siblings, 1 reply; 6+ messages in thread From: Steffen Klassert @ 2012-12-13 10:19 UTC (permalink / raw) To: roy.qing.li; +Cc: netdev 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(). ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfrm: do not check x->km.state 2012-12-13 10:19 ` Steffen Klassert @ 2012-12-13 19:19 ` David Miller 2012-12-14 7:02 ` RongQing Li 0 siblings, 1 reply; 6+ messages in thread From: David Miller @ 2012-12-13 19:19 UTC (permalink / raw) To: steffen.klassert; +Cc: roy.qing.li, netdev 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. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfrm: do not check x->km.state 2012-12-13 19:19 ` David Miller @ 2012-12-14 7:02 ` RongQing Li 2012-12-14 11:45 ` Steffen Klassert 0 siblings, 1 reply; 6+ messages in thread From: RongQing Li @ 2012-12-14 7:02 UTC (permalink / raw) To: David Miller; +Cc: steffen.klassert, netdev 2012/12/14 David Miller <davem@davemloft.net>: > 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. Thanks. since xfrm_output_one() calls xfrm_state_check_expire() too, but without checking (x->km.state != XFRM_STATE_VALID), I think we can not directly remove the check of km.state from xfrm_state_check_expire(). I have two option, which one do you think it is better? 1. remove this check in xfrm_state_check_expire, and add a check in xfrm_output_one diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 95a338c..c245370 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c @@ -61,6 +61,12 @@ static int xfrm_output_one(struct sk_buff *skb, int err) } spin_lock_bh(&x->lock); + + if (unlikely(x->km.state != XFRM_STATE_VALID)) { + XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEINVALID); + goto drop_unlock; + } + err = xfrm_state_check_expire(x); if (err) { XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEEXPIRED); diff --git a/net/xfrm/xfrm_proc.c b/net/xfrm/xfrm_proc.c index d0a1af8..e4cd441 100644 --- a/net/xfrm/xfrm_proc.c +++ b/net/xfrm/xfrm_proc.c @@ -39,6 +39,7 @@ static const struct snmp_mib xfrm_mib_list[] = { SNMP_MIB_ITEM("XfrmOutStateModeError", LINUX_MIB_XFRMOUTSTATEMODEERROR), SNMP_MIB_ITEM("XfrmOutStateSeqError", LINUX_MIB_XFRMOUTSTATESEQERROR), SNMP_MIB_ITEM("XfrmOutStateExpired", LINUX_MIB_XFRMOUTSTATEEXPIRED), + SNMP_MIB_ITEM("XfrmOutStateInvalid", LINUX_MIB_XFRMOUTSTATEINVALID), SNMP_MIB_ITEM("XfrmOutPolBlock", LINUX_MIB_XFRMOUTPOLBLOCK), SNMP_MIB_ITEM("XfrmOutPolDead", LINUX_MIB_XFRMOUTPOLDEAD), SNMP_MIB_ITEM("XfrmOutPolError", LINUX_MIB_XFRMOUTPOLERROR), diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 3459692..05db236 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -1370,9 +1370,6 @@ int xfrm_state_check_expire(struct xfrm_state *x) if (!x->curlft.use_time) x->curlft.use_time = get_seconds(); - if (x->km.state != XFRM_STATE_VALID) - return -EINVAL; - if (x->curlft.bytes >= x->lft.hard_byte_limit || x->curlft.packets >= x->lft.hard_packet_limit) { x->km.state = XFRM_STATE_EXPIRED; 2. Only remove this check in xfrm6_input.c --- a/net/ipv6/xfrm6_input.c +++ b/net/ipv6/xfrm6_input.c @@ -109,7 +109,6 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, 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) { /* found a valid state */ ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] xfrm: do not check x->km.state 2012-12-14 7:02 ` RongQing Li @ 2012-12-14 11:45 ` Steffen Klassert 2012-12-15 1:36 ` RongQing Li 0 siblings, 1 reply; 6+ messages in thread From: Steffen Klassert @ 2012-12-14 11:45 UTC (permalink / raw) To: RongQing Li; +Cc: David Miller, netdev On Fri, Dec 14, 2012 at 03:02:32PM +0800, RongQing Li wrote: > > since xfrm_output_one() calls xfrm_state_check_expire() too, but without > checking (x->km.state != XFRM_STATE_VALID), I think we can not directly > remove the check of km.state from xfrm_state_check_expire(). I have two > option, which one do you think it is better? > > 1. remove this check in xfrm_state_check_expire, and add a check in > xfrm_output_one > I think the first option ist the better one. It removes a superfluous check and we get some more statistics. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] xfrm: do not check x->km.state 2012-12-14 11:45 ` Steffen Klassert @ 2012-12-15 1:36 ` RongQing Li 0 siblings, 0 replies; 6+ messages in thread From: RongQing Li @ 2012-12-15 1:36 UTC (permalink / raw) To: Steffen Klassert; +Cc: David Miller, netdev 2012/12/14 Steffen Klassert <steffen.klassert@secunet.com>: >> 1. remove this check in xfrm_state_check_expire, and add a check in >> xfrm_output_one >> > > I think the first option ist the better one. It removes a superfluous > check and we get some more statistics. I see, thanks -Roy ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-15 1:36 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-12-13 9:06 [PATCH] xfrm: do not check x->km.state roy.qing.li 2012-12-13 10:19 ` Steffen Klassert 2012-12-13 19:19 ` David Miller 2012-12-14 7:02 ` RongQing Li 2012-12-14 11:45 ` Steffen Klassert 2012-12-15 1:36 ` RongQing Li
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).