From eade8eac09ad8cfdaf762e88d382daf6017201d7 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <lk4d4@docker.com>
Date: Fri, 13 Mar 2015 11:33:49 -0700
Subject: [PATCH] Update libcontainer to
 5d6c507d7cfeff97172deedf3db13b5295bcacef

It includes new Type() method for Factory, which needed for replacing
execdriver.Driver.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
---
 project/vendor.sh                             |  2 +-
 .../github.com/docker/libcontainer/Dockerfile |  2 +-
 .../docker/libcontainer/configs/network.go    |  6 +++++
 .../github.com/docker/libcontainer/factory.go |  3 +++
 .../docker/libcontainer/factory_linux.go      |  4 ++++
 .../docker/libcontainer/factory_linux_test.go |  4 ++++
 .../docker/libcontainer/network_linux.go      |  5 ++++
 .../docker/libcontainer/nsinit/exec.go        |  3 +--
 .../docker/libcontainer/nsinit/main.go        |  2 +-
 .../docker/libcontainer/nsinit/utils.go       | 24 +++++++++----------
 .../docker/libcontainer/rootfs_linux.go       | 18 +++++++++++++-
 .../docker/libcontainer/update-vendor.sh      |  2 +-
 12 files changed, 56 insertions(+), 19 deletions(-)

diff --git a/project/vendor.sh b/project/vendor.sh
index 713ad92781..6fb5a6f8fe 100755
--- a/project/vendor.sh
+++ b/project/vendor.sh
@@ -68,7 +68,7 @@ if [ "$1" = '--go' ]; then
 	mv tmp-tar src/code.google.com/p/go/src/pkg/archive/tar
 fi
 
-clone git github.com/docker/libcontainer aa10040b570386c1ae311c6245b9e21295b2b83a
+clone git github.com/docker/libcontainer 5d6c507d7cfeff97172deedf3db13b5295bcacef
 # see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file)
 rm -rf src/github.com/docker/libcontainer/vendor
 eval "$(grep '^clone ' src/github.com/docker/libcontainer/update-vendor.sh | grep -v 'github.com/codegangsta/cli' | grep -v 'github.com/Sirupsen/logrus')"
diff --git a/vendor/src/github.com/docker/libcontainer/Dockerfile b/vendor/src/github.com/docker/libcontainer/Dockerfile
index 0771c808ea..e2c441615a 100644
--- a/vendor/src/github.com/docker/libcontainer/Dockerfile
+++ b/vendor/src/github.com/docker/libcontainer/Dockerfile
@@ -7,7 +7,7 @@ RUN go get github.com/docker/docker/pkg/term
 
 # setup a playground for us to spawn containers in
 RUN mkdir /busybox && \
-    curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.02/rootfs.tar' | tar -xC /busybox
+    curl -sSL 'https://github.com/jpetazzo/docker-busybox/raw/buildroot-2014.11/rootfs.tar' | tar -xC /busybox
 
 RUN curl -sSL https://raw.githubusercontent.com/docker/docker/master/project/dind -o /dind && \
     chmod +x /dind
diff --git a/vendor/src/github.com/docker/libcontainer/configs/network.go b/vendor/src/github.com/docker/libcontainer/configs/network.go
index 5544398830..9d5ed7a65f 100644
--- a/vendor/src/github.com/docker/libcontainer/configs/network.go
+++ b/vendor/src/github.com/docker/libcontainer/configs/network.go
@@ -42,6 +42,12 @@ type Network struct {
 	// HostInterfaceName is a unique name of a veth pair that resides on in the host interface of the
 	// container.
 	HostInterfaceName string `json:"host_interface_name"`
+
+	// HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
+	// bridge port in the case of type veth
+	// Note: This is unsupported on some systems.
+	// Note: This does not apply to loopback interfaces.
+	HairpinMode bool `json:"hairpin_mode"`
 }
 
 // Routes can be specified to create entries in the route table as the container is started
diff --git a/vendor/src/github.com/docker/libcontainer/factory.go b/vendor/src/github.com/docker/libcontainer/factory.go
index 37e629645b..0c9fa63a32 100644
--- a/vendor/src/github.com/docker/libcontainer/factory.go
+++ b/vendor/src/github.com/docker/libcontainer/factory.go
@@ -41,4 +41,7 @@ type Factory interface {
 	// pipe connection error
 	// system error
 	StartInitialization(pipefd uintptr) error
+
+	// Type returns info string about factory type (e.g. lxc, libcontainer...)
+	Type() string
 }
diff --git a/vendor/src/github.com/docker/libcontainer/factory_linux.go b/vendor/src/github.com/docker/libcontainer/factory_linux.go
index 468398c015..ecd3dd5c97 100644
--- a/vendor/src/github.com/docker/libcontainer/factory_linux.go
+++ b/vendor/src/github.com/docker/libcontainer/factory_linux.go
@@ -172,6 +172,10 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
 	}, nil
 }
 
+func (l *LinuxFactory) Type() string {
+	return "libcontainer"
+}
+
 // StartInitialization loads a container by opening the pipe fd from the parent to read the configuration and state
 // This is a low level implementation detail of the reexec and should not be consumed externally
 func (l *LinuxFactory) StartInitialization(pipefd uintptr) (err error) {
diff --git a/vendor/src/github.com/docker/libcontainer/factory_linux_test.go b/vendor/src/github.com/docker/libcontainer/factory_linux_test.go
index 19fc77ba56..968f6a9657 100644
--- a/vendor/src/github.com/docker/libcontainer/factory_linux_test.go
+++ b/vendor/src/github.com/docker/libcontainer/factory_linux_test.go
@@ -43,6 +43,10 @@ func TestFactoryNew(t *testing.T) {
 	if lfactory.Root != root {
 		t.Fatalf("expected factory root to be %q but received %q", root, lfactory.Root)
 	}
+
+	if factory.Type() != "libcontainer" {
+		t.Fatalf("unexpected factory type: %q, expected %q", factory.Type(), "libcontainer")
+	}
 }
 
 func TestFactoryLoadNotExists(t *testing.T) {
diff --git a/vendor/src/github.com/docker/libcontainer/network_linux.go b/vendor/src/github.com/docker/libcontainer/network_linux.go
index 687c5e8fa0..46c606a2bb 100644
--- a/vendor/src/github.com/docker/libcontainer/network_linux.go
+++ b/vendor/src/github.com/docker/libcontainer/network_linux.go
@@ -135,6 +135,11 @@ func (v *veth) create(n *network, nspid int) (err error) {
 	if err := netlink.NetworkSetMTU(host, n.Mtu); err != nil {
 		return err
 	}
+	if n.HairpinMode {
+		if err := netlink.SetHairpinMode(host, true); err != nil {
+			return err
+		}
+	}
 	if err := netlink.NetworkLinkUp(host); err != nil {
 		return err
 	}
diff --git a/vendor/src/github.com/docker/libcontainer/nsinit/exec.go b/vendor/src/github.com/docker/libcontainer/nsinit/exec.go
index c2b9b0b0f7..9d302aa31e 100644
--- a/vendor/src/github.com/docker/libcontainer/nsinit/exec.go
+++ b/vendor/src/github.com/docker/libcontainer/nsinit/exec.go
@@ -24,8 +24,7 @@ var execCommand = cli.Command{
 	Flags: append([]cli.Flag{
 		cli.BoolFlag{Name: "tty,t", Usage: "allocate a TTY to the container"},
 		cli.StringFlag{Name: "id", Value: "nsinit", Usage: "specify the ID for a container"},
-		cli.StringFlag{Name: "config", Value: "container.json", Usage: "path to the configuration file"},
-		cli.BoolFlag{Name: "create", Usage: "create the container's configuration on the fly with arguments"},
+		cli.StringFlag{Name: "config", Value: "", Usage: "path to the configuration file"},
 		cli.StringFlag{Name: "user,u", Value: "root", Usage: "set the user, uid, and/or gid for the process"},
 		cli.StringFlag{Name: "cwd", Value: "", Usage: "set the current working dir"},
 		cli.StringSliceFlag{Name: "env", Value: standardEnvironment, Usage: "set environment variables for the process"},
diff --git a/vendor/src/github.com/docker/libcontainer/nsinit/main.go b/vendor/src/github.com/docker/libcontainer/nsinit/main.go
index f8ccd62ef5..922d74ccbb 100644
--- a/vendor/src/github.com/docker/libcontainer/nsinit/main.go
+++ b/vendor/src/github.com/docker/libcontainer/nsinit/main.go
@@ -14,7 +14,7 @@ func main() {
 	app.Author = "libcontainer maintainers"
 	app.Flags = []cli.Flag{
 		cli.StringFlag{Name: "root", Value: ".", Usage: "root directory for containers"},
-		cli.StringFlag{Name: "log-file", Value: "nsinit-debug.log", Usage: "set the log file to output logs to"},
+		cli.StringFlag{Name: "log-file", Value: "", Usage: "set the log file to output logs to"},
 		cli.BoolFlag{Name: "debug", Usage: "enable debug output in the logs"},
 	}
 	app.Commands = []cli.Command{
diff --git a/vendor/src/github.com/docker/libcontainer/nsinit/utils.go b/vendor/src/github.com/docker/libcontainer/nsinit/utils.go
index dad75aec86..4deca76640 100644
--- a/vendor/src/github.com/docker/libcontainer/nsinit/utils.go
+++ b/vendor/src/github.com/docker/libcontainer/nsinit/utils.go
@@ -11,20 +11,20 @@ import (
 )
 
 func loadConfig(context *cli.Context) (*configs.Config, error) {
-	if context.Bool("create") {
-		config := getTemplate()
-		modify(config, context)
+	if path := context.String("config"); path != "" {
+		f, err := os.Open(path)
+		if err != nil {
+			return nil, err
+		}
+		defer f.Close()
+		var config *configs.Config
+		if err := json.NewDecoder(f).Decode(&config); err != nil {
+			return nil, err
+		}
 		return config, nil
 	}
-	f, err := os.Open(context.String("config"))
-	if err != nil {
-		return nil, err
-	}
-	defer f.Close()
-	var config *configs.Config
-	if err := json.NewDecoder(f).Decode(&config); err != nil {
-		return nil, err
-	}
+	config := getTemplate()
+	modify(config, context)
 	return config, nil
 }
 
diff --git a/vendor/src/github.com/docker/libcontainer/rootfs_linux.go b/vendor/src/github.com/docker/libcontainer/rootfs_linux.go
index a1fb8f490a..5a94e68658 100644
--- a/vendor/src/github.com/docker/libcontainer/rootfs_linux.go
+++ b/vendor/src/github.com/docker/libcontainer/rootfs_linux.go
@@ -100,7 +100,23 @@ func mount(m *configs.Mount, rootfs, mountLabel string) error {
 			return err
 		}
 		return syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), "")
-	case "tmpfs", "mqueue", "devpts", "sysfs":
+	case "tmpfs":
+		stat, err := os.Stat(dest)
+		if err != nil {
+			if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
+				return err
+			}
+		}
+		if err := syscall.Mount(m.Source, dest, m.Device, uintptr(m.Flags), data); err != nil {
+			return err
+		}
+		if stat != nil {
+			if err = os.Chmod(dest, stat.Mode()); err != nil {
+				return err
+			}
+		}
+		return nil
+	case "mqueue", "devpts", "sysfs":
 		if err := os.MkdirAll(dest, 0755); err != nil && !os.IsExist(err) {
 			return err
 		}
diff --git a/vendor/src/github.com/docker/libcontainer/update-vendor.sh b/vendor/src/github.com/docker/libcontainer/update-vendor.sh
index c48fb5f0ba..12077256e8 100755
--- a/vendor/src/github.com/docker/libcontainer/update-vendor.sh
+++ b/vendor/src/github.com/docker/libcontainer/update-vendor.sh
@@ -43,7 +43,7 @@ clone() {
 clone git github.com/codegangsta/cli 1.1.0
 clone git github.com/coreos/go-systemd v2
 clone git github.com/godbus/dbus v2
-clone git github.com/Sirupsen/logrus v0.6.0
+clone git github.com/Sirupsen/logrus v0.6.6
 clone git github.com/syndtr/gocapability e55e583369
 
 # intentionally not vendoring Docker itself...  that'd be a circle :)