diff options
| author | Don Slice <dslice@cumulusnetworks.com> | 2018-05-10 09:10:18 -0400 |
|---|---|---|
| committer | Don Slice <dslice@cumulusnetworks.com> | 2018-05-10 17:59:27 +0000 |
| commit | 47a306a040d76f88a482ce83cab082894940adfd (patch) | |
| tree | 2339f0bc311e738e966697ec3d4437b722cda435 | |
| parent | 3dc755e492093c42d0983620da810893c413c533 (diff) | |
bgpd: fix auto-completion for neighbors and peer-groups
Before this fix, both real neighbors and peer-groups were lumped
together in auto-completion and it didn't work at all for
peer-groups. This fix changes that behavior to do the right
thing.
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
| -rw-r--r-- | bgpd/bgp_vty.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index e1b050bf59..fccda446fa 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -12153,7 +12153,6 @@ static void bgp_ac_neighbor(vector comps, struct cmd_token *token) { struct bgp *bgp; struct peer *peer; - struct peer_group *group; struct listnode *lnbgp, *lnpeer; for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { @@ -12177,11 +12176,6 @@ static void bgp_ac_neighbor(vector comps, struct cmd_token *token) vector_set(comps, XSTRDUP(MTYPE_COMPLETION, name)); } - - if (token->type == VARIABLE_TKN) - for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) - vector_set(comps, XSTRDUP(MTYPE_COMPLETION, - group->name)); } } @@ -12191,9 +12185,27 @@ static const struct cmd_variable_handler bgp_var_neighbor[] = { {.varname = "peer", .completions = bgp_ac_neighbor}, {.completions = NULL}}; +static void bgp_ac_peergroup(vector comps, struct cmd_token *token) +{ + struct bgp *bgp; + struct peer_group *group; + struct listnode *lnbgp, *lnpeer; + + for (ALL_LIST_ELEMENTS_RO(bm->bgp, lnbgp, bgp)) { + for (ALL_LIST_ELEMENTS_RO(bgp->group, lnpeer, group)) + vector_set(comps, XSTRDUP(MTYPE_COMPLETION, + group->name)); + } +} + +static const struct cmd_variable_handler bgp_var_peergroup[] = { + {.tokenname = "PGNAME", .completions = bgp_ac_peergroup}, + {.completions = NULL} }; + void bgp_vty_init(void) { cmd_variable_handler_register(bgp_var_neighbor); + cmd_variable_handler_register(bgp_var_peergroup); /* Install bgp top node. */ install_node(&bgp_node, bgp_config_write); |
