diff --git a/route/bgp_path.go b/route/bgp_path.go index c142103f5ef94fee674e13cd89369cd655b43b2e..bf95c53943405e05002764f7aa0719d133debdca 100644 --- a/route/bgp_path.go +++ b/route/bgp_path.go @@ -5,6 +5,8 @@ import ( "fmt" "strings" + "github.com/taktv6/tflow2/convert" + bnet "github.com/bio-routing/bio-rd/net" "github.com/bio-routing/bio-rd/protocols/bgp/types" ) @@ -252,7 +254,7 @@ func (b *BGPPath) Print() string { ret += fmt.Sprintf("\t\tLargeCommunities: %v\n", b.LargeCommunities) if b.OriginatorID != 0 { - oid := uint32To4Byte(b.OriginatorID) + oid := convert.Uint32Byte(b.OriginatorID) ret += fmt.Sprintf("\t\tOriginatorID: %d.%d.%d.%d\n", oid[0], oid[1], oid[2], oid[3]) } if b.ClusterList != nil { @@ -330,7 +332,7 @@ func (b *BGPPath) Copy() *BGPPath { // ComputeHash computes an hash over all attributes of the path func (b *BGPPath) ComputeHash() string { - s := fmt.Sprintf("%s\t%d\t%v\t%d\t%d\t%v\t%d\t%s\t%v\t%v\t%d", + s := fmt.Sprintf("%s\t%d\t%v\t%d\t%d\t%v\t%d\t%s\t%v\t%v\t%d\t%d\t%v", b.NextHop, b.LocalPref, b.ASPath, @@ -340,10 +342,10 @@ func (b *BGPPath) ComputeHash() string { b.BGPIdentifier, b.Source, b.Communities, - b.OriginatorID, - b.ClusterList, b.LargeCommunities, - b.PathIdentifier) + b.PathIdentifier, + b.OriginatorID, + b.ClusterList) return fmt.Sprintf("%x", sha256.Sum256([]byte(s))) } @@ -362,7 +364,7 @@ func (b *BGPPath) CommunitiesString() string { func (b *BGPPath) ClusterListString() string { str := "" for _, cid := range b.ClusterList { - octes := uint32To4Byte(cid) + octes := convert.Uint32Byte(cid) str += fmt.Sprintf("%d.%d.%d.%d ", octes[0], octes[1], octes[2], octes[3]) } diff --git a/route/bgp_test.go b/route/bgp_test.go index 760306af6c0006479fd2c8c401581b57eff5ab48..dfb42f8dae70d6194d8f122aa48416e3aa101856 100644 --- a/route/bgp_test.go +++ b/route/bgp_test.go @@ -36,9 +36,9 @@ func TestComputeHash(t *testing.T) { Source: bnet.IPv4(4), } - assert.Equal(t, "1058916ff3e6a51c7d8a47945d13fc3fcd8ee578a6d376505f46d58979b30fae", p.ComputeHash()) + assert.Equal(t, "5907ed8960ccc14eed8f1a34a8eb3e6c82a8dd947d6cbf67eb58ca292f4588d5", p.ComputeHash()) p.LocalPref = 150 - assert.NotEqual(t, "1058916ff3e6a51c7d8a47945d13fc3fcd8ee578a6d376505f46d58979b30fae", p.ComputeHash()) + assert.NotEqual(t, "5907ed8960ccc14eed8f1a34a8eb3e6c82a8dd947d6cbf67eb58ca292f4588d5", p.ComputeHash()) }