Commit aaf042299a for qemu.org

commit aaf042299acf83919862c7d7dd5fc36acf4e0671
Author: Stéphane Graber <stgraber@stgraber.org>
Date:   Thu Sep 11 13:14:15 2025 +0100

    hw/usb/network: Remove hardcoded 0x40 prefix in STRING_ETHADDR response

    USB NICs have a "40:" prefix hardcoded for all MAC addresses when we
    return the guest the MAC address if it queries the STRING_ETHADDR USB
    string property.  This doesn't match what we use for the
    OID_802_3_PERMANENT_ADDRESS or OID_802_3_CURRENT_ADDRESS OIDs for
    NDIS, or the MAC address we actually use in the QEMU networking code
    to send/receive packets for this device, or the NIC info string we
    print for users.  In all those other places we directly use
    s->conf.macaddr.a, which is the full thing the user asks for.

    This overrides user-provided configuration and leads to an inconsistent
    experience.

    I couldn't find any documented reason (comment or git commits) for
    this behavior.  It seems like everyone is just expecting the MAC
    address to be fully passed through to the guest, but it isn't.

    This may have been a debugging hack that accidentally made it through
    to the accepted patch: it has been in the code since it was originally
    added back in 2008.

    This is also particularly problematic as the "40:" prefix isn't a
    reserved prefix for MAC addresses (IEEE OUI).  There are a number of
    valid allocations out there which use this prefix, meaning that QEMU
    may be causing MAC address conflicts.

    Cc: qemu-stable@nongnu.org
    Fixes: 6c9f886ceae5b ("Add CDC-Ethernet usb NIC (original patch from Thomas Sailer)"
    Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2951
    Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
    [PMM: beef up commit message based on mailing list discussion]
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

diff --git a/hw/usb/dev-network.c b/hw/usb/dev-network.c
index 81cc09dcac..1df2454181 100644
--- a/hw/usb/dev-network.c
+++ b/hw/usb/dev-network.c
@@ -1383,7 +1383,7 @@ static void usb_net_realize(USBDevice *dev, Error **errp)
     qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
     snprintf(s->usbstring_mac, sizeof(s->usbstring_mac),
              "%02x%02x%02x%02x%02x%02x",
-             0x40,
+             s->conf.macaddr.a[0],
              s->conf.macaddr.a[1],
              s->conf.macaddr.a[2],
              s->conf.macaddr.a[3],