Skip to contentSkip to conversation

xfrm: removes a superfluous check and add a statistic

PATCH Applied [email protected] 3 participants 4 messages Dec 28, 2012 – Jan 7, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfrm: removes a superfluous check and add a statistic

From: Li RongQing <[email protected]>

Remove the check if x->km.state equal to XFRM_STATE_VALID in xfrm_state_check_expire(), which will be done before call xfrm_state_check_expire().

add a LINUX_MIB_XFRMOUTSTATEINVALID statistic to record the outbound error due to invalid xfrm state.

---
 include/uapi/linux/snmp.h |    1 +
 net/xfrm/xfrm_output.c    |    6 ++++++
 net/xfrm/xfrm_proc.c      |    1 +
 net/xfrm/xfrm_state.c     |    3 ---
 4 files changed, 8 insertions(+), 3 deletions(-)
include/uapi/linux/snmp.h +1 -0
index fdfba23..b49eab8 100644
@@ -278,6 +278,7 @@ enum
 	LINUX_MIB_XFRMOUTPOLDEAD,		/* XfrmOutPolDead */
 	LINUX_MIB_XFRMOUTPOLERROR,		/* XfrmOutPolError */
 	LINUX_MIB_XFRMFWDHDRERROR,		/* XfrmFwdHdrError*/
+	LINUX_MIB_XFRMOUTSTATEINVALID,		/* XfrmOutStateInvalid */
 	__LINUX_MIB_XFRMMAX
 };
 
net/xfrm/xfrm_output.c +6 -0
index 95a338c..3670526 100644
@@ -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 error_nolock;
+		}
+
 		err = xfrm_state_check_expire(x);
 		if (err) {
 			XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTSTATEEXPIRED);
net/xfrm/xfrm_proc.c +1 -0
index d0a1af8..6039038 100644
@@ -43,6 +43,7 @@ static const struct snmp_mib xfrm_mib_list[] = {
 	SNMP_MIB_ITEM("XfrmOutPolDead", LINUX_MIB_XFRMOUTPOLDEAD),
 	SNMP_MIB_ITEM("XfrmOutPolError", LINUX_MIB_XFRMOUTPOLERROR),
 	SNMP_MIB_ITEM("XfrmFwdHdrError", LINUX_MIB_XFRMFWDHDRERROR),
+	SNMP_MIB_ITEM("XfrmOutStateInvalid", LINUX_MIB_XFRMOUTSTATEINVALID),
 	SNMP_MIB_SENTINEL
 };
 
net/xfrm/xfrm_state.c +0 -3
index 3459692..05db236 100644
@@ -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;
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

From: [email protected]
Date: Fri, 28 Dec 2012 16:06:28 +0800

Quoted 10 lines

From: Li RongQing <[email protected]>

Remove the check if x->km.state equal to XFRM_STATE_VALID in xfrm_state_check_expire(), which will be done before call xfrm_state_check_expire().

add a LINUX_MIB_XFRMOUTSTATEINVALID statistic to record the outbound error due to invalid xfrm state.

I'll let Steffen pick this up when he returns from his holiday break.

Please CC: him on all IPSEC changes since he is the primary IPSEC maintainer and is the one who will integrate your IPSEC patches into his ipsec GIT tree.

maintainer
#2 lore raw
Quoted 9 lines · David Miller

From: [email protected]
Date: Fri, 28 Dec 2012 16:06:28 +0800

Quoted 6 lines

From: Li RongQing <[email protected]>

Remove the check if x->km.state equal to XFRM_STATE_VALID in xfrm_state_check_expire(), which will be done before call xfrm_state_check_expire().

Quoted 7 lines
Quoted 4 lines

add a LINUX_MIB_XFRMOUTSTATEINVALID statistic to record the outbound error due to invalid xfrm state.

I'll let Steffen pick this up when he returns from his holiday break.

I'll take care of all the pending IPsec patches once I'm back at office on monday.

Thanks for your patience.

maintainer Applied
#3 lore raw
In reply to [email protected]
Quoted 10 lines · On Fri, Dec 28, 2012 at 04:06:28PM +0800, [email protected] wrote:

From: Li RongQing <[email protected]>

Remove the check if x->km.state equal to XFRM_STATE_VALID in xfrm_state_check_expire(), which will be done before call xfrm_state_check_expire().

add a LINUX_MIB_XFRMOUTSTATEINVALID statistic to record the outbound error due to invalid xfrm state.

Applied to ipsec-next,

Thanks!