summaryrefslogtreecommitdiffhomepage
path: root/table/table_manager.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-11-22 14:35:01 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-11-23 21:21:34 +0900
commit2c2cd2bec281c3cabb51dc59511b43f00378f40a (patch)
treee2b0193b979aa6ecaa07d110ca2994b5fa061cb2 /table/table_manager.go
parent3730a171c41a8bc9a62e72bab5f8906f37a0ac7c (diff)
table: add attribute hash value to Path structure
This is for batching paths into one bgp message. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/table_manager.go')
-rw-r--r--table/table_manager.go14
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)
}
}