Kaynağa Gözat

Fix windows cross compile with new netlink

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
Michael Crosby 9 yıl önce
ebeveyn
işleme
7d8b5fc3aa
3 değiştirilmiş dosya ile 24 ekleme ve 21 silme
  1. 4 0
      daemon/container_windows.go
  2. 0 21
      daemon/daemon.go
  3. 20 0
      daemon/daemon_unix.go

+ 4 - 0
daemon/container_windows.go

@@ -183,3 +183,7 @@ func (container *Container) unmountIpcMounts() error {
 func (container *Container) ipcMounts() []execdriver.Mount {
 	return nil
 }
+
+func getDefaultRouteMtu() (int, error) {
+	return -1, errSystemNotSupported
+}

+ 0 - 21
daemon/daemon.go

@@ -10,7 +10,6 @@ import (
 	"fmt"
 	"io"
 	"io/ioutil"
-	"net"
 	"os"
 	"path/filepath"
 	"regexp"
@@ -53,7 +52,6 @@ import (
 	"github.com/docker/docker/volume/local"
 	"github.com/docker/docker/volume/store"
 	"github.com/docker/libnetwork"
-	"github.com/vishvananda/netlink"
 )
 
 var (
@@ -1077,25 +1075,6 @@ func setDefaultMtu(config *Config) {
 
 var errNoDefaultRoute = errors.New("no default route was found")
 
-// getDefaultRouteMtu returns the MTU for the default route's interface.
-func getDefaultRouteMtu() (int, error) {
-	routes, err := netlink.RouteList(nil, 0)
-	if err != nil {
-		return 0, err
-	}
-	for _, r := range routes {
-		// a nil Dst means that this is the default route.
-		if r.Dst == nil {
-			i, err := net.InterfaceByIndex(r.LinkIndex)
-			if err != nil {
-				continue
-			}
-			return i.MTU, nil
-		}
-	}
-	return 0, errNoDefaultRoute
-}
-
 // verifyContainerSettings performs validation of the hostconfig and config
 // structures.
 func (daemon *Daemon) verifyContainerSettings(ctx context.Context, hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {

+ 20 - 0
daemon/daemon_unix.go

@@ -28,6 +28,7 @@ import (
 	"github.com/docker/libnetwork/netlabel"
 	"github.com/docker/libnetwork/options"
 	"github.com/opencontainers/runc/libcontainer/label"
+	"github.com/vishvananda/netlink"
 )
 
 const (
@@ -554,3 +555,22 @@ func (daemon *Daemon) newBaseContainer(id string) Container {
 		VolumesRW:   make(map[string]bool),
 	}
 }
+
+// getDefaultRouteMtu returns the MTU for the default route's interface.
+func getDefaultRouteMtu() (int, error) {
+	routes, err := netlink.RouteList(nil, 0)
+	if err != nil {
+		return 0, err
+	}
+	for _, r := range routes {
+		// a nil Dst means that this is the default route.
+		if r.Dst == nil {
+			i, err := net.InterfaceByIndex(r.LinkIndex)
+			if err != nil {
+				continue
+			}
+			return i.MTU, nil
+		}
+	}
+	return 0, errNoDefaultRoute
+}