Skip to content

Commit

Permalink
Merge "Make FlowProto run independent of flow-aging, KSync and flow-a…
Browse files Browse the repository at this point in the history
…udit"
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Nov 20, 2015
2 parents faf6219 + d7509bf commit 28c770b
Show file tree
Hide file tree
Showing 33 changed files with 413 additions and 375 deletions.
4 changes: 2 additions & 2 deletions src/db/db_table_partition.cc
Expand Up @@ -134,7 +134,7 @@ DBEntry *DBTablePartition::FindInternal(const DBEntry *entry) {
return NULL;
}
DBEntry *DBTablePartition::FindNoLock(const DBEntry *entry) {
CHECK_CONCURRENCY("db::DBTable", "Agent::FlowHandler", "Agent::FlowTable");
CHECK_CONCURRENCY("db::DBTable", "Agent::FlowEvent", "Agent::FlowUpdate");
return FindInternal(entry);
}

Expand All @@ -144,7 +144,7 @@ DBEntry *DBTablePartition::Find(const DBEntry *entry) {
}

DBEntry *DBTablePartition::FindNoLock(const DBRequestKey *key) {
CHECK_CONCURRENCY("db::DBTable", "Agent::FlowHandler", "Agent::FlowTable");
CHECK_CONCURRENCY("db::DBTable", "Agent::FlowEvent", "Agent::FlowUpdate");
DBTable *table = static_cast<DBTable *>(parent());
std::auto_ptr<DBEntry> entry_ptr = table->AllocEntry(key);
return FindInternal(entry_ptr.get());
Expand Down
10 changes: 3 additions & 7 deletions src/ksync/ksync_object.cc
Expand Up @@ -208,15 +208,11 @@ void KSyncObject::Delete(KSyncEntry *entry) {
SafeNotifyEvent(entry, KSyncEntry::DEL_REQ);
}

void KSyncObject::InsertToTree(KSyncEntry *entry) {
tbb::recursive_mutex::scoped_lock lock(lock_);
assert(entry->GetRefCount() > 0);
tree_.insert(*entry);
}

void KSyncObject::RemoveFromTree(KSyncEntry *entry) {
void KSyncObject::ChangeKey(KSyncEntry *entry, uint32_t arg) {
tbb::recursive_mutex::scoped_lock lock(lock_);
assert(tree_.erase(*entry) > 0);
UpdateKey(entry, arg);
tree_.insert(*entry);
}

void KSyncObject::FreeInd(KSyncEntry *entry, uint32_t index) {
Expand Down
4 changes: 2 additions & 2 deletions src/ksync/ksync_object.h
Expand Up @@ -152,8 +152,8 @@ class KSyncObject {
// Big lock on the tree
// TODO: Make this more fine granular
tbb::recursive_mutex lock_;
void InsertToTree(KSyncEntry* entry);
void RemoveFromTree(KSyncEntry* entry);
void ChangeKey(KSyncEntry *entry, uint32_t arg);
virtual void UpdateKey(KSyncEntry *entry, uint32_t arg) { }

private:
friend class KSyncEntry;
Expand Down
22 changes: 7 additions & 15 deletions src/vnsw/agent/cmn/agent.cc
Expand Up @@ -101,8 +101,9 @@ void Agent::SetAgentTaskPolicy() {
initialized = true;

const char *db_exclude_list[] = {
"Agent::FlowTable",
"Agent::FlowHandler",
kTaskFlowEvent,
kTaskFlowUpdate,
kTaskFlowAudit,
"Agent::Services",
"Agent::StatsCollector",
"sandesh::RecvQueue",
Expand All @@ -117,22 +118,17 @@ void Agent::SetAgentTaskPolicy() {
const char *flow_table_exclude_list[] = {
AGENT_INIT_TASKNAME
};
SetTaskPolicyOne("Agent::FlowTable", flow_table_exclude_list,
SetTaskPolicyOne(kTaskFlowEvent, flow_table_exclude_list,
sizeof(flow_table_exclude_list) / sizeof(char *));

const char *flow_exclude_list[] = {
"Agent::StatsCollector",
"io::ReaderTask",
"Agent::PktFlowResponder",
AGENT_INIT_TASKNAME
};
SetTaskPolicyOne("Agent::FlowHandler", flow_exclude_list,
SetTaskPolicyOne(kTaskFlowUpdate, flow_exclude_list,
sizeof(flow_exclude_list) / sizeof(char *));

const char *sandesh_exclude_list[] = {
"db::DBTable",
"Agent::FlowTable",
"Agent::FlowHandler",
"Agent::Services",
"Agent::StatsCollector",
"io::ReaderTask",
Expand All @@ -143,8 +139,6 @@ void Agent::SetAgentTaskPolicy() {
sizeof(sandesh_exclude_list) / sizeof(char *));

const char *xmpp_config_exclude_list[] = {
"Agent::FlowTable",
"Agent::FlowHandler",
"Agent::Services",
"Agent::StatsCollector",
"sandesh::RecvQueue",
Expand Down Expand Up @@ -176,8 +170,6 @@ void Agent::SetAgentTaskPolicy() {
sizeof(walk_cancel_exclude_list) / sizeof(char *));

const char *ksync_exclude_list[] = {
"Agent::FlowTable",
"Agent::FlowHandler",
"Agent::StatsCollector",
"db::DBTable",
"Agent::PktFlowResponder",
Expand Down Expand Up @@ -623,8 +615,8 @@ bool Agent::isVmwareVcenterMode() const {
void Agent::ConcurrencyCheck() {
if (test_mode_) {
CHECK_CONCURRENCY("db::DBTable", "Agent::KSync", AGENT_INIT_TASKNAME,
"Flow::Management", "Agent::FlowHandler",
"Agent::FlowTable");
"Flow::Management", kTaskFlowUpdate,
kTaskFlowEvent);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/vnsw/agent/cmn/agent.h
Expand Up @@ -200,6 +200,10 @@ extern void RouterIdDepInit(Agent *agent);

#define VROUTER_SERVER_PORT 20914

#define kTaskFlowUpdate "Agent::FlowUpdate"
#define kTaskFlowEvent "Agent::FlowEvent"
#define kTaskFlowAudit "KSync::FlowAudit"

class Agent {
public:
static const uint32_t kDefaultMaxLinkLocalOpenFds = 2048;
Expand Down
14 changes: 7 additions & 7 deletions src/vnsw/agent/oper/test/test_find_scale.cc
Expand Up @@ -219,7 +219,7 @@ class ScaleTask : public Task {
public:
ScaleTask(VlanTable *table, bool use_key, bool do_lock, int thread_count,
uint32_t find_count) :
Task(TaskScheduler::GetInstance()->GetTaskId("Agent::FlowTable"), -1),
Task(TaskScheduler::GetInstance()->GetTaskId(kTaskFlowEvent), -1),
table_(table), do_lock_(do_lock), use_key_(use_key),
thread_count_(thread_count), find_count_(find_count) {
}
Expand All @@ -244,7 +244,7 @@ class ScaleTask : public Task {

// Find routine tests
TEST_F(DBTest, Find) {
ConcurrencyScope scope("Agent::FlowTable");
ConcurrencyScope scope(kTaskFlowEvent);
VlanTableReqKey key(101);
EXPECT_TRUE(table_->Find(&key) != NULL);
EXPECT_TRUE(table_->FindNoLock(&key) != NULL);
Expand All @@ -256,7 +256,7 @@ TEST_F(DBTest, Find) {

// Find routine tests
TEST_F(DBTest, VlanScaleNoTask) {
ConcurrencyScope scope("Agent::FlowTable");
ConcurrencyScope scope(kTaskFlowEvent);
uint32_t count = FIND_COUNT;

uint64_t key_with_lock = vlan_table_->FindScale(101, count,true, true);
Expand All @@ -275,7 +275,7 @@ TEST_F(DBTest, VlanScaleNoTask) {
}

TEST_F(DBTest, VlanScaleTask) {
ConcurrencyScope scope("Agent::FlowTable");
ConcurrencyScope scope(kTaskFlowEvent);
scale_count_ = 0;
uint32_t count = FIND_COUNT/4;

Expand Down Expand Up @@ -339,7 +339,7 @@ class ScaleInterfaceTask : public Task {
public:
ScaleInterfaceTask(DBTable *table, bool use_key, bool do_lock,
int thread_count, uint32_t find_count) :
Task(TaskScheduler::GetInstance()->GetTaskId("Agent::FlowTable"), -1),
Task(TaskScheduler::GetInstance()->GetTaskId(kTaskFlowEvent), -1),
table_(table), do_lock_(do_lock), use_key_(use_key),
thread_count_(thread_count), find_count_(find_count) {
}
Expand All @@ -362,7 +362,7 @@ class ScaleInterfaceTask : public Task {
};

TEST_F(DBTest, ScaleVmInterface) {
ConcurrencyScope scope("Agent::FlowHandler");
ConcurrencyScope scope(kTaskFlowUpdate);
DBTable *table =
static_cast<DBTable *>(Agent::GetInstance()->interface_table());
uint32_t count = FIND_COUNT;
Expand All @@ -383,7 +383,7 @@ TEST_F(DBTest, ScaleVmInterface) {
}

TEST_F(DBTest, ScaleTaskVmInterface) {
ConcurrencyScope scope("Agent::FlowHandler");
ConcurrencyScope scope(kTaskFlowUpdate);
scale_count_ = 0;
uint32_t count = FIND_COUNT/4;
DBTable *table =
Expand Down
6 changes: 2 additions & 4 deletions src/vnsw/agent/pkt/flow_entry.cc
Expand Up @@ -44,7 +44,7 @@
#include <pkt/pkt_types.h>
#include <pkt/pkt_sandesh_flow.h>
#include <pkt/flow_mgmt.h>
#include <pkt/flow_mgmt_response.h>
#include <pkt/flow_event.h>
#include <pkt/flow_entry.h>
#include <uve/agent_uve.h>
#include <uve/vm_uve_table.h>
Expand Down Expand Up @@ -454,9 +454,7 @@ void FlowEntry::set_flow_handle(uint32_t flow_handle) {
// Skip ksync index manipulation, for deleted flow entry
// as ksync entry is not available for deleted flow
if (!deleted_ && flow_handle_ == kInvalidFlowHandle) {
flow_table_->RemoveFromKSyncTree(this);
ksync_entry_->set_hash_id(flow_handle);
flow_table_->AddToKSyncTree(this);
flow_table_->UpdateFlowHandle(this, flow_handle);
}
flow_handle_ = flow_handle;
flow_table_->UpdateKSync(this, true);
Expand Down
100 changes: 100 additions & 0 deletions src/vnsw/agent/pkt/flow_event.h
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
*/
#ifndef __AGENT_FLOW_EVENT_H__
#define __AGENT_FLOW_EVENT_H__

#include "flow_table.h"

////////////////////////////////////////////////////////////////////////////
// Control events for flow management
////////////////////////////////////////////////////////////////////////////
class FlowEvent {
public:
enum Event {
INVALID,
// Flow add message from VRouter
VROUTER_FLOW_MSG,
// Event to delete a flow entry
DELETE_FLOW,
// Event by audit module to delete a flow
AUDIT_FLOW,
// Revaluate flow due to deletion of a DBEntry. Other than for INET
// routes, delete of a DBEntry will result in deletion of flows using
// the DBEntry
DELETE_DBENTRY,
// Revaluate route due to change in a DBEntry. This event is used to
// revaluate a flow on add/change of interface, vm, vn etc...
// The action typically invovles only re-evaluating ACL lookup actions
REVALUATE_DBENTRY,
// Add/Delete of route can result in flow using a next higher/lower
// prefix. The event will re-valuate the complete flow due to change
// in route used for flow
REVALUATE_FLOW,
// Flow entry should be freed from kTaskFlowEvent task context.
// Event to ensure flow entry is freed from right context
FREE_FLOW_REF,
// A DBEntry should be freed from kTaskFlowEvent task context.
// Event to ensure DBEntry entry reference is freed from right context
FREE_DBENTRY
};

FlowEvent() :
event_(INVALID), flow_(NULL), pkt_info_(), db_entry_(NULL),
gen_id_(0), del_rev_flow_(false) {
}

FlowEvent(Event event, FlowEntry *flow) :
event_(event), flow_(flow), pkt_info_(), db_entry_(NULL),
gen_id_(0), del_rev_flow_(false) {
}

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) {
}

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) {
}

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) {
}

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_() {
}

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_) {
}

virtual ~FlowEvent() { }

Event event() const { return event_; }
FlowEntry *flow() const { return flow_.get(); }
void set_flow(FlowEntry *flow) { flow_ = flow; }
const DBEntry *db_entry() const { return db_entry_; }
void set_db_entry(const DBEntry *db_entry) { db_entry_ = db_entry; }
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_; }
PktInfoPtr pkt_info() const { return pkt_info_; }

private:
Event event_;
FlowEntryPtr flow_;
PktInfoPtr pkt_info_;
const DBEntry *db_entry_;
uint32_t gen_id_;
FlowKey flow_key_;
bool del_rev_flow_;
};

#endif // __AGENT_FLOW_EVENT_H__
1 change: 0 additions & 1 deletion src/vnsw/agent/pkt/flow_handler.h
Expand Up @@ -8,7 +8,6 @@
#include "pkt/proto_handler.h"

static const std::string unknown_vn_ = "__UNKNOWN__";
static const std::string kFlowHandlerTask = "Agent::FlowHandler";

struct PktInfo;
class PktFlowInfo;
Expand Down

0 comments on commit 28c770b

Please sign in to comment.