mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
cli: don't calculate # of advertised routes when not necessary
Signed-off-by: Wataru Ishida <[email protected]>
This commit is contained in:
committed by
FUJITA Tomonori
parent
d5be199501
commit
f8b9b0a7ed
+11
-7
@@ -127,8 +127,8 @@ func (cli *Client) EnableZebra(c *config.Zebra) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) getNeighbor(name string, afi int, vrf string) ([]*config.Neighbor, error) {
|
||||
ret, err := cli.cli.GetNeighbor(context.Background(), &api.GetNeighborRequest{EnableAdvertised: name != ""})
|
||||
func (cli *Client) getNeighbor(name string, afi int, vrf string, enableAdvertised bool) ([]*config.Neighbor, error) {
|
||||
ret, err := cli.cli.GetNeighbor(context.Background(), &api.GetNeighborRequest{EnableAdvertised: enableAdvertised})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -158,19 +158,23 @@ func (cli *Client) getNeighbor(name string, afi int, vrf string) ([]*config.Neig
|
||||
}
|
||||
|
||||
func (cli *Client) ListNeighbor() ([]*config.Neighbor, error) {
|
||||
return cli.getNeighbor("", 0, "")
|
||||
return cli.getNeighbor("", 0, "", false)
|
||||
}
|
||||
|
||||
func (cli *Client) ListNeighborByTransport(afi int) ([]*config.Neighbor, error) {
|
||||
return cli.getNeighbor("", afi, "")
|
||||
return cli.getNeighbor("", afi, "", false)
|
||||
}
|
||||
|
||||
func (cli *Client) ListNeighborByVRF(vrf string) ([]*config.Neighbor, error) {
|
||||
return cli.getNeighbor("", 0, vrf)
|
||||
return cli.getNeighbor("", 0, vrf, false)
|
||||
}
|
||||
|
||||
func (cli *Client) GetNeighbor(name string) (*config.Neighbor, error) {
|
||||
ns, err := cli.getNeighbor(name, 0, "")
|
||||
func (cli *Client) GetNeighbor(name string, options ...bool) (*config.Neighbor, error) {
|
||||
enableAdvertised := false
|
||||
if len(options) > 0 && options[0] {
|
||||
enableAdvertised = true
|
||||
}
|
||||
ns, err := cli.getNeighbor(name, 0, "", enableAdvertised)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ func getNeighbors(vrf string) (neighbors, error) {
|
||||
return neighbors(n), err
|
||||
}
|
||||
|
||||
func getNeighbor(name string) (*config.Neighbor, error) {
|
||||
return client.GetNeighbor(name)
|
||||
func getNeighbor(name string, enableAdvertised bool) (*config.Neighbor, error) {
|
||||
return client.GetNeighbor(name, enableAdvertised)
|
||||
}
|
||||
|
||||
func showNeighbors(vrf string) error {
|
||||
@@ -142,7 +142,7 @@ func showNeighbors(vrf string) error {
|
||||
}
|
||||
|
||||
func showNeighbor(args []string) error {
|
||||
p, e := getNeighbor(args[0])
|
||||
p, e := getNeighbor(args[0], true)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
@@ -580,7 +580,7 @@ func showNeighborRib(r string, name string, args []string) error {
|
||||
switch r {
|
||||
case CMD_LOCAL, CMD_ADJ_IN, CMD_ACCEPTED, CMD_REJECTED, CMD_ADJ_OUT:
|
||||
if rib.Info("").NumDestination == 0 {
|
||||
peer, err := getNeighbor(name)
|
||||
peer, err := getNeighbor(name, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -862,7 +862,7 @@ func NewNeighborCmd() *cobra.Command {
|
||||
}
|
||||
}
|
||||
if addr == "" {
|
||||
peer, err := getNeighbor(args[len(args)-1])
|
||||
peer, err := getNeighbor(args[len(args)-1], false)
|
||||
if err != nil {
|
||||
exitWithError(err)
|
||||
}
|
||||
@@ -893,7 +893,7 @@ func NewNeighborCmd() *cobra.Command {
|
||||
policyCmd := &cobra.Command{
|
||||
Use: CMD_POLICY,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
peer, err := getNeighbor(args[0])
|
||||
peer, err := getNeighbor(args[0], false)
|
||||
if err != nil {
|
||||
exitWithError(err)
|
||||
}
|
||||
@@ -910,7 +910,7 @@ func NewNeighborCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: v,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
peer, err := getNeighbor(args[0])
|
||||
peer, err := getNeighbor(args[0], false)
|
||||
if err != nil {
|
||||
exitWithError(err)
|
||||
}
|
||||
@@ -926,7 +926,7 @@ func NewNeighborCmd() *cobra.Command {
|
||||
subcmd := &cobra.Command{
|
||||
Use: w,
|
||||
Run: func(subcmd *cobra.Command, args []string) {
|
||||
peer, err := getNeighbor(args[len(args)-1])
|
||||
peer, err := getNeighbor(args[len(args)-1], false)
|
||||
if err != nil {
|
||||
exitWithError(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user