diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 6e0e079cd8..d7f6b65384 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -925,7 +925,7 @@ DEFUN (no_auto_summary, /* "router bgp" commands. */ DEFUN_NOSH (router_bgp, router_bgp_cmd, - "router bgp [(1-4294967295) [ VIEWVRFNAME]]", + "router bgp [(1-4294967295)$instasn [ VIEWVRFNAME]]", ROUTER_STR BGP_STR AS_STR @@ -1015,7 +1015,7 @@ DEFUN_NOSH (router_bgp, /* "no router bgp" commands. */ DEFUN (no_router_bgp, no_router_bgp_cmd, - "no router bgp [(1-4294967295) [ VIEWVRFNAME]]", + "no router bgp [(1-4294967295)$instasn [ VIEWVRFNAME]]", NO_STR ROUTER_STR BGP_STR diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 6f794928f8..cb90d39266 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -7878,8 +7878,31 @@ static void bgp_viewvrf_autocomplete(vector comps, struct cmd_token *token) } } +static void bgp_instasn_autocomplete(vector comps, struct cmd_token *token) +{ + struct listnode *next, *next2; + struct bgp *bgp, *bgp2; + char buf[11]; + + for (ALL_LIST_ELEMENTS_RO(bm->bgp, next, bgp)) { + /* deduplicate */ + for (ALL_LIST_ELEMENTS_RO(bm->bgp, next2, bgp2)) { + if (bgp2->as == bgp->as) + break; + if (bgp2 == bgp) + break; + } + if (bgp2 != bgp) + continue; + + snprintf(buf, sizeof(buf), "%u", bgp->as); + vector_set(comps, XSTRDUP(MTYPE_COMPLETION, buf)); + } +} + static const struct cmd_variable_handler bgp_viewvrf_var_handlers[] = { {.tokenname = "VIEWVRFNAME", .completions = bgp_viewvrf_autocomplete}, + {.varname = "instasn", .completions = bgp_instasn_autocomplete}, {.completions = NULL}, };