Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful shutdown of virtual client doesn't flush remaing packets to real client #14

Closed
aramperes opened this issue Oct 17, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@aramperes
Copy link
Owner

In some cases, graceful shutdown by the virtual client socket will abort sending data back to the real client, which causes incomplete TCP exchanges with the real client. It only seems to happen on random occasions and with large HTTP requests; but I will need to investigate some more.

@aramperes aramperes added the bug Something isn't working label Oct 17, 2021
@aramperes aramperes changed the title Graceful shutdown of virtual client socket doesn't flush remaing packets to real client Graceful shutdown of virtual client doesn't flush remaing packets to real client Oct 17, 2021
aramperes added a commit that referenced this issue Oct 17, 2021
@aramperes
Copy link
Owner Author

aramperes commented Oct 17, 2021

So this seems to be because I'm running onetun behind ingress-nginx, which keeps a persistent connection to onetun.

After an HTTP request completes:

  • The peer closes the connection (FIN)
  • The virtual client's state changes to ESTABLISHED->CLOSE-WAIT
  • The virtual interface ACKs the FIN

... but the virtual interface and client connection stay alive. On subsequent requests from ingress-nginx, onetun reuses the same virtual interface without reopening the connection and sends the data without doing the handshake. The peer then returns RST.

aramperes added a commit that referenced this issue Oct 17, 2021
@aramperes
Copy link
Owner Author

Handling the CLOSE-WAIT state by closing the connection once the client is done sending data seems like a good fix. The only potential improvement would be to send FIN instead of RST in those cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant