Skip to content

Commit 920bfd4

Browse files
committed
fix mac build
netlink does not exist in mac systems meaning that mac users will get an error when trying to build or run tests to avoid that we can use unix.AF_INET instread of netlink family Looking at netlink code the original definition is the same Signed-off-by: Michael Filanov <[email protected]>
1 parent 792c169 commit 920bfd4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/onsi/gomega v1.36.3
1212
github.com/vishvananda/netlink v1.3.0
1313
go.uber.org/multierr v1.11.0
14+
golang.org/x/sys v0.31.0
1415
k8s.io/api v0.32.3
1516
k8s.io/apimachinery v0.32.3
1617
k8s.io/client-go v0.32.3
@@ -81,7 +82,6 @@ require (
8182
golang.org/x/net v0.37.0 // indirect
8283
golang.org/x/oauth2 v0.25.0 // indirect
8384
golang.org/x/sync v0.12.0 // indirect
84-
golang.org/x/sys v0.31.0 // indirect
8585
golang.org/x/term v0.30.0 // indirect
8686
golang.org/x/text v0.23.0 // indirect
8787
golang.org/x/time v0.7.0 // indirect

pkg/lib/netlink/netlink.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net"
66

77
"github.com/vishvananda/netlink"
8+
"golang.org/x/sys/unix"
89
)
910

1011
func New() NetlinkLib {
@@ -56,7 +57,7 @@ func (w *libWrapper) IsLinkAdminStateUp(link Link) bool {
5657

5758
// IPv4Adresses return the IPv4 addresses of a link
5859
func (w *libWrapper) IPv4Addresses(link Link) ([]netlink.Addr, error) {
59-
return netlink.AddrList(link, netlink.FAMILY_V4)
60+
return netlink.AddrList(link, unix.AF_INET)
6061
}
6162

6263
// AddrDel delete an IP address from a link
@@ -94,5 +95,5 @@ func (w *libWrapper) GetRouteSrc(dst string) (string, error) {
9495
}
9596

9697
func (w *libWrapper) NeighList(linkIndex int) ([]netlink.Neigh, error) {
97-
return netlink.NeighList(linkIndex, netlink.FAMILY_V4)
98+
return netlink.NeighList(linkIndex, unix.AF_INET)
9899
}

0 commit comments

Comments
 (0)