mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
userspace: Enable IP checksum offloading by default.
The netdev receiving packets is supposed to provide the flags indicating if the IP checksum was verified and it is GOOD or BAD, otherwise the stack will check when appropriate by software. If the packet comes with good checksum, then postpone the checksum calculation to the egress device if needed. When encapsulate a packet with that flag, set the checksum of the inner IP header since that is not yet supported. Calculate the IP checksum when the packet is going to be sent over a device that doesn't support the feature. Linux devices don't support IP checksum offload alone, so the support is not enabled. Signed-off-by: Flavio Leitner <fbl@sysclose.org> Co-authored-by: Flavio Leitner <fbl@sysclose.org> Signed-off-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
committed by
Ilya Maximets
parent
4433cc6860
commit
5d11c47d3e
@@ -169,9 +169,14 @@ odp_set_ipv4(struct dp_packet *packet, const struct ovs_key_ipv4 *key,
|
||||
new_tos = key->ipv4_tos | (nh->ip_tos & ~mask->ipv4_tos);
|
||||
|
||||
if (nh->ip_tos != new_tos) {
|
||||
nh->ip_csum = recalc_csum16(nh->ip_csum,
|
||||
htons((uint16_t) nh->ip_tos),
|
||||
htons((uint16_t) new_tos));
|
||||
if (dp_packet_hwol_tx_ip_csum(packet)) {
|
||||
dp_packet_ol_reset_ip_csum_good(packet);
|
||||
} else {
|
||||
nh->ip_csum = recalc_csum16(nh->ip_csum,
|
||||
htons((uint16_t) nh->ip_tos),
|
||||
htons((uint16_t) new_tos));
|
||||
}
|
||||
|
||||
nh->ip_tos = new_tos;
|
||||
}
|
||||
}
|
||||
@@ -180,8 +185,14 @@ odp_set_ipv4(struct dp_packet *packet, const struct ovs_key_ipv4 *key,
|
||||
new_ttl = key->ipv4_ttl | (nh->ip_ttl & ~mask->ipv4_ttl);
|
||||
|
||||
if (OVS_LIKELY(nh->ip_ttl != new_ttl)) {
|
||||
nh->ip_csum = recalc_csum16(nh->ip_csum, htons(nh->ip_ttl << 8),
|
||||
htons(new_ttl << 8));
|
||||
if (dp_packet_hwol_tx_ip_csum(packet)) {
|
||||
dp_packet_ol_reset_ip_csum_good(packet);
|
||||
} else {
|
||||
nh->ip_csum = recalc_csum16(nh->ip_csum,
|
||||
htons(nh->ip_ttl << 8),
|
||||
htons(new_ttl << 8));
|
||||
}
|
||||
|
||||
nh->ip_ttl = new_ttl;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user