openvswitch / ovs-issues

Issue tracker repo for Open vSwitch
10 stars 3 forks source link

[Windows] Incorrect checksum of reply packets after OVS unDNAT #265

Closed hongliangl closed 1 year ago

hongliangl commented 1 year ago

When a remote client accesses a Windows container whose interface is attached to a Windows OVS, the reply packets of Windows container is not patched by Windows OVS correctly. For example:

For the client, it doesn't access the Windows container IP directly. The processing is like the following:

For the 6th captured packet, before entering OVS, we can see the TCP checksum value is bf30, and it is the pseudo header checksum, not the checksum of TCP pseudo header, TCP header and TCP palyload. Note that, it is legal for Windows container to send packets with such TCP checksum.

image-20221010193000352

After the packet is unDNATed by OVS, we can see that the source IP and source TCP port has been changed by OVS DNAT, as a result, the TCP checksum should be also updated. Note that, since there is no offload in OVS as well as in client, the checksum should be calculated from the data of TCP pseudo header, TCP header and TCP palyload after unDNAT. For the same 6th captured packet, we can see the TCP checksum is incorrect. The packet with the incorrect TCP checksum will be dropped by client, and we can see there are TCP Retransmission packets.

image-20221010192931121

The TCP connection has the chance to work since after one or more times TCP Retransmission, there is a chance for Windows container to send a packet with correct TCP checksum value (calculated from TCP pseudo header, TCP header and TCP palyload), then OVS can also get the correct TCP checksum value after unDNAT, and the connection succeeds. However, there is also a chance for Windows container to always send packets with incorrect TCP checksum value (TCP pseudo header checksum), then the connection fails.

Here is the captured packets file showed in above pictures. caps.tar.gz