From 8d5d5face5198b1024d85acbd497b5a0c6b6f4dc Mon Sep 17 00:00:00 2001
From: Paul Holzinger <pholzing@redhat.com>
Date: Mon, 26 Jul 2021 13:59:29 +0200
Subject: dual-stack network: fix duplicated subnet assignment

Make sure podman network create reads all subnets from existing cni configs
and not only the first one.

Fixes #11032

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
---
 libpod/network/network.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'libpod/network')

diff --git a/libpod/network/network.go b/libpod/network/network.go
index ed4e6388a..805988432 100644
--- a/libpod/network/network.go
+++ b/libpod/network/network.go
@@ -111,8 +111,10 @@ func allocatorToIPNets(networks []*allocator.Net) []*net.IPNet {
 		if len(network.IPAM.Ranges) > 0 {
 			// this is the new IPAM range style
 			// append each subnet from ipam the rangeset
-			for _, r := range network.IPAM.Ranges[0] {
-				nets = append(nets, newIPNetFromSubnet(r.Subnet))
+			for _, allocatorRange := range network.IPAM.Ranges {
+				for _, r := range allocatorRange {
+					nets = append(nets, newIPNetFromSubnet(r.Subnet))
+				}
 			}
 		} else {
 			//	 looks like the old, deprecated style
-- 
cgit v1.2.3-54-g00ecf