summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go')
-rw-r--r--vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go b/vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go
index b33e4c0d0..c2ec91eaf 100644
--- a/vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go
+++ b/vendor/github.com/hashicorp/go-sockaddr/route_info_linux.go
@@ -5,10 +5,6 @@ import (
"os/exec"
)
-var cmds map[string][]string = map[string][]string{
- "ip": {"/sbin/ip", "route"},
-}
-
type routeInfo struct {
cmds map[string][]string
}
@@ -16,15 +12,22 @@ type routeInfo struct {
// NewRouteInfo returns a Linux-specific implementation of the RouteInfo
// interface.
func NewRouteInfo() (routeInfo, error) {
+ // CoreOS Container Linux moved ip to /usr/bin/ip, so look it up on
+ // $PATH and fallback to /sbin/ip on error.
+ path, _ := exec.LookPath("ip")
+ if path == "" {
+ path = "/sbin/ip"
+ }
+
return routeInfo{
- cmds: cmds,
+ cmds: map[string][]string{"ip": {path, "route"}},
}, nil
}
// GetDefaultInterfaceName returns the interface name attached to the default
// route on the default interface.
func (ri routeInfo) GetDefaultInterfaceName() (string, error) {
- out, err := exec.Command(cmds["ip"][0], cmds["ip"][1:]...).Output()
+ out, err := exec.Command(ri.cmds["ip"][0], ri.cmds["ip"][1:]...).Output()
if err != nil {
return "", err
}