]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: count some per-peer stats (for BMP)
authorDavid Lamparter <equinox@diac24.net>
Wed, 24 Apr 2019 19:40:50 +0000 (21:40 +0200)
committerDavid Lamparter <equinox@diac24.net>
Wed, 3 Jul 2019 14:53:12 +0000 (16:53 +0200)
These counters are accessible through BMP and may be useful to monitor
bgpd.  A CLI to show them could also be added if people are interested.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
bgpd/bgp_packet.c
bgpd/bgp_route.c
bgpd/bgpd.h

index 9a836f2215f9c1ab4a72e505b7c60515c6eb4b59..e907c6a10de8a9ff13def6db7c8ccf2c8655b2d7 100644 (file)
@@ -1518,6 +1518,8 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size)
            || BGP_DEBUG(update, UPDATE_PREFIX)) {
                ret = bgp_dump_attr(&attr, peer->rcvd_attr_str, BUFSIZ);
 
+               peer->stat_upd_7606++;
+
                if (attr_parse_ret == BGP_ATTR_PARSE_WITHDRAW)
                        flog_err(
                                EC_BGP_UPDATE_RCV,
index 9e3ad4e8f298686486681e4c5f5b049cabe04922..683aa61e757686347c5f4876fa1b840446bd3f32 100644 (file)
@@ -3068,6 +3068,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
 
                if (aspath_loop_check(attr->aspath, peer->change_local_as)
                    > aspath_loop_count) {
+                       peer->stat_pfx_aspath_loop++;
                        reason = "as-path contains our own AS;";
                        goto filtered;
                }
@@ -3088,6 +3089,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
                    || (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)
                        && aspath_loop_check(attr->aspath, bgp->confed_id)
                                   > peer->allowas_in[afi][safi])) {
+                       peer->stat_pfx_aspath_loop++;
                        reason = "as-path contains our own AS;";
                        goto filtered;
                }
@@ -3096,18 +3098,21 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
        /* Route reflector originator ID check.  */
        if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)
            && IPV4_ADDR_SAME(&bgp->router_id, &attr->originator_id)) {
+               peer->stat_pfx_originator_loop++;
                reason = "originator is us;";
                goto filtered;
        }
 
        /* Route reflector cluster ID check.  */
        if (bgp_cluster_filter(peer, attr)) {
+               peer->stat_pfx_cluster_loop++;
                reason = "reflected from the same cluster;";
                goto filtered;
        }
 
        /* Apply incoming filter.  */
        if (bgp_input_filter(peer, p, attr, afi, safi) == FILTER_DENY) {
+               peer->stat_pfx_filter++;
                reason = "filter;";
                goto filtered;
        }
@@ -3138,6 +3143,7 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
         * the attr (which takes over the memory references) */
        if (bgp_input_modifier(peer, p, &new_attr, afi, safi, NULL)
            == RMAP_DENY) {
+               peer->stat_pfx_filter++;
                reason = "route-map;";
                bgp_attr_flush(&new_attr);
                goto filtered;
@@ -3163,12 +3169,14 @@ int bgp_update(struct peer *peer, struct prefix *p, uint32_t addpath_id,
        /* next hop check.  */
        if (!CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD)
            && bgp_update_martian_nexthop(bgp, afi, safi, &new_attr)) {
+               peer->stat_pfx_nh_invalid++;
                reason = "martian or self next-hop;";
                bgp_attr_flush(&new_attr);
                goto filtered;
        }
 
        if (bgp_mac_entry_exists(p) || bgp_mac_exist(&attr->rmac)) {
+               peer->stat_pfx_nh_invalid++;
                reason = "self mac;";
                goto filtered;
        }
@@ -3727,6 +3735,8 @@ int bgp_withdraw(struct peer *peer, struct prefix *p, uint32_t addpath_id,
        if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG)
            && peer != bgp->peer_self)
                if (!bgp_adj_in_unset(rn, peer, addpath_id)) {
+                       peer->stat_pfx_dup_withdraw++;
+
                        if (bgp_debug_update(peer, p, NULL, 1)) {
                                bgp_debug_rdpfxpath2str(
                                        afi, safi, prd, p, label, num_labels,
index 8bdc0099ae68f5b0c9bb484caad38765f910326e..c329c8a7eaffb1e526b66a4abfe97eda28a9c6fa 100644 (file)
@@ -1077,6 +1077,14 @@ struct peer {
        _Atomic uint32_t dynamic_cap_in;  /* Dynamic Capability input count.  */
        _Atomic uint32_t dynamic_cap_out; /* Dynamic Capability output count. */
 
+       uint32_t stat_pfx_filter;
+       uint32_t stat_pfx_aspath_loop;
+       uint32_t stat_pfx_originator_loop;
+       uint32_t stat_pfx_cluster_loop;
+       uint32_t stat_pfx_nh_invalid;
+       uint32_t stat_pfx_dup_withdraw;
+       uint32_t stat_upd_7606;  /* RFC7606: treat-as-withdraw */
+
        /* BGP state count */
        uint32_t established; /* Established */
        uint32_t dropped;     /* Dropped */