FAILED: patch "[PATCH] usb: gadget: u_ether: Fix host MAC address case" failed to apply to 4.14-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.14.y
git checkout FETCH_HEAD
git cherry-pick -x 3c0f4f09c063e143822393d99cb2b19a85451c07
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023052234-curfew-scuttle-1090@gregkh' --subject-prefix 'PATCH 4.14.y' HEAD^..
Possible dependencies:
3c0f4f09c063 ("usb: gadget: u_ether: Fix host MAC address case") 938fc6453176 ("usb: gadget: u_ether: Convert prints to device prints") 508aeb54e4f0 ("usb: gadget: u_ether: Remove duplicated include in u_ether.c") 890d5b40908b ("usb: gadget: u_ether: fix race in setting MAC address in setup phase") 3a37a9636cf3 ("net: dev: Add extack argument to dev_set_mac_address()")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 3c0f4f09c063e143822393d99cb2b19a85451c07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Konrad=20Gr=C3=A4fe?= <[email protected]>
Date: Fri, 5 May 2023 16:36:40 +0200
Subject: [PATCH] usb: gadget: u_ether: Fix host MAC address case
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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
drivers/usb/gadget/function/u_ether.c +3 -0
@@ -17,6 +17,7 @@#include <linux/etherdevice.h> #include <linux/ethtool.h> #include <linux/if_vlan.h> +#include <linux/string_helpers.h> #include <linux/usb/composite.h> #include "u_ether.h"
@@ -965,6 +966,8 @@ int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len) dev =netdev_priv (net);snprintf (host_addr, len,"%pm" , dev->host_mac); +string_upper (host_addr, host_addr); +return strlen (host_addr); }EXPORT_SYMBOL_GPL (gether_get_host_addr_cdc);