summaryrefslogtreecommitdiffhomepage
path: root/api/util.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-09-21 14:07:26 +0900
committerIWASE Yusuke <iwase.yusuke0@gmail.com>2017-09-25 15:30:16 +0900
commit9b278ba79ba2d12598405d1109b0b90b42e68357 (patch)
tree45100d0bfa136c547ab116361c827f18ca4411cf /api/util.go
parentce258f05d2fd9c3f66b831cae1e40bc9958cef1f (diff)
api: GetPath API alternative to GetRib
With the extremely large RIBs, GetRib gRPC API hits the limits of each message size, because this API is using simple request/response RPC. This patch introduces a new API GetPath which using streaming RPC and can retrieve RIBs even if extremely large. Note: GetRib can be replaced with GetPath and obsoleted in the future. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'api/util.go')
-rw-r--r--api/util.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/api/util.go b/api/util.go
index 7cb9d2b8..ce7a1d02 100644
--- a/api/util.go
+++ b/api/util.go
@@ -46,7 +46,7 @@ func (t *Table) ToNativeTable(option ...ToNativeOption) (*table.Table, error) {
}
func getNLRI(family bgp.RouteFamily, buf []byte) (bgp.AddrPrefixInterface, error) {
- afi, safi := bgp.RouteFamilyToAfiSafi(bgp.RouteFamily(family))
+ afi, safi := bgp.RouteFamilyToAfiSafi(family)
nlri, err := bgp.NewPrefixFromRouteFamily(afi, safi)
if err != nil {
return nil, err
@@ -85,6 +85,10 @@ func (d *Destination) ToNativeDestination(option ...ToNativeOption) (*table.Dest
return table.NewDestination(nlri, 0, paths...), nil
}
+func (p *Path) GetNativeNlri() (bgp.AddrPrefixInterface, error) {
+ return getNLRI(bgp.RouteFamily(p.Family), p.Nlri)
+}
+
func (p *Path) ToNativePath(option ...ToNativeOption) (*table.Path, error) {
info := &table.PeerInfo{
AS: p.SourceAsn,