summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPavel Vorontsov <pvorontsovd@gmail.com>2020-02-18 15:11:50 +0300
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2020-02-19 13:35:26 +0900
commit659ef4bc371c5b99496ace901c380e5956b146b2 (patch)
tree33219f859f6e72c170e0d14b5ce17c2372eb15a6
parent789664e8c32730b0a98874dccfbb167fd9fe20b0 (diff)
add summary command for vrf to cli #2235
-rw-r--r--cmd/gobgp/neighbor.go4
-rw-r--r--cmd/gobgp/vrf.go14
2 files changed, 15 insertions, 3 deletions
diff --git a/cmd/gobgp/neighbor.go b/cmd/gobgp/neighbor.go
index ef8e904b..5b0d5012 100644
--- a/cmd/gobgp/neighbor.go
+++ b/cmd/gobgp/neighbor.go
@@ -713,7 +713,7 @@ func showValidationInfo(p *api.Path, shownAs map[uint32]struct{}) error {
func showRibInfo(r, name string) error {
def := addr2AddressFamily(net.ParseIP(name))
- if r == cmdGlobal {
+ if r == cmdGlobal || r == cmdVRF {
def = ipv4UC
}
family, err := checkAddressFamily(def)
@@ -731,6 +731,8 @@ func showRibInfo(r, name string) error {
t = api.TableType_ADJ_IN
case cmdAdjOut:
t = api.TableType_ADJ_OUT
+ case cmdVRF:
+ t = api.TableType_VRF
default:
return fmt.Errorf("invalid resource to show RIB info: %s", r)
}
diff --git a/cmd/gobgp/vrf.go b/cmd/gobgp/vrf.go
index 73162519..1034091c 100644
--- a/cmd/gobgp/vrf.go
+++ b/cmd/gobgp/vrf.go
@@ -115,7 +115,7 @@ func showVrfs() error {
return nil
}
-func showVrf(name string) error {
+func showVrfRib(name string) error {
return showNeighborRib(cmdVRF, name, nil)
}
@@ -196,7 +196,7 @@ func newVrfCmd() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
var err error
if len(args) == 1 {
- err = showVrf(args[0])
+ err = showVrfRib(args[0])
} else {
err = fmt.Errorf("usage: gobgp vrf <vrf-name> rib")
}
@@ -285,5 +285,15 @@ func newVrfCmd() *cobra.Command {
}
vrfCmd.PersistentFlags().StringVarP(&subOpts.AddressFamily, "address-family", "a", "", "address family")
+ summaryCmd := &cobra.Command{
+ Use: cmdSummary,
+ Run: func(cmd *cobra.Command, args []string) {
+ if err := showRibInfo(cmdVRF, args[0]); err != nil {
+ exitWithError(err)
+ }
+ },
+ }
+ ribCmd.AddCommand(summaryCmd)
+
return vrfCmd
}