diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-11-22 14:35:01 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-11-23 21:21:34 +0900 |
commit | 2c2cd2bec281c3cabb51dc59511b43f00378f40a (patch) | |
tree | e2b0193b979aa6ecaa07d110ca2994b5fa061cb2 /api | |
parent | 3730a171c41a8bc9a62e72bab5f8906f37a0ac7c (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 'api')
-rw-r--r-- | api/grpc_server.go | 13 |
1 files changed, 13 insertions, 0 deletions
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) } |