diff options
author | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2016-10-16 07:35:02 +0000 |
---|---|---|
committer | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2016-10-16 14:07:06 +0000 |
commit | 1f4a3192af12c240e08941490ad8d9dfd7f1bb10 (patch) | |
tree | 8f61edea2e019d45b02d3356202f7839245ee234 /table/adj.go | |
parent | 11969f468543e881d7a4c758bb8f7af5797793b5 (diff) |
cli/api: support getting table summary information
$ gobgp global rib summary -a ipv4
$ gobgp neighbor 10.0.0.1 local summary
$ gobgp neighbor 10.0.0.1 adj-in summary
$ gobgp neighbor 10.0.0.1 adj-out summary
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/adj.go')
-rw-r--r-- | table/adj.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/table/adj.go b/table/adj.go index b38e02b8..ea7b4151 100644 --- a/table/adj.go +++ b/table/adj.go @@ -16,6 +16,7 @@ package table import ( + "fmt" "github.com/osrg/gobgp/packet/bgp" ) @@ -188,3 +189,16 @@ func (adj *AdjRib) Select(family bgp.RouteFamily, accepted bool, option ...Table option = append(option, TableSelectOption{adj: true}) return tbl.Select(option...) } + +func (adj *AdjRib) TableInfo(family bgp.RouteFamily) (*TableInfo, error) { + if _, ok := adj.table[family]; !ok { + return nil, fmt.Errorf("%s unsupported") + } + c := adj.Count([]bgp.RouteFamily{family}) + a := adj.Accepted([]bgp.RouteFamily{family}) + return &TableInfo{ + NumDestination: c, + NumPath: c, + NumAccepted: a, + }, nil +} |