Skip to content

Commit

Permalink
Merge "Send Forward/reverse flow info in FlowDataLog messages" into R3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jun 22, 2016
2 parents d578def + e36595e commit e111711
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/sandesh/common/flow.sandesh
Expand Up @@ -37,6 +37,7 @@ struct FlowLogData {
34: optional u16 underlay_source_port;
35: optional string vmi_uuid;
36: optional string drop_reason;
37: optional bool forward_flow;
}

flowlog sandesh FlowLogDataObject {
Expand Down
6 changes: 6 additions & 0 deletions src/vnsw/agent/uve/test/test_stats_mock.cc
Expand Up @@ -1019,6 +1019,9 @@ TEST_F(StatsTestMock, Underlay_3) {
FlowLogData flow_log = f->last_sent_flow_log();
EXPECT_EQ(flow_log.get_underlay_source_port(), 0);

//Verify that forward_flow field is set
EXPECT_TRUE((flow_log.__isset.forward_flow));

//Verify that teardown_time is not set
EXPECT_FALSE((flow_log.__isset.teardown_time));

Expand All @@ -1032,6 +1035,9 @@ TEST_F(StatsTestMock, Underlay_3) {
EXPECT_TRUE((flow_log.__isset.teardown_time));
EXPECT_TRUE((flow_log.get_teardown_time() != 0));

//Verify that forward_flow field is set
EXPECT_TRUE((flow_log.__isset.forward_flow));

//Remove remote VM routes
util_.DeleteRemoteRoute("vrf5", remote_vm4_ip, peer_);
client->WaitForIdle();
Expand Down
19 changes: 12 additions & 7 deletions src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.cc
Expand Up @@ -542,16 +542,16 @@ bool FlowStatsCollector::Run() {
if (flow_tree_.size() == 0) {
return true;
}

// Update number of entries to visit in flow.
UpdateEntriesToVisit();

// Start task to scan the entries
if (ageing_task_ == NULL) {
ageing_task_ = new AgeingTask(this);
agent_uve_->agent()->task_scheduler()->Enqueue(ageing_task_);
agent_uve_->agent()->task_scheduler()->Enqueue(ageing_task_);
}
return true;
return true;
}

// Called on runnig of a task
Expand Down Expand Up @@ -804,6 +804,11 @@ void FlowStatsCollector::ExportFlow(FlowExportInfo *info,
s_flow.set_sourcevn(flow->data().source_vn_match);
s_flow.set_destvn(flow->data().dest_vn_match);
s_flow.set_vm(flow->data().vm_cfg_name);
if (flow->is_flags_set(FlowEntry::ReverseFlow)) {
s_flow.set_forward_flow(false);
} else {
s_flow.set_forward_flow(true);
}

string drop_reason = FlowEntry::DropReasonStr(flow->data().drop_reason);
s_flow.set_drop_reason(drop_reason);
Expand Down Expand Up @@ -871,6 +876,7 @@ bool FlowStatsManager::UpdateFlowThreshold() {
if (!flow_export_count_) {
return true;
}

// Calculate Flow Export rate
if (prev_flow_export_rate_compute_time_) {
uint64_t diff_secs = 0;
Expand Down Expand Up @@ -1076,11 +1082,10 @@ void FlowStatsCollector::EvictedFlowStatsUpdate(const FlowEntryPtr &flow,
// Introspect routines
/////////////////////////////////////////////////////////////////////////////
void FlowStatsCollectionParamsReq::HandleRequest() const {
FlowStatsCollector *col = Agent::GetInstance()->
flow_stats_manager()->default_flow_stats_collector();
FlowStatsManager *mgr = Agent::GetInstance()->flow_stats_manager();
FlowStatsCollectionParamsResp *resp = new FlowStatsCollectionParamsResp();
resp->set_flow_export_rate(col->flow_export_rate());
resp->set_sampling_threshold(col->threshold());
resp->set_flow_export_rate(mgr->flow_export_rate());
resp->set_sampling_threshold(mgr->threshold());

resp->set_context(context());
resp->Response();
Expand Down
7 changes: 0 additions & 7 deletions src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.h
Expand Up @@ -103,9 +103,6 @@ class FlowStatsCollector : public StatsCollector {
void set_flow_tcp_syn_age_time(uint64_t interval) {
flow_tcp_syn_age_time_ = interval;
}
uint32_t flow_export_count() const { return flow_export_count_; }
void set_flow_export_count(uint32_t val) { flow_export_count_ = val; }
uint32_t flow_export_rate() const { return flow_export_rate_; }
uint32_t threshold() const;
boost::uuids::uuid rand_gen();
bool Run();
Expand Down Expand Up @@ -239,10 +236,6 @@ class FlowStatsCollector : public StatsCollector {

FlowEntryTree flow_tree_;
Queue request_queue_;
uint32_t flow_export_count_;
uint64_t prev_flow_export_rate_compute_time_;
uint32_t flow_export_rate_;
uint32_t prev_cfg_flow_export_rate_;
std::vector<FlowLogData> msg_list_;
uint8_t msg_index_;
tbb::atomic<bool> deleted_;
Expand Down

0 comments on commit e111711

Please sign in to comment.