Skip to contentSkip to conversation

sctp: Use software checksum under certain

PATCH In review Vlad Yasevich 4 participants 11 messages Oct 16, 2013 – Oct 18, 2013

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

v4 cover sctp: Use software checksum under certain

There are some cards that support SCTP checksum offloading. When using these cards with IPSec or forcing IP fragmentation of SCTP traffic, the checksum is computed incorrectly due to the fact that xfrm and IP/IPv6 fragmentation code do not know that this is SCTP traffic and do not know that checksum has to be computed differently.

To fix this, we let SCTP detect these conditions and perform software checksum calculation.

Fan Du (1):
sctp: Use software crc32 checksum when xfrm transform will happen.

Vlad Yasevich (2):
net: dst: provide accessor function to dst->xfrm
sctp: Perform software checksum if packet has to be fragmented.

 include/net/dst.h | 12 ++++++++++++
 net/sctp/output.c |  3 ++-
 2 files changed, 14 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v4 1/3 net: dst: provide accessor function to dst->xfrm

dst->xfrm is conditionally defined. Provide accessor funtion that is always available.

---
 include/net/dst.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/net/dst.h +12 -0
index 3bc4865..3c4c944 100644
@@ -479,10 +479,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
 extern 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 */
Signature · 1 line
1.8.3.1
Acked-by on v4 1/3
#2 lore raw

Re: [PATCH v4 net 1/3] net: dst: provide accessor function to dst->xfrm

Quoted 43 lines · Vlad Yasevich

dst->xfrm is conditionally defined. Provide accessor funtion that is always available.

---
 include/net/dst.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/net/dst.h +12 -0
index 3bc4865..3c4c944 100644
@@ -479,10 +479,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
 extern 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 */
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH v4 2/3 sctp: Use software crc32 checksum when xfrm transform will happen.

In reply to Vlad Yasevich

From: Fan Du <[email protected]>

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 checksum operation(sum every thing up and pack the 16bits result in the checksum field). The result is fail establishment of sctp communication.

Cc Neil Horman <[email protected]>
Cc Steffen Klassert <[email protected]>
---
 net/sctp/output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/output.c +2 -1
index 0ac3a65..d35b54c 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.8.3.1
Acked-by on v4 2/3
#4 lore raw

Re: [PATCH v4 net 2/3] sctp: Use software crc32 checksum when xfrm transform will happen.

Quoted 38 lines · Vlad Yasevich

From: Fan Du <[email protected]>

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 checksum operation(sum every thing up and pack the 16bits result in the checksum field). The result is fail establishment of sctp communication.

Cc Neil Horman <[email protected]>
Cc Steffen Klassert <[email protected]>
---
 net/sctp/output.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/output.c +2 -1
index 0ac3a65..d35b54c 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 · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH v4 3/3 sctp: Perform software checksum if packet has to be fragmented.

In reply to Vlad Yasevich

IP/IPv6 fragmentation knows how to compute only TCP/UDP checksum. This causes problems if SCTP packets has to be fragmented and ipsummed has been set to PARTIAL due to checksum offload support. This condition can happen when retransmitting after MTU discover, or when INIT or other control chunks are larger then MTU. Check for the rare fragmentation condition in SCTP and use software checksum calculation in this case.

---
 net/sctp/output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/output.c +1 -1
index d35b54c..3191373 100644
@@ -537,7 +537,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
 	 */
 	if (!sctp_checksum_disable) {
 		if (!(dst->dev->features & NETIF_F_SCTP_CSUM) ||
-		    (dst_xfrm(dst) != NULL)) {
+		    (dst_xfrm(dst) != NULL) || packet->ipfragok) {
 			__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.8.3.1
Acked-by on v4 3/3
#6 lore raw

Re: [PATCH v4 net 3/3] sctp: Perform software checksum if packet has to be fragmented.

Quoted 35 lines · Vlad Yasevich

IP/IPv6 fragmentation knows how to compute only TCP/UDP checksum. This causes problems if SCTP packets has to be fragmented and ipsummed has been set to PARTIAL due to checksum offload support. This condition can happen when retransmitting after MTU discover, or when INIT or other control chunks are larger then MTU. Check for the rare fragmentation condition in SCTP and use software checksum calculation in this case.

---
 net/sctp/output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/output.c +1 -1
index d35b54c..3191373 100644
@@ -537,7 +537,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
 	 */
 	if (!sctp_checksum_disable) {
 		if (!(dst->dev->features & NETIF_F_SCTP_CSUM) ||
-		    (dst_xfrm(dst) != NULL)) {
+		    (dst_xfrm(dst) != NULL) || packet->ipfragok) {
 			__u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
 
 			/* 3) Put the resultant value into the checksum field in the
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on the v4 series
#7 lore raw
In reply to Vlad Yasevich
Quoted 12 lines · Vlad Yasevich

There are some cards that support SCTP checksum offloading. When using these cards with IPSec or forcing IP fragmentation of SCTP traffic, the checksum is computed incorrectly due to the fact that xfrm and IP/IPv6 fragmentation code do not know that this is SCTP traffic and do not know that checksum has to be computed differently.

To fix this, we let SCTP detect these conditions and perform software checksum calculation.

Fan Du (1):
sctp: Use software crc32 checksum when xfrm transform will happen.

Quoted 8 lines

Vlad Yasevich (2):
net: dst: provide accessor function to dst->xfrm
sctp: Perform software checksum if packet has to be fragmented.

  include/net/dst.h | 12 ++++++++++++
  net/sctp/output.c |  3 ++-
  2 files changed, 14 insertions(+), 1 deletion(-)
maintainer
#8 lore raw
In reply to Vlad Yasevich

From: Vlad Yasevich <[email protected]>
Date: Tue, 15 Oct 2013 22:01:28 -0400

Quoted 8 lines

There are some cards that support SCTP checksum offloading. When using these cards with IPSec or forcing IP fragmentation of SCTP traffic, the checksum is computed incorrectly due to the fact that xfrm and IP/IPv6 fragmentation code do not know that this is SCTP traffic and do not know that checksum has to be computed differently.

To fix this, we let SCTP detect these conditions and perform software checksum calculation.

Series applied, thanks Vlad.

#9 lore raw
Quoted 9 lines · David Miller

From: Vlad Yasevich <[email protected]>
Date: Tue, 15 Oct 2013 22:01:28 -0400

Quoted 6 lines

There are some cards that support SCTP checksum offloading. When using these cards with IPSec or forcing IP fragmentation of SCTP traffic, the checksum is computed incorrectly due to the fact that xfrm and IP/IPv6 fragmentation code do not know that this is SCTP traffic and do not know that checksum has to be computed differently.

Quoted 5 lines
Quoted 2 lines

To fix this, we let SCTP detect these conditions and perform software checksum calculation.

Series applied, thanks Vlad.

Hi David

Could you please queue this to stable as well.

Thanks
-vlad

maintainer
#10 lore raw

From: Vlad Yasevich <[email protected]>
Date: Thu, 17 Oct 2013 16:21:31 -0400

Quoted 1 line

Could you please queue this to stable as well.

Done.