diff options
| author | Chirag Shah <chirag@nvidia.com> | 2020-09-17 14:20:44 -0700 |
|---|---|---|
| committer | Chirag Shah <chirag@nvidia.com> | 2020-10-03 11:25:38 -0700 |
| commit | 4b63e358bc213bfa9d1baeda6fbbdfa39df60d2e (patch) | |
| tree | 3c30befb2773ab4d7514466f5facfdd5bf4ec6a7 | |
| parent | 5e42cb2fb088a28202e60ec57a4116f3d1f0afd5 (diff) | |
bgpd: no router bgp check candidate config
For `no router bgp` without ASN check candidate
config for default bgp instance presence to avoid
failure from checking backend db where bgp instance
may not be created.
This situation can be seen in transactional cli mode
with following config.
bharat(config)# router bgp 101
bharat(config-router)# exit
bharat(config)# no router bgp
% No BGP process is configured
bharat(config)# no router bgp
% No BGP process is configured
bharat(config)#
Signed-off-by: Chirag Shah <chirag@nvidia.com>
| -rw-r--r-- | bgpd/bgp_vty.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 2a5ef34d09..38dad59e60 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1311,13 +1311,17 @@ DEFUN_YANG(no_router_bgp, struct bgp *bgp; const char *name = NULL; char base_xpath[XPATH_MAXLEN]; + const struct lyd_node *bgp_glb_dnode; // "no router bgp" without an ASN if (argc == 3) { // Pending: Make VRF option available for ASN less config - bgp = bgp_get_default(); + snprintf(base_xpath, sizeof(base_xpath), FRR_BGP_GLOBAL_XPATH, + "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME); - if (bgp == NULL) { + bgp_glb_dnode = yang_dnode_get(vty->candidate_config->dnode, + base_xpath); + if (!bgp_glb_dnode) { vty_out(vty, "%% No BGP process is configured\n"); return CMD_WARNING_CONFIG_FAILED; } @@ -1327,6 +1331,11 @@ DEFUN_YANG(no_router_bgp, return CMD_WARNING_CONFIG_FAILED; } + /* tcli mode bgp would not be set until apply stage. */ + bgp = nb_running_get_entry(bgp_glb_dnode, NULL, false); + if (!bgp) + return CMD_SUCCESS; + if (bgp->l3vni) { vty_out(vty, "%% Please unconfigure l3vni %u", bgp->l3vni); |
