зеркало из https://github.com/microsoft/docker.git
Use netlink directly instead of /bin/ip in Sysinit
The sysinit code only uses /bin/ip to set a default gateway. This is pretty easy to do via netlink directly, so we can avoid the ip dependency.
This commit is contained in:
Родитель
bf61d41d6c
Коммит
607c1a520e
11
sysinit.go
11
sysinit.go
|
@ -3,8 +3,10 @@ package docker
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/netlink"
|
||||
"github.com/dotcloud/docker/utils"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
|
@ -17,7 +19,14 @@ func setupNetworking(gw string) {
|
|||
if gw == "" {
|
||||
return
|
||||
}
|
||||
if _, err := ip("route", "add", "default", "via", gw); err != nil {
|
||||
|
||||
ip := net.ParseIP(gw)
|
||||
if ip == nil {
|
||||
log.Fatalf("Unable to set up networking, %s is not a valid IP", gw)
|
||||
return
|
||||
}
|
||||
|
||||
if err := netlink.AddDefaultGw(ip); err != nil {
|
||||
log.Fatalf("Unable to set up networking: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче