From 8fd3e3f6b641be890e480b4275e32a43f510d44a Mon Sep 17 00:00:00 2001 From: Subin M Date: Mon, 16 Mar 2015 11:05:55 +0530 Subject: [PATCH 1/4] Support ChooseHostInterface on Mac OS X --- pkg/proxy/proxier.go | 4 +- pkg/proxy/proxier_test.go | 20 +++++----- pkg/util/util.go | 62 +++++++++++++----------------- pkg/util/util_test.go | 80 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 115 insertions(+), 51 deletions(-) diff --git a/pkg/proxy/proxier.go b/pkg/proxy/proxier.go index 864036dfede86..199fdd5472302 100644 --- a/pkg/proxy/proxier.go +++ b/pkg/proxy/proxier.go @@ -325,10 +325,10 @@ func NewProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.In return nil } glog.Infof("Setting Proxy IP to %v", hostIP) - return CreateProxier(loadBalancer, listenIP, iptables, hostIP) + return createProxier(loadBalancer, listenIP, iptables, hostIP) } -func CreateProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.Interface, hostIP net.IP) *Proxier { +func createProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.Interface, hostIP net.IP) *Proxier { glog.Infof("Initializing iptables") // Clean up old messes. Ignore erors. iptablesDeleteOld(iptables) diff --git a/pkg/proxy/proxier_test.go b/pkg/proxy/proxier_test.go index 6f23084e4718b..aa79eae5fa56e 100644 --- a/pkg/proxy/proxier_test.go +++ b/pkg/proxy/proxier_test.go @@ -201,7 +201,7 @@ func TestTCPProxy(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -221,7 +221,7 @@ func TestUDPProxy(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) @@ -250,7 +250,7 @@ func TestTCPProxyStop(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -281,7 +281,7 @@ func TestUDPProxyStop(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) @@ -312,7 +312,7 @@ func TestTCPProxyUpdateDelete(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -342,7 +342,7 @@ func TestUDPProxyUpdateDelete(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) @@ -372,7 +372,7 @@ func TestTCPProxyUpdateDeleteUpdate(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -411,7 +411,7 @@ func TestUDPProxyUpdateDeleteUpdate(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) @@ -450,7 +450,7 @@ func TestTCPProxyUpdatePort(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "TCP", 0, time.Second) @@ -486,7 +486,7 @@ func TestUDPProxyUpdatePort(t *testing.T) { }, }) - p := CreateProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) + p := createProxier(lb, net.ParseIP("0.0.0.0"), &fakeIptables{}, net.ParseIP("127.0.0.1")) waitForNumProxyLoops(t, p, 0) svcInfo, err := p.addServiceOnPort("echo", "UDP", 0, time.Second) diff --git a/pkg/util/util.go b/pkg/util/util.go index 281ca27f5714d..063e53dfa2969 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -378,46 +378,27 @@ func getIPFromInterface(intfName string, nw networkInterfacer) (net.IP, error) { return nil, nil } -func flagsSet(flags net.Flags, test net.Flags) bool { - return flags&test != 0 -} - -func flagsClear(flags net.Flags, test net.Flags) bool { - return flags&test == 0 -} - -func chooseHostInterfaceNativeGo() (net.IP, error) { - intfs, err := net.Interfaces() +//chooseHostInterfaceNativeGo is a method used fetch an IP for a daemon. +//It iterates over the interfaces returned by Interfaces() method +//and picks the first interface which is not Loopback. +//For a node with no internet connection ,it returns error +func chooseHostInterfaceNativeGo(nw networkInterfacer) (net.IP, error) { + intfs, err := nw.Interfaces() if err != nil { return nil, err } i := 0 for i = range intfs { - if flagsSet(intfs[i].Flags, net.FlagUp) && flagsClear(intfs[i].Flags, net.FlagLoopback|net.FlagPointToPoint) { - addrs, err := intfs[i].Addrs() - if err != nil { - return nil, err - } - if len(addrs) > 0 { - // This interface should suffice. - break - } + finalIP, err := getIPFromInterface(intfs[i].Name, nw) + if err != nil { + return nil, err + } + if finalIP != nil { + glog.V(4).Infof("Choosing IP %v ", finalIP) + return finalIP, nil } } - if i == len(intfs) { - return nil, err - } - glog.V(2).Infof("Choosing interface %s for from-host portals", intfs[i].Name) - addrs, err := intfs[i].Addrs() - if err != nil { - return nil, err - } - glog.V(2).Infof("Interface %s = %s", intfs[i].Name, addrs[0].String()) - ip, _, err := net.ParseCIDR(addrs[0].String()) - if err != nil { - return nil, err - } - return ip, nil + return nil, nil } //ChooseHostInterface is a method used fetch an IP for a daemon. @@ -425,21 +406,22 @@ func chooseHostInterfaceNativeGo() (net.IP, error) { //For a node with no internet connection ,it returns error //For a multi n/w interface node it returns the IP of the interface with gateway on it. func ChooseHostInterface() (net.IP, error) { - inFile, err := os.Open("/proc/net/route") + var nw networkInterfacer = networkInterface{} + inFile, err := os.Open("/proc/net/route1") if err != nil { if os.IsNotExist(err) { - return chooseHostInterfaceNativeGo() + return chooseHostInterfaceNativeGo(nw) } return nil, err } defer inFile.Close() - var nw networkInterfacer = networkInterface{} return chooseHostInterfaceFromRoute(inFile, nw) } type networkInterfacer interface { InterfaceByName(intfName string) (*net.Interface, error) Addrs(intf *net.Interface) ([]net.Addr, error) + Interfaces() ([]net.Interface, error) } type networkInterface struct{} @@ -460,6 +442,14 @@ func (_ networkInterface) Addrs(intf *net.Interface) ([]net.Addr, error) { return addrs, nil } +func (_ networkInterface) Interfaces() ([]net.Interface, error) { + intfs, err := net.Interfaces() + if err != nil { + return nil, err + } + return intfs, nil +} + func chooseHostInterfaceFromRoute(inFile io.Reader, nw networkInterfacer) (net.IP, error) { routes, err := getRoutes(inFile) if err != nil { diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index ec694ecee74c2..6eaf494279e40 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -489,15 +489,35 @@ type validNetworkInterface struct { } func (_ validNetworkInterface) InterfaceByName(intfName string) (*net.Interface, error) { - c := net.Interface{Index: 0, MTU: 0, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp} + var c net.Interface + if intfName == "eth3" { + c = net.Interface{Index: 0, MTU: 0, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast} + } else if intfName == "eth1" { + c = net.Interface{Index: 0, MTU: 0, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast} + } else if intfName == "lo" { + c = net.Interface{Index: 0, MTU: 0, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback} + } return &c, nil } func (_ validNetworkInterface) Addrs(intf *net.Interface) ([]net.Addr, error) { var ifat []net.Addr - ifat = []net.Addr{ - addrStruct{val: "fe80::2f7:6fff:fe6e:2956/64"}, addrStruct{val: "10.254.71.145/17"}} + if intf.Name == "eth3" { + ifat = []net.Addr{ + addrStruct{val: "fe80::2f7:6fff:fe6e:2956/64"}, addrStruct{val: "10.254.71.145/17"}} + } else if intf.Name == "eth1" { + ifat = []net.Addr{ + addrStruct{val: "fe80::5484:7aff:fefe:9799/64"}, addrStruct{val: "172.17.42.1/16"}} + } else if intf.Name == "lo" { + ifat = []net.Addr{addrStruct{val: "127.0.0.1/8"}, addrStruct{val: "::1/128"}} + } return ifat, nil } +func (_ validNetworkInterface) Interfaces() ([]net.Interface, error) { + var intfs []net.Interface = []net.Interface{net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback}, + net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}, + net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}} + return intfs, nil +} type validNetworkInterfacewithIpv6Only struct { } @@ -511,6 +531,12 @@ func (_ validNetworkInterfacewithIpv6Only) Addrs(intf *net.Interface) ([]net.Add ifat = []net.Addr{addrStruct{val: "fe80::2f7:6fff:fe6e:2956/64"}} return ifat, nil } +func (_ validNetworkInterfacewithIpv6Only) Interfaces() ([]net.Interface, error) { + var intfs []net.Interface = []net.Interface{net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback}, + net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}, + net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}} + return intfs, nil +} type noNetworkInterface struct { } @@ -521,6 +547,9 @@ func (_ noNetworkInterface) InterfaceByName(intfName string) (*net.Interface, er func (_ noNetworkInterface) Addrs(intf *net.Interface) ([]net.Addr, error) { return nil, nil } +func (_ noNetworkInterface) Interfaces() ([]net.Interface, error) { + return nil, nil +} type networkInterfacewithNoAddrs struct { } @@ -532,6 +561,9 @@ func (_ networkInterfacewithNoAddrs) InterfaceByName(intfName string) (*net.Inte func (_ networkInterfacewithNoAddrs) Addrs(intf *net.Interface) ([]net.Addr, error) { return nil, fmt.Errorf("unable get Addrs") } +func (_ networkInterfacewithNoAddrs) Interfaces() ([]net.Interface, error) { + return nil, nil +} type networkInterfacewithIpv6addrs struct { } @@ -545,6 +577,48 @@ func (_ networkInterfacewithIpv6addrs) Addrs(intf *net.Interface) ([]net.Addr, e ifat = []net.Addr{addrStruct{val: "fe80::2f7:6ffff:fe6e:2956/64"}} return ifat, nil } +func (_ networkInterfacewithIpv6addrs) Interfaces() ([]net.Interface, error) { + var intfs []net.Interface = []net.Interface{net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback}, + net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}, + net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}} + return intfs, nil +} + +type loopback struct { +} + +func (_ loopback) InterfaceByName(intfName string) (*net.Interface, error) { + c := net.Interface{Index: 0, MTU: 0, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp} + return &c, nil +} +func (_ loopback) Addrs(intf *net.Interface) ([]net.Addr, error) { + var ifat []net.Addr + ifat = []net.Addr{addrStruct{val: "127.0.0.1/8"}, addrStruct{val: "::1/128"}} + return ifat, nil +} +func (_ loopback) Interfaces() ([]net.Interface, error) { + var intfs []net.Interface = []net.Interface{net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback}} + return intfs, nil +} + +func TestChooseHostInterfaceNativeGo(t *testing.T) { + testCases := []struct { + tcase string + nw networkInterfacer + expected net.IP + }{ + {"valid", validNetworkInterface{}, net.ParseIP("172.17.42.1")}, + {"ipv6", validNetworkInterfacewithIpv6Only{}, nil}, + {"nothing", noNetworkInterface{}, nil}, + {"loopbackOnly", loopback{}, nil}, + } + for _, tc := range testCases { + ip, err := chooseHostInterfaceNativeGo(tc.nw) + if !ip.Equal(tc.expected) { + t.Errorf("case[%v]: expected %v, got %+v .err : %v", tc.tcase, tc.expected, ip, err) + } + } +} func TestGetIPFromInterface(t *testing.T) { testCases := []struct { From 86f8aa682c01b481a875c80a176982ea039510b9 Mon Sep 17 00:00:00 2001 From: Subin M Date: Mon, 16 Mar 2015 11:14:09 +0530 Subject: [PATCH 2/4] minor fixes to file name --- pkg/util/util.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/util/util.go b/pkg/util/util.go index 063e53dfa2969..d59a77cd815ee 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -378,10 +378,10 @@ func getIPFromInterface(intfName string, nw networkInterfacer) (net.IP, error) { return nil, nil } -//chooseHostInterfaceNativeGo is a method used fetch an IP for a daemon. +//chooseHostInterfaceNativeGo is a method used to fetch an IP for a daemon. //It iterates over the interfaces returned by Interfaces() method //and picks the first interface which is not Loopback. -//For a node with no internet connection ,it returns error +//This method may pick docker or other bridges func chooseHostInterfaceNativeGo(nw networkInterfacer) (net.IP, error) { intfs, err := nw.Interfaces() if err != nil { @@ -407,7 +407,7 @@ func chooseHostInterfaceNativeGo(nw networkInterfacer) (net.IP, error) { //For a multi n/w interface node it returns the IP of the interface with gateway on it. func ChooseHostInterface() (net.IP, error) { var nw networkInterfacer = networkInterface{} - inFile, err := os.Open("/proc/net/route1") + inFile, err := os.Open("/proc/net/route") if err != nil { if os.IsNotExist(err) { return chooseHostInterfaceNativeGo(nw) From 2baf01044d224ed7f6a4e725c805edb727a50801 Mon Sep 17 00:00:00 2001 From: Subin M Date: Mon, 16 Mar 2015 12:07:32 +0530 Subject: [PATCH 3/4] fix formatting errors --- pkg/util/util_test.go | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index 6eaf494279e40..506f5d6a4a210 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -513,9 +513,10 @@ func (_ validNetworkInterface) Addrs(intf *net.Interface) ([]net.Addr, error) { return ifat, nil } func (_ validNetworkInterface) Interfaces() ([]net.Interface, error) { - var intfs []net.Interface = []net.Interface{net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback}, - net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}, - net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}} + lo := net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback} + eth1 := net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast} + eth3 := net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast} + var intfs []net.Interface = []net.Interface{lo, eth1, eth3} return intfs, nil } @@ -532,9 +533,10 @@ func (_ validNetworkInterfacewithIpv6Only) Addrs(intf *net.Interface) ([]net.Add return ifat, nil } func (_ validNetworkInterfacewithIpv6Only) Interfaces() ([]net.Interface, error) { - var intfs []net.Interface = []net.Interface{net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback}, - net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}, - net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}} + lo := net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback} + eth1 := net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast} + eth3 := net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast} + var intfs []net.Interface = []net.Interface{lo, eth1, eth3} return intfs, nil } @@ -578,9 +580,10 @@ func (_ networkInterfacewithIpv6addrs) Addrs(intf *net.Interface) ([]net.Addr, e return ifat, nil } func (_ networkInterfacewithIpv6addrs) Interfaces() ([]net.Interface, error) { - var intfs []net.Interface = []net.Interface{net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback}, - net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}, - net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast}} + lo := net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback} + eth1 := net.Interface{Index: 2, MTU: 1500, Name: "eth1", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast} + eth3 := net.Interface{Index: 3, MTU: 1500, Name: "eth3", HardwareAddr: nil, Flags: net.FlagUp | net.FlagBroadcast | net.FlagMulticast} + var intfs []net.Interface = []net.Interface{lo, eth1, eth3} return intfs, nil } @@ -588,7 +591,7 @@ type loopback struct { } func (_ loopback) InterfaceByName(intfName string) (*net.Interface, error) { - c := net.Interface{Index: 0, MTU: 0, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp} + c := net.Interface{Index: 0, MTU: 0, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback} return &c, nil } func (_ loopback) Addrs(intf *net.Interface) ([]net.Addr, error) { @@ -597,7 +600,8 @@ func (_ loopback) Addrs(intf *net.Interface) ([]net.Addr, error) { return ifat, nil } func (_ loopback) Interfaces() ([]net.Interface, error) { - var intfs []net.Interface = []net.Interface{net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback}} + c := net.Interface{Index: 1, MTU: 1500, Name: "lo", HardwareAddr: nil, Flags: net.FlagUp | net.FlagLoopback} + var intfs []net.Interface = []net.Interface{c} return intfs, nil } From a3db444e801f3452fe86a61bfd69dbffcad1fca2 Mon Sep 17 00:00:00 2001 From: Subin M Date: Tue, 17 Mar 2015 07:09:28 +0530 Subject: [PATCH 4/4] adding log message for file not found --- pkg/util/util.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/util/util.go b/pkg/util/util.go index d59a77cd815ee..32132e42fde09 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -410,6 +410,7 @@ func ChooseHostInterface() (net.IP, error) { inFile, err := os.Open("/proc/net/route") if err != nil { if os.IsNotExist(err) { + glog.V(4).Infof("Unable to find /proc/net/route file: %v", err) return chooseHostInterfaceNativeGo(nw) } return nil, err