Skip to content

Commit

Permalink
Add go1.10 build constraint
Browse files Browse the repository at this point in the history
This prevents netns from being used on older Go runtimes on which it's
not safe to perform any state manipulations of a scheduling thread
(golang/go#20676).

Signed-off-by: Martynas Pumputis <m@lambda.lt>
  • Loading branch information
brb committed Dec 21, 2018
1 parent 13995c7 commit b8d862b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,14 @@ func main() {
}

```

## NOTE

The library can be safely used only with Go >= 1.10 due to [golang/go#20676](https://github.com/golang/go/issues/20676).

After locking a goroutine to its current OS thread with `runtime.LockOSThread()`
and changing its network namespace, any new subsequent goroutine won't be
scheduled on that thread while it's locked. Therefore, the new goroutine
will run in a different namespace leading to unexpected results.

See [here](https://www.weave.works/blog/linux-namespaces-golang-followup) for more details.
2 changes: 1 addition & 1 deletion netns_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build linux
// +build linux,go1.10

package netns

Expand Down

0 comments on commit b8d862b

Please sign in to comment.