fix(proto): discard stale abandoned path packets#732
Conversation
5ce8936 to
e50c455
Compare
|
Thank you for the PR. Can you say a little more about what motivated you to fix this? Were you hitting this bug in practice? If so, what was your setup like? Knowing these things might help us understand how to test noq better. |
|
IIUC there is a compounding issue that Instead it should send a stateless reset to the peer upon receiving this packet, which would kill the peer. This is why the above question of how this occurred is really important: because firstly this shouldn't normally happen and secondly it would kill the connection on the remote side. However even if we did do that, because revoking the CIDs at the endpoint is also an asynchronous event this bug could still be triggered. So this fix is still needed. |
flub
left a comment
There was a problem hiding this comment.
Could you please provide trace-level logs of this happening? Because there are a few things here that are impossible: a path needs to be discarded while a coalesced packet is being received. But coalescing only happens during the handshake, when there is only one path in existence and when multipath is not yet possible so paths can not be abandoned.
I do believe that a rogue packet could possibly be received still after the path state is discarded. But really we need to know why that happened and the best thing to do is look at trace logs for this.
Thanks!
|
Hi @flub , Thanks for looking into this - I saw the following panic on one of my servers running https://github.com/losfair/iroh-http-gateway. Only happened once so far - unfortunately log level was unset, so no trace-level logs: |
|
@losfair can you reproduce this? because like this there isn't enough information, so please configure logging and run with RUST_LOG=trace and than we should be able to get more details about what triggered this as it will show the exact packets that were being sent and received. |
e50c455 to
0f48d41
Compare
|
@flub I added a test that reproduces the issue properly and fixed the patch. Running with trace level logs for ~10 hrs and haven't seen a reproduction yet though... |
handle_coalesced against a discarded path|
So somehow the first datagram from the server is duplicated on the network and is then received again after the connection has closed PathId::ZERO? That does seem like something that could occur. But I still really want to understand why this happens. Can you share logs of a server and client where this happens (before the fix)? I have some hunches but I need logs to check this. Duplicated packets are probably created by the server-side. But normally it would deduplicate them. I am guessing that the initial EndpointAddr contains both a RelayUrl and an IP that functions, how big is the latency difference? I assume that the IP connection wins and that for some reason the connection that very quickly migrates to a different IP address, closing PathId::ZERO, again, why? And possibly this happens faster than the relay connection has delivered the first datagram from the client to the relay. At which point the relay connection may see this as a genuinely new connection attempt. But I'm just guessing. Please give us some evidence. Please fix clippy as well, pref tests won't work so that's fine. |
Still waiting for this to happen again so that I have trace level logs...
I'm connecting with endpoint id only - so I guess it has to rely on relay initially before direct path discovery works? I have some custom routing setup on the client machine - something like: So client <-> server are reachable via three different paths:
|
divagant-martian
left a comment
There was a problem hiding this comment.
handle_packet is part of noq-protos public api, so the fix is needed nonetheless imo, and the test does prove the issue. I defer to @matheus23 and @flub if they have further requirements.
They might ask you to name the test regression_ tho
a comment that this used to panic inside the test would help too
flub
left a comment
There was a problem hiding this comment.
I think fix and test are good. Am still puzzled how this was triggered though.
Time to finally share my spicy take on this: distinguishing regression tests from other tests is... fun but not helpful in any way. |
Description
Fixes a panic when a stale coalesced datagram is delivered for a path after that path’s state has already been discarded. The packet receive path now early-discards packets whose
path_idis no longer inpathsbut is known inabandoned_paths, before coalesced packet handling can assume the path still exists.Change checklist