summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Gopkg.lock8
-rw-r--r--api/grpc_server.go13
-rw-r--r--table/path.go9
-rw-r--r--table/table_manager.go14
4 files changed, 43 insertions, 1 deletions
diff --git a/Gopkg.lock b/Gopkg.lock
index 2a3fff10..5e06c299 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -20,6 +20,12 @@
version = "v1.1.0"
[[projects]]
+ branch = "master"
+ name = "github.com/dgryski/go-farm"
+ packages = ["."]
+ revision = "ac7624ea8da311f2fbbd94401d8c1cf66089f9fb"
+
+[[projects]]
name = "github.com/eapache/channels"
packages = ["."]
revision = "47238d5aae8c0fefd518ef2bee46290909cf8263"
@@ -220,6 +226,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
- inputs-digest = "146db92061e64997aa59085cf4fa06f72668ed1c6b79be10ce8b654e575e4edc"
+ inputs-digest = "215ec1190c8bd8e4b8ed7691e5f4cfd33100b60045ca47b866db2c0762e30fbd"
solver-name = "gps-cdcl"
solver-version = 1
diff --git a/api/grpc_server.go b/api/grpc_server.go
index 18e4e4d4..15bf769f 100644
--- a/api/grpc_server.go
+++ b/api/grpc_server.go
@@ -16,6 +16,7 @@
package gobgpapi
import (
+ "bytes"
"fmt"
"io"
"net"
@@ -26,6 +27,7 @@ import (
"sync"
"time"
+ farm "github.com/dgryski/go-farm"
log "github.com/sirupsen/logrus"
"golang.org/x/net/context"
"google.golang.org/grpc"
@@ -766,6 +768,17 @@ func (s *Server) api2PathList(resource Resource, ApiPathList []*Path) ([]*table.
pattr = append(pattr, bgp.NewPathAttributeExtendedCommunities(extcomms))
}
newPath := table.NewPath(pi, nlri, path.IsWithdraw, pattr, time.Now(), path.NoImplicitWithdraw)
+ if path.IsWithdraw == false {
+ total := bytes.NewBuffer(make([]byte, 0))
+ for _, a := range newPath.GetPathAttrs() {
+ if a.GetType() == bgp.BGP_ATTR_TYPE_MP_REACH_NLRI {
+ continue
+ }
+ b, _ := a.Serialize()
+ total.Write(b)
+ }
+ newPath.SetHash(farm.Hash32(total.Bytes()))
+ }
newPath.SetIsFromExternal(path.IsFromExternal)
pathList = append(pathList, newPath)
}
diff --git a/table/path.go b/table/path.go
index 875fd04e..cf4603f2 100644
--- a/table/path.go
+++ b/table/path.go
@@ -154,6 +154,7 @@ type Path struct {
info *originInfo
IsWithdraw bool
pathAttrs []bgp.PathAttributeInterface
+ attrsHash uint32
reason BestPathReason
parent *Path
dels []bgp.BGPAttrType
@@ -1242,3 +1243,11 @@ func (p *Path) ToLocal() *Path {
path.IsNexthopInvalid = p.IsNexthopInvalid
return path
}
+
+func (p *Path) SetHash(v uint32) {
+ p.attrsHash = v
+}
+
+func (p *Path) GetHash() uint32 {
+ return p.attrsHash
+}
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)
}
}