Files
Antonio Ojea 07e3f1bba9 podman support for IPv6 networks
podman containers using IPv6 were missing the default route, breaking
deployments trying to use them.

The problem is that the default route was hardcoded to IPv4, this
takes into consideration the podman subnet IP family to generate
the corresponding default route.

Signed-off-by: Antonio Ojea <aojea@redhat.com>
2020-08-15 12:11:01 +02:00

20 lines
420 B
Go

package network
import (
"net"
"github.com/containernetworking/plugins/pkg/ip"
)
// CalcGatewayIP takes a network and returns the first IP in it.
func CalcGatewayIP(ipn *net.IPNet) net.IP {
// taken from cni bridge plugin as it is not exported
nid := ipn.IP.Mask(ipn.Mask)
return ip.NextIP(nid)
}
// IsIPv6 returns if netIP is IPv6.
func IsIPv6(netIP net.IP) bool {
return netIP != nil && netIP.To4() == nil
}