Commit 8a58f62f authored by Dan Williams's avatar Dan Williams

proxy/userspace: honor listen IP address as host IP if given

Allows the proxier to be used on an interface that's not the default route, otherwise hostIP gets set to the default route interface even if that's not what the user intended. If listen IP isn't given, falls back to previous behavior.
parent a9bf4410
...@@ -166,9 +166,15 @@ func NewCustomProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptab ...@@ -166,9 +166,15 @@ func NewCustomProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptab
return nil, ErrProxyOnLocalhost return nil, ErrProxyOnLocalhost
} }
hostIP, err := utilnet.ChooseHostInterface() // If listenIP is given, assume that is the intended host IP. Otherwise
if err != nil { // try to find a suitable host IP address from network interfaces.
return nil, fmt.Errorf("failed to select a host interface: %v", err) var err error
hostIP := listenIP
if hostIP.Equal(net.IPv4zero) {
hostIP, err = utilnet.ChooseHostInterface()
if err != nil {
return nil, fmt.Errorf("failed to select a host interface: %v", err)
}
} }
err = setRLimit(64 * 1000) err = setRLimit(64 * 1000)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment