Fix netlink dependency with new pkg
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
6bd3e6357c
commit
d0fdc3b5df
1 changed files with 10 additions and 4 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
@ -52,7 +53,7 @@ import (
|
|||
"github.com/docker/docker/volume/local"
|
||||
"github.com/docker/docker/volume/store"
|
||||
"github.com/docker/libnetwork"
|
||||
"github.com/opencontainers/runc/libcontainer/netlink"
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1078,13 +1079,18 @@ 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.NetworkGetRoutes()
|
||||
routes, err := netlink.RouteList(nil, 0)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
for _, r := range routes {
|
||||
if r.Default && r.Iface != nil {
|
||||
return r.Iface.MTU, nil
|
||||
// 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
|
||||
|
|
Loading…
Add table
Reference in a new issue