From 43aa59653862fbbed0e1ccb813a23444be57acaa Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 30 Mar 2020 14:47:15 -0400 Subject: [PATCH] bgpd: display ingress packet queue size In the past, we always displayed the number of buffered ingress packets as zero because there was no packet buffering in the input path and therefore never any queue size to report. They're buffered now so we can display something meaningful instead of 0. Also change the inq / outq lookups to be atomic, since they can be modified elsewhere. These should still compile down to an unfenced word read but it's good to be explicit. Signed-off-by: Quentin Young --- bgpd/bgp_vty.c | 51 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index aea6dbbf4e..a35bfe47ed 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9036,11 +9036,20 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, json_object_int_add(json_peer, "msgSent", PEER_TOTAL_TX(peer)); + atomic_size_t outq_count, inq_count; + outq_count = atomic_load_explicit( + &peer->obuf->count, + memory_order_relaxed); + inq_count = atomic_load_explicit( + &peer->ibuf->count, + memory_order_relaxed); + json_object_int_add(json_peer, "tableVersion", peer->version[afi][safi]); json_object_int_add(json_peer, "outq", - peer->obuf->count); - json_object_int_add(json_peer, "inq", 0); + outq_count); + json_object_int_add(json_peer, "inq", + inq_count); peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, use_json, json_peer); @@ -9122,12 +9131,21 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, vty_out(vty, "%*s", max_neighbor_width - len, " "); + atomic_size_t outq_count, inq_count; + outq_count = atomic_load_explicit( + &peer->obuf->count, + memory_order_relaxed); + inq_count = atomic_load_explicit( + &peer->ibuf->count, + memory_order_relaxed); + vty_out(vty, - "4 %10u %9u %9u %8" PRIu64 " %4d %4zu %8s", + "4 %10u %9u %9u %8" PRIu64 + " %4zu %4zu %8s", peer->as, PEER_TOTAL_RX(peer), PEER_TOTAL_TX(peer), - peer->version[afi][safi], 0, - peer->obuf->count, + peer->version[afi][safi], inq_count, + outq_count, peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); @@ -11711,9 +11729,17 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, json_object *json_stat = NULL; json_stat = json_object_new_object(); /* Packet counts. */ - json_object_int_add(json_stat, "depthInq", 0); + + atomic_size_t outq_count, inq_count; + outq_count = atomic_load_explicit(&p->obuf->count, + memory_order_relaxed); + inq_count = atomic_load_explicit(&p->ibuf->count, + memory_order_relaxed); + + json_object_int_add(json_stat, "depthInq", + (unsigned long)inq_count); json_object_int_add(json_stat, "depthOutq", - (unsigned long)p->obuf->count); + (unsigned long)outq_count); json_object_int_add(json_stat, "opensSent", atomic_load_explicit(&p->open_out, memory_order_relaxed)); @@ -11754,11 +11780,16 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, json_object_int_add(json_stat, "totalRecv", PEER_TOTAL_RX(p)); json_object_object_add(json_neigh, "messageStats", json_stat); } else { + atomic_size_t outq_count, inq_count; + outq_count = atomic_load_explicit(&p->obuf->count, + memory_order_relaxed); + inq_count = atomic_load_explicit(&p->ibuf->count, + memory_order_relaxed); + /* Packet counts. */ vty_out(vty, " Message statistics:\n"); - vty_out(vty, " Inq depth is 0\n"); - vty_out(vty, " Outq depth is %lu\n", - (unsigned long)p->obuf->count); + vty_out(vty, " Inq depth is %zu\n", inq_count); + vty_out(vty, " Outq depth is %zu\n", outq_count); vty_out(vty, " Sent Rcvd\n"); vty_out(vty, " Opens: %10d %10d\n", atomic_load_explicit(&p->open_out, -- 2.39.5