switch (ret) {
case BGP_ERR_AS_MISMATCH:
vty_out(vty, "BGP is already running; AS is %s\n",
- bgp->as_pretty);
+ bgp ? bgp->as_pretty : "unknown");
return CMD_WARNING_CONFIG_FAILED;
case BGP_ERR_INSTANCE_MISMATCH:
vty_out(vty,
"BGP instance name and AS number mismatch\n");
- vty_out(vty,
- "BGP instance is already running; AS is %s\n",
- bgp->as_pretty);
+ vty_out(vty, "BGP instance is already running; AS is %s\n",
+ bgp ? bgp->as_pretty : "unknown");
return CMD_WARNING_CONFIG_FAILED;
}
+ if (!bgp) {
+ vty_out(vty, "BGP instance not found\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
/*
* If we just instantiated the default instance, complete
* any pending VRF-VPN leaking that was configured via
* earlier "router bgp X vrf FOO" blocks.
*/
- if (bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+ if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
vpn_leak_postchange_all();
- if (inst_type == BGP_INSTANCE_TYPE_VRF ||
- IS_BGP_INSTANCE_HIDDEN(bgp)) {
+ if (inst_type == BGP_INSTANCE_TYPE_VRF || IS_BGP_INSTANCE_HIDDEN(bgp)) {
bgp_vpn_leak_export(bgp);
UNSET_FLAG(bgp->flags, BGP_FLAG_INSTANCE_HIDDEN);
UNSET_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS);