Skip to contentSkip to conversation

{xfrm, sctp} Stick to software crc32 even if hardware is capable of that

PATCH RESEND Superseded Fan Du 3 participants 5 messages Oct 14, 2013 – Oct 15, 2013

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Fan Du

author
#0 lore raw

PATCH RESEND v2 1/1 {xfrm, sctp} Stick to software crc32 even if hardware is capable of that

igb/ixgbe have hardware sctp checksum support, when this feature is enabled and also IPsec is armed to protect sctp traffic, ugly things happened as xfrm_output checks CHECKSUM_PARTIAL to do check sum operation(sum every thing up and pack the 16bits result in the checksum field). The result is fail establishment of sctp communication.

Cc Vlad Yasevich <[email protected]>
Cc Neil Horman <[email protected]>
Cc Steffen Klassert <[email protected]>
---
 net/sctp/output.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
net/sctp/output.c +13 -1
index 0ac3a65..6de6402 100644
@@ -372,6 +372,16 @@ static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk)
 	atomic_inc(&sk->sk_wmem_alloc);
 }
 
+static int is_xfrm_armed(struct dst_entry *dst)
+{
+#ifdef CONFIG_XFRM
+	/* If dst->xfrm is valid, this skb needs to be transformed */
+	return dst->xfrm != NULL;
+#else
+	return 0;
+#endif
+}
+
 /* All packets are sent to the network through this function from
  * sctp_outq_tail().
  *
@@ -536,7 +546,9 @@ int sctp_packet_transmit(struct sctp_packet *packet)
 	 * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
 	 */
 	if (!sctp_checksum_disable) {
-		if (!(dst->dev->features & NETIF_F_SCTP_CSUM)) {
+		if ((!(dst->dev->features & NETIF_F_SCTP_CSUM)) ||
+			is_xfrm_armed(dst)) {
+
 			__u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
 
 			/* 3) Put the resultant value into the checksum field in the
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 22 lines · Fan Du

igb/ixgbe have hardware sctp checksum support, when this feature is enabled and also IPsec is armed to protect sctp traffic, ugly things happened as xfrm_output checks CHECKSUM_PARTIAL to do check sum operation(sum every thing up and pack the 16bits result in the checksum field). The result is fail establishment of sctp communication.

Cc Vlad Yasevich <[email protected]>
Cc Neil Horman <[email protected]>
Cc Steffen Klassert <[email protected]>
---
  net/sctp/output.c |   14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
net/sctp/output.c +0 -0
index 0ac3a65..6de6402 100644
@@ -372,6 +372,16 @@ static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk)
  	atomic_inc(&sk->sk_wmem_alloc);
  }

net/sctp/output.c static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk) · line 383

Quoted 10 lines
net/sctp/output.c +9 -0
 
+static int is_xfrm_armed(struct dst_entry *dst)
+{
+#ifdef CONFIG_XFRM
+	/* If dst->xfrm is valid, this skb needs to be transformed */
+	return dst->xfrm != NULL;
+#else
+	return 0;
+#endif
+}

Instead of putting this into SCTP code, isn't the above rather a candidate for include/net/xfrm.h, e.g. as ... bool xfrm_is_armed(...) ?

Quoted 15 lines
net/sctp/output.c +3 -1
  /* All packets are sent to the network through this function from
   * sctp_outq_tail().
   *
@@ -536,7 +546,9 @@ int sctp_packet_transmit(struct sctp_packet *packet)
  	 * by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
  	 */
  	if (!sctp_checksum_disable) {
-		if (!(dst->dev->features & NETIF_F_SCTP_CSUM)) {
+		if ((!(dst->dev->features & NETIF_F_SCTP_CSUM)) ||
+			is_xfrm_armed(dst)) {
+
  			__u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
 
  			/* 3) Put the resultant value into the checksum field in the
author
#2 lore raw
Quoted 24 lines · Daniel Borkmann
Quoted 23 lines · Fan Du

igb/ixgbe have hardware sctp checksum support, when this feature is enabled and also IPsec is armed to protect sctp traffic, ugly things happened as xfrm_output checks CHECKSUM_PARTIAL to do check sum operation(sum every thing up and pack the 16bits result in the checksum field). The result is fail establishment of sctp communication.

Cc Vlad Yasevich <[email protected]>
Cc Neil Horman <[email protected]>
Cc Steffen Klassert <[email protected]>
---
  net/sctp/output.c |   14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
net/sctp/output.c +0 -0
index 0ac3a65..6de6402 100644
@@ -372,6 +372,16 @@ static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk)
      atomic_inc(&sk->sk_wmem_alloc);
  }
 
Quoted 12 lines

net/sctp/output.c static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk) · line 383

Quoted 9 lines
net/sctp/output.c +9 -0
+static int is_xfrm_armed(struct dst_entry *dst)
+{
+#ifdef CONFIG_XFRM
+    /* If dst->xfrm is valid, this skb needs to be transformed */
+    return dst->xfrm != NULL;
+#else
+    return 0;
+#endif
+}

Instead of putting this into SCTP code, isn't the above rather a candidate for include/net/xfrm.h, e.g. as ... bool xfrm_is_armed(...) ?

Should be in such style in terms of its name, but this is truly SCTP specific in this scenario. No one elsewhere barely need this as far as I can tell...

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

--fan
#3 lore raw
Quoted 43 lines · Fan Du
Quoted 2 lines · Daniel Borkmann
Quoted 1 line · Fan Du

igb/ixgbe have hardware sctp checksum support, when this feature is

enabled

Quoted 1 line
Quoted 1 line

and also IPsec is armed to protect sctp traffic, ugly things

happened as

Quoted 1 line
Quoted 1 line

xfrm_output checks CHECKSUM_PARTIAL to do check sum operation(sum

every thing

Quoted 1 line
Quoted 1 line

up and pack the 16bits result in the checksum field). The result is

fail

Quoted 11 lines
Quoted 11 lines

establishment of sctp communication.

Cc Vlad Yasevich <[email protected]>
Cc Neil Horman <[email protected]>
Cc Steffen Klassert <[email protected]>
---
  net/sctp/output.c |   14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
Quoted 5 lines

net/sctp/output.c static void sctp_packet_set_owner_w(struct

Quoted 5 lines
net/sctp/output.c +0 -0
index 0ac3a65..6de6402 100644
@@ -372,6 +372,16 @@ static void sctp_packet_set_owner_w(struct

sk_buff *skb, struct sock *sk)

Quoted 14 lines

net/sctp/output.c static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk) · line 383

Quoted 12 lines
net/sctp/output.c +9 -0
      atomic_inc(&sk->sk_wmem_alloc);
  }
 
+static int is_xfrm_armed(struct dst_entry *dst)
+{
+#ifdef CONFIG_XFRM
+    /* If dst->xfrm is valid, this skb needs to be transformed */
+    return dst->xfrm != NULL;
+#else
+    return 0;
+#endif
+}

Instead of putting this into SCTP code, isn't the above rather a

Quoted 6 lines

candidate for

Quoted 1 line

include/net/xfrm.h, e.g. as ... bool xfrm_is_armed(...) ?

Should be in such style in terms of its name, but this is truly SCTP specific in this scenario.
No one elsewhere barely need this as far as I can tell...

It almost begs for dst_xfrm() function that returns NULL or dst->xfrm. Thar can live in dst code.

-vlad

Signature · 1 line
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
author
#4 lore raw
Quoted 48 lines · Vlad Yasevich
Quoted 44 lines · Fan Du
Quoted 2 lines · Daniel Borkmann
Quoted 1 line · Fan Du

igb/ixgbe have hardware sctp checksum support, when this feature is

enabled

Quoted 1 line
Quoted 1 line

and also IPsec is armed to protect sctp traffic, ugly things

happened as

Quoted 1 line
Quoted 1 line

xfrm_output checks CHECKSUM_PARTIAL to do check sum operation(sum

every thing

Quoted 1 line
Quoted 1 line

up and pack the 16bits result in the checksum field). The result is

fail

Quoted 11 lines
Quoted 11 lines

establishment of sctp communication.

Cc Vlad Yasevich<[email protected]>
Cc Neil Horman<[email protected]>
Cc Steffen Klassert<[email protected]>
---
   net/sctp/output.c |   14 +++++++++++++-
   1 file changed, 13 insertions(+), 1 deletion(-)
Quoted 5 lines

net/sctp/output.c static void sctp_packet_set_owner_w(struct

Quoted 5 lines
net/sctp/output.c +0 -0
index 0ac3a65..6de6402 100644
@@ -372,6 +372,16 @@ static void sctp_packet_set_owner_w(struct

sk_buff *skb, struct sock *sk)

Quoted 14 lines

net/sctp/output.c static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk) · line 383

Quoted 12 lines
net/sctp/output.c +9 -0
       atomic_inc(&sk->sk_wmem_alloc);
   }
 
+static int is_xfrm_armed(struct dst_entry *dst)
+{
+#ifdef CONFIG_XFRM
+    /* If dst->xfrm is valid, this skb needs to be transformed */
+    return dst->xfrm != NULL;
+#else
+    return 0;
+#endif
+}

Instead of putting this into SCTP code, isn't the above rather a

candidate for

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

include/net/xfrm.h, e.g. as ... bool xfrm_is_armed(...) ?

Should be in such style in terms of its name, but this is truly SCTP specific in this scenario.
No one elsewhere barely need this as far as I can tell...

It almost begs for dst_xfrm() function that returns NULL or dst->xfrm. Thar can live in dst code.

Ok, I will show my love in such style in v3.

Quoted 2 lines

-vlad

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

--fan