smoltcp-rs / smoltcp

a smol tcp/ip stack
BSD Zero Clause License
3.8k stars 428 forks source link

support `TP_STATUS_CSUMNOTREADY` #670

Open M1cha opened 2 years ago

M1cha commented 2 years ago

Currently, the dhcp client doesn't work in (some) VMs, in my case a LXD container communicating through a linux bridge. I'm using the raw_socket phy to test this.

The reason for that is that - while the IPv4 checksum is valid - the UDP checksum is not since it's expected to be ignored even though it's non-zero.

To detect this we'd have to use recvmsg instead of read inside RawSocketDesc::recv. Getting this information to where it's needed might be quite invasive though because we need a way to tell udp::Repr::parse to ignore the checksum for some packets.

References: https://github.com/mirror/busybox/blob/e512aeb0fb3c585948ae6517cfdf4a53cf99774d/networking/udhcp/dhcpc.c#L952

Dirbaio commented 1 year ago

Is the value in the checksum field not zero? If it's zero it should be accepted:

https://github.com/smoltcp-rs/smoltcp/blob/1f7e1fadc8487e01254f1849c38f5e02145ad83f/src/wire/udp.rs#L118-L124

If it's garbage instead of zero then I'd say this is a Linux bug...