From edf0e918e32f4f109329881310b798f3b2c7defb Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 16 Dec 2020 20:28:07 +0100 Subject: Always add the default gateway to the cni config file `podman network create` should always add a gateway to the cni config. If no gateway is given use the first ip in the subnet. CNI does not require the gateway field but we need it because of network inspect. This worked with previous version but was dropped in Commit(e7a72d72fd59). Fixes #8748 Signed-off-by: Paul Holzinger --- libpod/network/netconflist.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libpod/network/netconflist.go') diff --git a/libpod/network/netconflist.go b/libpod/network/netconflist.go index d61b96ecb..af25ee59c 100644 --- a/libpod/network/netconflist.go +++ b/libpod/network/netconflist.go @@ -95,6 +95,10 @@ func NewIPAMLocalHostRange(subnet *net.IPNet, ipRange *net.IPNet, gw net.IP) ([] } if gw != nil { hostRange.Gateway = gw.String() + } else { + // Add first ip in subnet as gateway. It is not required + // by cni but should be included because of network inspect. + hostRange.Gateway = CalcGatewayIP(subnet).String() } ranges = append(ranges, hostRange) return ranges, nil -- cgit v1.2.3-54-g00ecf