Description
If there's a TCP socket open, and then the smoltcp changes IP address (due to eg being plugged into a different Ethernet network), the socket stays established and still transmits packets with the old source IP address.
No matter what, a host should never transmit packets with a source IP that's not its own :)
In the packet capture below you can see the DHCP server gives the address 10.42.0.59
to the smoltcp host, but it continues transmitting packets for the old 192.168.1.37
address. Eventually the socket times out and the application establishes a new one, which then gets the right source IP and communication returns.
I think the same bug can be triggered by explicitly calling tcp_socket.connect
with a wrong source address. Maybe with UDP and other sockets too.
Not sure what the best solution is.
- Simply check in
Interface
that we have the source address, and fail emitting if not? The socket would still have to timeout, but at least we don't emit garbage into the network. - Check in TcpSocket that emitting failed due to wrong source addr and change to Closed? Seems better because it allows the application to immediately notice and reconnect, but i'm not sure if there are any disadvantages.
This is somewhat related with #458