Skip to content

Commit

Permalink
Send TOR mastership info in Prouter UVE.
Browse files Browse the repository at this point in the history
Defined a field named connected_agent_list in Prouter UVE. Master agent
will populate this field with its name as the only element in the list. Backup
agents will send empty list. This list can be aggregated by analytics module
and if the size of the list is 0 or more than 1, alarm can be raised.

Partial-Bug: #1550888
(cherry picked from commit 2ba42f6)

Change-Id: I637fec9d53fe2de291bd0f697a408bb21053f679
  • Loading branch information
ashoksr committed Mar 18, 2016
1 parent b21904a commit bc859ab
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 7 deletions.
Expand Up @@ -11,9 +11,10 @@ using namespace process;
using namespace std;

ConnectionStateEntry::ConnectionStateEntry(ConnectionStateTable *table,
const std::string &device_name) :
table_(table), device_name_(device_name), device_entry_(NULL),
ha_stale_dev_vn_table_(NULL) {
const std::string &device_name,
const boost::uuids::uuid &u) :
table_(table), device_name_(device_name), device_uuid_(u),
device_entry_(NULL), ha_stale_dev_vn_table_(NULL) {
refcount_ = 0;
}

Expand Down Expand Up @@ -71,7 +72,8 @@ ConnectionStateTable::~ConnectionStateTable() {

void ConnectionStateTable::AddIdlToConnectionState(const std::string &dev_name,
OvsdbClientIdl *idl) {
ConnectionStateEntry *state = new ConnectionStateEntry(this, dev_name);
ConnectionStateEntry *state = new ConnectionStateEntry(this, dev_name,
boost::uuids::nil_uuid());
pair<EntryMap::iterator, bool> ret;
ret = entry_map_.insert(pair<string, ConnectionStateEntry*>(dev_name,
state));
Expand Down Expand Up @@ -137,7 +139,7 @@ void ConnectionStateTable::PhysicalDeviceNotify(DBTablePartBase *part,
if (dev->name().empty())
return;

state = new ConnectionStateEntry(this, dev->name());
state = new ConnectionStateEntry(this, dev->name(), dev->uuid());
pair<EntryMap::iterator, bool> ret;
ret = entry_map_.insert(pair<string, ConnectionStateEntry*>(dev->name(),
state));
Expand All @@ -146,6 +148,7 @@ void ConnectionStateTable::PhysicalDeviceNotify(DBTablePartBase *part,
delete state;
}
state = ret.first->second;
ret.first->second->device_uuid_ = dev->uuid();
ret.first->second->device_entry_ = dev;
dev->SetState(table_, id_, ret.first->second);
UpdateConnectionInfo(ret.first->second, false);
Expand All @@ -160,6 +163,7 @@ void ConnectionStateTable::PhysicalDeviceNotify(DBTablePartBase *part,

void ConnectionStateTable::UpdateConnectionInfo(ConnectionStateEntry *entry,
bool deleted) {
NotifyUve(entry, deleted);
if (agent_->connection_state() == NULL)
return;

Expand Down Expand Up @@ -193,3 +197,25 @@ void ConnectionStateTable::UpdateConnectionInfo(ConnectionStateEntry *entry,
}
}

void ConnectionStateTable::NotifyUve(ConnectionStateEntry *entry,
bool deleted) {
/* If device uuid is not available we cannot notify Uve Module */
if (entry->device_uuid_ == boost::uuids::nil_uuid())
return;

if (agent_->uve() == NULL || agent_->uve()->prouter_uve_table() == NULL)
return;

ProuterUveTable *ptable = agent_->uve()->prouter_uve_table();
if (deleted) {
ptable->UpdateMastership(entry->device_uuid_, false);
} else {
bool mastership = true;
if (entry->device_entry_ == NULL) {
mastership = false;
} else if (entry->idl_list_.empty()) {
mastership = false;
}
ptable->UpdateMastership(entry->device_uuid_, mastership);
}
}
Expand Up @@ -15,6 +15,7 @@

#include <cmn/agent.h>
#include <oper/physical_device.h>
#include <uve/agent_uve_base.h>

#include "ovsdb_client_idl.h"

Expand Down Expand Up @@ -47,6 +48,7 @@ class ConnectionStateTable {

// API to update connection info state
void UpdateConnectionInfo(ConnectionStateEntry *entry, bool deleted);
void NotifyUve(ConnectionStateEntry *entry, bool deleted);

Agent *agent_;
DBTableBase *table_;
Expand All @@ -62,7 +64,8 @@ class ConnectionStateEntry : public DBState {
public:
typedef std::set<OvsdbClientIdl *> IdlList;
ConnectionStateEntry(ConnectionStateTable *table,
const std::string &device_name);
const std::string &device_name,
const boost::uuids::uuid &u);
virtual ~ConnectionStateEntry();

bool IsConnectionActive();
Expand All @@ -78,6 +81,7 @@ class ConnectionStateEntry : public DBState {

ConnectionStateTable *table_;
std::string device_name_;
boost::uuids::uuid device_uuid_;
PhysicalDevice *device_entry_;
IdlList idl_list_;
// Ha Stale Dev VN table for the device, which listens to physical
Expand Down
5 changes: 5 additions & 0 deletions src/vnsw/agent/uve/prouter.sandesh
Expand Up @@ -16,6 +16,11 @@ struct ProuterData {
4: optional list<string> physical_interface_list
5: optional list<string> logical_interface_list
6: optional string agent_name
/* The following list can atmost have one element. It is defined as list
to support aggregation. Backup agent will send empty list for the
following field while master agent will send its name as the only
element in the list */
7: optional list<string> connected_agent_list (aggtype="union")
}

/**
Expand Down
24 changes: 23 additions & 1 deletion src/vnsw/agent/uve/prouter_uve_table.cc
Expand Up @@ -203,7 +203,7 @@ void ProuterUveTable::PhyInterfaceUveEntry::Update(const Interface *pintf) {

ProuterUveTable::ProuterUveEntry::ProuterUveEntry(const PhysicalDevice *p) :
name_(p->name()), uuid_(p->uuid()), physical_interface_set_(),
changed_(true), deleted_(false), renewed_(false) {
changed_(true), deleted_(false), renewed_(false), mastership_(p->master()) {
}

ProuterUveTable::LogicalInterfaceUveEntry::LogicalInterfaceUveEntry
Expand Down Expand Up @@ -349,6 +349,7 @@ void ProuterUveTable::FrameProuterMsg(ProuterUveEntry *entry,
ProuterData *uve) const {
vector<string> phy_if_list;
vector<string> logical_list;
vector<string> connected_agent_list;
/* We are using hostname instead of fq-name because Prouter UVE sent by
* other modules to send topology information uses hostname and we want
* both these information to be seen in same UVE */
Expand All @@ -371,6 +372,13 @@ void ProuterUveTable::FrameProuterMsg(ProuterUveEntry *entry,
++lit;
}
uve->set_logical_interface_list(logical_list);
if (entry->mastership_) {
connected_agent_list.push_back(agent_->agent_name());
uve->set_connected_agent_list(connected_agent_list);
} else {
/* Send Empty list */
uve->set_connected_agent_list(connected_agent_list);
}
}

bool ProuterUveTable::SendProuterMsg(ProuterUveEntry *entry) {
Expand Down Expand Up @@ -424,6 +432,7 @@ ProuterUveTable::ProuterUveEntry* ProuterUveTable::AddHandler
UveProuterMap::iterator it = ret.first;
ProuterUveEntry *entry = it->second.get();
entry->changed_ = true;
entry->mastership_ = p->master();
if (entry->deleted_) {
entry->renewed_ = true;
}
Expand Down Expand Up @@ -560,6 +569,7 @@ void ProuterUveTable::PhysicalDeviceNotify(DBTablePartBase *partition,
} else {
/* For Change notifications send only the msg */
ProuterUveEntry *entry = PDEntryToProuterUveEntry(pr->uuid());
entry->mastership_ = pr->master();
entry->changed_ = true;
}
}
Expand Down Expand Up @@ -853,3 +863,15 @@ void ProuterUveTable::DispatchPhysicalInterfaceMsg
(const UvePhysicalInterfaceAgent &uve) {
UvePhysicalInterfaceAgentTrace::Send(uve);
}

void ProuterUveTable::UpdateMastership(const boost::uuids::uuid &u, bool value)
{
ProuterUveEntry *entry = PDEntryToProuterUveEntry(u);
if (entry == NULL) {
return;
}
if (entry->mastership_ != value) {
entry->mastership_ = value;
entry->changed_ = true;
}
}
2 changes: 2 additions & 0 deletions src/vnsw/agent/uve/prouter_uve_table.h
Expand Up @@ -79,6 +79,7 @@ class ProuterUveTable {
bool changed_;
bool deleted_;
bool renewed_;
bool mastership_;
};
typedef boost::shared_ptr<ProuterUveEntry> ProuterUveEntryPtr;
typedef std::map<boost::uuids::uuid, ProuterUveEntryPtr> UveProuterMap;
Expand Down Expand Up @@ -113,6 +114,7 @@ class ProuterUveTable {
bool TimerExpiry();
bool PITimerExpiry();
bool LITimerExpiry();
void UpdateMastership(const boost::uuids::uuid &u, bool value);

protected:
UveProuterMap uve_prouter_map_;
Expand Down

0 comments on commit bc859ab

Please sign in to comment.