Skip to content

Commit 3c0f4f0

Browse files
konradgraefegregkh
authored andcommitted
usb: gadget: u_ether: Fix host MAC address case
The CDC-ECM specification [1] requires to send the host MAC address as an uppercase hexadecimal string in chapter "5.4 Ethernet Networking Functional Descriptor": The Unicode character is chosen from the set of values 30h through 39h and 41h through 46h (0-9 and A-F). However, snprintf(.., "%pm", ..) generates a lowercase MAC address string. While most host drivers are tolerant to this, UsbNcm.sys on Windows 10 is not. Instead it uses a different MAC address with all bytes set to zero including and after the first byte containing a lowercase letter. On Windows 11 Microsoft fixed it, but apparently they did not backport the fix. This change fixes the issue by upper-casing the MAC to comply with the specification. [1]: https://www.usb.org/document-library/class-definitions-communication-devices-12, file ECM120.pdf Fixes: bcd4a1c ("usb: gadget: u_ether: construct with default values and add setters/getters") Cc: [email protected] Signed-off-by: Konrad Gräfe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d8f2826 commit 3c0f4f0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/usb/gadget/function/u_ether.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/etherdevice.h>
1818
#include <linux/ethtool.h>
1919
#include <linux/if_vlan.h>
20+
#include <linux/string_helpers.h>
2021
#include <linux/usb/composite.h>
2122

2223
#include "u_ether.h"
@@ -965,6 +966,8 @@ int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len)
965966
dev = netdev_priv(net);
966967
snprintf(host_addr, len, "%pm", dev->host_mac);
967968

969+
string_upper(host_addr, host_addr);
970+
968971
return strlen(host_addr);
969972
}
970973
EXPORT_SYMBOL_GPL(gether_get_host_addr_cdc);

0 commit comments

Comments
 (0)