Skip to content

Commit

Permalink
Reset stats structure and compute total (reach, unreach, eor) rx/tx c…
Browse files Browse the repository at this point in the history
…orrectly

Change-Id: Id0cad78e033907e176c4b7d3cd7b42db1b657430
Partial-Bug: #1576437
  • Loading branch information
ananth-at-camphor-networks committed Oct 4, 2016
1 parent b98fa38 commit 6b089c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 24 deletions.
24 changes: 3 additions & 21 deletions src/bgp/bgp_xmpp_channel.cc
Expand Up @@ -84,11 +84,6 @@ static uint32_t GetMedFromLocalPref(uint32_t local_pref) {
return numeric_limits<uint32_t>::max() - local_pref;
}

BgpXmppChannel::ErrorStats::ErrorStats()
: inet6_rx_bad_xml_token_count(0), inet6_rx_bad_prefix_count(0),
inet6_rx_bad_nexthop_count(0), inet6_rx_bad_afi_safi_count(0) {
}

void BgpXmppChannel::ErrorStats::incr_inet6_rx_bad_xml_token_count() {
++inet6_rx_bad_xml_token_count;
}
Expand Down Expand Up @@ -121,19 +116,6 @@ uint64_t BgpXmppChannel::ErrorStats::get_inet6_rx_bad_afi_safi_count() const {
return inet6_rx_bad_afi_safi_count;
}

BgpXmppChannel::Stats::Stats()
: rt_updates(0), reach(0), unreach(0) {
}

BgpXmppChannel::ChannelStats::ChannelStats()
: instance_subscribe(0),
instance_unsubscribe(0),
table_subscribe(0),
table_subscribe_complete(0),
table_unsubscribe(0),
table_unsubscribe_complete(0) {
}

class BgpXmppChannel::PeerStats : public IPeerDebugStats {
public:
explicit PeerStats(BgpXmppChannel *peer)
Expand Down Expand Up @@ -194,17 +176,17 @@ class BgpXmppChannel::PeerStats : public IPeerDebugStats {
}

virtual void GetRxRouteUpdateStats(UpdateStats *stats) const {
stats->total = parent_->stats_[RX].rt_updates;
stats->reach = parent_->stats_[RX].reach;
stats->unreach = parent_->stats_[RX].unreach;
stats->end_of_rib = parent_->stats_[RX].end_of_rib;
stats->total = stats->reach + stats->unreach + stats->end_of_rib;
}

virtual void GetTxRouteUpdateStats(UpdateStats *stats) const {
stats->total = parent_->stats_[TX].rt_updates;
stats->reach = parent_->stats_[TX].reach;
stats->unreach = parent_->stats_[TX].unreach;
stats->end_of_rib = parent_->stats_[TX].end_of_rib;
stats->total = stats->reach + stats->unreach + stats->end_of_rib;
}

virtual void GetRxSocketStats(IPeerDebugStats::SocketStats *stats) const {
Expand Down Expand Up @@ -1567,7 +1549,7 @@ bool BgpXmppChannel::ProcessEnetItem(string vrf_name,

req.data.reset(new EvpnTable::RequestData(attr, nexthops,
subscription_gen_id));
stats_[0].reach++;
stats_[RX].reach++;
} else {
req.oper = DBRequest::DB_ENTRY_DELETE;
stats_[RX].unreach++;
Expand Down
6 changes: 3 additions & 3 deletions src/bgp/bgp_xmpp_channel.h
Expand Up @@ -51,14 +51,14 @@ class BgpXmppChannel {
TX,
};
struct Stats {
Stats();
Stats() { memset(this, 0, sizeof(*this)); }
uint64_t rt_updates;
uint64_t reach;
uint64_t unreach;
uint64_t end_of_rib;
};
struct ChannelStats {
ChannelStats();
ChannelStats() { memset(this, 0, sizeof(*this)); }
uint64_t instance_subscribe;
uint64_t instance_unsubscribe;
uint64_t table_subscribe;
Expand All @@ -68,7 +68,7 @@ class BgpXmppChannel {
};

struct ErrorStats {
ErrorStats();
ErrorStats() { memset(this, 0, sizeof(*this)); }
void incr_inet6_rx_bad_xml_token_count();
void incr_inet6_rx_bad_prefix_count();
void incr_inet6_rx_bad_nexthop_count();
Expand Down

0 comments on commit 6b089c5

Please sign in to comment.