From 669c262435278241f05f5ff8481ace8eb30c6879 Mon Sep 17 00:00:00 2001 From: Christopher Dziomba Date: Wed, 20 Dec 2023 17:09:04 +0100 Subject: [PATCH] Fix link prefix and TaaS used as L3 config --- pkg/nl/list.go | 2 +- pkg/nl/taas.go | 6 +++--- pkg/reconciler/layer3.go | 20 ++++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pkg/nl/list.go b/pkg/nl/list.go index 927eb54b..34576a4f 100644 --- a/pkg/nl/list.go +++ b/pkg/nl/list.go @@ -211,7 +211,7 @@ func (*NetlinkManager) ListTaas() ([]TaasInformation, error) { } info := TaasInformation{ - Name: link.Attrs().Name[3:], + Name: link.Attrs().Name, Table: int(link.(*netlink.Vrf).Table), } diff --git a/pkg/nl/taas.go b/pkg/nl/taas.go index 84dfb7d0..bacd35e6 100644 --- a/pkg/nl/taas.go +++ b/pkg/nl/taas.go @@ -8,12 +8,12 @@ type TaasInformation struct { } func (n *NetlinkManager) CreateTaas(info TaasInformation) error { - _, err := n.createVRF(taasVrfPrefix+info.Name, info.Table) + _, err := n.createVRF(info.Name, info.Table) if err != nil { return fmt.Errorf("error creating VRF for TaaS: %w", err) } - err = n.setUp(taasVrfPrefix + info.Name) + err = n.setUp(info.Name) if err != nil { return fmt.Errorf("error set VRF up for TaaS: %w", err) } @@ -22,7 +22,7 @@ func (n *NetlinkManager) CreateTaas(info TaasInformation) error { } func (n *NetlinkManager) CleanupTaas(info TaasInformation) error { - err := n.deleteLink(taasVrfPrefix + info.Name) + err := n.deleteLink(info.Name) if err != nil { return fmt.Errorf("error deleting VRF for TaaS: %w", err) } diff --git a/pkg/reconciler/layer3.go b/pkg/reconciler/layer3.go index bea52d17..3a4f86f7 100644 --- a/pkg/reconciler/layer3.go +++ b/pkg/reconciler/layer3.go @@ -47,25 +47,29 @@ func (r *reconcile) reconcileLayer3(l3vnis []networkv1alpha1.VRFRouteConfigurati vrfFromTaas := createVrfFromTaaS(taas) - vrfConfigs := []frr.VRFConfiguration{} + allConfigs := []frr.VRFConfiguration{} + l3Configs := []frr.VRFConfiguration{} + taasConfigs := []frr.VRFConfiguration{} for key := range vrfConfigMap { - vrfConfigs = append(vrfConfigs, vrfConfigMap[key]) + allConfigs = append(allConfigs, vrfConfigMap[key]) + l3Configs = append(l3Configs, vrfConfigMap[key]) } for key := range vrfFromTaas { - vrfConfigs = append(vrfConfigs, vrfFromTaas[key]) + allConfigs = append(allConfigs, vrfFromTaas[key]) + taasConfigs = append(taasConfigs, vrfConfigMap[key]) } - sort.SliceStable(vrfConfigs, func(i, j int) bool { - return vrfConfigs[i].VNI < vrfConfigs[j].VNI + sort.SliceStable(allConfigs, func(i, j int) bool { + return allConfigs[i].VNI < allConfigs[j].VNI }) - created, err := r.reconcileL3Netlink(vrfConfigs) + created, err := r.reconcileL3Netlink(l3Configs) if err != nil { r.Logger.Error(err, "error reconciling Netlink") return err } - err = r.reconcileTaasNetlink(vrfConfigs) + err = r.reconcileTaasNetlink(taasConfigs) if err != nil { return err } @@ -73,7 +77,7 @@ func (r *reconcile) reconcileLayer3(l3vnis []networkv1alpha1.VRFRouteConfigurati // We wait here for two seconds to let FRR settle after updating netlink devices time.Sleep(defaultSleep) - err = r.configureFRR(vrfConfigs) + err = r.configureFRR(allConfigs) if err != nil { return err }