Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(proto): fix internal representation of OPT #2151

Merged
merged 6 commits into from Feb 29, 2024

Conversation

esensar
Copy link
Contributor

@esensar esensar commented Feb 22, 2024

Current implementation of OPT represents options as hash map, which prevents same EdnsCode from appearing more than once. There are options that may appear more than once
(e.g. EDE https://www.rfc-editor.org/rfc/rfc8914.html).

Unfortunately, this is a breaking change. I haven't figured out a solution that would not break the API and would not introduce some kind of overhead.

BREAKING CHANGE: Changes representation of OPT from HashMap to a Vec, which means that as_ref and as_mut also now return &Vec rather than &HashMap.

Current implementation of OPT represents options as hash map, which
prevents same `EdnsCode` from appearing more than once. There are
options that may appear more than once
(e.g. EDE https://www.rfc-editor.org/rfc/rfc8914.html).

Unfortunately, this is a breaking change. I haven't figured out a
solution that would not break the API and would not introduce some kind
of overhead.

BREAKING CHANGE: Changes representation of OPT from `HashMap` to a
`Vec`, which means that `as_ref` and `as_mut` also now return `&Vec`
rather than `&HashMap`.
Copy link
Collaborator

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me -- I don't think breaking the API is a big deal. Thanks!

Maybe you should add a comment explicitly talking about the constraint of some EdnsCodes being allowed to appear more than once?

crates/proto/src/rr/rdata/opt.rs Outdated Show resolved Hide resolved
crates/proto/src/rr/rdata/opt.rs Outdated Show resolved Hide resolved
@esensar
Copy link
Contributor Author

esensar commented Feb 22, 2024

This seems reasonable to me -- I don't think breaking the API is a big deal. Thanks!

Maybe you should add a comment explicitly talking about the constraint of some EdnsCodes being allowed to appear more than once?

That makes sense. I have added the comment as well as a utility for reading all options for a specific code.

Copy link
Collaborator

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, would be good to get a review from @bluejekyll.

Copy link
Member

@bluejekyll bluejekyll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@bluejekyll bluejekyll merged commit 0a2ee2c into hickory-dns:main Feb 29, 2024
18 checks passed
@esensar esensar deleted the fix/opt_options_repr branch February 29, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants