bdd812cc906c1320dc9ccd8a2e97a0be7b0a199e
[openwrt/openwrt.git] /
1 From 9bfb4bcda7ba32d73ea322ea56a8ebe32e9247f6 Mon Sep 17 00:00:00 2001
2 From: Lech Perczak <lech.perczak@gmail.com>
3 Date: Sat, 2 Apr 2022 02:19:57 +0200
4 Subject: [PATCH 3/3] rndis_host: limit scope of bogus MAC address detection to
5 ZTE devices
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Reporting of bogus MAC addresses and ignoring configuration of new
11 destination address wasn't observed outside of a range of ZTE devices,
12 among which this seems to be the common bug. Align rndis_host driver
13 with implementation found in cdc_ether, which also limits this workaround
14 to ZTE devices.
15
16 Suggested-by: Bjørn Mork <bjorn@mork.no>
17 Cc: Kristian Evensen <kristian.evensen@gmail.com>
18 Cc: Oliver Neukum <oliver@neukum.org>
19 Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
20 ---
21 drivers/net/usb/rndis_host.c | 17 ++++++++++++-----
22 1 file changed, 12 insertions(+), 5 deletions(-)
23
24 --- a/drivers/net/usb/rndis_host.c
25 +++ b/drivers/net/usb/rndis_host.c
26 @@ -419,10 +419,7 @@ generic_rndis_bind(struct usbnet *dev, s
27 goto halt_fail_and_release;
28 }
29
30 - if (bp[0] & 0x02)
31 - eth_hw_addr_random(net);
32 - else
33 - ether_addr_copy(net->dev_addr, bp);
34 + ether_addr_copy(net->dev_addr, bp);
35
36 /* set a nonzero filter to enable data transfers */
37 memset(u.set, 0, sizeof *u.set);
38 @@ -464,6 +461,16 @@ static int rndis_bind(struct usbnet *dev
39 return generic_rndis_bind(dev, intf, FLAG_RNDIS_PHYM_NOT_WIRELESS);
40 }
41
42 +static int zte_rndis_bind(struct usbnet *dev, struct usb_interface *intf)
43 +{
44 + int status = rndis_bind(dev, intf);
45 +
46 + if (!status && (dev->net->dev_addr[0] & 0x02))
47 + eth_hw_addr_random(dev->net);
48 +
49 + return status;
50 +}
51 +
52 void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
53 {
54 struct rndis_halt *halt;
55 @@ -616,7 +623,7 @@ static const struct driver_info zte_rndi
56 .description = "ZTE RNDIS device",
57 .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
58 .data = RNDIS_DRIVER_DATA_DST_MAC_FIXUP,
59 - .bind = rndis_bind,
60 + .bind = zte_rndis_bind,
61 .unbind = rndis_unbind,
62 .status = rndis_status,
63 .rx_fixup = rndis_rx_fixup,