VirtualBox

Opened 10 years ago

Closed 10 years ago

#13116 closed defect (fixed)

unidirectional close across port forwarded TCP connection results in output truncation => Fixed in SVN

Reported by: jonseymour Owned by:
Component: network/NAT Version: VirtualBox 4.3.10
Keywords: Cc:
Guest type: all Host type: Mac OS X

Description

G'day,

I've reproduced a problem that was originally reported by this ticket

https://www.virtualbox.org/ticket/4925

That ticket was closed without being fixed. In that case the host was a Linux host. In my case, the host is an OSX host, but the symptoms are identical.

Namely, if the host connects to the guest via a forwarded port, and then shuts down the write side of the connection, then the the host does not receive all the remaining output from the guest.

The apparent reason for this is that when the shutdown is issued, two TCP ACK packets are generated by the host for output already received. The first of these is never received by the guest. The second one has an incorrect Ack sequence number and so is discarded by the guest. Since the guest never receives the expected ACK, it stops sending all remaining output to the host and so the host observes truncated response.

The problem does not occur if the host connects to the guest via a bridged interface or via the SSH port-forward.

I have implemented a client/server pair that demonstrates the issue. I have reproduced the issue with both Linux and Windows 8.1 guests.

The source for this program is available here: https://github.com/jonseymour/osx-loopback. To compile the source, the go toolset is required. I can supply the compiled executeables upon request.

Change History (9)

comment:1 by jonseymour, 10 years ago

NOTE: This commend contains an assertion that port forwarding with "NAT Network" works better than "NAT". I no longer believe that is the case. I have left the original note as is ---

Digging into this a little bit further, it appears the issue is caused by the implementation of

lwip_shutdown in ./src/VBox/Devices/Network/lwip/src/api/sockets.c

To quote:

int lwip_shutdown(int s, int how)
{
  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how));
  return lwip_close(s); /* XXX temporary hack until proper implementation */
}

In other words, the socket is being closed rather than shutdown.

I noticed ./src/VBox/Devices/Network/lwip/src/api/sockets.c does attempt to implement this call correctly and on a hunch reconfigured my VM to use the experimental NAT service as documented in http://www.virtualbox.org/manual/ch06.html#network_nat_service

Sure enough that worked.

Version 2, edited 10 years ago by jonseymour (previous) (next) (diff)

comment:2 by jonseymour, 10 years ago

I just doubled checked my testing of the "NAT Networks" network type and unfortunately, I think there was a problem with my testing. If anything using "NAT Network" is worse than simply using NAT (e.g. the output is truncated even earlier)

Also, I had a closer look at the VirtualBox code and I came to the conclusion that in the current code base lwip_shutdown() from ./src/VBox/Devices/Network/lwip/src/api/sockets.c is probably not in the active code path.

comment:3 by Valery Ushakov, 10 years ago

Yes, half-close of the inbound half of a tcp connection is broken in NAT.

With "NAT Network" it should work. Your test works for me on linux host.

comment:4 by jonseymour, 10 years ago

Thanks for the issue about the Linux host.

I will try to confirm this myself. Also, I will double check OSX results "NAT Network" again to be sure.

comment:5 by Valery Ushakov, 10 years ago

Tested NAT Network case on OSX host and indeed there is a problem with inbound half-close there.

comment:6 by Valery Ushakov, 10 years ago

This should be fixed in the next dot-dot release.

comment:7 by Frank Mehnert, 10 years ago

Summary: unidirectional close across port forwarded TCP connection results in output truncationunidirectional close across port forwarded TCP connection results in output truncation => Fixed in SVN

comment:8 by Frank Mehnert, 10 years ago

Here is a test build which contains the fix. Feedback welcome!

comment:9 by Frank Mehnert, 10 years ago

Resolution: fixed
Status: newclosed

Fix is part of VBox 4.3.14.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use