Skip to content

Commit

Permalink
netdev-linux: Do not offload IP checksum.
Browse files Browse the repository at this point in the history
Offloading checksum with a virtio_net_hdr header works only for L4.
Remove false claim that IP checksum offloading is supported.

As a consequence, L3 checksum can be assumed to be correct when
preparing a L4 offload request.

Fixes: 3337e6d ("userspace: Enable L4 checksum offloading by default.")
Acked-by: Mike Pattrick <[email protected]>
Signed-off-by: David Marchand <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
david-marchand authored and igsilya committed Aug 13, 2024
1 parent 82ed9ef commit 4ba6511
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions lib/netdev-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,8 +1061,7 @@ netdev_linux_construct_tap(struct netdev *netdev_)

if (tap_supports_vnet_hdr
&& ioctl(netdev->tap_fd, TUNSETOFFLOAD, oflags) == 0) {
netdev_->ol_flags |= (NETDEV_TX_OFFLOAD_IPV4_CKSUM
| NETDEV_TX_OFFLOAD_TCP_CKSUM
netdev_->ol_flags |= (NETDEV_TX_OFFLOAD_TCP_CKSUM
| NETDEV_TX_OFFLOAD_UDP_CKSUM);

if (userspace_tso_enabled()) {
Expand Down Expand Up @@ -2510,13 +2509,11 @@ netdev_linux_set_ol(struct netdev *netdev_)
char *string;
uint32_t value;
} t_list[] = {
{"tx-checksum-ipv4", NETDEV_TX_OFFLOAD_IPV4_CKSUM |
NETDEV_TX_OFFLOAD_TCP_CKSUM |
{"tx-checksum-ipv4", NETDEV_TX_OFFLOAD_TCP_CKSUM |
NETDEV_TX_OFFLOAD_UDP_CKSUM},
{"tx-checksum-ipv6", NETDEV_TX_OFFLOAD_TCP_CKSUM |
NETDEV_TX_OFFLOAD_UDP_CKSUM},
{"tx-checksum-ip-generic", NETDEV_TX_OFFLOAD_IPV4_CKSUM |
NETDEV_TX_OFFLOAD_TCP_CKSUM |
{"tx-checksum-ip-generic", NETDEV_TX_OFFLOAD_TCP_CKSUM |
NETDEV_TX_OFFLOAD_UDP_CKSUM},
{"tx-checksum-sctp", NETDEV_TX_OFFLOAD_SCTP_CKSUM},
{"tx-tcp-segmentation", NETDEV_TX_OFFLOAD_TCP_TSO},
Expand Down Expand Up @@ -7203,13 +7200,6 @@ netdev_linux_prepend_vnet_hdr(struct dp_packet *b, int mtu)
/* The packet has good L4 checksum. No need to validate again. */
vnet->csum_start = vnet->csum_offset = (OVS_FORCE __virtio16) 0;
vnet->flags = VIRTIO_NET_HDR_F_DATA_VALID;

/* It is possible that L4 is good but the IPv4 checksum isn't
* complete. For example in the case of UDP encapsulation of an ARP
* packet where the UDP checksum is 0. */
if (dp_packet_hwol_l3_csum_ipv4_ol(b)) {
dp_packet_ip_set_header_csum(b, false);
}
} else if (dp_packet_hwol_tx_l4_checksum(b)) {
/* The csum calculation is offloaded. */
if (dp_packet_hwol_l4_is_tcp(b)) {
Expand Down

0 comments on commit 4ba6511

Please sign in to comment.