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

SourceNatConfig could store infallible block numbers instead of fallible port pairs #5571

Open
jgallagher opened this issue Apr 19, 2024 · 3 comments
Milestone

Comments

@jgallagher
Copy link
Contributor

So.... I'm wondering if rather than first_port and last_port this can just take the multiple of NUM_SOURCE_NAT_PORTS. Since NUM_SOURCE_NAT_PORTS is 2^14 and the number of ports is 2^16, there are only 4 possible values. So this could actually take an enum, say, SourceNatPortBlock { Block0, Block1, Block2, Block3 }. That would make this constructor infallible.

Then you can serialize the data in that fashion as well, and deserialization won't require further validation.

Some places may have a port pair, and you can have a constructor that converts that into a SourceNatPortBlock, returning the below error. But places that don't have the raw ports won't have to deal with errors.

Not sure how much it increases work for you, maybe in a followup/after r8 if it disrupts this work too much?

Originally posted by @sunshowers in #5560 (comment)

@jgallagher jgallagher added this to the Unscheduled milestone Apr 19, 2024
@sunshowers
Copy link
Contributor

Something to consider is whether the fact that source NAT can only be in one of 4 port blocks will ever change in the future.

@bnaecker
Copy link
Collaborator

bnaecker commented Apr 20, 2024 via email

@sunshowers
Copy link
Contributor

Thanks @bnaecker! I think that should be okay, and honestly easier to do with an enum.

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

No branches or pull requests

3 participants