From: Stefan Junker Date: Wed, 23 Sep 2015 09:03:22 +0000 (+0200) Subject: plugins/ptp: allow host veth to be UP X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=8d3eb91a374b7b66479404be4acd9b56ab4f93eb;p=plugins.git plugins/ptp: allow host veth to be UP --- diff --git a/ip/link.go b/ip/link.go index 3936ed9..e97dcd2 100644 --- a/ip/link.go +++ b/ip/link.go @@ -77,8 +77,9 @@ func RandomVethName() (string, error) { return fmt.Sprintf("veth%x", entropy), nil } -// SetupVeth sets up a virtual ethernet link. -// Should be in container netns. +// SetupVeth creates the virtual ethernet pair and sets up the container's end in the container netns. +// Setting up the host end up has to be done in the host netns outside of this function. +// This is because moving the host veth end will cause it to be brought down automatically when it is moved to the host netns. func SetupVeth(contVethName string, mtu int, hostNS *os.File) (hostVeth, contVeth netlink.Link, err error) { var hostVethName string hostVethName, contVeth, err = makeVeth(contVethName, mtu) @@ -97,11 +98,6 @@ func SetupVeth(contVethName string, mtu int, hostNS *os.File) (hostVeth, contVet return } - if err = netlink.LinkSetUp(hostVeth); err != nil { - err = fmt.Errorf("failed to set %q up: %v", contVethName, err) - return - } - if err = netlink.LinkSetNsFd(hostVeth, int(hostNS.Fd())); err != nil { err = fmt.Errorf("failed to move veth to host netns: %v", err) return