Skip to content

Commit

Permalink
Fix comments and add check in case of IPv6 only node
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>
  • Loading branch information
rbrtbnfgl committed Aug 4, 2022
1 parent b5f2344 commit c366ee0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/netutil/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func getIPFromInterface(ifaceName string) (string, error) {
if err != nil {
return "", errors.Wrapf(err, "unable to parse CIDR for interface %s", iface.Name)
}
// skipping if not ipv4
// if not IPv4 adding it on IPv6 list
if ip.To4() == nil {
if ip.IsGlobalUnicast() {
globalUnicastsIPv6 = append(globalUnicastsIPv6, ip.String())
Expand Down
9 changes: 6 additions & 3 deletions pkg/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ func GetHostnameAndIPs(name string, nodeIPs cli.StringSlice) (string, []net.IP,
return "", nil, err
}
ips = append(ips, hostIP)
hostIPv6, err := apinet.ResolveBindAddress(net.IPv6loopback)
if err == nil && !hostIPv6.Equal(hostIP) {
ips = append(ips, hostIPv6)
// If IPv6 it's an IPv6 only node
if hostIP.To4() != nil {
hostIPv6, err := apinet.ResolveBindAddress(net.IPv6loopback)
if err == nil && !hostIPv6.Equal(hostIP) {
ips = append(ips, hostIPv6)
}
}
} else {
var err error
Expand Down

0 comments on commit c366ee0

Please sign in to comment.