Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Fix the usage of WithNetNS* functions #2419

Closed
7 tasks done
brb opened this issue Jul 4, 2016 · 2 comments
Closed
7 tasks done

Fix the usage of WithNetNS* functions #2419

brb opened this issue Jul 4, 2016 · 2 comments

Comments

@brb
Copy link
Contributor

brb commented Jul 4, 2016

As it's been mentioned in #2388 , the WithNetNS* family of functions and their usage are not safe. To address the issues, the work function has to be executed in a separate process which is not associated with the Go runtime process which created it.

Currently, WithNetNS* is used by the following functions:

  • common/utils.go:FindNetDevs
  • common/utils.go:GetWeaveNetDevs
  • net/veth.go:interfaceExistsInNamespace
  • net/veth.go:AttachContainer
  • net/veth.go:DetachContainer
  • plugin/net/cni.go:CmdAdd
  • plugin/net/cni.go:CmdDel

In some cases, shelling out is not necessary - it's enough to move a netns dependant code to the end of execution and to ensure that the code does not create any go-routine which require a particular netns.

@brb brb added this to the 1.6.1 milestone Jul 4, 2016
@brb brb self-assigned this Jul 4, 2016
@brb brb mentioned this issue Jul 4, 2016
@brb
Copy link
Contributor Author

brb commented Jul 6, 2016

plugin/net/cni.go:CmdAdd: it does not require any changes, because the WithNetNS* call happens at the very end of execution and the CNI plugin stops a process once it has finished processing the request.

@brb
Copy link
Contributor Author

brb commented Jul 7, 2016

As a subtask: add a shim for starting a process or do the init hack to make sure that all threads of the runtime is in a given netns. Otherwise, we cannot create any go-routine inside a former work() function.

@awh awh modified the milestones: 1.7.0, 1.6.1 Aug 10, 2016
@awh awh modified the milestones: 1.7.0, 1.8.0 Sep 23, 2016
@awh awh assigned brb and unassigned brb Oct 12, 2016
@awh awh closed this as completed in #2475 Oct 26, 2016
awh added a commit that referenced this issue Oct 26, 2016
Add a safer version of WithNetNS*
brb added a commit that referenced this issue Nov 3, 2016
This reverts commit a5ff7ab, reversing
changes made to 04a6e6d.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants