From 2c2cd2bec281c3cabb51dc59511b43f00378f40a Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 22 Nov 2017 14:35:01 +0900 Subject: table: add attribute hash value to Path structure This is for batching paths into one bgp message. Signed-off-by: FUJITA Tomonori --- table/table_manager.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'table/table_manager.go') diff --git a/table/table_manager.go b/table/table_manager.go index 0331cc70..b94b546e 100644 --- a/table/table_manager.go +++ b/table/table_manager.go @@ -21,6 +21,7 @@ import ( "net" "time" + farm "github.com/dgryski/go-farm" "github.com/osrg/gobgp/packet/bgp" log "github.com/sirupsen/logrus" ) @@ -68,9 +69,21 @@ func ProcessMessage(m *bgp.BGPMessage, peerInfo *PeerInfo, timestamp time.Time) if reach != nil { listLen += len(reach.Value) } + + var hash uint32 + if len(adds) > 0 || reach != nil { + total := bytes.NewBuffer(make([]byte, 0)) + for _, a := range attrs { + b, _ := a.Serialize() + total.Write(b) + } + hash = farm.Hash32(total.Bytes()) + } + pathList := make([]*Path, 0, listLen) for _, nlri := range adds { p := NewPath(peerInfo, nlri, false, attrs, timestamp, false) + p.SetHash(hash) pathList = append(pathList, p) } if reach != nil { @@ -81,6 +94,7 @@ func ProcessMessage(m *bgp.BGPMessage, peerInfo *PeerInfo, timestamp time.Time) for _, nlri := range reach.Value { p := NewPath(peerInfo, nlri, false, reachAttrs, timestamp, false) + p.SetHash(hash) pathList = append(pathList, p) } } -- cgit v1.2.3