morrownr / 8821au-20210708

Linux Driver for USB WiFi Adapters that are based on the RTL8811AU and RTL8821AU Chipsets - v5.12.5.2
Other
740 stars 110 forks source link

Wrong ICMPv6 checksum with passthru MACVLAN attached #109

Open tomty89 opened 1 year ago

tomty89 commented 1 year ago

I have a USB WLAN NIC (a 0411:0242 by Buffalo) that recently I would like to pass to an nspawn container. Since the NIC itself cannot be moved into another netns, I create a passthru mode MACVLAN on top of it for the goal.

Everything seems to work fine with IPv4 (and ARP), but then I notice that IPv6 (LL/ULA only; so nothing to do with the router) does not work for some reason. After some tcpdump -X and some other tests, I notice that the problem is ICMP(v6)-specific and has something to do with the ICMP checksum, and is specific to this WLAN NIC. (Well I mean like, this driver, not limited to this fork though.)

After a quick search on github I found some seemingly related code: https://github.com/morrownr/8821au-20210708/blob/19660ee3f67125d2ef31b626f9fff946bd3e8d01/core/rtw_br_ext.c#L1353-L1358

Then I rebuild the driver with the code above commented, ICMPv6 starts to work.

I have no idea what "NAT25" is, or under what circumstances this actually needs to be called (and hence the checksum needs to be updated): https://github.com/morrownr/8821au-20210708/blob/19660ee3f67125d2ef31b626f9fff946bd3e8d01/core/rtw_br_ext.c#L245 (In the case of passthru MACVLAN, the MAC address of the MACVLAN is at least by default the same as its underlying "link"; and at least in the case of WiFi, AFAIK we cannot really change MAC after SSID aasociation.)

The bottom line is, AFAICT the code won't come up with correct checksum anyway, so it seems to me that it is more or less safe to be commented out? (The worst case would be, AFAICT, the checksum is not updated to a correct value, while this code seems to give a wrong checksum even when the correct value has not changed.)

Certainly it would be wonderful if you know what's exactly wrong in the code and we can just have it fixed instead.

Btw even with MAC changing before association (e.g. per-network MAC randomization done by iwd), things seem to work fine as well with the code commented out.

Also ICMPv6 works fine if the NIC is used without any MACVLAN. Together with the name rtw_br_ext.c, I wonder if this piece of code is some kind of broken hack that allows the NIC to be bridged even when working in station mode?