Fix windows cross compile with new netlink

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-09-24 14:59:23 -07:00
parent 189d2c7985
commit 7d8b5fc3aa
3 changed files with 24 additions and 21 deletions

View File

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

View File

@ -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) {

View File

@ -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
}