mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00

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>
20 lines
420 B
Go
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
|
|
}
|