cni icon indicating copy to clipboard operation
cni copied to clipboard

fix 714-plugin add netns validation reinforcement

Open Poor12 opened this issue 2 years ago • 9 comments

fix-714: https://github.com/containernetworking/plugins/issues/714

Poor12 avatar Mar 31 '22 07:03 Poor12

Is something like this? Need your review. :) @squeed

Poor12 avatar Apr 01 '22 01:04 Poor12

Coverage Status

Coverage increased (+0.02%) to 72.228% when pulling c31383f95b58c7cfebe3383d3c11366b3a8a57ca on Poor12:fix-714 into 8dba3824fbfdf9fe69e72cd2f2330c06303e2a84 on containernetworking:main.

coveralls avatar Apr 19 '22 12:04 coveralls

@Poor12 surprise: this doesn't build on Windows :). We'll need to stub out the function with build flags.

squeed avatar Apr 19 '22 12:04 squeed

@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.

Poor12 avatar Apr 20 '22 01:04 Poor12

I am not familiar with this. Could you do me a favor?Thanks a lot.

 # github.com/vishvananda/netns
Error: C:\Users\runneradmin\go\pkg\mod\github.com\vishvananda\[email protected]\netns.go:28:13: undefined: unix.Stat_t
Error: C:\Users\runneradmin\go\pkg\mod\github.com\vishvananda\[email protected]\netns.go:29:12: undefined: unix.Fstat
Error: C:\Users\runneradmin\go\pkg\mod\github.com\vishvananda\[email protected]\netns.go:32:12: undefined: unix.Fstat
Error: C:\Users\runneradmin\go\pkg\mod\github.com\vishvananda\[email protected]\netns.go:43:8: undefined: unix.Stat_t
Error: C:\Users\runneradmin\go\pkg\mod\github.com\vishvananda\[email protected]\netns.go:44:12: undefined: unix.Fstat
Error: C:\Users\runneradmin\go\pkg\mod\github.com\vishvananda\[email protected]\netns.go:56:8: undefined: unix.Stat_t
Error: C:\Users\runneradmin\go\pkg\mod\github.com\vishvananda\[email protected]\netns.go:57:12: undefined: unix.Fstat
Error: C:\Users\runneradmin\go\pkg\mod\github.com\vishvananda\[email protected]\netns.go:71:12: undefined: unix.Close

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.

  1. Make a new file called netns_linux.go and put getCurrentNS(), getCurrentThreadNetNSPath(), and checkNetNS() into that.
  2. Make a new file called netns_windows.go and stub out the checkNetNS() function there like:
func checkNetNS(nsPath string) (bool, *types.Error) {
    return false, nil
}

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.

dcbw avatar Apr 27 '22 15:04 dcbw

Thanks for informing this. I have not seen _windows files before. And Happy Labor Day :) @dcbw

Poor12 avatar Apr 28 '22 02:04 Poor12

/cc @squeed @dcbw

Poor12 avatar May 20 '22 02:05 Poor12

Is there any progress about this issue?

kkBill avatar Jun 14 '22 15:06 kkBill

Excuse me, several months ago I started a issue about https://github.com/containernetworking/plugins/issues/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.

  1. Do we still need to fix this problem?Or we don't think it's a problem?
  2. Is there a more reasonable solution for this problem?

cc @squeed @dcbw @mars1024 @matthewdupre @mccv1r0 @MikeZappa87 @jellonek Really sorry if disturbing you.

Poor12 avatar Jun 20 '22 13:06 Poor12