Skip to contentSkip to conversation

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

PATCH In review Fan Du 2 participants 4 messages Oct 15, 2013 – Oct 16, 2013

Subsystems (3)
lore
Share & tools
lore

Fan Du

author
#0 lore raw

PATCH v3 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]>

---
v3:
- Rename is_xfrm_armed by dst_xfrm
- Move this funtion in include/net/dst.h

v2:
- Split v1 into two separate patches.

---
 include/net/dst.h |   12 ++++++++++++
 net/sctp/output.c |    3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)
include/net/dst.h +12 -0
index 211dcf1..44995c1 100644
@@ -478,10 +478,22 @@ static inline struct dst_entry *xfrm_lookup(struct net *net,
 {
 	return dst_orig;
 } 
+
+static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
+{
+	return NULL;
+}
+
 #else
 struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
 			      const struct flowi *fl, struct sock *sk,
 			      int flags);
+
+/* skb attached with this dst needs transformation if dst->xfrm is valid */
+static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
+{
+	return dst->xfrm;
+}
 #endif
 
 #endif /* _NET_DST_H */
net/sctp/output.c +2 -1
index 0ac3a65..24b3718 100644
@@ -536,7 +536,8 @@ 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) ||
+			(dst_xfrm(dst) != NULL)) {
 			__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 11 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]>

Looks good to me.

-vlad

Quoted 55 lines

---
v3:
- Rename is_xfrm_armed by dst_xfrm
- Move this funtion in include/net/dst.h

v2:
- Split v1 into two separate patches.

---
  include/net/dst.h |   12 ++++++++++++
  net/sctp/output.c |    3 ++-
  2 files changed, 14 insertions(+), 1 deletion(-)
include/net/dst.h +12 -0
index 211dcf1..44995c1 100644
@@ -478,10 +478,22 @@ static inline struct dst_entry *xfrm_lookup(struct net *net,
  {
  	return dst_orig;
  }
+
+static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
+{
+	return NULL;
+}
+
  #else
  struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
  			      const struct flowi *fl, struct sock *sk,
  			      int flags);
+
+/* skb attached with this dst needs transformation if dst->xfrm is valid */
+static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
+{
+	return dst->xfrm;
+}
  #endif
 
  #endif /* _NET_DST_H */
net/sctp/output.c +2 -1
index 0ac3a65..24b3718 100644
@@ -536,7 +536,8 @@ 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) ||
+			(dst_xfrm(dst) != NULL)) {
  			__u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
 
  			/* 3) Put the resultant value into the checksum field in the
#2 lore raw
Quoted 9 lines · Vlad Yasevich
Quoted 8 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.

Quoted 8 lines
Quoted 5 lines
Cc Vlad Yasevich <[email protected]>
Cc Neil Horman <[email protected]>
Cc Steffen Klassert <[email protected]>

Looks good to me.

Just tryied applying this and looks like you based this on net-next. This fixes a rather ugly bug when checksum offloading is done. I am going to rebase this and re-submit for net.

-vlad

Quoted 62 lines

-vlad

Quoted 59 lines

---
v3:
- Rename is_xfrm_armed by dst_xfrm
- Move this funtion in include/net/dst.h

v2:
- Split v1 into two separate patches.

---
  include/net/dst.h |   12 ++++++++++++
  net/sctp/output.c |    3 ++-
  2 files changed, 14 insertions(+), 1 deletion(-)
include/net/dst.h +8 -0
index 211dcf1..44995c1 100644
@@ -478,10 +478,22 @@ static inline struct dst_entry
 *xfrm_lookup(struct net *net,
  {
      return dst_orig;
  }
+
+static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
+{
+    return NULL;
+}
+
  #else
  struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry
 *dst_orig,
                    const struct flowi *fl, struct sock *sk,
                    int flags);
+
+/* skb attached with this dst needs transformation if dst->xfrm is

valid */

include/net/dst.h +4 -0
+static inline struct xfrm_state *dst_xfrm(const struct dst_entry *dst)
+{
+    return dst->xfrm;
+}
  #endif
 
  #endif /* _NET_DST_H */
net/sctp/output.c +2 -1
index 0ac3a65..24b3718 100644
@@ -536,7 +536,8 @@ 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) ||
+            (dst_xfrm(dst) != NULL)) {
              __u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
 
              /* 3) Put the resultant value into the checksum field in

the

author
#3 lore raw
Quoted 16 lines · Vlad Yasevich
Quoted 15 lines · Vlad Yasevich
Quoted 13 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]>
Quoted 6 lines
Quoted 2 lines

Looks good to me.

Just tryied applying this and looks like you based this on net-next. This fixes a rather ugly bug when checksum offloading is done. I am going to rebase this and re-submit for net.

:( Sorry for the inconvenience. Stable tree might hurts also.

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

--fan