diff --git a/src/ksync/ksync_sock.h b/src/ksync/ksync_sock.h index f45bb3db191..56507e7858b 100644 --- a/src/ksync/ksync_sock.h +++ b/src/ksync/ksync_sock.h @@ -246,7 +246,6 @@ class KSyncSock { int SendBulkMessage(KSyncBulkSandeshContext *bulk_context, uint32_t seqno); bool TryAddToBulk(KSyncBulkSandeshContext *bulk_context, IoContext *ioc); void OnEmptyQueue(bool done); - int tx_count() const { return tx_count_; } // Start Ksync Asio operations static void Start(bool read_inline); diff --git a/src/ksync/ksync_sock_user.cc b/src/ksync/ksync_sock_user.cc index dfa6b5b5a31..2d36c3e6197 100644 --- a/src/ksync/ksync_sock_user.cc +++ b/src/ksync/ksync_sock_user.cc @@ -639,20 +639,6 @@ void KSyncSockTypeMap::IncrFlowStats(int idx, int pkts, int bytes) { } } -void KSyncSockTypeMap::SetEvictedFlag(int idx) { - vr_flow_entry *f = &flow_table_[idx]; - if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) { - f->fe_flags |= VR_FLOW_FLAG_EVICTED; - } -} - -void KSyncSockTypeMap::ResetEvictedFlag(int idx) { - vr_flow_entry *f = &flow_table_[idx]; - if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) { - f->fe_flags &= ~VR_FLOW_FLAG_EVICTED; - } -} - void KSyncSockTypeMap::SetTcpFlag(int idx, uint32_t flags) { vr_flow_entry *f = &flow_table_[idx]; if (f->fe_flags & VR_FLOW_FLAG_ACTIVE) { diff --git a/src/ksync/ksync_sock_user.h b/src/ksync/ksync_sock_user.h index 4f4d9ff483c..a664c0f6490 100644 --- a/src/ksync/ksync_sock_user.h +++ b/src/ksync/ksync_sock_user.h @@ -176,8 +176,6 @@ class KSyncSockTypeMap : public KSyncSock { static void SetFlowEntry(vr_flow_req *req, bool set); static void IncrFlowStats(int idx, int pkts, int bytes); static void SetTcpFlag(int idx, uint32_t flags); - static void SetEvictedFlag(int idx); - static void ResetEvictedFlag(int idx); static void SetOFlowStats(int idx, uint8_t pkts, uint16_t bytes); static void SetFlowTcpFlags(int idx, uint16_t flags);; static void FlowNatResponse(uint32_t seq_num, vr_flow_req *req); diff --git a/src/vnsw/agent/pkt/flow_entry.cc b/src/vnsw/agent/pkt/flow_entry.cc index 5084be6b0d6..c9a9ccd4015 100644 --- a/src/vnsw/agent/pkt/flow_entry.cc +++ b/src/vnsw/agent/pkt/flow_entry.cc @@ -348,7 +348,6 @@ void FlowEntry::Reset() { sg_rule_uuid_= FlowPolicyStateStr.at(NOT_EVALUATED); ksync_index_entry_ = std::auto_ptr (new KSyncFlowIndexEntry()); - vrouter_evicted_ = false; } void FlowEntry::Reset(const FlowKey &k) { diff --git a/src/vnsw/agent/pkt/flow_entry.h b/src/vnsw/agent/pkt/flow_entry.h index 0bfc34db5be..4eb81f52099 100644 --- a/src/vnsw/agent/pkt/flow_entry.h +++ b/src/vnsw/agent/pkt/flow_entry.h @@ -483,8 +483,6 @@ class FlowEntry { void set_fsc(FlowStatsCollector *fsc) { fsc_ = fsc; } - void set_vrouter_evicted(bool value) { vrouter_evicted_ = value; } - bool vrouter_evicted() const { return vrouter_evicted_; } static std::string DropReasonStr(uint16_t reason); private: friend class FlowTable; @@ -530,7 +528,6 @@ class FlowEntry { tbb::mutex mutex_; boost::intrusive::list_member_hook<> free_list_node_; FlowStatsCollector *fsc_; - bool vrouter_evicted_; // IMPORTANT: Remember to update Reset() routine if new fields are added // IMPORTANT: Remember to update Copy() routine if new fields are added diff --git a/src/vnsw/agent/pkt/flow_event.h b/src/vnsw/agent/pkt/flow_event.h index faf4dacb641..efd2b632dd7 100644 --- a/src/vnsw/agent/pkt/flow_event.h +++ b/src/vnsw/agent/pkt/flow_event.h @@ -58,61 +58,60 @@ class FlowEvent { FlowEvent() : event_(INVALID), flow_(NULL), pkt_info_(), db_entry_(NULL), - gen_id_(0), del_rev_flow_(false), vrouter_evicted_(false), + gen_id_(0), del_rev_flow_(false), flow_handle_(FlowEntry::kInvalidFlowHandle), ksync_entry_(NULL), ksync_event_() { } FlowEvent(Event event) : event_(event), flow_(NULL), pkt_info_(), db_entry_(NULL), - gen_id_(0), del_rev_flow_(false), vrouter_evicted_(false), - ksync_entry_(NULL), ksync_event_() { + gen_id_(0), del_rev_flow_(false), ksync_entry_(NULL), ksync_event_() { } FlowEvent(Event event, FlowEntry *flow) : event_(event), flow_(flow), pkt_info_(), db_entry_(NULL), - gen_id_(0), del_rev_flow_(false), vrouter_evicted_(false), + gen_id_(0), del_rev_flow_(false), flow_handle_(FlowEntry::kInvalidFlowHandle), ksync_entry_(NULL), ksync_event_() { } FlowEvent(Event event, FlowEntry *flow, uint32_t flow_handle) : event_(event), flow_(flow), pkt_info_(), db_entry_(NULL), - gen_id_(0), del_rev_flow_(false), vrouter_evicted_(false), - flow_handle_(flow_handle), ksync_entry_(NULL), ksync_event_() { + gen_id_(0), del_rev_flow_(false), flow_handle_(flow_handle), + ksync_entry_(NULL), ksync_event_() { } FlowEvent(Event event, FlowEntry *flow, const DBEntry *db_entry) : event_(event), flow_(flow), pkt_info_(), db_entry_(db_entry), - gen_id_(0), del_rev_flow_(false), vrouter_evicted_(false), + gen_id_(0), del_rev_flow_(false), flow_handle_(FlowEntry::kInvalidFlowHandle), ksync_entry_(NULL), ksync_event_() { } FlowEvent(Event event, const DBEntry *db_entry, uint32_t gen_id) : event_(event), flow_(NULL), pkt_info_(), db_entry_(db_entry), - gen_id_(gen_id), del_rev_flow_(false), vrouter_evicted_(false), + gen_id_(gen_id), del_rev_flow_(false), flow_handle_(FlowEntry::kInvalidFlowHandle), ksync_entry_(NULL), ksync_event_() { } - FlowEvent(Event event, const FlowKey &key, bool del_rev_flow, bool evict) : + FlowEvent(Event event, const FlowKey &key, bool del_rev_flow) : event_(event), flow_(NULL), pkt_info_(), db_entry_(NULL), gen_id_(0), flow_key_(key), del_rev_flow_(del_rev_flow), - vrouter_evicted_(evict), flow_handle_(FlowEntry::kInvalidFlowHandle), - ksync_entry_(NULL), ksync_event_() { + flow_handle_(FlowEntry::kInvalidFlowHandle), ksync_entry_(NULL), + ksync_event_() { } FlowEvent(Event event, PktInfoPtr pkt_info) : event_(event), flow_(NULL), pkt_info_(pkt_info), db_entry_(NULL), - gen_id_(0), flow_key_(), del_rev_flow_(), vrouter_evicted_(false), + gen_id_(0), flow_key_(), del_rev_flow_(), flow_handle_(FlowEntry::kInvalidFlowHandle), ksync_entry_(NULL), ksync_event_() { } FlowEvent(KSyncEntry *entry, KSyncEntry::KSyncEvent event) : event_(KSYNC_EVENT), flow_(NULL), pkt_info_(), db_entry_(NULL), - gen_id_(0), flow_key_(), del_rev_flow_(), vrouter_evicted_(false), + gen_id_(0), flow_key_(), del_rev_flow_(), flow_handle_(FlowEntry::kInvalidFlowHandle), ksync_entry_(entry), ksync_event_(event) { } @@ -120,22 +119,21 @@ class FlowEvent { FlowEvent(KSyncEntry *entry, uint32_t flow_handle) : event_(FLOW_HANDLE_UPDATE), flow_(NULL), pkt_info_(), db_entry_(NULL), gen_id_(0), flow_key_(), del_rev_flow_(), - vrouter_evicted_(false), flow_handle_(flow_handle), ksync_entry_(entry), - ksync_event_() { + flow_handle_(flow_handle), ksync_entry_(entry), ksync_event_() { } FlowEvent(KSyncEntry *entry) : event_(KSYNC_VROUTER_ERROR), flow_(NULL), pkt_info_(), db_entry_(NULL), gen_id_(0), flow_key_(), del_rev_flow_(), - vrouter_evicted_(false), flow_handle_(FlowEntry::kInvalidFlowHandle), - ksync_entry_(entry), ksync_event_() { + flow_handle_(FlowEntry::kInvalidFlowHandle), ksync_entry_(entry), + ksync_event_() { } FlowEvent(const FlowEvent &rhs) : event_(rhs.event_), flow_(rhs.flow()), pkt_info_(rhs.pkt_info_), db_entry_(rhs.db_entry_), gen_id_(rhs.gen_id_), flow_key_(rhs.flow_key_), del_rev_flow_(rhs.del_rev_flow_), - vrouter_evicted_(rhs.vrouter_evicted_), flow_handle_(rhs.flow_handle_), + flow_handle_(rhs.flow_handle_), ksync_entry_(rhs.ksync_entry_), ksync_event_(rhs.ksync_event_) { } @@ -149,7 +147,6 @@ class FlowEvent { uint32_t gen_id() const { return gen_id_; } const FlowKey &get_flow_key() const { return flow_key_; } bool get_del_rev_flow() const { return del_rev_flow_; } - bool get_vrouter_evicted() const { return vrouter_evicted_; } PktInfoPtr pkt_info() const { return pkt_info_; } uint32_t flow_handle() const { return flow_handle_; } @@ -163,7 +160,6 @@ class FlowEvent { uint32_t gen_id_; FlowKey flow_key_; bool del_rev_flow_; - bool vrouter_evicted_; uint32_t flow_handle_; KSyncEntry::KSyncEntryPtr ksync_entry_; KSyncEntry::KSyncEvent ksync_event_; diff --git a/src/vnsw/agent/pkt/flow_mgmt.cc b/src/vnsw/agent/pkt/flow_mgmt.cc index 1a5c6b3bbaa..31f95a3cf96 100644 --- a/src/vnsw/agent/pkt/flow_mgmt.cc +++ b/src/vnsw/agent/pkt/flow_mgmt.cc @@ -259,7 +259,7 @@ bool BgpAsAServiceFlowMgmtEntry::NonOperEntryDelete(FlowMgmtManager *mgr, Tree::iterator it = tree_.begin(); while (it != tree_.end()) { - FlowEvent flow_resp(event, (*it)->key(), true, false); + FlowEvent flow_resp(event, (*it)->key(), true); flow_resp.set_flow(*it); mgr->EnqueueFlowEvent(flow_resp); it++; diff --git a/src/vnsw/agent/pkt/flow_proto.cc b/src/vnsw/agent/pkt/flow_proto.cc index 03bd073f346..db6f0aacf02 100644 --- a/src/vnsw/agent/pkt/flow_proto.cc +++ b/src/vnsw/agent/pkt/flow_proto.cc @@ -259,8 +259,7 @@ bool FlowProto::FlowEventHandler(const FlowEvent &req, FlowTable *table) { case FlowEvent::DELETE_FLOW: { FlowTable *table = GetFlowTable(req.get_flow_key()); - table->Delete(req.get_flow_key(), req.get_del_rev_flow(), - req.get_vrouter_evicted()); + table->Delete(req.get_flow_key(), req.get_del_rev_flow()); break; } @@ -355,10 +354,8 @@ bool FlowProto::FlowEventHandler(const FlowEvent &req, FlowTable *table) { return true; } -void FlowProto::DeleteFlowRequest(const FlowKey &flow_key, bool del_rev_flow, - bool evicted) { - EnqueueFlowEvent(FlowEvent(FlowEvent::DELETE_FLOW, flow_key, del_rev_flow, - evicted)); +void FlowProto::DeleteFlowRequest(const FlowKey &flow_key, bool del_rev_flow) { + EnqueueFlowEvent(FlowEvent(FlowEvent::DELETE_FLOW, flow_key, del_rev_flow)); return; } @@ -380,7 +377,7 @@ void FlowProto::CreateAuditEntry(FlowEntry *flow) { void FlowProto::GrowFreeListRequest(const FlowKey &key) { - EnqueueFlowEvent(FlowEvent(FlowEvent::GROW_FREE_LIST, key, false, false)); + EnqueueFlowEvent(FlowEvent(FlowEvent::GROW_FREE_LIST, key, false)); return; } diff --git a/src/vnsw/agent/pkt/flow_proto.h b/src/vnsw/agent/pkt/flow_proto.h index 00366bfee7e..f73b6a2186e 100644 --- a/src/vnsw/agent/pkt/flow_proto.h +++ b/src/vnsw/agent/pkt/flow_proto.h @@ -62,8 +62,7 @@ class FlowProto : public Proto { void EnqueueEvent(const FlowEvent &event, FlowTable *table); void EnqueueFlowEvent(const FlowEvent &event); - void DeleteFlowRequest(const FlowKey &flow_key, bool del_rev_flow, - bool evicted); + void DeleteFlowRequest(const FlowKey &flow_key, bool del_rev_flow); void EvictFlowRequest(FlowEntry *flow, uint32_t flow_handle); void RetryIndexAcquireRequest(FlowEntry *flow, uint32_t flow_handle); void CreateAuditEntry(FlowEntry *flow); diff --git a/src/vnsw/agent/pkt/flow_table.cc b/src/vnsw/agent/pkt/flow_table.cc index 808392467e7..ee170915ef3 100644 --- a/src/vnsw/agent/pkt/flow_table.cc +++ b/src/vnsw/agent/pkt/flow_table.cc @@ -263,8 +263,7 @@ void FlowTable::DeleteInternal(FlowEntryMap::iterator &it, uint64_t time) { agent_->stats()->UpdateFlowDelMinMaxStats(time); } -bool FlowTable::Delete(const FlowKey &key, bool del_reverse_flow, - bool vrouter_evicted) { +bool FlowTable::Delete(const FlowKey &key, bool del_reverse_flow) { FlowEntryMap::iterator it; FlowEntry *fe; @@ -273,7 +272,6 @@ bool FlowTable::Delete(const FlowKey &key, bool del_reverse_flow, return false; } fe = it->second; - fe->set_vrouter_evicted(vrouter_evicted); FlowEntry *reverse_flow = NULL; if (del_reverse_flow) { @@ -290,7 +288,6 @@ bool FlowTable::Delete(const FlowKey &key, bool del_reverse_flow, it = flow_entry_map_.find(reverse_flow->key()); if (it != flow_entry_map_.end()) { - it->second->set_vrouter_evicted(vrouter_evicted); DeleteInternal(it, time); return true; } @@ -308,7 +305,7 @@ void FlowTable::DeleteAll() { it->second == entry->reverse_flow_entry()) { ++it; } - Delete(entry->key(), true, false); + Delete(entry->key(), true); } } @@ -369,7 +366,7 @@ void FlowTable::UpdateReverseFlow(FlowEntry *flow, FlowEntry *rflow) { //same reverse flow as its is nat'd with fabric sip/dip. //To avoid this delete old flow and dont let new flow to be short flow. if (rflow_rev) { - Delete(rflow_rev->key(), false, false); + Delete(rflow_rev->key(), false); rflow_rev = NULL; } } @@ -671,7 +668,7 @@ void FlowTable::RevaluateFlow(FlowEntry *flow) { // Handle deletion of a Route. Flow management module has identified that route // must be deleted void FlowTable::DeleteMessage(FlowEntry *flow) { - Delete(flow->key(), true, false); + Delete(flow->key(), true); DeleteFlowInfo(flow); } diff --git a/src/vnsw/agent/pkt/flow_table.h b/src/vnsw/agent/pkt/flow_table.h index 47ca28e41ad..b56f07676ae 100644 --- a/src/vnsw/agent/pkt/flow_table.h +++ b/src/vnsw/agent/pkt/flow_table.h @@ -163,7 +163,7 @@ class FlowTable { bool IsEvictedFlow(const FlowKey &key); void Add(FlowEntry *flow, FlowEntry *rflow); void Update(FlowEntry *flow, FlowEntry *rflow); - bool Delete(const FlowKey &key, bool del_reverse_flow, bool evicted); + bool Delete(const FlowKey &key, bool del_reverse_flow); bool Delete(const FlowKey &flow_key); void DeleteAll(); // Test code only used method diff --git a/src/vnsw/agent/pkt/test/test_flow_eviction.cc b/src/vnsw/agent/pkt/test/test_flow_eviction.cc index aee12e023f7..e1aba988706 100644 --- a/src/vnsw/agent/pkt/test/test_flow_eviction.cc +++ b/src/vnsw/agent/pkt/test/test_flow_eviction.cc @@ -9,7 +9,6 @@ #include "ksync/ksync_sock_user.h" #include "oper/tunnel_nh.h" #include "pkt/flow_mgmt.h" -#include "uve/test/test_uve_util.h" #include #define vm1_ip "1.1.1.1" @@ -24,7 +23,7 @@ struct PortInfo input[] = { class FlowEvictionTest : public ::testing::Test { public: - FlowEvictionTest() : peer_(NULL), agent_(Agent::GetInstance()), util_() { + FlowEvictionTest() : peer_(NULL), agent_(Agent::GetInstance()) { flow_proto_ = agent_->pkt()->get_flow_proto(); flow_mgmt_ = agent_->pkt()->flow_mgmt_manager(); eth = EthInterfaceGet("vnet0"); @@ -106,7 +105,6 @@ class FlowEvictionTest : public ::testing::Test { char router_id_[80]; InetUnicastAgentRouteTable *inet4_table_; KSyncSockTypeMap *ksync_sock_; - TestUveUtil util_; }; // New flow no-eviction @@ -419,7 +417,7 @@ TEST_F(FlowEvictionTest, Delete_Evicted_Flow_1) { EXPECT_TRUE(FlowGet(vrf_id, remote_vm1_ip, vm1_ip, 2, 0, 0, vif0->flow_key_nh()->id()) == false); - flow_proto_->DeleteFlowRequest(key, true, false); + flow_proto_->DeleteFlowRequest(key, true); client->WaitForIdle(); // New flow should be present @@ -443,7 +441,7 @@ TEST_F(FlowEvictionTest, Delete_Evicted_Flow_2) { EXPECT_TRUE(flow != NULL); // Generate delete request followed by flow-evict - flow_proto_->DeleteFlowRequest(flow->key(), true, false); + flow_proto_->DeleteFlowRequest(flow->key(), true); // Generate a flow that evicts flow created above TxIpMplsPacket(eth->id(), remote_compute, router_id_, vif0->label(), remote_vm1_ip, vm1_ip, 1, 1); @@ -476,7 +474,7 @@ TEST_F(FlowEvictionTest, Delete_Index_Unassigned_Flow_1) { EXPECT_TRUE(flow != NULL); FlowKey key = flow->key(); - flow_proto_->DeleteFlowRequest(key, true, false); + flow_proto_->DeleteFlowRequest(key, true); client->WaitForIdle(); ksync_sock_->DisableReceiveQueue(false); @@ -486,53 +484,6 @@ TEST_F(FlowEvictionTest, Delete_Index_Unassigned_Flow_1) { vif0->flow_key_nh()->id()) == NULL); } -TEST_F(FlowEvictionTest, AgeOutVrouterEvictedFlow) { - TxIpMplsPacket(eth->id(), remote_compute, router_id_, vif0->label(), - remote_vm1_ip, vm1_ip, 1, 1); - client->WaitForIdle(); - - uint32_t vrf_id = vif0->vrf_id(); - FlowEntry *flow = FlowGet(vrf_id, remote_vm1_ip, vm1_ip, 1, 0, 0, - vif0->flow_key_nh()->id()); - EXPECT_TRUE(flow != NULL); - uint32_t flow_handle = flow->flow_handle(); - EXPECT_TRUE(flow_handle != FlowEntry::kInvalidFlowHandle); - KSyncSock *sock = KSyncSock::Get(0); - - //Fetch the delete_count_ for delete enqueues - uint32_t delete_count = agent_->GetFlowProto()->flow_stats()->delete_count_; - uint32_t tx_count = sock->tx_count(); - - //Invoke FlowStatsCollector to enqueue delete for evicted flow. - util_.EnqueueFlowStatsCollectorTask(); - client->WaitForIdle(); - - //Verify that delete count has not been modified - EXPECT_EQ(delete_count, agent_->GetFlowProto()->flow_stats()-> - delete_count_); - - //Set Evicted flag for the flow - KSyncSockTypeMap::SetEvictedFlag(flow_handle); - - //Invoke FlowStatsCollector to enqueue delete for evicted flow. - util_.EnqueueFlowStatsCollectorTask(); - client->WaitForIdle(); - - //Verify that delete count has been increased by 1 - EXPECT_EQ((delete_count + 1), agent_->GetFlowProto()->flow_stats()-> - delete_count_); - - //Verify that evicted flows have been removed - WAIT_FOR(100, 100, (flow_proto_->FlowCount() == 0)); - - //Verify that tx_count is unchanged after deletion of evicted flows - //because agent does not sent any message to vrouter for evicted flows - EXPECT_EQ(tx_count, sock->tx_count()); - - //Reset the Evicted flag set by this test-case - KSyncSockTypeMap::ResetEvictedFlag(flow_handle); -} - int main(int argc, char *argv[]) { int ret = 0; diff --git a/src/vnsw/agent/pkt/test/test_flow_util.h b/src/vnsw/agent/pkt/test/test_flow_util.h index 163e5730180..4775fcff886 100644 --- a/src/vnsw/agent/pkt/test/test_flow_util.h +++ b/src/vnsw/agent/pkt/test/test_flow_util.h @@ -246,7 +246,7 @@ class TestFlowPkt { virtual bool Run() { FlowTable *table = Agent::GetInstance()->pkt()->get_flow_proto()->GetFlowTable(key_); - table->Delete(key_, true, false); + table->Delete(key_, true); return true; } std::string Description() const { return "FlowDeleteTask"; } diff --git a/src/vnsw/agent/pkt/test/test_flowtable.cc b/src/vnsw/agent/pkt/test/test_flowtable.cc index 58b1a6da07d..a14e8078ee9 100644 --- a/src/vnsw/agent/pkt/test/test_flowtable.cc +++ b/src/vnsw/agent/pkt/test/test_flowtable.cc @@ -270,7 +270,7 @@ class FlowTableTest : public ::testing::Test { flow->InitFlowKey(&key); FlowTable *table = Agent::GetInstance()->pkt()->get_flow_proto()->GetFlowTable(key); - table->Delete(key, true, false); + table->Delete(key, true); client->WaitForIdle(); } diff --git a/src/vnsw/agent/test/test_util.cc b/src/vnsw/agent/test/test_util.cc index 8c007c488f4..f7ad68ed100 100644 --- a/src/vnsw/agent/test/test_util.cc +++ b/src/vnsw/agent/test/test_util.cc @@ -2792,7 +2792,7 @@ static bool FlowDeleteTrigger(FlowKey key) { return true; } - table->Delete(key, true, false); + table->Delete(key, true); return true; } diff --git a/src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.cc b/src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.cc index d7f4d1eb25e..634abccef68 100644 --- a/src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.cc +++ b/src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.cc @@ -289,10 +289,8 @@ void FlowStatsCollector::UpdateStatsAndExportFlow(FlowExportInfo *info, ExportFlow(key, info, 0, 0); } -void FlowStatsCollector::FlowDeleteEnqueue(const FlowKey &key, bool rev, - bool evicted) { - agent_uve_->agent()->pkt()->get_flow_proto()-> - DeleteFlowRequest(key, rev, evicted); +void FlowStatsCollector::FlowDeleteEnqueue(const FlowKey &key, bool rev) { + agent_uve_->agent()->pkt()->get_flow_proto()->DeleteFlowRequest(key, rev); } void FlowStatsCollector::UpdateFlowStatsInternal(FlowExportInfo *info, @@ -346,7 +344,7 @@ bool FlowStatsCollector::Run() { FlowExportInfo *rev_info = NULL; FlowExportInfo *info = NULL; uint32_t count = 0; - bool key_updation_reqd = true, deleted, vrouter_evicted; + bool key_updation_reqd = true, deleted; Agent *agent = agent_uve_->agent(); FlowTable *flow_obj = agent->pkt()->flow_table(0); FlowKey key; @@ -368,18 +366,12 @@ bool FlowStatsCollector::Run() { info = &it->second; it++; deleted = false; - vrouter_evicted = false; flow_iteration_key_ = it->first; const vr_flow_entry *k_flow = ksync_obj->GetValidKFlowEntry (key, info->flow_handle()); - if (k_flow && ksync_obj->IsEvictionMarked(k_flow)) { - deleted = true; - vrouter_evicted = true; - rev_info = FindFlowExportInfo(info->rev_flow_key()); - } // Can the flow be aged? - if (!deleted && ShouldBeAged(info, k_flow, curr_time, key)) { + if (ShouldBeAged(info, k_flow, curr_time, key)) { rev_info = FindFlowExportInfo(info->rev_flow_key()); // If reverse_flow is present, wait till both are aged if (rev_info) { @@ -403,8 +395,7 @@ bool FlowStatsCollector::Run() { it++; } } - FlowDeleteEnqueue(key, rev_info != NULL? true : false, - vrouter_evicted); + FlowDeleteEnqueue(key, rev_info != NULL? true : false); if (rev_info) { count++; if (count == flow_count_per_pass_) { @@ -447,7 +438,7 @@ bool FlowStatsCollector::Run() { it++; } } - FlowDeleteEnqueue(key, true, vrouter_evicted); + FlowDeleteEnqueue(key, true); if (rev_info) { count++; if (count == flow_count_per_pass_) { diff --git a/src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.h b/src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.h index 576ea6eaa9f..3d6430ab5e7 100644 --- a/src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.h +++ b/src/vnsw/agent/vrouter/flow_stats/flow_stats_collector.h @@ -144,7 +144,7 @@ class FlowStatsCollector : public StatsCollector { bool teardown_time, uint64_t *diff_bytes, uint64_t *diff_pkts); - void FlowDeleteEnqueue(const FlowKey &key, bool rev, bool evicted); + void FlowDeleteEnqueue(const FlowKey &key, bool rev); void EnqueueFlowMsg(); void DispatchPendingFlowMsg(); void GetFlowSandeshActionParams(const FlowAction &action_info, diff --git a/src/vnsw/agent/vrouter/ksync/flowtable_ksync.cc b/src/vnsw/agent/vrouter/ksync/flowtable_ksync.cc index 2d94e3bbce8..b35752503b9 100644 --- a/src/vnsw/agent/vrouter/ksync/flowtable_ksync.cc +++ b/src/vnsw/agent/vrouter/ksync/flowtable_ksync.cc @@ -183,10 +183,6 @@ int FlowTableKSyncEntry::Encode(sandesh_op::type op, char *buf, int buf_len) { return 0; } - if (flow_entry_->vrouter_evicted()) { - return 0; - } - req.set_fr_op(flow_op::FLOW_SET); req.set_fr_rid(0); req.set_fr_index(hash_id_); @@ -526,22 +522,19 @@ void FlowTableKSyncEntry::ErrorHandler(int err, uint32_t seq_no) const { seq_no); return; } - if (err == EINVAL) { - if (flow_entry_->deleted()) { - return; - } - const FlowKey &key = flow_entry_->key(); - if (key.protocol == IPPROTO_TCP) { - // TCP flows may be evicted in vrouter, ignore the error - // and enqueue the flow for delete - ksync_obj_->ksync()->agent()->pkt()-> - get_flow_proto()->DeleteFlowRequest(key, true, true); - return; - } + if (err == EINVAL && IgnoreVrouterError()) { + return; } KSyncEntry::ErrorHandler(err, seq_no); } +bool FlowTableKSyncEntry::IgnoreVrouterError() const { + if (flow_entry_->deleted()) + return true; + + return false; +} + std::string FlowTableKSyncEntry::VrouterError(uint32_t error) const { if (error == EBADF) return "Flow Key Mismatch"; diff --git a/src/vnsw/agent/vrouter/ksync/flowtable_ksync.h b/src/vnsw/agent/vrouter/ksync/flowtable_ksync.h index f715f40d78c..3fa629e7101 100644 --- a/src/vnsw/agent/vrouter/ksync/flowtable_ksync.h +++ b/src/vnsw/agent/vrouter/ksync/flowtable_ksync.h @@ -55,6 +55,7 @@ class FlowTableKSyncEntry : public KSyncNetlinkEntry { virtual std::string VrouterError(uint32_t error) const; private: friend class KSyncFlowEntryFreeList; + bool IgnoreVrouterError() const; FlowEntryPtr flow_entry_; uint32_t hash_id_; diff --git a/src/vnsw/agent/vrouter/ksync/ksync_flow_memory.cc b/src/vnsw/agent/vrouter/ksync/ksync_flow_memory.cc index cf708003260..0cae91a2b8b 100644 --- a/src/vnsw/agent/vrouter/ksync/ksync_flow_memory.cc +++ b/src/vnsw/agent/vrouter/ksync/ksync_flow_memory.cc @@ -207,14 +207,10 @@ const vr_flow_entry *KSyncFlowMemory::GetValidKFlowEntry(const FlowKey &key, if (table->IsEvictedFlow(key) && !IsEvictionMarked(kflow)) { return NULL; } - /* Don't compare keys, if the flow is marked for eviction as keys - * would be reset by vrouter for evicted flows */ - if (!IsEvictionMarked(kflow)) { - FlowKey rhs; - KFlow2FlowKey(kflow, &rhs); - if (!key.IsEqual(rhs)) { - return NULL; - } + FlowKey rhs; + KFlow2FlowKey(kflow, &rhs); + if (!key.IsEqual(rhs)) { + return NULL; } /* TODO: If a flow is evicted from vrouter and later flow with same * key is assigned with same index, then we may end up reading diff --git a/src/vnsw/agent/vrouter/ksync/ksync_flow_memory.h b/src/vnsw/agent/vrouter/ksync/ksync_flow_memory.h index 8785068d692..3f708848b23 100644 --- a/src/vnsw/agent/vrouter/ksync/ksync_flow_memory.h +++ b/src/vnsw/agent/vrouter/ksync/ksync_flow_memory.h @@ -50,8 +50,8 @@ class KSyncFlowMemory { void set_flow_table_path(const std::string &path) { flow_table_path_ = path; } - bool IsEvictionMarked(const vr_flow_entry *entry) const; private: + bool IsEvictionMarked(const vr_flow_entry *entry) const; void KFlow2FlowKey(const vr_flow_entry *entry, FlowKey *key) const; KSync *ksync_;