Skip to content

Commit 70ac15b

Browse files
committed
fix: Never panic in RelayTransport::poll_recv
1 parent dd65c89 commit 70ac15b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

iroh/src/magicsock/transports/relay.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@ impl RelayTransport {
100100
}
101101
};
102102

103+
if buf_out.len() < dm.datagrams.contents.len() {
104+
// Our receive buffer isn't big enough to process this datagram.
105+
// Continuing would cause a panic.
106+
break;
107+
// In theory we could put some logic in here to fragment the datagram in case
108+
// we still have enough room in our `buf_out` left to fit a couple of
109+
// `dm.datagrams.segment_size`es, but we *should* have cut those datagrams
110+
// to appropriate sizes earlier in the pipeline (just before we put them
111+
// into the `relay_datagram_recv_queue` in the `ActiveRelayActor`).
112+
// So the only case in which this happens is we receive a datagram via the relay
113+
// that's essentially bigger than our configured `max_udp_payload_size`.
114+
// In that case we drop it and let MTU discovery take over.
115+
}
103116
buf_out[..dm.datagrams.contents.len()].copy_from_slice(&dm.datagrams.contents);
104117
meta_out.len = dm.datagrams.contents.len();
105118
meta_out.stride = dm

0 commit comments

Comments
 (0)