-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix 714-plugin add netns validation reinforcement #890
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
Conversation
Is something like this? Need your review. :) @squeed |
pkg/skel/skel.go
Outdated
|
||
func checkNetNS(nsPath string) (bool, *types.Error) { | ||
ns, err := netns.GetFromPath(nsPath) | ||
if err != nil { |
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.
We need to support CNI DEL for empty nsPath as well as already-deleted nsPath. So, paradoxically, I think we can return true
here if err != nil
.
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.
Do you mean we just pass the check and let plugins deal with empty plugins as well as already-deleted nsPath?
pkg/skel/skel.go
Outdated
if err != nil { | ||
return err | ||
} | ||
if cmdArgs.NetnsOverride != "TRUE" { |
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.
@Poor12 could we make this a case-insensitive comparison for "true", and also add a check for "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.
make it.
@@ -241,6 +277,17 @@ func (t *dispatcher) pluginMain(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error, | |||
return types.NewError(types.ErrIncompatibleCNIVersion, "plugin version does not allow CHECK", "") | |||
case "DEL": | |||
err = t.checkVersionAndCall(cmdArgs, versionInfo, cmdDel) | |||
if err != nil { |
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.
Should we check this for ADD as well? I don't see why not...
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.
Add check for ADD.
@Poor12 surprise: this doesn't build on Windows :). We'll need to stub out the function with build flags. |
I am not familiar with this. Could you do me a favor?Thanks a lot. |
That just means that because the netlink library and Unix stuff doesn't work on Windows, you need to move that code to a different file. Here's what you do.
Files with _ at the end are automatically only built on the platform in question. It's magic :) That way Linux builds will use the full implementation, and the Windows builds will use the stub implementation that just returns OK. @MikeZappa87 says that Windows doesn't have a good way (that we know of) to get the root compartment, so let's just ignore this on Windows for now. |
Thanks for informing this. I have not seen _windows files before. And Happy Labor Day :) @dcbw |
|
||
package ns | ||
|
||
func CheckNetNS(nsPath string) (bool, *types.Error) { |
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.
@Poor12 you need to import "github.com/containernetworking/cni/pkg/types"
here to get types.Error.
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.
Done
Is there any progress about this issue? |
Excuse me, several months ago I started a issue about containernetworking/plugins#714 and have proposed a tentative solution but got very few replies lately. Actually our productive environment has had this problem for a while and we really hope to fix this problem in the community in order to avoid the problem of upstream and downstream inconsistencies caused by our private modification. But during several months waiting for a response from the community, I have several confusion about this problem.
cc @squeed @dcbw @mars1024 @matthewdupre @mccv1r0 @MikeZappa87 @jellonek |
Signed-off-by: Poor12 <[email protected]>
fix-714: containernetworking/plugins#714