From ced434053d9b5bf280de476b3a93988a3eabb78b Mon Sep 17 00:00:00 2001 From: pengbinbin Date: Sat, 3 Jul 2021 13:42:27 +0800 Subject: [PATCH] add judge before use slices's index --- pkg/daemon/controller.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/daemon/controller.go b/pkg/daemon/controller.go index 47cd74f7992..f7b3f813487 100644 --- a/pkg/daemon/controller.go +++ b/pkg/daemon/controller.go @@ -475,7 +475,9 @@ func (c *Controller) getPolicyRouting(subnet *kubeovnv1.Subnet) ([]netlink.Rule, } else { for i := range protocols { rule.Family, _ = util.ProtocolToFamily(protocols[i]) - _, rule.Src, _ = net.ParseCIDR(cidr[i]) + if len(cidr) == len(protocols) { + _, rule.Src, _ = net.ParseCIDR(cidr[i]) + } rules = append(rules, *rule) } }