vrf: Fix testing for loopback coming from the address (#17372)

This commit is contained in:
Anis Eleuch
2023-06-07 17:53:05 +01:00
committed by GitHub
parent 442c50ff00
commit eba378e4a1

View File

@@ -73,6 +73,9 @@ func setTCPParametersFn(opts TCPOptions) func(network, address string, c syscall
_ = syscall.SetsockoptInt(fd, syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT, opts.UserTimeout)
if opts.Interface != "" {
if h, _, err := net.SplitHostPort(address); err == nil {
address = h
}
// Create socket on specific vrf device.
// To catch all kinds of special cases this filters specifically for loopback networks.
if ip := net.ParseIP(address); ip != nil && !ip.IsLoopback() {