]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_vty.c
staticd: Do not ready prefix for printing till it's decoded
[mirror_frr.git] / bgpd / bgp_vty.c
index 61769a576370f6520e05f2819b160f93af00085f..2a4421aa54d30089d77699025c5100ec70f8075e 100644 (file)
@@ -602,7 +602,7 @@ static int bgp_clear(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
                        bgp->update_delay_over = 0;
 
                if (!found)
-                       vty_out(vty, "%%BGP: No %s peer configured",
+                       vty_out(vty, "%%BGP: No %s peer configured\n",
                                afi_safi_print(afi, safi));
 
                return CMD_SUCCESS;
@@ -972,6 +972,7 @@ DEFUN_NOSH (router_bgp,
        int idx_asn = 2;
        int idx_view_vrf = 3;
        int idx_vrf = 4;
+       int is_new_bgp = 0;
        int ret;
        as_t as;
        struct bgp *bgp;
@@ -1011,6 +1012,9 @@ DEFUN_NOSH (router_bgp,
                                inst_type = BGP_INSTANCE_TYPE_VIEW;
                }
 
+               if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+                       is_new_bgp = (bgp_lookup(as, name) == NULL);
+
                ret = bgp_get(&bgp, &as, name, inst_type);
                switch (ret) {
                case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET:
@@ -1034,7 +1038,7 @@ DEFUN_NOSH (router_bgp,
                 * any pending VRF-VPN leaking that was configured via
                 * earlier "router bgp X vrf FOO" blocks.
                 */
-               if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+               if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
                        vpn_leak_postchange_all();
 
                /* Pending: handle when user tries to change a view to vrf n vv.
@@ -7209,7 +7213,9 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
                        if (prd && memcmp(rn->p.u.val, prd->val, 8) != 0)
                                continue;
 
-                       if ((table = rn->info) != NULL) {
+                       table = bgp_node_get_bgp_table_info(rn);
+                       if (table != NULL) {
+
                                if ((rm = bgp_node_match(table, &match))
                                    != NULL) {
                                        if (rm->p.prefixlen
@@ -9718,7 +9724,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json,
                                                                json_object_string_add(
                                                                        json_nxt,
                                                                        print_store,
-                                                                       "received");
+                                                                       "recieved"); /* misspelled for compatibility */
                                                        }
                                                }
                                                json_object_object_add(
@@ -10912,7 +10918,6 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp,
        if (use_json) {
                vty_out(vty, "%s\n", json_object_to_json_string_ext(
                                             json, JSON_C_TO_STRING_PRETTY));
-               json_object_free(json);
        } else {
                vty_out(vty, "\n");
        }
@@ -10987,8 +10992,10 @@ static void bgp_show_all_instances_neighbors_vty(struct vty *vty,
                }
        }
 
-       if (use_json)
+       if (use_json) {
                vty_out(vty, "}\n");
+               json_object_free(json);
+       }
        else if (!nbr_output)
                vty_out(vty, "%% BGP instance not found\n");
 }