ns: add interface, use it, and fix thread-related namespace switch issues
authorDan Williams <dcbw@redhat.com>
Tue, 5 Apr 2016 16:10:31 +0000 (11:10 -0500)
committerDan Williams <dcbw@redhat.com>
Fri, 20 May 2016 22:10:25 +0000 (17:10 -0500)
commitc0d34c692f03f42b355cd3fe7a4ae28b2b5556eb
treecbc2a2b3c56131c253ae5d0bfb8b1ee9b122a39b
parent3e1c3c60da691c053cde65d511e7591f259a061c
ns: add interface, use it, and fix thread-related namespace switch issues

Add a namespace object interface for somewhat cleaner code when
creating and switching between network namespaces.  All created
namespaces are now mounted in /var/run/netns to ensure they
have persistent inodes and paths that can be passed around
between plugin components without relying on the current namespace
being correct.

Also remove the thread-locking arguments from the ns package
per https://github.com/appc/cni/issues/183 by doing all the namespace
changes in a separate goroutine that locks/unlocks itself, instead of
the caller having to track OS thread locking.
19 files changed:
pkg/ip/link.go
pkg/ns/README.md [new file with mode: 0644]
pkg/ns/consts_linux_386.go [deleted file]
pkg/ns/consts_linux_amd64.go [deleted file]
pkg/ns/consts_linux_arm.go [deleted file]
pkg/ns/ns.go
pkg/ns/ns_test.go
pkg/testhelpers/testhelpers.go [deleted file]
pkg/testhelpers/testhelpers_suite_test.go [deleted file]
pkg/testhelpers/testhelpers_test.go [deleted file]
plugins/ipam/dhcp/lease.go
plugins/main/bridge/bridge.go
plugins/main/ipvlan/ipvlan.go
plugins/main/loopback/loopback.go
plugins/main/loopback/loopback_test.go
plugins/main/macvlan/macvlan.go
plugins/main/ptp/ptp.go
plugins/meta/tuning/tuning.go
test