Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Remove Ip::Address implicit sockaddr_in6 conversion #1823
base: master
Are you sure you want to change the base?
Remove Ip::Address implicit sockaddr_in6 conversion #1823
Changes from 1 commit
ddca48a
fadedfb
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support adding a sockaddr_storage constructor, but why remove this constructor? What is wrong with it (other than the fact that it allows implicit conversions -- a problem that should be fixed by adding "explicit" rather than by removing)?
PR description says "Migration to sockaddr_storage API", but that phrase does not answer my question (and raises more red flags). If that phrase was meant to explain why sockaddr_in6 conversion constructor is removed, please rephrase. Otherwise, please remove that PR description phrase completely, so that we do not have to argue about (and adjust it to clarify) its meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructor (and matching assignment operator) are no longer used after this PR updates the callers to
sockaddr_storage
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... but their code is still there; it is just not wrapped in a Address methods anymore and is now duplicated and hidden. I was going to flag that problem in later review iterations (if still necessary)...
For now, I was hoping that you will agree to restore those methods, preserve Ip::Address API symmetry with respect to IPv4/IPv6, and focus on prohibiting implicit conversions and/or on adding explicit sockaddr_storage conversion support. The last two are good goals that can be accomplished without removing those IPv6-specific methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this particular code will disappear due to another change request, but the idea expressed here applies to (another area in) adjusted code as well.
If possible, please avoid never-nil pointers to local objects and reduce the difference with the current code:
Same for the other similar changes in this PR, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will do once that other discussion is resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do the opposite -- continue to use
sockaddr_in6 ipv6val
definition and then just cast ipv6 to a sockaddr_storage reference at the time of conversion to Ip::Address? Doing so would simplify and clarify this code. Right now, code further below appears to configure one variable (ipv6val) but use another (ss). If we do not have to use sockaddr_storage as ip6val storage while configuring ipv6val, then let's remove that complication.... and adjust Ip::Address construction accordingly.
Same for other similar test cases, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not without adding more technical debt for the future.
sockaddr_storage
is defined as being large enough to store the largestsockaddr_*
type. That includes experimental IPv7+ address types and some edge-cases like interface-scoped IPv6. If we went withsockaddr_in6
we would lock Squid to only supporting "pure" IPv6.I would like to get the API as minimal as possible without locking out capabilities like that. But not to go as far as a C library with
sockaddr *
raw-pointers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see any technical debt. I suspect that my suggestion was misinterpreted.
I now also realize that the second part of my suggestion was wrong -- one must not cast a sockaddr_in6 variable to sockaddr_storage. Only the opposite cast is safe!
I see no relationship between the facts mentioned above and my suggestion (that we should (continue to) use sockaddr_in6 type to create a sockaddr_in6 address for the test case). We obviously want to test with Ip::Address with IPv6 addresses. Let's (continue to) use the corresponding sockaddr_in6 type for that test. There is no reason to outlaw that type; we ought to support it at least until the last sockaddr_in6 expression is gone from Squid primary code.
In this PR, this code should continue to (naturally) configure its IPv6 input using sockaddr_in6.
In a future PR, when we add support for experimental IPv7 addresses, the test code will (naturally) configure its IPv7 input using sockaddr_in7.
We can also add sockaddr_storage tests, of course. They can (and probably should) reuse the bulk of existing sockaddr_in6 and sockaddr_in test code, memcopying configured sockaddr_in... addresses to sockaddr_storage variables.
No API changes or "locking out capabilities" suggested in this change request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am reluctant to do this one. While it matches up with the earlier IPv4 constructor test case, the intention of this case is to verify that the
sockaddr_storage
content is correctly interpreted byIp::Address
when being set via anipv6val
pointer/reference.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rephrase to avoid contaminating this trivial change request with complex changes from another one: