Skip to content

Commit

Permalink
netfilter: nat: skip checksum on offload SCTP packets
Browse files Browse the repository at this point in the history
SCTP GSO and hardware can do CRC32c computation after netfilter processing,
so we can avoid calling sctp_compute_checksum() on skb if skb->ip_summed
is equal to CHECKSUM_PARTIAL. Moreover, set skb->ip_summed to CHECKSUM_NONE
when the NAT code computes the CRC, to prevent offloaders from computing
it again (on ixgbe this resulted in a transmission with wrong L4 checksum).

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Davide Caratti authored and Pablo Neira Ayuso committed Dec 7, 2016
1 parent 3b760dc commit 3189a29
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/netfilter/nf_nat_proto_sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ sctp_manip_pkt(struct sk_buff *skb,
hdr->dest = tuple->dst.u.sctp.port;
}

hdr->checksum = sctp_compute_cksum(skb, hdroff);
if (skb->ip_summed != CHECKSUM_PARTIAL) {
hdr->checksum = sctp_compute_cksum(skb, hdroff);
skb->ip_summed = CHECKSUM_NONE;
}

return true;
}
Expand Down

0 comments on commit 3189a29

Please sign in to comment.