Skip to content

Commit

Permalink
Merge branch '1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
awh committed Jul 28, 2016
2 parents 34415c3 + b06ddeb commit f5a30c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/netns.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package net

import (
"errors"
"runtime"

"github.com/vishvananda/netlink"
"github.com/vishvananda/netns"
)

var ErrLinkNotFound = errors.New("Link not found")

// NB: The following function is unsafe, because:
// - It changes a network namespace (netns) of an OS thread which runs
// the function. During execution, the Go runtime might clone a new OS thread
Expand Down Expand Up @@ -42,6 +45,9 @@ func WithNetNSLinkUnsafe(ns netns.NsHandle, ifName string, work func(link netlin
return WithNetNSUnsafe(ns, func() error {
link, err := netlink.LinkByName(ifName)
if err != nil {
if err.Error() == errors.New("Link not found").Error() {
return ErrLinkNotFound
}
return err
}
return work(link)
Expand Down
5 changes: 5 additions & 0 deletions prog/weaveutil/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (

"github.com/fsouza/go-dockerclient"
"github.com/vishvananda/netlink"

"github.com/weaveworks/weave/common"
weavenet "github.com/weaveworks/weave/net"
)

func containerAddrs(args []string) error {
Expand All @@ -21,6 +23,9 @@ func containerAddrs(args []string) error {

pred, err := common.ConnectedToBridgePredicate(bridgeName)
if err != nil {
if err == weavenet.ErrLinkNotFound {
return nil
}
return err
}

Expand Down

0 comments on commit f5a30c7

Please sign in to comment.