882-v5.19-rndis_host-limit-scope-of-bogus-MAC-address-detectio.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 1bfbe1799b9ec5d00f7f032d6e7db1980e466aeb Mon Sep 17 00:00:00 2001
  2. From: Lech Perczak <[email protected]>
  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. Reporting of bogus MAC addresses and ignoring configuration of new
  10. destination address wasn't observed outside of a range of ZTE devices,
  11. among which this seems to be the common bug. Align rndis_host driver
  12. with implementation found in cdc_ether, which also limits this workaround
  13. to ZTE devices.
  14. Suggested-by: Bjørn Mork <[email protected]>
  15. Cc: Kristian Evensen <[email protected]>
  16. Cc: Oliver Neukum <[email protected]>
  17. Signed-off-by: Lech Perczak <[email protected]>
  18. ---
  19. drivers/net/usb/rndis_host.c | 17 ++++++++++++-----
  20. 1 file changed, 12 insertions(+), 5 deletions(-)
  21. --- a/drivers/net/usb/rndis_host.c
  22. +++ b/drivers/net/usb/rndis_host.c
  23. @@ -419,10 +419,7 @@ generic_rndis_bind(struct usbnet *dev, s
  24. goto halt_fail_and_release;
  25. }
  26. - if (bp[0] & 0x02)
  27. - eth_hw_addr_random(net);
  28. - else
  29. - ether_addr_copy(net->dev_addr, bp);
  30. + ether_addr_copy(net->dev_addr, bp);
  31. /* set a nonzero filter to enable data transfers */
  32. memset(u.set, 0, sizeof *u.set);
  33. @@ -464,6 +461,16 @@ static int rndis_bind(struct usbnet *dev
  34. return generic_rndis_bind(dev, intf, FLAG_RNDIS_PHYM_NOT_WIRELESS);
  35. }
  36. +static int zte_rndis_bind(struct usbnet *dev, struct usb_interface *intf)
  37. +{
  38. + int status = rndis_bind(dev, intf);
  39. +
  40. + if (!status && (dev->net->dev_addr[0] & 0x02))
  41. + eth_hw_addr_random(dev->net);
  42. +
  43. + return status;
  44. +}
  45. +
  46. void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
  47. {
  48. struct rndis_halt *halt;
  49. @@ -616,7 +623,7 @@ static const struct driver_info zte_rndi
  50. .description = "ZTE RNDIS device",
  51. .flags = FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
  52. .data = RNDIS_DRIVER_DATA_DST_MAC_FIXUP,
  53. - .bind = rndis_bind,
  54. + .bind = zte_rndis_bind,
  55. .unbind = rndis_unbind,
  56. .status = rndis_status,
  57. .rx_fixup = rndis_rx_fixup,