1
0
mirror of https://github.com/docker/cli.git synced 2026-01-18 08:21:31 +03:00

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.
Upstream-commit: 607c1a520e6d39d0f0ee21f1d281931484206b57
Component: engine
This commit is contained in:
Alexander Larsson
2013-09-17 15:02:12 +02:00
committed by Victor Vieux
parent 038f533285
commit b0926faccd

View File

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