Revert "plugins/ptp: allow host veth to be UP"
authorStefan Junker <mail@stefanjunker.de>
Thu, 24 Sep 2015 16:28:14 +0000 (18:28 +0200)
committerStefan Junker <mail@stefanjunker.de>
Thu, 24 Sep 2015 16:32:18 +0000 (18:32 +0200)
This reverts commit 231d2d5a27f3ba54219c3f0b1c8ef2c5dab4faaf.

ip/link.go

index e97dcd2..3936ed9 100644 (file)
@@ -77,9 +77,8 @@ func RandomVethName() (string, error) {
        return fmt.Sprintf("veth%x", entropy), nil
 }
 
-// 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.
+// SetupVeth sets up a virtual ethernet link.
+// Should be in container 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)
@@ -98,6 +97,11 @@ 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