diff --git a/pkg/daemon/gateway_linux.go b/pkg/daemon/gateway_linux.go index 0b9cc4ba504f..dc667409b91e 100644 --- a/pkg/daemon/gateway_linux.go +++ b/pkg/daemon/gateway_linux.go @@ -810,8 +810,6 @@ func (c *Controller) reconcileTProxyIPTableRules(protocol string) error { continue } - hostIP := pod.Status.HostIP - subnet, err := c.subnetsLister.Get(subnetName) if err != nil { err = fmt.Errorf("failed to get subnet '%s', err: %v", subnetName, err) diff --git a/pkg/tproxy/tproxy_tcp.go b/pkg/tproxy/tproxy_tcp.go index 2f0a8c527f43..e7ef9f4dc295 100644 --- a/pkg/tproxy/tproxy_tcp.go +++ b/pkg/tproxy/tproxy_tcp.go @@ -5,7 +5,7 @@ import ( "net" "os" "strings" - "syscall" + sys "syscall" ) // Listener describes a TCP Listener @@ -70,12 +70,12 @@ func listenTCP(device, network string, laddr *net.TCPAddr) (net.Listener, error) defer fileDescriptorSource.Close() if device != "" { - if err = syscall.BindToDevice(int(fileDescriptorSource.Fd()), device); err != nil { + if err = sys.BindToDevice(int(fileDescriptorSource.Fd()), device); err != nil { return nil, &net.OpError{Op: "listen", Net: network, Source: nil, Addr: laddr, Err: fmt.Errorf("set socket option: SO_BINDTODEVICE(%s): %s", device, err)} } } - if err = syscall.SetsockoptInt(int(fileDescriptorSource.Fd()), syscall.SOL_IP, syscall.IP_TRANSPARENT, 1); err != nil { + if err = sys.SetsockoptInt(int(fileDescriptorSource.Fd()), sys.SOL_IP, sys.IP_TRANSPARENT, 1); err != nil { return nil, &net.OpError{Op: "listen", Net: network, Source: nil, Addr: laddr, Err: fmt.Errorf("set socket option: IP_TRANSPARENT: %s", err)} } @@ -96,19 +96,19 @@ type Conn struct { // tcpAddToSockerAddr will convert a TCPAddr // into a Sockaddr that may be used when // connecting and binding sockets -func tcpAddrToSocketAddr(addr *net.TCPAddr) (syscall.Sockaddr, error) { +func tcpAddrToSocketAddr(addr *net.TCPAddr) (sys.Sockaddr, error) { switch { case addr.IP.To4() != nil: ip := [4]byte{} copy(ip[:], addr.IP.To4()) - return &syscall.SockaddrInet4{Addr: ip, Port: addr.Port}, nil + return &sys.SockaddrInet4{Addr: ip, Port: addr.Port}, nil default: ip := [16]byte{} copy(ip[:], addr.IP.To16()) - return &syscall.SockaddrInet6{Addr: ip, Port: addr.Port}, nil + return &sys.SockaddrInet6{Addr: ip, Port: addr.Port}, nil } } @@ -118,16 +118,16 @@ func tcpAddrToSocketAddr(addr *net.TCPAddr) (syscall.Sockaddr, error) { func tcpAddrFamily(net string, laddr, raddr *net.TCPAddr) int { switch net[len(net)-1] { case '4': - return syscall.AF_INET + return sys.AF_INET case '6': - return syscall.AF_INET6 + return sys.AF_INET6 } if (laddr == nil || laddr.IP.To4() != nil) && (raddr == nil || laddr.IP.To4() != nil) { - return syscall.AF_INET + return sys.AF_INET } - return syscall.AF_INET6 + return sys.AF_INET6 } // DialTCP will open a @@ -152,41 +152,41 @@ func dialTCP(device string, laddr, raddr *net.TCPAddr, dontAssumeRemote bool, is return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("build local socket address: %s", err)} } - fileDescriptor, err := syscall.Socket(tcpAddrFamily("tcp", raddr, laddr), syscall.SOCK_STREAM, syscall.IPPROTO_TCP) + fileDescriptor, err := sys.Socket(tcpAddrFamily("tcp", raddr, laddr), sys.SOCK_STREAM, sys.IPPROTO_TCP) if err != nil { return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("socket open: %s", err)} } if device != "" { - if err = syscall.BindToDevice(int(fileDescriptor), device); err != nil { + if err = sys.BindToDevice(int(fileDescriptor), device); err != nil { return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("set socket option: SO_BINDTODEVICE(%s): %s", device, err)} } } - if err = syscall.SetsockoptInt(fileDescriptor, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1); err != nil { - syscall.Close(fileDescriptor) + if err = sys.SetsockoptInt(fileDescriptor, sys.SOL_SOCKET, sys.SO_REUSEADDR, 1); err != nil { + sys.Close(fileDescriptor) return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("set socket option: SO_REUSEADDR: %s", err)} } - if err = syscall.SetsockoptInt(fileDescriptor, syscall.SOL_IP, syscall.IP_TRANSPARENT, 1); err != nil { - syscall.Close(fileDescriptor) + if err = sys.SetsockoptInt(fileDescriptor, sys.SOL_IP, sys.IP_TRANSPARENT, 1); err != nil { + sys.Close(fileDescriptor) return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("set socket option: IP_TRANSPARENT: %s", err)} } - if err = syscall.SetNonblock(fileDescriptor, isnonblocking); err != nil { - syscall.Close(fileDescriptor) + if err = sys.SetNonblock(fileDescriptor, isnonblocking); err != nil { + sys.Close(fileDescriptor) return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("set socket option: SO_NONBLOCK: %s", err)} } if !dontAssumeRemote { - if err = syscall.Bind(fileDescriptor, localSocketAddress); err != nil { - syscall.Close(fileDescriptor) + if err = sys.Bind(fileDescriptor, localSocketAddress); err != nil { + sys.Close(fileDescriptor) return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("socket bind: %s", err)} } } - if err = syscall.Connect(fileDescriptor, remoteSocketAddress); err != nil && !strings.Contains(err.Error(), "operation now in progress") { - syscall.Close(fileDescriptor) + if err = sys.Connect(fileDescriptor, remoteSocketAddress); err != nil && !strings.Contains(err.Error(), "operation now in progress") { + sys.Close(fileDescriptor) return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("socket connect: %s", err)} } @@ -195,7 +195,7 @@ func dialTCP(device string, laddr, raddr *net.TCPAddr, dontAssumeRemote bool, is remoteConn, err := net.FileConn(fdFile) if err != nil { - syscall.Close(fileDescriptor) + sys.Close(fileDescriptor) return nil, &net.OpError{Op: "dial", Err: fmt.Errorf("convert file descriptor to connection: %s", err)} } diff --git a/test/e2e/kube-ovn/pod/pod.go b/test/e2e/kube-ovn/pod/pod.go index 0a95679c7334..3bb7a5315529 100644 --- a/test/e2e/kube-ovn/pod/pod.go +++ b/test/e2e/kube-ovn/pod/pod.go @@ -171,7 +171,7 @@ var _ = framework.Describe("[group:pod]", func() { InitialDelaySeconds: 10, } - pod = podClient.Create(pod) + _ = podClient.Create(pod) time.Sleep(11 * time.Second) pod = podClient.GetPod(podName) @@ -222,7 +222,7 @@ var _ = framework.Describe("[group:pod]", func() { InitialDelaySeconds: 10, } - pod = podClient.Create(pod) + _ = podClient.Create(pod) time.Sleep(11 * time.Second) pod = podClient.GetPod(podName)