]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: add bmp adj-rib-in 64 bit gauge value
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 25 Apr 2024 14:53:21 +0000 (16:53 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 26 Apr 2024 06:11:44 +0000 (08:11 +0200)
There is no support for option 7, as per RFC7854.
Add the 64 bit counter in the peer structure.
Add the 64 bit bmp value write api.
Add the missing per peer statistic.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
bgpd/bgp_advertise.c
bgpd/bgp_bmp.c
bgpd/bgpd.h
doc/user/bmp.rst

index a81f288c7accd2016aa0bf5fa358a3540d343f48..d519749f6bcac3abb094d30245982799dc5b9ed1 100644 (file)
@@ -182,12 +182,15 @@ void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr,
        adj->uptime = monotime(NULL);
        adj->addpath_rx_id = addpath_id;
        BGP_ADJ_IN_ADD(dest, adj);
+       peer->stat_pfx_adj_rib_in++;
        bgp_dest_lock_node(dest);
 }
 
 void bgp_adj_in_remove(struct bgp_dest **dest, struct bgp_adj_in *bai)
 {
        bgp_attr_unintern(&bai->attr);
+       if (bai->peer)
+               bai->peer->stat_pfx_adj_rib_in--;
        BGP_ADJ_IN_DEL(*dest, bai);
        *dest = bgp_dest_unlock_node(*dest);
        peer_unlock(bai->peer); /* adj_in peer reference */
index 5fcb8c5645556684bf2726854c564ecdeb648d52..d4e1f871ab6eb893fdb955e2cda18db2c420f41c 100644 (file)
@@ -1592,6 +1592,15 @@ static void bmp_stat_put_u32(struct stream *s, size_t *cnt, uint16_t type,
        (*cnt)++;
 }
 
+static void bmp_stat_put_u64(struct stream *s, size_t *cnt, uint16_t type,
+                            uint64_t value)
+{
+       stream_putw(s, type);
+       stream_putw(s, 8);
+       stream_putq(s, value);
+       (*cnt)++;
+}
+
 static void bmp_stats(struct event *thread)
 {
        struct bmp_targets *bt = EVENT_ARG(thread);
@@ -1635,6 +1644,8 @@ static void bmp_stats(struct event *thread)
                                peer->stat_upd_7606);
                bmp_stat_put_u32(s, &count, BMP_STATS_FRR_NH_INVALID,
                                peer->stat_pfx_nh_invalid);
+               bmp_stat_put_u64(s, &count, BMP_STATS_SIZE_ADJ_RIB_IN,
+                                peer->stat_pfx_adj_rib_in);
 
                stream_putl_at(s, count_pos, count);
 
index e882a181b50ceac91eae152d98be9ac347974dd2..107fc8b95c045a4be9082ed24b066c5ce24df161 100644 (file)
@@ -1667,6 +1667,7 @@ struct peer {
        uint32_t stat_pfx_nh_invalid;
        uint32_t stat_pfx_dup_withdraw;
        uint32_t stat_upd_7606;  /* RFC7606: treat-as-withdraw */
+       uint64_t stat_pfx_adj_rib_in; /* RFC7854 : Number of routes in Adj-RIBs-In */
 
        /* BGP state count */
        uint32_t established; /* Established */
index 0f46832059785db4ef3bdf6c4c8e828532754faa..c553b7c985dbdff6fd64aaac4843067d4e72f1bc 100644 (file)
@@ -23,6 +23,7 @@ The `BMP` implementation in FRR has the following properties:
   - 3: count of **prefixes** with loop in cluster id
   - 4: count of **prefixes** with loop in AS-path
   - 5: count of **prefixes** with loop in originator
+  - 7: count of **routes** in adj-rib-in
   - 11: count of updates subjected to :rfc:`7607` "treat as withdrawal"
     handling due to errors
   - 65531: *experimental* count of prefixes rejected due to invalid next-hop