Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove netlink package dependency from the ip package #10885

Merged
merged 1 commit into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/datapath/linux/node_addressing.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
// code should really move into this package.

func listLocalAddresses(family int) ([]net.IP, error) {
ipsToExclude := ip.GetExcludedIPs()
ipsToExclude := node.GetExcludedIPs()
addrs, err := netlink.AddrList(nil, family)
if err != nil {
return nil, err
Expand Down
9 changes: 0 additions & 9 deletions pkg/ip/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,8 @@ func initPrivatePrefixes() {
}
}

var excludedIPs []net.IP

func init() {
initPrivatePrefixes()
initExcludedIPs()
}

// IsExcluded returns whether a given IP is must be excluded
Expand All @@ -784,12 +781,6 @@ func IsPublicAddr(ip net.IP) bool {
return true
}

// GetExcludedIPs returns a list of IPs from netdevices that Cilium
// needs to exclude to operate
func GetExcludedIPs() []net.IP {
return excludedIPs
}

// GetCIDRPrefixesFromIPs returns all of the ips as a slice of *net.IPNet.
func GetCIDRPrefixesFromIPs(ips []net.IP) []*net.IPNet {
if len(ips) == 0 {
Expand Down
14 changes: 11 additions & 3 deletions pkg/ip/ip_darwin.go → pkg/node/ip.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2019 Authors of Cilium
// Copyright 2017-2020 Authors of Cilium
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,6 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package ip
package node

func initExcludedIPs() {}
import "net"

var excludedIPs []net.IP

// GetExcludedIPs returns a list of IPs from netdevices that Cilium
// needs to exclude to operate
func GetExcludedIPs() []net.IP {
return excludedIPs
}
6 changes: 5 additions & 1 deletion pkg/ip/ip_linux.go → pkg/node/ip_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package ip
package node

import (
"strings"

"github.com/vishvananda/netlink"
)

func init() {
initExcludedIPs()
}

func initExcludedIPs() {
// We exclude below bad device prefixes from address selection ...
prefixes := []string{
Expand Down
4 changes: 2 additions & 2 deletions pkg/node/node_address_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2018 Authors of Cilium
// Copyright 2016-2020 Authors of Cilium
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,7 +36,7 @@ func firstGlobalAddr(intf string, preferredIP net.IP, family int) (net.IP, error
var ipLen int
var err error

ipsToExclude := ip.GetExcludedIPs()
ipsToExclude := GetExcludedIPs()
linkScopeMax := unix.RT_SCOPE_UNIVERSE
if family == netlink.FAMILY_V4 {
ipLen = 4
Expand Down