Skip to content

Commit b73c43f

Browse files
osctobedavem330
authored andcommitted
net: sctp: fix checksum marking for outgoing packets
Packets to devices without NETIF_F_SCTP_CSUM (including NETIF_F_NO_CSUM) should be properly checksummed because the packets can be diverted or rerouted after construction. This still leaves packets diverted from NETIF_F_SCTP_CSUM-enabled devices with broken checksums. Fixing this needs implementing software offload fallback in networking core. For users of sctp_checksum_disable, skb->ip_summed should be left as CHECKSUM_NONE and not CHECKSUM_UNNECESSARY as per include/linux/skbuff.h. Signed-off-by: Michał Mirosław <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 51414d4 commit b73c43f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

net/sctp/output.c

+8-11
Original file line numberDiff line numberDiff line change
@@ -500,23 +500,20 @@ int sctp_packet_transmit(struct sctp_packet *packet)
500500
* Note: Adler-32 is no longer applicable, as has been replaced
501501
* by CRC32-C as described in <draft-ietf-tsvwg-sctpcsum-02.txt>.
502502
*/
503-
if (!sctp_checksum_disable &&
504-
!(dst->dev->features & (NETIF_F_NO_CSUM | NETIF_F_SCTP_CSUM))) {
505-
__u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
503+
if (!sctp_checksum_disable) {
504+
if (!(dst->dev->features & NETIF_F_SCTP_CSUM)) {
505+
__u32 crc32 = sctp_start_cksum((__u8 *)sh, cksum_buf_len);
506506

507-
/* 3) Put the resultant value into the checksum field in the
508-
* common header, and leave the rest of the bits unchanged.
509-
*/
510-
sh->checksum = sctp_end_cksum(crc32);
511-
} else {
512-
if (dst->dev->features & NETIF_F_SCTP_CSUM) {
507+
/* 3) Put the resultant value into the checksum field in the
508+
* common header, and leave the rest of the bits unchanged.
509+
*/
510+
sh->checksum = sctp_end_cksum(crc32);
511+
} else {
513512
/* no need to seed pseudo checksum for SCTP */
514513
nskb->ip_summed = CHECKSUM_PARTIAL;
515514
nskb->csum_start = (skb_transport_header(nskb) -
516515
nskb->head);
517516
nskb->csum_offset = offsetof(struct sctphdr, checksum);
518-
} else {
519-
nskb->ip_summed = CHECKSUM_UNNECESSARY;
520517
}
521518
}
522519

0 commit comments

Comments
 (0)