Merge pull request #57429 from m1093782566/syscall-unix

Automatic merge from submit-queue (batch tested with PRs 57292, 56274, 57435, 57438, 57429). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

replace syscall with sys/unix pkg in ipvs/netlink call

**What this PR does / why we need it**:

This PR replaces syscall with sys/unix pkg in ipvs/netlink call as the Go doc for syscall says:

	NOTE: This package is locked down.
	Code outside the standard Go repository should be migrated to use the corresponding package in the golang.org/x/sys repository.
	That is also where updates required by new systems or versions should be applied.
	See https://golang.org/s/go1.4-syscall for more information.

**Which issue(s) this PR fixes**:
Fixes  #57430

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```

/assign @thockin @brendandburns
pull/6/head
Kubernetes Submit Queue 2017-12-20 22:16:51 -08:00 committed by GitHub
commit 263fa7856a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 11 deletions

View File

@ -75,6 +75,7 @@ go_library(
] + select({
"@io_bazel_rules_go//go/platform:linux_amd64": [
"//vendor/github.com/vishvananda/netlink:go_default_library",
"//vendor/golang.org/x/sys/unix:go_default_library",
],
"//conditions:default": [],
}),

View File

@ -21,17 +21,11 @@ package ipvs
import (
"fmt"
"net"
"syscall"
// TODO: replace syscall with golang.org/x/sys/unix?
// The Go doc for syscall says:
// NOTE: This package is locked down.
// Code outside the standard Go repository should be migrated to use the corresponding package in the golang.org/x/sys repository.
// That is also where updates required by new systems or versions should be applied.
// See https://golang.org/s/go1.4-syscall for more information.
"k8s.io/apimachinery/pkg/util/sets"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
)
type netlinkHandle struct {
@ -55,7 +49,7 @@ func (h *netlinkHandle) EnsureAddressBind(address, devName string) (exist bool,
}
if err := h.AddrAdd(dev, &netlink.Addr{IPNet: netlink.NewIPNet(addr)}); err != nil {
// "EEXIST" will be returned if the address is already bound to device
if err == syscall.Errno(syscall.EEXIST) {
if err == unix.EEXIST {
return true, nil
}
return false, fmt.Errorf("error bind address: %s to interface: %s, err: %v", address, devName, err)
@ -136,9 +130,9 @@ func (h *netlinkHandle) GetLocalAddresses(filterDev string) (sets.String, error)
}
routeFilter := &netlink.Route{
Table: syscall.RT_TABLE_LOCAL,
Type: syscall.RTN_LOCAL,
Protocol: syscall.RTPROT_KERNEL,
Table: unix.RT_TABLE_LOCAL,
Type: unix.RTN_LOCAL,
Protocol: unix.RTPROT_KERNEL,
}
filterMask := netlink.RT_FILTER_TABLE | netlink.RT_FILTER_TYPE | netlink.RT_FILTER_PROTOCOL