From 3fbc7fdc65d04689b565d76617f67f9e1a1d771f Mon Sep 17 00:00:00 2001 From: Istvan Ruzman Date: Tue, 2 Jul 2024 14:30:23 +0200 Subject: [PATCH] fix: set AddPathLen for BGP Routes when received via grpc (#471) --- route/bgp_path.go | 4 +++- route/bgp_path_test.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/route/bgp_path.go b/route/bgp_path.go index 598f63f9..46a06c9b 100644 --- a/route/bgp_path.go +++ b/route/bgp_path.go @@ -125,6 +125,7 @@ func (b *BGPPath) ToProto() *api.BGPPath { // BGPPathFromProtoBGPPath converts a proto BGPPath to BGPPath func BGPPathFromProtoBGPPath(pb *api.BGPPath, dedup bool) *BGPPath { + asPath := types.ASPathFromProtoASPath(pb.AsPath) p := &BGPPath{ BGPPathA: &BGPPathA{ NextHop: bnet.IPFromProtoIP(pb.NextHop).Ptr(), @@ -138,7 +139,8 @@ func BGPPathFromProtoBGPPath(pb *api.BGPPath, dedup bool) *BGPPath { OnlyToCustomer: pb.OnlyToCustomer, }, PathIdentifier: pb.PathIdentifier, - ASPath: types.ASPathFromProtoASPath(pb.AsPath), + ASPath: asPath, + ASPathLen: asPath.Length(), BMPPostPolicy: pb.BmpPostPolicy, } diff --git a/route/bgp_path_test.go b/route/bgp_path_test.go index 83235143..221a164d 100644 --- a/route/bgp_path_test.go +++ b/route/bgp_path_test.go @@ -75,6 +75,7 @@ func TestBGPPathFromProtoBGPPath(t *testing.T) { }, }, }, + ASPathLen: 2, Communities: &types.Communities{100, 200, 300}, LargeCommunities: &types.LargeCommunities{