From patchwork Tue Apr 25 12:58:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Konrad_Gr=C3=A4fe?= X-Patchwork-Id: 677115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A20EC77B61 for ; Tue, 25 Apr 2023 13:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233730AbjDYN02 (ORCPT ); Tue, 25 Apr 2023 09:26:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjDYN01 (ORCPT ); Tue, 25 Apr 2023 09:26:27 -0400 Received: from www484.your-server.de (www484.your-server.de [78.47.237.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED4F44ED9 for ; Tue, 25 Apr 2023 06:26:25 -0700 (PDT) Received: from sslproxy01.your-server.de ([78.46.139.224]) by www484.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1prIFx-0002In-KE; Tue, 25 Apr 2023 14:58:53 +0200 Received: from [2003:ca:6730:e8f8:2015:edd6:c621:94ed] by sslproxy01.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1prIFx-000AaG-CV; Tue, 25 Apr 2023 14:58:53 +0200 Message-ID: Date: Tue, 25 Apr 2023 14:58:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 From: =?utf-8?q?Konrad_Gr=C3=A4fe?= Subject: [PATCH] usb: gadget: u_ether: Fix host MAC address case To: gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org Content-Language: en-US X-Authenticated-Sender: k.graefe@gateware.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26887/Tue Apr 25 09:23:39 2023) Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org As the CDC-ECM specification states the host MAC address must be sent to the host as an uppercase hexadecimal string: 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. Signed-off-by: Konrad Gräfe --- drivers/usb/gadget/function/u_ether.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git drivers/usb/gadget/function/u_ether.c drivers/usb/gadget/function/u_ether.c index 6956ad8ba8dd..49d29b04ef93 100644 --- drivers/usb/gadget/function/u_ether.c +++ drivers/usb/gadget/function/u_ether.c @@ -958,6 +958,7 @@ EXPORT_SYMBOL_GPL(gether_get_host_addr); int gether_get_host_addr_cdc(struct net_device *net, char *host_addr, int len) { struct eth_dev *dev; + int i, slen; if (len < 13) return -EINVAL; @@ -965,7 +966,14 @@ 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); - return strlen(host_addr); + + slen = strlen(host_addr); + + for(i = 0; i < slen; i++) { + host_addr[i] = toupper(host_addr[i]); + } + + return slen; } EXPORT_SYMBOL_GPL(gether_get_host_addr_cdc);