Skip to content

Commit

Permalink
Fix link prefix and TaaS used as L3 config
Browse files Browse the repository at this point in the history
  • Loading branch information
chdxD1 committed Dec 20, 2023
1 parent 49d3a0e commit 2f2f18b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/nl/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/nl/taas.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
20 changes: 12 additions & 8 deletions pkg/reconciler/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,37 @@ func (r *reconcile) reconcileLayer3(l3vnis []networkv1alpha1.VRFRouteConfigurati

vrfFromTaas := createVrfFromTaaS(taas)

vrfConfigs := []frr.VRFConfiguration{}
var allConfigs []frr.VRFConfiguration
var l3Configs []frr.VRFConfiguration
var 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
}

// 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
}
Expand Down

0 comments on commit 2f2f18b

Please sign in to comment.