From patchwork Wed Apr 13 01:44:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lech Perczak X-Patchwork-Id: 561430 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 066A9C433F5 for ; Wed, 13 Apr 2022 01:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231574AbiDMBqt (ORCPT ); Tue, 12 Apr 2022 21:46:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbiDMBqs (ORCPT ); Tue, 12 Apr 2022 21:46:48 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854CC527E2; Tue, 12 Apr 2022 18:44:28 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id q189so428172ljb.13; Tue, 12 Apr 2022 18:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zkubLbvnObY1baOgGYmcIpfvZWKIYrnrnDJvJRuO99c=; b=iP93ud5TGE1YXlVZxo16VEX7ef3imfx8ywXN4s6m0f95U7LrxG/0A0UNt34YZfCHd8 BHV3TJtLZSAnmc5YenRY84WjAeieG2j91NufqIzea5D+MFM54xGtLTkfs6s+fX/LBKpY IiYT406K0PmS0Ng4LZOeEGqprFU7akPLK3DPFNOkyz0U72cQyI+V+1zXptcR0U1yLJH1 x6yOjp0aF+WPv3KaZUpw54CdZIBVlq0DnyJshf6vPdeGNB3vjTWd0n7TNtS0z9KyksZY 3L44j9dz3/R5jXHUS4hzCvUcBgbd2e7j8mTTSvkzv+iajqf9IAUkY3JOSkhGEe90Ddz0 9hdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zkubLbvnObY1baOgGYmcIpfvZWKIYrnrnDJvJRuO99c=; b=AeOtzbFibQlY0LWxS9yJgsT5yFZW+jycN8otZkkF/w2BZi6d+GaxFQ6HX82kKeaVox xq7Kf7Z7RiZqiJGAVskutjj8ltKarytOPvBlfnOVxmy6lZt/U4Yq9Gfz2d7rJQXp8ga8 XER48vH34rAO3tognie/hSOO1KA3P6eeLi40rmrnNzHcP4V0SN9QmZ1gfMTcjC8CgIyK 8a57C44YoddnwF3oW3sF6tRGyJL4LNw7kTWPrJQ+KJWk0zWqIyH2C0JkyWvSwgL47OeV cyxPnFdEwbaikYMQoGcAcPJ/D75F10/fGrlm0OlD0Xt7aRfoo3Vh3RlOX9i2lbBhqzwo qW0Q== X-Gm-Message-State: AOAM530c45WyRmdfUPxDEiSzKygz7zGoXc9+UN+z5Ykddu/hKNM+hhRG SAwzbc7TipKKSlIOj8ey7cDLQxsWSO2fsw== X-Google-Smtp-Source: ABdhPJxbeeffhjT+tXkpQ5yF4Z7pt/Sb7K6WC1Lfyw4Z9bU8MJyB5c7IioBvS+24k6w1MnBTQbeMAQ== X-Received: by 2002:a05:651c:a0e:b0:249:90c8:453d with SMTP id k14-20020a05651c0a0e00b0024990c8453dmr24574366ljq.399.1649814266813; Tue, 12 Apr 2022 18:44:26 -0700 (PDT) Received: from rafiki.local ([2001:470:6180::c8d]) by smtp.gmail.com with ESMTPSA id u3-20020a197903000000b00464f4c76ebbsm1915574lfc.94.2022.04.12.18.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 18:44:26 -0700 (PDT) From: Lech Perczak To: netdev@vger.kernel.org, linux-usb@vger.kernel.org Cc: Lech Perczak , Kristian Evensen , =?utf-8?q?Bj=C3=B8rn_Mork?= , Oliver Neukum Subject: [PATCH v3 1/3] cdc_ether: export usbnet_cdc_zte_rx_fixup Date: Wed, 13 Apr 2022 03:44:14 +0200 Message-Id: <20220413014416.2306843-2-lech.perczak@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220413014416.2306843-1-lech.perczak@gmail.com> References: <20220413014416.2306843-1-lech.perczak@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Commit bfe9b9d2df66 ("cdc_ether: Improve ZTE MF823/831/910 handling") introduces a workaround for certain ZTE modems reporting invalid MAC addresses over CDC-ECM. The same issue was present on their RNDIS interface,which was fixed in commit a5a18bdf7453 ("rndis_host: Set valid random MAC on buggy devices"). However, internal modem of ZTE MF286R router, on its RNDIS interface, also exhibits a second issue fixed already in CDC-ECM, of the device not respecting configured random MAC address. In order to share the fixup for this with rndis_host driver, export the workaround function, which will be re-used in the following commit in rndis_host. Cc: Kristian Evensen Cc: Bjørn Mork Cc: Oliver Neukum Signed-off-by: Lech Perczak --- v3: No changes to the patch. v2: - Updated line wrapping in commit description. No changes to patch contents. drivers/net/usb/cdc_ether.c | 3 ++- include/linux/usb/usbnet.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 9b4dfa3001d6..2de09ad5bac0 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c @@ -479,7 +479,7 @@ static int usbnet_cdc_zte_bind(struct usbnet *dev, struct usb_interface *intf) * device MAC address has been updated). Always set MAC address to that of the * device. */ -static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb) +int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb) { if (skb->len < ETH_HLEN || !(skb->data[0] & 0x02)) return 1; @@ -489,6 +489,7 @@ static int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb) return 1; } +EXPORT_SYMBOL_GPL(usbnet_cdc_zte_rx_fixup); /* Ensure correct link state * diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index 8336e86ce606..1b4d72d5e891 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h @@ -214,6 +214,7 @@ extern int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf) extern int usbnet_cdc_bind(struct usbnet *, struct usb_interface *); extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *); extern void usbnet_cdc_status(struct usbnet *, struct urb *); +extern int usbnet_cdc_zte_rx_fixup(struct usbnet *dev, struct sk_buff *skb); /* CDC and RNDIS support the same host-chosen packet filters for IN transfers */ #define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \ From patchwork Wed Apr 13 01:44:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lech Perczak X-Patchwork-Id: 561176 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 B9245C433EF for ; Wed, 13 Apr 2022 01:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231583AbiDMBq4 (ORCPT ); Tue, 12 Apr 2022 21:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbiDMBqt (ORCPT ); Tue, 12 Apr 2022 21:46:49 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7521A52B09; Tue, 12 Apr 2022 18:44:29 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id r2so440840ljd.10; Tue, 12 Apr 2022 18:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FKiSgiOe/KxIh3uBpz2dfDi8hyR0p8dYicu+hw26LIs=; b=nv78b3ofgFI1GtqbVCVRctlJ89T4WdbyGxjYzHhSl4tH/kJftJaRUEXu6/MqA45MsB jDZTWdbQFEQUuwsrmF5gUQ+L5OfBLZ/5vpFpnHN7G6OLkhFjxPUYAFxFEJe5K0BpkpRU D1Fcmhaf2jC6wxc7X+Iy3mIiZCfkRb/hCgbvnC6cypBERFxbVQcEXf+Oc+LQPzGz0ciG h0tZsxJgGIMekAWnbHiIRpWvZbMCZeAfizr9TOIL2ELYIRJRQ/2Zg8DN/9ck/qBOLTKH bdf15I9Mqa2SlmWQG9nXo7u2AtVpsIWWkgzpfnjPCuETZ+uRPujcDaCvPnwZ57h8irun iImA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FKiSgiOe/KxIh3uBpz2dfDi8hyR0p8dYicu+hw26LIs=; b=IRJVvjj+5PI3rju34tS3pX8MRhF2HhSmoYAYAHGedC/iNkdNvOZAw2zKg3mspCLu/l cLSA7nrDRKpkG64wVf7OVXX61mErxnr8LrrTNuDw9cIWUYx7RacxeM+t+kqBKraLmX/8 nmoZ2V+gvRPKoaSv5ofNCsb6zI6YWkbewk1fkoA3Sn/+2BRarPWOvZGg04YMoTGetm+R xfzzr7geOBk3vA6hGs2w/KIjfmz0NiGgcvYMVCW06KwPQYQS2+ZJbG7D2SH+F9YqblkT c4ayKh/zk2aPnSg6uoEIjHxa6NcgLG2lc6JmW3ZnwGslV9tg+4fU5wIH4ZL1/y3EW92J GDNA== X-Gm-Message-State: AOAM5319RlE3jn+YN0pXEetqhJdr2+YLt5IHqNdEjx1+O8Wwguege4/V W0BSOnDOuRiTCM0P7lc61aGbQD+x/FGbJw== X-Google-Smtp-Source: ABdhPJxPL2JqxmBE/m2CW3kfnZTg+BA58YpXuwq/l7+ygPRYP15I4z8zrbAY6y/p3Ha3428FOd/cWQ== X-Received: by 2002:a2e:a90c:0:b0:24a:fe8f:595c with SMTP id j12-20020a2ea90c000000b0024afe8f595cmr25426508ljq.423.1649814267733; Tue, 12 Apr 2022 18:44:27 -0700 (PDT) Received: from rafiki.local ([2001:470:6180::c8d]) by smtp.gmail.com with ESMTPSA id u3-20020a197903000000b00464f4c76ebbsm1915574lfc.94.2022.04.12.18.44.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 18:44:27 -0700 (PDT) From: Lech Perczak To: netdev@vger.kernel.org, linux-usb@vger.kernel.org Cc: Lech Perczak , =?utf-8?q?Bj=C3=B8rn_Mork?= , Kristian Evensen , Oliver Neukum Subject: [PATCH v3 2/3] rndis_host: enable the bogus MAC fixup for ZTE devices from cdc_ether Date: Wed, 13 Apr 2022 03:44:15 +0200 Message-Id: <20220413014416.2306843-3-lech.perczak@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220413014416.2306843-1-lech.perczak@gmail.com> References: <20220413014416.2306843-1-lech.perczak@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Certain ZTE modems, namely: MF823. MF831, MF910, built-in modem from MF286R, expose both CDC-ECM and RNDIS network interfaces. They have a trait of ignoring the locally-administered MAC address configured on the interface both in CDC-ECM and RNDIS part, and this leads to dropping of incoming traffic by the host. However, the workaround was only present in CDC-ECM, and MF286R explicitly requires it in RNDIS mode. Re-use the workaround in rndis_host as well, to fix operation of MF286R module, some versions of which expose only the RNDIS interface. Do so by introducing new flag, RNDIS_DRIVER_DATA_DST_MAC_FIXUP, and testing for it in rndis_rx_fixup. This is required, as RNDIS uses frame batching, and all of the packets inside the batch need the fixup. This might introduce a performance penalty, because test is done for every returned Ethernet frame. Apply the workaround to both "flavors" of RNDIS interfaces, as older ZTE modems, like MF823 found in the wild, report the USB_CLASS_COMM class interfaces, while MF286R reports USB_CLASS_WIRELESS_CONTROLLER. Suggested-by: Bjørn Mork Cc: Kristian Evensen Cc: Oliver Neukum Signed-off-by: Lech Perczak --- v3: - Fixed wrong identifier commit description. - Removed one unneded whitespace change. v2: - Ensured that MAC fixup is applied to all Ethernet frames inside an RNDIS batch. Thanks to Bjørn for finding the issue. - Introduced new driver flag to facilitate the above. drivers/net/usb/rndis_host.c | 32 ++++++++++++++++++++++++++++++++ include/linux/usb/rndis_host.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c index 247f58cb0f84..7a9ece2de2c5 100644 --- a/drivers/net/usb/rndis_host.c +++ b/drivers/net/usb/rndis_host.c @@ -485,10 +485,14 @@ EXPORT_SYMBOL_GPL(rndis_unbind); */ int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb) { + bool dst_mac_fixup; + /* This check is no longer done by usbnet */ if (skb->len < dev->net->hard_header_len) return 0; + dst_mac_fixup = !!(dev->driver_info->data & RNDIS_DRIVER_DATA_DST_MAC_FIXUP); + /* peripheral may have batched packets to us... */ while (likely(skb->len)) { struct rndis_data_hdr *hdr = (void *)skb->data; @@ -523,10 +527,17 @@ int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb) break; skb_pull(skb, msg_len - sizeof *hdr); skb_trim(skb2, data_len); + + if (unlikely(dst_mac_fixup)) + usbnet_cdc_zte_rx_fixup(dev, skb2); + usbnet_skb_return(dev, skb2); } /* caller will usbnet_skb_return the remaining packet */ + if (unlikely(dst_mac_fixup)) + usbnet_cdc_zte_rx_fixup(dev, skb); + return 1; } EXPORT_SYMBOL_GPL(rndis_rx_fixup); @@ -600,6 +611,17 @@ static const struct driver_info rndis_poll_status_info = { .tx_fixup = rndis_tx_fixup, }; +static const struct driver_info zte_rndis_info = { + .description = "ZTE RNDIS device", + .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT, + .data = RNDIS_DRIVER_DATA_DST_MAC_FIXUP, + .bind = rndis_bind, + .unbind = rndis_unbind, + .status = rndis_status, + .rx_fixup = rndis_rx_fixup, + .tx_fixup = rndis_tx_fixup, +}; + /*-------------------------------------------------------------------------*/ static const struct usb_device_id products [] = { @@ -613,6 +635,16 @@ static const struct usb_device_id products [] = { USB_VENDOR_AND_INTERFACE_INFO(0x238b, USB_CLASS_COMM, 2 /* ACM */, 0x0ff), .driver_info = (unsigned long)&rndis_info, +}, { + /* ZTE WWAN modules */ + USB_VENDOR_AND_INTERFACE_INFO(0x19d2, + USB_CLASS_WIRELESS_CONTROLLER, 1, 3), + .driver_info = (unsigned long)&zte_rndis_info, +}, { + /* ZTE WWAN modules, ACM flavour */ + USB_VENDOR_AND_INTERFACE_INFO(0x19d2, + USB_CLASS_COMM, 2 /* ACM */, 0x0ff), + .driver_info = (unsigned long)&zte_rndis_info, }, { /* RNDIS is MSFT's un-official variant of CDC ACM */ USB_INTERFACE_INFO(USB_CLASS_COMM, 2 /* ACM */, 0x0ff), diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h index 809bccd08455..cc42db51bbba 100644 --- a/include/linux/usb/rndis_host.h +++ b/include/linux/usb/rndis_host.h @@ -197,6 +197,7 @@ struct rndis_keepalive_c { /* IN (optionally OUT) */ /* Flags for driver_info::data */ #define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */ +#define RNDIS_DRIVER_DATA_DST_MAC_FIXUP 2 /* device ignores configured MAC address */ extern void rndis_status(struct usbnet *dev, struct urb *urb); extern int From patchwork Wed Apr 13 01:44:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lech Perczak X-Patchwork-Id: 561429 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 86450C4332F for ; Wed, 13 Apr 2022 01:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231576AbiDMBq4 (ORCPT ); Tue, 12 Apr 2022 21:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbiDMBqt (ORCPT ); Tue, 12 Apr 2022 21:46:49 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41CB352E40; Tue, 12 Apr 2022 18:44:30 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id 17so483410lji.1; Tue, 12 Apr 2022 18:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5aNZYeUYDfIbOemrUHc4Mql5VkqNDGGwgnSk/laqkR8=; b=VzgWXGnNjnqKhQd5YAZ8hWVjbUagXCcZb1WhEAaG745M6nxWZybOVC6aWeLeP02rlG xCCXJZ1JOChfI9rlBIFXL9v5dWfFxzFXRi5MqKfcqCEWJvH80zHFcI1XghlYgdBP3c7B l+oqLiDKI1/lkNmoic28HPMyCX/kflxriWsX8p+4zoBUlQYZ7tshDEp9okY0gTw5YwGw MIQ8GNPfzt8kkElYSusRZt4ky67FiOg/3MGhIAeJCoq+of61j1Nz176OOhqYSUtawIgF AyffHQ//1iAjQjEbc9Iq5Amz169n4dMLfJyZLYp3ahYl0URTpMM86Tp/PMIBHQFVJwXl /lWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5aNZYeUYDfIbOemrUHc4Mql5VkqNDGGwgnSk/laqkR8=; b=UTMH6QPqtQqNdLPcI6lw0VD1vUwfWT6u9nh1Iw5gqzHjNFAc2Qys3gy0a1bL9CjiMs BVkjEjMu73l3bXSIIVDL9fX0qlQR8gGlTgljDKNSu/NtCPDywwykPTt5IDYkq+rcw6Mz ADrPu8MPjII4Gce4x5fHu51IgX8lMpoMarEVoW+ntU5/MV+U3CkdMC7Yk8R8sLGuKqR3 9FWVXhWJayzli2dvbGB5wiQlA9N969XqmlBaIonvz2Ly+Az4xdd/zQ1bmbSwQ409XJFf Hd8eQO+WRps92sAHe5S2LfBLvpagF+2yMQDN1/97Xr3A+Yf45sA77yVKSfUMAuZLZ2Zm eGHw== X-Gm-Message-State: AOAM53017K5DfuKOE4zVrxtfNyfZ7gcLdWRt+TtO4ffCJBw3IdHW/ODF tXH7nSkvG7o4uYhGbQtf0y46ukK6nSC2CA== X-Google-Smtp-Source: ABdhPJzJNa1HQ6lfobavQaQ7VNNQ10OKCHmmnj1nm2HBxzA3IeI1Be5V/coATxAvyiNSQUQ4CX+bNQ== X-Received: by 2002:a2e:934d:0:b0:24b:41cf:fb50 with SMTP id m13-20020a2e934d000000b0024b41cffb50mr19008281ljh.336.1649814268559; Tue, 12 Apr 2022 18:44:28 -0700 (PDT) Received: from rafiki.local ([2001:470:6180::c8d]) by smtp.gmail.com with ESMTPSA id u3-20020a197903000000b00464f4c76ebbsm1915574lfc.94.2022.04.12.18.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 18:44:28 -0700 (PDT) From: Lech Perczak To: netdev@vger.kernel.org, linux-usb@vger.kernel.org Cc: Lech Perczak , =?utf-8?q?Bj=C3=B8rn_Mork?= , Kristian Evensen , Oliver Neukum Subject: [PATCH v3 3/3] rndis_host: limit scope of bogus MAC address detection to ZTE devices Date: Wed, 13 Apr 2022 03:44:16 +0200 Message-Id: <20220413014416.2306843-4-lech.perczak@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220413014416.2306843-1-lech.perczak@gmail.com> References: <20220413014416.2306843-1-lech.perczak@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Reporting of bogus MAC addresses and ignoring configuration of new destination address wasn't observed outside of a range of ZTE devices, among which this seems to be the common bug. Align rndis_host driver with implementation found in cdc_ether, which also limits this workaround to ZTE devices. Suggested-by: Bjørn Mork Cc: Kristian Evensen Cc: Oliver Neukum Signed-off-by: Lech Perczak --- v3: No changes to the patch. v2: - No logical changes, just rebased on top of previous patches. drivers/net/usb/rndis_host.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/usb/rndis_host.c b/drivers/net/usb/rndis_host.c index 7a9ece2de2c5..4e70dec30e5a 100644 --- a/drivers/net/usb/rndis_host.c +++ b/drivers/net/usb/rndis_host.c @@ -418,10 +418,7 @@ generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags) goto halt_fail_and_release; } - if (bp[0] & 0x02) - eth_hw_addr_random(net); - else - eth_hw_addr_set(net, bp); + eth_hw_addr_set(net, bp); /* set a nonzero filter to enable data transfers */ memset(u.set, 0, sizeof *u.set); @@ -463,6 +460,16 @@ static int rndis_bind(struct usbnet *dev, struct usb_interface *intf) return generic_rndis_bind(dev, intf, FLAG_RNDIS_PHYM_NOT_WIRELESS); } +static int zte_rndis_bind(struct usbnet *dev, struct usb_interface *intf) +{ + int status = rndis_bind(dev, intf); + + if (!status && (dev->net->dev_addr[0] & 0x02)) + eth_hw_addr_random(dev->net); + + return status; +} + void rndis_unbind(struct usbnet *dev, struct usb_interface *intf) { struct rndis_halt *halt; @@ -615,7 +622,7 @@ static const struct driver_info zte_rndis_info = { .description = "ZTE RNDIS device", .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT, .data = RNDIS_DRIVER_DATA_DST_MAC_FIXUP, - .bind = rndis_bind, + .bind = zte_rndis_bind, .unbind = rndis_unbind, .status = rndis_status, .rx_fixup = rndis_rx_fixup,