From c55e97aefb2651a9065e16c1f636e1281585d2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Thu, 5 Sep 2024 13:56:53 +0800 Subject: [PATCH] ci: bump golangci-lint to v1.60.3 (#4474) Signed-off-by: zhangzujian --- .github/workflows/build-x86-image.yaml | 2 +- pkg/daemon/ovs_linux.go | 9 ++++++--- pkg/speaker/utils.go | 2 +- pkg/tproxy/tproxy_tcp_linux.go | 5 +++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-x86-image.yaml b/.github/workflows/build-x86-image.yaml index 9787017d1bf..a43c4fdf96f 100644 --- a/.github/workflows/build-x86-image.yaml +++ b/.github/workflows/build-x86-image.yaml @@ -23,7 +23,7 @@ concurrency: env: GO_VERSION: '' KIND_VERSION: v0.24.0 - GOLANGCI_LINT_VERSION: 'v1.60.1' + GOLANGCI_LINT_VERSION: 'v1.60.3' HELM_VERSION: v3.15.4 SUBMARINER_VERSION: '0.18.0' diff --git a/pkg/daemon/ovs_linux.go b/pkg/daemon/ovs_linux.go index efec4b27056..40b1f154964 100644 --- a/pkg/daemon/ovs_linux.go +++ b/pkg/daemon/ovs_linux.go @@ -256,7 +256,8 @@ func (csh cniServerHandler) releaseVf(podName, podNamespace, podNetns, ifName, n ifName, vfName, podDesc, err) } // move VF device to host netns - if err = netlink.LinkSetNsFd(link, int(hostNS.Fd())); err != nil { + fd := int(netns.Fd()) // #nosec G115 + if err = netlink.LinkSetNsFd(link, fd); err != nil { return fmt.Errorf("failed to move container interface %s back to host namespace %s: %w", ifName, podDesc, err) } @@ -407,7 +408,8 @@ func (csh cniServerHandler) configureContainerNic(podName, podNamespace, nicName return nil, err } - if err = netlink.LinkSetNsFd(containerLink, int(netns.Fd())); err != nil { + fd := int(netns.Fd()) // #nosec G115 + if err = netlink.LinkSetNsFd(containerLink, fd); err != nil { return nil, fmt.Errorf("failed to move link to netns: %w", err) } @@ -791,7 +793,8 @@ func configureNodeGwNic(portName, ip, gw string, macAddr net.HardwareAddr, mtu i } gwLink, err := netlink.LinkByName(util.NodeGwNic) if err == nil { - if err = netlink.LinkSetNsFd(gwLink, int(gwNS.Fd())); err != nil { + fd := int(gwNS.Fd()) // #nosec G115 + if err = netlink.LinkSetNsFd(gwLink, fd); err != nil { klog.Errorf("failed to move link into netns: %v", err) return err } diff --git a/pkg/speaker/utils.go b/pkg/speaker/utils.go index 22e9e6b7b1b..7778a84d5a5 100644 --- a/pkg/speaker/utils.go +++ b/pkg/speaker/utils.go @@ -86,7 +86,7 @@ func parseRoute(route string) (string, uint32, error) { if err != nil { return "", 0, err } - prefixLen = uint32(intLen) + prefixLen = uint32(intLen) // #nosec G115 } return prefix, prefixLen, nil } diff --git a/pkg/tproxy/tproxy_tcp_linux.go b/pkg/tproxy/tproxy_tcp_linux.go index 90cd54e786f..bab981dab45 100644 --- a/pkg/tproxy/tproxy_tcp_linux.go +++ b/pkg/tproxy/tproxy_tcp_linux.go @@ -81,13 +81,14 @@ func listenTCP(device, network string, laddr *net.TCPAddr) (net.Listener, error) } }() + fd := int(fileDescriptorSource.Fd()) // #nosec G115 if device != "" { - if err = syscall.BindToDevice(int(fileDescriptorSource.Fd()), device); err != nil { + if err = syscall.BindToDevice(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): %w", device, err)} } } - if err = syscall.SetsockoptInt(int(fileDescriptorSource.Fd()), syscall.SOL_IP, syscall.IP_TRANSPARENT, 1); err != nil { + if err = syscall.SetsockoptInt(fd, syscall.SOL_IP, syscall.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: %w", err)} }