-
Notifications
You must be signed in to change notification settings - Fork 367
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
Enable nosprintfhostport linter #5223
base: main
Are you sure you want to change the base?
Conversation
pkg/apis/k0s/v1beta1/network.go
Outdated
address := ipnet.IP.To4() | ||
if IsIPv6String(ipnet.IP.String()) { | ||
if address == nil { | ||
address = ipnet.IP.To16() | ||
} |
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 wonder if this could just become
address := ipnet.IP.To4() | |
if IsIPv6String(ipnet.IP.String()) { | |
if address == nil { | |
address = ipnet.IP.To16() | |
} | |
address := ipnet.IP |
? Not sure if would make any difference if a v4 address might be passed on in its 16 byte representation.
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.
It should not make any difference at all. We return a string.
I support this change.
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.
After a second look, I realized that the code actually relies on the 4 byte representation a few lines below, and produces a nonsense DNS address when ServiceCIDR describes a v6 network: E.g. given the CIDR fd00:abcd:1234::/64
, the calculated address will be fd00:abcf:1234::
, which is outside of the network to begin with. The ipnet.Contains
check doesn't work as expected since address
and ipnet.IP
point to the same slice, i.e. the modifications to address
will also affect ipnet
.
That said, n.ServiceCIDR
shouldn't be a v6 network in the first place, that's what n.DualStack.IPv6ServiceCIDR
is for. This is all a bit weird: the IsIPv6String
check has been added in #1292, to support "IPv6 only". Are we actually supporting this? If yes, then this function is definitely broken.
What do we want to do?
- Error out if ServiceCIDR is a v6 network?
- Fix the "IPv6 only" mode by calculating a meaningful v6 DNS address?
In any case, the ipnet.Contains
check needs fixing, i.e. we need to properly copy address
by value.
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.
Proposed fix:
This pull request has merge conflicts that need to be resolved. |
ee1c1cc
to
71f6f8a
Compare
This pull request has merge conflicts that need to be resolved. |
71f6f8a
to
75aae36
Compare
This pull request has merge conflicts that need to be resolved. |
75aae36
to
09cf3a2
Compare
This pull request has merge conflicts that need to be resolved. |
09cf3a2
to
43b162e
Compare
This pull request has merge conflicts that need to be resolved. |
43b162e
to
25180fb
Compare
This pull request has merge conflicts that need to be resolved. |
25180fb
to
d95f462
Compare
This pull request has merge conflicts that need to be resolved. |
... and fix lints on the way. Inline the IsIPV6String function, as it had only one use left, which was inlined as a one-liner. Signed-off-by: Tom Wieczorek <[email protected]>
d95f462
to
b25b56b
Compare
Description
... and fix lints on the way.
Inline the IsIPV6String function, as it had only one use left, which was inlined as a one-liner.
Type of change
How Has This Been Tested?
Checklist: