diff options
Diffstat (limited to 'table/table_manager.go')
-rw-r--r-- | table/table_manager.go | 14 |
1 files changed, 14 insertions, 0 deletions
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) } } |