Skip to content

Commit

Permalink
Merge "Make UUID random generator as non-static member of FlowTable" …
Browse files Browse the repository at this point in the history
…into R3.0
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Feb 24, 2016
2 parents 84fadd6 + e851292 commit 6af81dc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/vnsw/agent/pkt/flow_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ FlowEntry::~FlowEntry() {
}

void FlowEntry::Reset() {
uuid_ = FlowTable::rand_gen_();
uuid_ = flow_table_->rand_gen();
egress_uuid_ = flow_table_->rand_gen();
data_.Reset();
l3_flow_ = true;
flow_handle_ = kInvalidFlowHandle;
Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/pkt/flow_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ class FlowEntry {
VmInterfaceKey reverse_flow_vmi() const;
void UpdateFipStatsInfo(uint32_t fip, uint32_t id, Agent *agent);
const boost::uuids::uuid &uuid() const { return uuid_; }
const boost::uuids::uuid &egress_uuid() const { return egress_uuid_; }
const std::string &sg_rule_uuid() const { return sg_rule_uuid_; }
const std::string &nw_ace_uuid() const { return nw_ace_uuid_; }
const std::string &peer_vrouter() const { return peer_vrouter_; }
Expand Down Expand Up @@ -525,6 +526,7 @@ class FlowEntry {
uint32_t flags_;
uint16_t short_flow_reason_;
boost::uuids::uuid uuid_;
boost::uuids::uuid egress_uuid_;
std::string sg_rule_uuid_;
std::string nw_ace_uuid_;
//IP address of the src vrouter for egress flows and dst vrouter for
Expand Down
7 changes: 5 additions & 2 deletions src/vnsw/agent/pkt/flow_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const uint32_t FlowEntryFreeList::kGrowSize;
const uint32_t FlowEntryFreeList::kMinThreshold;

SandeshTraceBufferPtr FlowTraceBuf(SandeshTraceBufferCreate("Flow", 5000));
boost::uuids::random_generator FlowTable::rand_gen_;

#define FLOW_LOCK(flow, rflow) \
tbb::mutex tmp_mutex, *mutex_ptr_1, *mutex_ptr_2; \
Expand All @@ -65,6 +64,7 @@ boost::uuids::random_generator FlowTable::rand_gen_;
/////////////////////////////////////////////////////////////////////////////
FlowTable::FlowTable(Agent *agent, uint16_t table_index) :
agent_(agent),
rand_gen_(boost::uuids::random_generator()),
table_index_(table_index),
ksync_object_(NULL),
flow_entry_map_(),
Expand All @@ -79,7 +79,6 @@ FlowTable::~FlowTable() {
void FlowTable::Init() {
flow_task_id_ = agent_->task_scheduler()->GetTaskId(kTaskFlowEvent);
FlowEntry::Init();
rand_gen_ = boost::uuids::random_generator();
return;
}

Expand Down Expand Up @@ -640,6 +639,10 @@ bool FlowTable::RevaluateRpfNH(FlowEntry *flow, const AgentRoute *rt) {
return false;
}

boost::uuids::uuid FlowTable::rand_gen() {
return rand_gen_();
}

// Handle flow revaluation on a route change
// Route change can result in multiple changes to flow
// InetRoute :
Expand Down
3 changes: 2 additions & 1 deletion src/vnsw/agent/pkt/flow_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ struct Inet4FlowKeyCmp {

class FlowTable {
public:
static boost::uuids::random_generator rand_gen_;

typedef std::map<FlowKey, FlowEntry *, Inet4FlowKeyCmp> FlowEntryMap;
typedef std::pair<FlowKey, FlowEntry *> FlowEntryMapPair;
Expand Down Expand Up @@ -219,6 +218,7 @@ class FlowTable {
bool RevaluateSgList(FlowEntry *flow, const AgentRoute *rt,
const SecurityGroupList &sg_list);
bool RevaluateRpfNH(FlowEntry *flow, const AgentRoute *rt);
boost::uuids::uuid rand_gen();

void UpdateKSync(FlowEntry *flow, bool update);
void DeleteKSync(FlowEntry *flow);
Expand Down Expand Up @@ -274,6 +274,7 @@ class FlowTable {
FlowEntry *rflow);

Agent *agent_;
boost::uuids::random_generator rand_gen_;
uint16_t table_index_;
FlowTableKSyncObject *ksync_object_;
FlowEntryMap flow_entry_map_;
Expand Down
7 changes: 5 additions & 2 deletions src/vnsw/agent/vrouter/flow_stats/flow_export_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ FlowExportInfo::FlowExportInfo() :
}

FlowExportInfo::FlowExportInfo(FlowEntry *fe, uint64_t setup_time) :
flow_uuid_(fe->uuid()), key_(fe->key()),
flow_uuid_(fe->uuid()), egress_uuid_(fe->egress_uuid()), key_(fe->key()),
source_vn_(fe->data().source_vn_match), dest_vn_(fe->data().dest_vn_match),
sg_rule_uuid_(fe->sg_rule_uuid()), nw_ace_uuid_(fe->nw_ace_uuid()),
setup_time_(setup_time), teardown_time_(0), last_modified_time_(setup_time),
Expand All @@ -28,7 +28,6 @@ FlowExportInfo::FlowExportInfo(FlowEntry *fe, uint64_t setup_time) :
tunnel_type_(fe->tunnel_type()), underlay_source_port_(0),
changed_(true), fip_(fe->fip()), fip_vmi_(fe->fip_vmi()), tcp_flags_(0),
delete_enqueued_(false) {
egress_uuid_ = FlowTable::rand_gen_();
FlowEntry *rflow = fe->reverse_flow_entry();
if (rflow) {
rev_flow_uuid_ = rflow->uuid();
Expand Down Expand Up @@ -96,6 +95,9 @@ bool FlowExportInfo::IsEqual(const FlowExportInfo &rhs) const {
if (drop_reason_ != rhs.drop_reason()) {
return false;
}
if (egress_uuid_ != rhs.egress_uuid()) {
return false;
}
return true;
}

Expand All @@ -115,6 +117,7 @@ void FlowExportInfo::Copy(const FlowExportInfo &rhs) {
rev_flow_uuid_ = rhs.rev_flow_uuid();
interface_uuid_ = rhs.interface_uuid();
drop_reason_ = rhs.drop_reason();
egress_uuid_ = rhs.egress_uuid();
changed_ = true;
}

Expand Down

0 comments on commit 6af81dc

Please sign in to comment.