dtls: defer oversized poll outputs#138
Conversation
algesten
left a comment
There was a problem hiding this comment.
I'm not saying we shouldn't land this, but I also wonder if it unnecessarily complicates the protocol.
Since it's UDP we are going to be hard limited by MTU, and it would be a strange setup to set MTU to one value and then hope to use a smaller output buffer only to run into this error straight away in the handshake (since a certificate is almost always split over multiple packets).
Are there reasonable scenarios where the output buffer is smaller than MTU?
|
@algesten yeah, this is trying to address a panic, but I agree it’s basically misuse/user error. My preference would be a type-protection pattern instead: make That is another API break though. I can rework this PR that way for inspection, or open a separate one. |
|
As a personal preference, I don't particularly mind panics for broken invariants. Setting one MTU and using a smaller sized buffer, is a user error - not even a runtime error. We could even go the other way and make an explicit Of course making errors impossible through type system is even better, but I don't find the gain so big here that I think it warrants the "type noise" in signatures. |
poll_outputcurrently assumes the caller-provided buffer is large enough forqueued packets, queued application data, and peer-certificate events. If the
buffer is too small, those paths can panic instead of letting the caller grow
the buffer and retry.
This makes oversized output return
Output::BufferTooSmall { needed }withoutdropping the pending item. A later call with a large enough buffer emits the
same packet/event/data.
Line delta:
Validation:
cargo fmt --checkgit diff --checkgit diff --check upstream/main...HEAD/home/ronen/.codex/skills/dimpl/scripts/check-snowflake-local.pl upstream/maincargo test --all-targets --features rcgencargo clippy --all-targets --features rcgen -- -D warningscargo test --no-default-features --features rust-cryptocargo clippy --no-default-features --features rust-crypto -- -D warningscargo test --doc --features rcgen