netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lech Perczak <lech.perczak@gmail.com>
To: netdev@vger.kernel.org, linux-usb@vger.kernel.org
Cc: "Lech Perczak" <lech.perczak@gmail.com>,
	"Bjørn Mork" <bjorn@mork.no>,
	"Kristian Evensen" <kristian.evensen@gmail.com>,
	"Oliver Neukum" <oliver@neukum.org>
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	[thread overview]
Message-ID: <20220413014416.2306843-4-lech.perczak@gmail.com> (raw)
In-Reply-To: <20220413014416.2306843-1-lech.perczak@gmail.com>

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 <bjorn@mork.no>
Cc: Kristian Evensen <kristian.evensen@gmail.com>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
---

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,
-- 
2.30.2


  parent reply	other threads:[~2022-04-13  1:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13  1:44 [PATCH v3 0/3] rndis_host: handle bogus MAC addresses in ZTE RNDIS devices Lech Perczak
2022-04-13  1:44 ` [PATCH v3 1/3] cdc_ether: export usbnet_cdc_zte_rx_fixup Lech Perczak
2022-04-13  1:44 ` [PATCH v3 2/3] rndis_host: enable the bogus MAC fixup for ZTE devices from cdc_ether Lech Perczak
2022-04-13  1:44 ` Lech Perczak [this message]
2022-04-14 13:30 ` [PATCH v3 0/3] rndis_host: handle bogus MAC addresses in ZTE RNDIS devices patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220413014416.2306843-4-lech.perczak@gmail.com \
    --to=lech.perczak@gmail.com \
    --cc=bjorn@mork.no \
    --cc=kristian.evensen@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oliver@neukum.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).