Skip to content

Commit

Permalink
Fix Invalid flow-rate exported from Vrouter UVE
Browse files Browse the repository at this point in the history
When flow added/deleted per second is exported, we should export flow
created/deleted from same time slot.
Closes-Bug: #1639698

Change-Id: I32f07b1c8221c3cbd7007c265809cf1fecaded9a
  • Loading branch information
ashoksr committed Nov 17, 2016
1 parent ba01c38 commit 1fb7f31
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
3 changes: 1 addition & 2 deletions src/vnsw/agent/uve/interface_uve_stats_table.cc
Expand Up @@ -100,8 +100,7 @@ bool InterfaceUveStatsTable::FrameInterfaceStatsMsg(UveInterfaceEntry* entry,
uint32_t active_flows = 0;
agent_->pkt()->get_flow_proto()->InterfaceFlowCount(vm_intf, &created,
&aged, &active_flows);
bool built = agent_uve->stats_manager()->BuildFlowRate(created, aged,
s->added, s->deleted,
bool built = agent_uve->stats_manager()->BuildFlowRate(s->added, s->deleted,
s->flow_info,
flow_rate);
if (built) {
Expand Down
29 changes: 22 additions & 7 deletions src/vnsw/agent/uve/stats_manager.cc
Expand Up @@ -321,9 +321,7 @@ bool StatsManager::RequestHandler(boost::shared_ptr<FlowAceStatsRequest> req) {
return true;
}

bool StatsManager::BuildFlowRate(uint64_t total_created_flows,
uint64_t total_aged_flows,
AgentStats::FlowCounters &created,
bool StatsManager::BuildFlowRate(AgentStats::FlowCounters &created,
AgentStats::FlowCounters &aged,
FlowRateComputeInfo &flow_info,
VrouterFlowRate &flow_rate) const {
Expand All @@ -334,17 +332,34 @@ bool StatsManager::BuildFlowRate(uint64_t total_created_flows,
uint64_t diff_time = cur_time - flow_info.prev_time_;
uint64_t diff_secs = diff_time / 1000000;
if (diff_secs) {
uint64_t created_flows = total_created_flows -
uint64_t created_flows = created.prev_flow_count -
flow_info.prev_flow_created_;
uint64_t aged_flows = total_aged_flows - flow_info.prev_flow_aged_;
uint64_t aged_flows = aged.prev_flow_count -
flow_info.prev_flow_aged_;
//Flow setup/delete rate are always sent
if (created_flows) {
max_add_rate = created.max_flows_per_second;
min_add_rate = created.min_flows_per_second;
if (max_add_rate == AgentStats::kInvalidFlowCount) {
LOG(WARN, "Invalid max_flow_adds_per_second " << max_add_rate);
max_add_rate = 0;
}
if (min_add_rate == AgentStats::kInvalidFlowCount) {
LOG(WARN, "Invalid min_flow_adds_per_second " << min_add_rate);
min_add_rate = 0;
}
}
if (aged_flows) {
max_del_rate = aged.max_flows_per_second;
min_del_rate = aged.min_flows_per_second;
if (max_del_rate == AgentStats::kInvalidFlowCount) {
LOG(WARN, "Invalid max_flow_deletes_per_second " << max_del_rate);
max_del_rate = 0;
}
if (min_del_rate == AgentStats::kInvalidFlowCount) {
LOG(WARN, "Invalid min_flow_deletes_per_second " << min_del_rate);
min_del_rate = 0;
}
}

flow_rate.set_added_flows(created_flows);
Expand All @@ -356,8 +371,8 @@ bool StatsManager::BuildFlowRate(uint64_t total_created_flows,
agent_->stats()->ResetFlowMinMaxStats(created);
agent_->stats()->ResetFlowMinMaxStats(aged);
flow_info.prev_time_ = cur_time;
flow_info.prev_flow_created_ = total_created_flows;
flow_info.prev_flow_aged_ = total_aged_flows;
flow_info.prev_flow_created_ = created.prev_flow_count;
flow_info.prev_flow_aged_ = aged.prev_flow_count;
return true;
}
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/vnsw/agent/uve/stats_manager.h
Expand Up @@ -180,8 +180,7 @@ class StatsManager {
void InitDone();
bool RequestHandler(boost::shared_ptr<FlowAceStatsRequest> req);
void EnqueueEvent(const boost::shared_ptr<FlowAceStatsRequest> &req);
bool BuildFlowRate(uint64_t flow_created, uint64_t flow_aged,
AgentStats::FlowCounters &created,
bool BuildFlowRate(AgentStats::FlowCounters &created,
AgentStats::FlowCounters &aged,
FlowRateComputeInfo &flow_info,
VrouterFlowRate &flow_rate) const;
Expand Down
8 changes: 2 additions & 6 deletions src/vnsw/agent/uve/vrouter_uve_entry.cc
Expand Up @@ -193,15 +193,12 @@ bool VrouterUveEntry::SendVrouterMsg() {
if (first) {
stats.set_uptime(start_time_);
}
uint64_t flow_created = agent_->stats()->flow_created();
uint64_t flow_aged = agent_->stats()->flow_aged();
AgentStats::FlowCounters &added = agent_->stats()->added();
AgentStats::FlowCounters &deleted = agent_->stats()->deleted();
uint32_t active_flows = agent_->pkt()->get_flow_proto()->FlowCount();

VrouterFlowRate flow_rate;
bool built = uve->stats_manager()->BuildFlowRate(flow_created, flow_aged,
added, deleted, flow_info_,
bool built = uve->stats_manager()->BuildFlowRate(added, deleted, flow_info_,
flow_rate);
if (built) {
flow_rate.set_active_flows(active_flows);
Expand Down Expand Up @@ -352,8 +349,7 @@ bool VrouterUveEntry::BuildPhysicalInterfaceFlowRate
agent_->pkt()->get_flow_proto()->InterfaceFlowCount(intf, &created,
&aged,
&active_flows);
bool built = uve->stats_manager()->BuildFlowRate(created, aged,
s->added, s->deleted,
bool built = uve->stats_manager()->BuildFlowRate(s->added, s->deleted,
s->flow_info,
flow_rate);
if (built) {
Expand Down

0 comments on commit 1fb7f31

Please sign in to comment.