From bbde806641d1c58cf16113af812904feeda3376d Mon Sep 17 00:00:00 2001 From: Tuetuopay Date: Mon, 22 Apr 2024 11:09:02 +0200 Subject: [PATCH] evpn: fix quadratic mac-mobility handling for gRPC routes The gRPC code paths uses different functions than the BGP code path. Thus is did not receive the fix for the mac mobility handling. Fixes: c393f43 ("evpn: fix quadratic evpn mac-mobility handling") --- internal/pkg/table/table.go | 8 ++++++-- internal/pkg/table/table_manager.go | 2 +- pkg/server/server.go | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/pkg/table/table.go b/internal/pkg/table/table.go index 83cab0ef8..5862aba6e 100644 --- a/internal/pkg/table/table.go +++ b/internal/pkg/table/table.go @@ -480,7 +480,7 @@ func (t *Table) GetKnownPathList(id string, as uint32) []*Path { return paths } -func (t *Table) GetKnownPathListWithMac(id string, as uint32, mac net.HardwareAddr) []*Path { +func (t *Table) GetKnownPathListWithMac(id string, as uint32, mac net.HardwareAddr, onlyBest bool) []*Path { var paths []*Path if rds, ok := t.macIndex[*(*string)(unsafe.Pointer(&mac))]; ok { for rd := range rds { @@ -490,7 +490,11 @@ func (t *Table) GetKnownPathListWithMac(id string, as uint32, mac net.HardwareAd copy(b[9:15], mac) key := *(*string)(unsafe.Pointer(&b)) if dst, ok := t.destinations[key]; ok { - paths = append(paths, dst.GetKnownPathList(id, as)...) + if onlyBest { + paths = append(paths, dst.GetBestPath(id, as)) + } else { + paths = append(paths, dst.GetKnownPathList(id, as)...) + } } } } diff --git a/internal/pkg/table/table_manager.go b/internal/pkg/table/table_manager.go index 3b4127a5e..dca893e5b 100644 --- a/internal/pkg/table/table_manager.go +++ b/internal/pkg/table/table_manager.go @@ -329,7 +329,7 @@ func (manager *TableManager) GetPathList(id string, as uint32, rfList []bgp.Rout func (manager *TableManager) GetPathListWithMac(id string, as uint32, rfList []bgp.RouteFamily, mac net.HardwareAddr) []*Path { var paths []*Path for _, t := range manager.tables(rfList...) { - paths = append(paths, t.GetKnownPathListWithMac(id, as, mac)...) + paths = append(paths, t.GetKnownPathListWithMac(id, as, mac, false)...) } return paths } diff --git a/pkg/server/server.go b/pkg/server/server.go index eb6338160..18a734f17 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -2121,7 +2121,8 @@ func (s *BgpServer) fixupApiPath(vrfId string, pathList []*table.Path) error { switch r := nlri.RouteTypeData.(type) { case *bgp.EVPNMacIPAdvertisementRoute: // MAC Mobility Extended Community - paths := s.globalRib.GetBestPathList(table.GLOBAL_RIB_NAME, 0, []bgp.RouteFamily{bgp.RF_EVPN}) + mac := path.GetNlri().(*bgp.EVPNNLRI).RouteTypeData.(*bgp.EVPNMacIPAdvertisementRoute).MacAddress + paths := s.globalRib.GetPathListWithMac(table.GLOBAL_RIB_NAME, 0, []bgp.RouteFamily{bgp.RF_EVPN}, mac) if m := getMacMobilityExtendedCommunity(r.ETag, r.MacAddress, paths); m != nil { pm := getMacMobilityExtendedCommunity(r.ETag, r.MacAddress, []*table.Path{path}) if pm == nil {