TCP: Un-parent child sockets once they've been accepted#3643
TCP: Un-parent child sockets once they've been accepted#3643sporksmith merged 5 commits intoshadow:mainfrom
Conversation
|
I think we might lose data if the client sends data and then closes the connection before the server accepts the connection. This may or may not be the case before this PR. TODO: figure out whether this happens and whether it happened before; fix it or file/update an issue. |
Hmm, maybe this is why the tgen tests are failing |
f00d1ef to
b40c26e
Compare
Added a test for this. It's handled correctly before and after.
It was something else - destroying the TCP server state while while references to the child sockets can still exist elsewhere and try to access it. Fixed. |
b40c26e to
c3a5f24
Compare
robgjansen
left a comment
There was a problem hiding this comment.
This looks reasonable to me other than my question about port numbers, but I think we might want @stevenengler to take a look too because of the importance of TCP correctness for us.
stevenengler
left a comment
There was a problem hiding this comment.
LGTM! I just have a few optional comments.
I can't comment on the ->child->parent refcounting stuff, but as long as the tests pass without shadow segfaulting then it's good with me :)
On failure this lets us see which part failed.
Regression test for shadow#3563. Currently doesn't pass under shadow.
Once a child socket has been `accept`ed (associated with a file descriptor and moved off of the listening socket's queue), we now remove the parent-child relationship and associate the local:remote address pair directly with the corresponding network interface, instead of continuing to route packets to the listening socket and having the listening socket route them to the child. This allows a listening socket to be completely cleaned up when it's closed instead of keeping it around to route packets to the child sockets, which allows us to disassociate and subsequently reuse the listening address. Fixes shadow#3563
53d9542 to
b11d9c4
Compare
Once a child socket has been
accepted (associated with a file descriptor and moved off of the listening socket's queue), we now remove the parent-child relationship and associate the local:remote address pair directly with the corresponding network interface, instead of continuing to route packets to the listening socket and having the listening socket route them to the child.This allows a listening socket to be unbound and cleaned up when it's closed instead of keeping it around to route packets to the child sockets, which allows us to reuse the address it had been bound to.
Fixes #3563.
I noticed and filed #3644 while working on this but verified that it was present before this PR as well.