]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_bmp.c
Merge pull request #5703 from ton31337/feature/limit_outgoing_prefixes
[mirror_frr.git] / bgpd / bgp_bmp.c
index b184c9f567ef5c7a3b24ff671de2d6509a8e0d35..24a9cab5d150f4dfe56963d9739c9b6f699118b8 100644 (file)
@@ -2079,9 +2079,12 @@ DEFPY(show_bmp,
        struct bmp_bgp *bmpbgp;
        struct bmp_targets *bt;
        struct bmp_listener *bl;
+       struct bmp_active *ba;
        struct bmp *bmp;
        struct ttable *tt;
        char buf[SU_ADDRSTRLEN];
+       char uptime[BGP_UPTIME_LEN];
+       char *out;
 
        frr_each(bmp_bgph, &bmp_bgph, bmpbgp) {
                vty_out(vty, "BMP state for BGP %s:\n\n",
@@ -2130,6 +2133,51 @@ DEFPY(show_bmp,
                                        sockunion2str(&bl->addr, buf,
                                                      SU_ADDRSTRLEN), bl->port);
 
+                       vty_out(vty, "\n    Outbound connections:\n");
+                       tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
+                       ttable_add_row(tt, "remote|state||timer");
+                       ttable_rowseps(tt, 0, BOTTOM, true, '-');
+                       frr_each (bmp_actives, &bt->actives, ba) {
+                               const char *state_str = "?";
+
+                               if (ba->bmp) {
+                                       peer_uptime(ba->bmp->t_up.tv_sec,
+                                                   uptime, sizeof(uptime),
+                                                   false, NULL);
+                                       ttable_add_row(tt, "%s:%d|Up|%s|%s",
+                                                      ba->hostname, ba->port,
+                                                      ba->bmp->remote, uptime);
+                                       continue;
+                               }
+
+                               uptime[0] = '\0';
+
+                               if (ba->t_timer) {
+                                       long trem = thread_timer_remain_second(
+                                               ba->t_timer);
+
+                                       peer_uptime(monotime(NULL) - trem,
+                                                   uptime, sizeof(uptime),
+                                                   false, NULL);
+                                       state_str = "RetryWait";
+                               } else if (ba->t_read) {
+                                       state_str = "Connecting";
+                               } else if (ba->resq.callback) {
+                                       state_str = "Resolving";
+                               }
+
+                               ttable_add_row(tt, "%s:%d|%s|%s|%s",
+                                              ba->hostname, ba->port,
+                                              state_str,
+                                              ba->last_err ? ba->last_err : "",
+                                              uptime);
+                               continue;
+                       }
+                       out = ttable_dump(tt, "\n");
+                       vty_out(vty, "%s", out);
+                       XFREE(MTYPE_TMP, out);
+                       ttable_del(tt);
+
                        vty_out(vty, "\n    %zu connected clients:\n",
                                        bmp_session_count(&bt->sessions));
                        tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]);
@@ -2138,7 +2186,6 @@ DEFPY(show_bmp,
 
                        frr_each (bmp_session, &bt->sessions, bmp) {
                                uint64_t total;
-                               char uptime[BGP_UPTIME_LEN];
                                size_t q, kq;
 
                                pullwr_stats(bmp->pullwr, &total, &q, &kq);
@@ -2153,7 +2200,7 @@ DEFPY(show_bmp,
                                               bmp->cnt_mirror_overruns,
                                               total, q, kq);
                        }
-                       char *out = ttable_dump(tt, "\n");
+                       out = ttable_dump(tt, "\n");
                        vty_out(vty, "%s", out);
                        XFREE(MTYPE_TMP, out);
                        ttable_del(tt);