Skip to contentSkip to conversation

xfrm: add LINUX_MIB_XFRMACQUIREERROR statistic counter

PATCH RESEND Superseded Fan Du 3 participants 4 messages May 20, 2013 – Jun 4, 2013

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Fan Du

author
#0 lore raw

PATCH RESEND 1/1 xfrm: add LINUX_MIB_XFRMACQUIREERROR statistic counter

When host ping its peer, ICMP echo request packet triggers IPsec policy, then host negotiates SA secret with its peer. After IKE installed SA for OUT direction, but before SA for IN direction installed, host get ICMP echo reply from its peer. At the time being, the SA state for IN direction could be XFRM_STATE_ACQ, then the received packet will be dropped after adding LINUX_MIB_XFRMINSTATEINVALID statistic.

Adding a LINUX_MIB_XFRMACQUIREERROR statistic counter for such scenario when SA in larval state is much clearer for user than LINUX_MIB_XFRMINSTATEINVALID which indicates the SA is totally bad.

---
 include/uapi/linux/snmp.h |    1 +
 net/xfrm/xfrm_input.c     |    5 +++++
 net/xfrm/xfrm_proc.c      |    1 +
 3 files changed, 7 insertions(+), 0 deletions(-)
include/uapi/linux/snmp.h +1 -0
index df2e8b4..3d072bf 100644
@@ -287,6 +287,7 @@ enum
 	LINUX_MIB_XFRMOUTPOLERROR,		/* XfrmOutPolError */
 	LINUX_MIB_XFRMFWDHDRERROR,		/* XfrmFwdHdrError*/
 	LINUX_MIB_XFRMOUTSTATEINVALID,		/* XfrmOutStateInvalid */
+	LINUX_MIB_XFRMACQUIREERROR,     /* XfrmAcquireError*/
 	__LINUX_MIB_XFRMMAX
 };
 
net/xfrm/xfrm_input.c +5 -0
index ab2bb42..8884399 100644
@@ -163,6 +163,11 @@ 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);
 			goto drop_unlock;
net/xfrm/xfrm_proc.c +1 -0
index c721b0d..80cd1e5 100644
@@ -44,6 +44,7 @@ static const struct snmp_mib xfrm_mib_list[] = {
 	SNMP_MIB_ITEM("XfrmOutPolError", LINUX_MIB_XFRMOUTPOLERROR),
 	SNMP_MIB_ITEM("XfrmFwdHdrError", LINUX_MIB_XFRMFWDHDRERROR),
 	SNMP_MIB_ITEM("XfrmOutStateInvalid", LINUX_MIB_XFRMOUTSTATEINVALID),
+	SNMP_MIB_ITEM("XfrmAcquireError", LINUX_MIB_XFRMACQUIREERROR),
 	SNMP_MIB_SENTINEL
 };
 
Signature · 1 line
1.7.4.1
#1 lore raw

Hello.

Quoted 25 lines · Fan Du

When host ping its peer, ICMP echo request packet triggers IPsec policy, then host negotiates SA secret with its peer. After IKE installed SA for OUT direction, but before SA for IN direction installed, host get ICMP echo reply from its peer. At the time being, the SA state for IN direction could be XFRM_STATE_ACQ, then the received packet will be dropped after adding LINUX_MIB_XFRMINSTATEINVALID statistic.

Adding a LINUX_MIB_XFRMACQUIREERROR statistic counter for such scenario when SA in larval state is much clearer for user than LINUX_MIB_XFRMINSTATEINVALID which indicates the SA is totally bad.

---
  include/uapi/linux/snmp.h |    1 +
  net/xfrm/xfrm_input.c     |    5 +++++
  net/xfrm/xfrm_proc.c      |    1 +
  3 files changed, 7 insertions(+), 0 deletions(-)
include/uapi/linux/snmp.h +0 -0
index df2e8b4..3d072bf 100644

include/uapi/linux/snmp.h enum · line 290

Quoted 4 lines
include/uapi/linux/snmp.h +1 -0
@@ -287,6 +287,7 @@ enum
  	LINUX_MIB_XFRMOUTPOLERROR,		/* XfrmOutPolError */
  	LINUX_MIB_XFRMFWDHDRERROR,		/* XfrmFwdHdrError*/
  	LINUX_MIB_XFRMOUTSTATEINVALID,		/* XfrmOutStateInvalid */
+	LINUX_MIB_XFRMACQUIREERROR,     /* XfrmAcquireError*/

Please indent the comment with tabs and align with the above ones.

WBR, Sergei

author
#2 lore raw

Hi, Sergei

Quoted 24 lines · Sergei Shtylyov

Hello.

Quoted 19 lines · Fan Du

When host ping its peer, ICMP echo request packet triggers IPsec policy, then host negotiates SA secret with its peer. After IKE installed SA for OUT direction, but before SA for IN direction installed, host get ICMP echo reply from its peer. At the time being, the SA state for IN direction could be XFRM_STATE_ACQ, then the received packet will be dropped after adding LINUX_MIB_XFRMINSTATEINVALID statistic.

Adding a LINUX_MIB_XFRMACQUIREERROR statistic counter for such scenario when SA in larval state is much clearer for user than LINUX_MIB_XFRMINSTATEINVALID which indicates the SA is totally bad.

---
include/uapi/linux/snmp.h | 1 +
net/xfrm/xfrm_input.c | 5 +++++
net/xfrm/xfrm_proc.c | 1 +

3 files changed, 7 insertions(+), 0 deletions(-)
Quoted 11 lines
Quoted 9 lines
include/uapi/linux/snmp.h +0 -0
index df2e8b4..3d072bf 100644
@@ -287,6 +287,7 @@ enum

LINUX_MIB_XFRMOUTPOLERROR, /* XfrmOutPolError */ LINUX_MIB_XFRMFWDHDRERROR, /* XfrmFwdHdrError*/ LINUX_MIB_XFRMOUTSTATEINVALID, /* XfrmOutStateInvalid */
+ LINUX_MIB_XFRMACQUIREERROR, /* XfrmAcquireError*/

Please indent the comment with tabs and align with the above ones.

Thanks for the point, I will fix this in next round after reviewing from Steffen and others.

Quoted 3 lines

WBR, Sergei

Signature · 3 lines
浮沉随浪只记今朝笑

--fan
maintainer
#3 lore raw
Quoted 39 lines · Fan Du

Hi, Sergei

Quoted 24 lines · Sergei Shtylyov

Hello.

Quoted 19 lines · Fan Du

When host ping its peer, ICMP echo request packet triggers IPsec policy, then host negotiates SA secret with its peer. After IKE installed SA for OUT direction, but before SA for IN direction installed, host get ICMP echo reply from its peer. At the time being, the SA state for IN direction could be XFRM_STATE_ACQ, then the received packet will be dropped after adding LINUX_MIB_XFRMINSTATEINVALID statistic.

Adding a LINUX_MIB_XFRMACQUIREERROR statistic counter for such scenario when SA in larval state is much clearer for user than LINUX_MIB_XFRMINSTATEINVALID which indicates the SA is totally bad.

---
include/uapi/linux/snmp.h | 1 +
net/xfrm/xfrm_input.c | 5 +++++
net/xfrm/xfrm_proc.c | 1 +

3 files changed, 7 insertions(+), 0 deletions(-)
Quoted 11 lines
Quoted 9 lines
include/uapi/linux/snmp.h +0 -0
index df2e8b4..3d072bf 100644
@@ -287,6 +287,7 @@ enum

LINUX_MIB_XFRMOUTPOLERROR, /* XfrmOutPolError */ LINUX_MIB_XFRMFWDHDRERROR, /* XfrmFwdHdrError*/ LINUX_MIB_XFRMOUTSTATEINVALID, /* XfrmOutStateInvalid */
+ LINUX_MIB_XFRMACQUIREERROR, /* XfrmAcquireError*/

Please indent the comment with tabs and align with the above ones.

Quoted 2 lines

Thanks for the point, I will fix this in next round after reviewing from Steffen and others.

The patch looks ok to me, please fix the indent and resend.

Thanks!