vio: Don't request csum offload if not negotiated
authorsf <sf@openbsd.org>
Fri, 26 Jul 2024 06:29:01 +0000 (06:29 +0000)
committersf <sf@openbsd.org>
Fri, 26 Jul 2024 06:29:01 +0000 (06:29 +0000)
The standard says "A driver MUST NOT enable an offload for which the
appropriate feature has not been negotiated."

ok jan@

sys/dev/pv/if_vio.c

index 5ff0cca..19f276c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_vio.c,v 1.42 2024/06/28 14:46:31 jan Exp $ */
+/*     $OpenBSD: if_vio.c,v 1.43 2024/07/26 06:29:01 sf Exp $  */
 
 /*
  * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg.
@@ -731,7 +731,8 @@ vio_init(struct ifnet *ifp)
        if (virtio_has_feature(vsc, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
                uint64_t features = 0;
 
-               SET(features, VIRTIO_NET_F_GUEST_CSUM);
+               if (virtio_has_feature(vsc, VIRTIO_NET_F_GUEST_CSUM))
+                       SET(features, VIRTIO_NET_F_GUEST_CSUM);
 
                if (ISSET(ifp->if_xflags, IFXF_LRO)) {
                        if (virtio_has_feature(vsc, VIRTIO_NET_F_GUEST_TSO4))