Re: [PATCH net-next v3] cdc_ether: Improve ZTE MF823/831/910 handling
From: Oliver Neukum
Date: Wed Jul 20 2016 - 03:58:06 EST
On Tue, 2016-07-19 at 16:54 +0200, Kristian Evensen wrote:
> The firmware in several ZTE devices (at least the MF823/831/910
> modems/mifis) use OS fingerprinting to determine which type of device
> export. In addition, these devices export a REST API which can be used
> control the type of device. So far, on Linux, the devices have been
> seen as
> RNDIS or CDC Ether.
> When CDC Ether is used, devices of the same type are, as with RNDIS,
> exported with the same, bogus random MAC address. In addition, the
> (at least on all firmware revisions I have found) use the bogus MAC
> sending traffic routed from external networks. And as a final feature,
> devices sometimes export the link state incorrectly. There are also
> references online to several other ZTE devices displaying this
> with several different PIDs and MAC addresses.
> This patch tries to improve the handling of ZTE devices by doing the
> * Create a new driver_info-struct that is used by ZTE devices that do
> have an explicit entry in the product table. This struct is the same
> as the
> default cdc_ether driver info, but a new bind- and an
> have been added.
> * In the new bind function, we check if we have read a random MAC from
> device. If we have, then we generate a new random MAC address. This
> ensure that all devices get a unique MAC.
> * The rx_fixup-function replaces the destination MAC address in the
> with that of the device. I have not seen a revision of these devices
> behaves correctly (i.e., sets the right destination MAC), so I chose
> not to
> do any comparison with for example the known, bogus addresses.
> * The MF823/MF832/MF910 sometimes export cdc carrier on twice on
> (the correct behavior is off then on). Work around this by manually
> carrier to off if an on-notification is received and the NOCARRIER-bit
> not set.
> This change will affect all devices, but it should take care of
> mistakes made by other manufacturers. I tried to think of/look/test
> problems/regressions that could be introduced by this behavior, but
> not find any. However, my familiarity with this code path is not that
> great, so there could be something I have overlooked.
> I have tested this patch with multiple revisions of all three devices,
> they behave as expected. In other words, they all got a valid, random
> the correct operational state and I can receive/sent traffic without
> problems. I also tested with some other cdc_ether devices I have and
> not find any problems/regressions caused by the two general changes.
> * I had forgot to remove the random MAC generation from
> (thanks Olive).
> * Rework logic in the ZTE bind-function a bit.
> * Only generate random MAC for ZTE devices (thanks Oliver Neukum).
> * Set random MAC and do RX fixup for all ZTE devices that do not have
> product-entry, as the bogus MAC have been seen on devices with several
> different PIDs/MAC addresses. In other words, it seems to be the
> behavior of ZTE CDC Ether devices (thanks Lars Melin).
> Signed-off-by: Kristian Evensen <kristian.evensen@xxxxxxxxx>
Acked-by: Oliver Neukum <oneukum@xxxxxxxx>