ipvs: sctp: fix checksumming on snat and dnat handlers
Subsystems (3)
PATCH 1/1 ipvs: sctp: fix checksumming on snat and dnat handlers
In reply to a message not in the archiveIn our test lab, we have a simple SCTP client connecting to a SCTP server via an IPVS load balancer. On some machines, load balancing works, but on others the initial handshake just fails, thus no SCTP connection whatsoever can be established!
We observed that the SCTP INIT-ACK handshake reply from the IPVS machine to the client had a correct IP checksum, but corrupt SCTP checksum when forwarded, thus on the client-side the packet was dropped and an intial handshake retriggered until all attempts run into the void.
To fix this issue, this patch i) adds a missing CHECKSUM_UNNECESSARY after the full checksum (re-)calculation (as done in IPVS TCP and UDP code as well), and ii) calculates the checksum in little-endian format (as fixed with the SCTP code in commit 4458f04c: sctp: Clean up sctp checksumming code). Stable backport of upstream commit 4b47bc9a.
--- net/netfilter/ipvs/ip_vs_proto_sctp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
net/netfilter/ipvs/ip_vs_proto_sctp.c +8 -6
@@ -70,7 +70,7 @@ sctp_snat_handler(struct sk_buff *skb,sctp_sctphdr_t *sctph;unsigned int sctphoff;struct sk_buff *iter; -__be32 crc32; +__u32 crc32;#ifdef CONFIG_IP_VS_IPV6 if (cp->af =AF_INET6 )
@@ -101,8 +101,9 @@ sctp_snat_handler(struct sk_buff *skb,skb_walk_frags (skb, iter) crc32 = sctp_update_cksum((u8 *) iter->data, skb_headlen(iter), crc32); - crc32 =sctp_end_cksum (crc32); - sctph->checksum = crc32; + sctph->checksum =sctp_end_cksum (crc32); + + skb->ip_summed =CHECKSUM_UNNECESSARY ;return 1 ; }
@@ -114,7 +115,7 @@ sctp_dnat_handler(struct sk_buff *skb,sctp_sctphdr_t *sctph;unsigned int sctphoff;struct sk_buff *iter; -__be32 crc32; +__u32 crc32;#ifdef CONFIG_IP_VS_IPV6 if (cp->af =AF_INET6 )
@@ -145,8 +146,9 @@ sctp_dnat_handler(struct sk_buff *skb,skb_walk_frags (skb, iter) crc32 = sctp_update_cksum((u8 *) iter->data, skb_headlen(iter), crc32); - crc32 =sctp_end_cksum (crc32); - sctph->checksum = crc32; + sctph->checksum =sctp_end_cksum (crc32); + + skb->ip_summed =CHECKSUM_UNNECESSARY ;return 1 ; }
Signature · 1 line
1.7.11.7
Quoted 79 lines · Daniel Borkmann
In our test lab, we have a simple SCTP client connecting to a SCTP server via an IPVS load balancer. On some machines, load balancing works, but on others the initial handshake just fails, thus no SCTP connection whatsoever can be established!
We observed that the SCTP INIT-ACK handshake reply from the IPVS machine to the client had a correct IP checksum, but corrupt SCTP checksum when forwarded, thus on the client-side the packet was dropped and an intial handshake retriggered until all attempts run into the void.
To fix this issue, this patch i) adds a missing
CHECKSUM_UNNECESSARYafter the full checksum (re-)calculation (as done in IPVS TCP and UDP code as well), and ii) calculates the checksum in little-endian format (as fixed with the SCTP code in commit4458f04c: sctp: Clean up sctp checksumming code). Stable backport of upstream commit4b47bc9a.Cc Julian Anastasov <[email protected]>Cc Simon Horman <[email protected]>Cc Pablo Neira Ayuso <[email protected]>Signed-off-by Daniel Borkmann <[email protected]>--- net/netfilter/ipvs/ip_vs_proto_sctp.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)net/netfilter/ipvs/ip_vs_proto_sctp.c +8
-6@@ -70,7 +70,7 @@ sctp_snat_handler(struct sk_buff *skb,sctp_sctphdr_t *sctph;unsigned int sctphoff;struct sk_buff *iter; -__be32 crc32; +__u32 crc32;#ifdef CONFIG_IP_VS_IPV6 if (cp->af =AF_INET6 )@@ -101,8 +101,9 @@ sctp_snat_handler(struct sk_buff *skb,skb_walk_frags (skb, iter) crc32 = sctp_update_cksum((u8 *) iter->data, skb_headlen(iter), crc32); - crc32 =sctp_end_cksum (crc32); - sctph->checksum = crc32; + sctph->checksum =sctp_end_cksum (crc32); + + skb->ip_summed =CHECKSUM_UNNECESSARY ;return 1 ; }@@ -114,7 +115,7 @@ sctp_dnat_handler(struct sk_buff *skb,sctp_sctphdr_t *sctph;unsigned int sctphoff;struct sk_buff *iter; -__be32 crc32; +__u32 crc32;#ifdef CONFIG_IP_VS_IPV6 if (cp->af =AF_INET6 )@@ -145,8 +146,9 @@ sctp_dnat_handler(struct sk_buff *skb,skb_walk_frags (skb, iter) crc32 = sctp_update_cksum((u8 *) iter->data, skb_headlen(iter), crc32); - crc32 =sctp_end_cksum (crc32); - sctph->checksum = crc32; + sctph->checksum =sctp_end_cksum (crc32); + + skb->ip_summed =CHECKSUM_UNNECESSARY ;return 1 ; }Signature · 6 lines
1.7.11.7 -- 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
Pablo Neira Ayuso
maintainerQuoted 22 lines · Neil Horman
Quoted 21 lines · Daniel Borkmann
In our test lab, we have a simple SCTP client connecting to a SCTP server via an IPVS load balancer. On some machines, load balancing works, but on others the initial handshake just fails, thus no SCTP connection whatsoever can be established!
We observed that the SCTP INIT-ACK handshake reply from the IPVS machine to the client had a correct IP checksum, but corrupt SCTP checksum when forwarded, thus on the client-side the packet was dropped and an intial handshake retriggered until all attempts run into the void.
To fix this issue, this patch i) adds a missing
CHECKSUM_UNNECESSARYafter the full checksum (re-)calculation (as done in IPVS TCP and UDP code as well), and ii) calculates the checksum in little-endian format (as fixed with the SCTP code in commit4458f04c: sctp: Clean up sctp checksumming code). Stable backport of upstream commit4b47bc9a.Cc Julian Anastasov <[email protected]>Cc Simon Horman <[email protected]>Cc Pablo Neira Ayuso <[email protected]>Signed-off-by Daniel Borkmann <[email protected]>
[...]
Quoted 1 line
Acked-by Neil Horman <[email protected]>
Enqueued to -stable. Thanks.