-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
CNI: add host-side interface info to cni.Result #24901
Conversation
Commit b1d47cba365c97754a87cf892552a0df27ce85fd does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
@czybjtu thanks for the PR 😄 One question, later on in the function IPs get their interface index added: https://github.com/cilium/cilium/blob/5b042476dd6f18c70bc7c0d7401cc596abf04b24/plugins/cilium-cni/main.go#L608 Would this still work if we add the host level interface first? |
Thanks for catching this. Have fixed it. PTAL. |
@@ -552,6 +557,9 @@ func cmdAdd(args *skel.CmdArgs) (err error) { | |||
err = fmt.Errorf("unable to prepare IP addressing for '%s': %s", ep.Addressing.IPV6, err) | |||
return | |||
} | |||
// Add to the result the Interface as index of Interfaces | |||
ipConfig.Interface = cniTypesV1.Int(len(res.Interfaces)) |
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.
Shouldn't this be:
ipConfig.Interface = cniTypesV1.Int(len(res.Interfaces)) | |
ipConfig.Interface = cniTypesV1.Int(len(res.Interfaces)-1) |
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.
You cannot do it this way because the index of an array starts from 0.
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.
Sorry I'm still confused,
So at this point res.Interfaces is either of length 0 or 1, if ip4 and ip6 are enabled then we're going to be referencing 2, which is out of bounds in the Interfaces array?
Does that make sense? This function is a bit confusing so I might be missing something here.
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.
On line L523, we add the host-side veth info to res.Interface
which has no ip.
On line L561 and L577, ipConfig
was refer to container-side veth info. ipConfig
is the last element that will be added to res.Interface
slice. So I think
// ipConfig.Interface represents its index in this slice.
ipConfig.Interface = cniTypesV1.Int(len(res.Interfaces))
is what we want.
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.
Does that still work if datapathmodeveth isn't enabled?
(Line 504)
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.
Yes. We add host side veth info to res.Interfaces
only when datapathmodeveth enabled. Everything is the same as before if datapathmodeveth was not enabled.
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.
Ok I see now, thanks for the clarification.
/test |
I've kicked off the tests to ensure there are no regressions introduced by this. Other than that I think we are just looking for @tommyp1ckles' feedback on the remaining open thread. Thanks for contributing :) |
/test-1.25-4.19 |
/test-1.26-net-next |
/test-1.16-4.19 |
/test-1.24-5.4 |
Changes LGTM 🙏 , just gonna make sure tests are passing |
/test Job 'Cilium-PR-K8s-1.25-kernel-4.19' failed: Click to show.Test Name
Failure Output
Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.25-kernel-4.19/2065/ If it is a flake and a GitHub issue doesn't already exist to track it, comment Then please upload the Jenkins artifacts to that issue. |
This pull request has been automatically marked as stale because it |
@czybjtu sorry, just getting back to this one, do you mind rebasing and we can make sure the tests pass. |
Done. PTAL. |
/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.
Looks good, just going to make sure tests pass
This doesn't seem to be related to this PR. |
I've approved the tests to run. Could you please add a commit description with some of the context you've outlined in the original issue? right now it's hard to tell what the intention is behind the change by just looking at the commit. |
This commit adds host-side interface name and mac address to cni.Result according to CNI Specification (https://www.cni.dev/docs/spec/#section-5-result-types) Signed-off-by: czybjtu <smartczy@outlook.com>
Updated the commit message. PTAL. |
not sure why tests failed, possible GH Actions issue 😕 /test |
@czybjtu GH actions is looking really off here. Can you rebase this PR and force push? |
Commit 8445e2b does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
1 similar comment
Commit 8445e2b does not contain "Signed-off-by". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
I have some problems when rebase upstream because the branch name has changed(master -> main). I will open a new same pr for this. |
New pr has been created. PTAL |
Fixes: #24899