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 DHCP option order not being preserved #76

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

f3rn0s
Copy link

@f3rn0s f3rn0s commented Aug 15, 2024

Fixes #75 by introducing a data-structure that will preserve insertion order.

@leshow
Copy link
Collaborator

leshow commented Aug 15, 2024

Just to be clear, removing the manual insert of End fixes your issue where the encoder did not produce a valid message right? It's just not going to be byte-by-byte the same because the option order will be different?

fyi, the v6 options use an array because it's possible to have multiple options with the same opt code. The items are stored sorted based on the underlying u16 (mostly so they can be accessed with a binary search), it does not preserve insertion order though.

I'm not sure I want to preserve the insertion order unless there's a really good reason. If we're going to break backwards compatibility, I'm leaning towards the btree I think.

@f3rn0s
Copy link
Author

f3rn0s commented Oct 10, 2024

Sorry for the delay on this. I'm unsure why this would break backwards compatibility.

It's giving 100% test passing on my machine, it looked like last time was a serde issue, so hopefully by explicitly enabling the serde feature of IndexMap this won't be a problem.

Also imo I think that a protocol encoding library should be byte-by-byte accurate across executions.

@stappersg
Copy link

stappersg commented Oct 10, 2024 via email

@leshow
Copy link
Collaborator

leshow commented Oct 13, 2024

@f3rn0s the iterator type makes it into the public API in IntoIter, that's the spot I'm concerned about the breaking change

Have either of you seen anything in RFC's which implied an option order?

I lean more towards btreemap because it's in the standard lib, requires no dependencies, and satisfies your concern of producing the same byte-by-byte output.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 11267679355

Details

  • 2 of 3 (66.67%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.1%) to 52.428%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/v4/options.rs 2 3 66.67%
Files with Coverage Reduction New Missed Lines %
src/v6/options.rs 1 54.78%
Totals Coverage Status
Change from base Build 9422513589: -0.1%
Covered Lines: 1598
Relevant Lines: 3048

💛 - Coveralls

@f3rn0s
Copy link
Author

f3rn0s commented Oct 13, 2024

@leshow I opted for IndexMap since that preserves insertion order over just a consistent, but not necessarily visible/modifiable, order.

There was no reference to ordering in RFC 2131 or 2132, but it would be nice to have granular control in case we came across a server or client implementation that has weird requirements.

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.

Encoder produces different results
4 participants