[Query] Netstack close is not closing all the registered endpoints #237
Unanswered
AmitKatyal-Sophos
asked this question in
Q&A
Replies: 1 comment 7 replies
-
Did you create a netstack for each websocket? |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We are using gvisor netstack with below configuration
User -----> NetStack --------> proxy
Problem statement
If user abruptly closes the connection, then all the TCP connections/endpoints relayed over the connection are not getting closed.
Root cause analysis
Please find below the analysis:
Reader go routine is blocked on the Read() from the endpoint. As there is no data to read, Read go routine is registering for the waiter.ReadableEvents. Please find below the code snippet.
https://github.com/google/gvisor/blob/b250ee717d8797a27ca31cc4ad43e10ba59d88f1/pkg/tcpip/adapters/gonet/gonet.go#L302-L329
NetStack close performs the below actions,
Close internally calls endpoint abort but abort endpoint just sends the RST to the client, and marks the endpoint state to error, but doesn't notify the reader go routine to come out of the blocking read. Since reader go routine is not notified, reader go routing is stuck and keep on waiting for the read ready event. As a result, TCP connections/endpoints are not getting terminated. Please find below the code snippets of netstack close handling.
Netstack close
https://github.com/google/gvisor/blob/b250ee717d8797a27ca31cc4ad43e10ba59d88f1/pkg/tcpip/stack/stack.go#L1725-L1735
Endpoint Abort
As the state is connected, abort will send the RST and return
https://github.com/google/gvisor/blob/b250ee717d8797a27ca31cc4ad43e10ba59d88f1/pkg/tcpip/transport/tcp/endpoint.go#L1006-L1018
IMO nestack close should have wake up the endpoint reader go routine so that connection gets termintated. Is this a known issue or am I missing something here ?
Beta Was this translation helpful? Give feedback.
All reactions