-
Notifications
You must be signed in to change notification settings - Fork 34
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 duplicate check with different mac format #397
Fix duplicate check with different mac format #397
Conversation
Hi @fossedihelm. Thanks for your PR. I'm waiting for a k8snetworkplumbingwg member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@RamLavi Can you have a look please? Thanks |
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 PR is required but IMO it doesn't do enough since there are other supported types of format for MAC addresses:
- canonical (
-
separator, which your PR adds support for) - hexstring (
:
separator, the only thing currently accepted by kubemacpool) - dot notation (
.
separator, in 4 char segments - e.g.0000.5e00.5301
) - hexadecimal
Maybe the correct thing to do is to create a MAC address - net.HardwareAddr
- using net.ParseMAC
and then get the string from it (whatever that is) ?
@maiqueb: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@maiqueb That's a great idea! IMHO we can also skip the |
Fine with me. I mean, there's nothing wrong in being redundant - checking against nil won't take long - but if you're sure that was already validated, all good. I just find it more readable / comforting to see the (ugly) golang pattern of |
aaa41c8
to
c4f5bff
Compare
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.
Looks good !
@maiqueb: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Yes, I generally agree! In this specific case, handling the error means to create something like this:
This is not a problem at all, but this will not allow us to create inline entry in the macMap. |
Maybe it's best to add a comment to the This is just a nit. Consider adding it if someone else asks you to change the code. |
I put this just before the ParseMAC func:
but yes, I can insert the description above the func! Thanks, will do! |
c4f5bff
to
2479b07
Compare
@maiqueb PTAL |
@maiqueb: changing LGTM is restricted to collaborators In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
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.
Hey @fossedihelm, thanks for your contribution!
Please see comments added.
Also, note the e2e test failing is concerning - and suggests that we missed something.. If you need help ping me
macPoolMap provides a save remove entry function that could always be preferred respect the directly `delete` function. Signed-off-by: fossedihelm <ffossemo@redhat.com>
/hold let's merge only after stable branches are introduced to KMP |
Thanks @RamLavi for the review! |
2479b07
to
447fd66
Compare
|
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.
thanks for the changes!
Big like for the Marshal function added.
Added one more comment.
447fd66
to
193b9a1
Compare
Thanks @RamLavi for the great suggestion! I addressed the commets. PTAL |
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.
last one :)
As per https://pkg.go.dev/net#ParseMAC, a macAddress can be specified as an IEEE 802 MAC-48, EUI-48, EUI-64, or a 20-octet IP using the following formats: - 00:00:5e:00:53:01 - 02:00:5e:10:00:00:00:01 - 00:00:00:00:fe:80:00:00:00:00:00:00:02:00:5e:10:00:00:00:01 - 00-00-5e-00-53-01 - 02-00-5e-10-00-00-00-01 - 00-00-00-00-fe-80-00-00-00-00-00-00-02-00-5e-10-00-00-00-01 - 0000.5e00.5301 - 0200.5e10.0000.0001 - 0000.0000.fe80.0000.0000.0000.0200.5e10.0000.0001 Currently, the duplicate mac check works only if the two compared mac address use the same separator. The duplicate check is made looking at the existence of key of the macMap. The keys of the mapMap are the macAddress string. With this commit, a `macKey` struct is introduced. The latter stores the normalized string of the macAddress and can be used as unique key and identifier of a macAddress. NB: Currently KubeVirt does not allow EUI-64 and 20-octet IP mac addresses. Signed-off-by: fossedihelm <ffossemo@redhat.com>
193b9a1
to
9e0c087
Compare
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.
/lgtm
/approve
@fossedihelm does this change need to be backported?
If not, then I'll remove the old after the CVE storm passes and I add the appropriate stable branches...
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: RamLavi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold cancel |
/cherry-pick release-0.42 |
@RamLavi: new pull request created: #407 In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
A macAddress can be specified with different separators:
Currently, the duplicate mac check works only if the two compared mac address use the same separator.
The duplicate check is made looking at the existence of key of the macMap. The keys of the mapMap are the macAddress string.
With this commit, a
macKey
struct is introduced. The latter stores the normalized string of the macAddress and can be used as unique key and identifier of a macAddress.What this PR does / why we need it:
Special notes for your reviewer:
Fixes https://issues.redhat.com/browse/CNV-30974
Release note: