Skip to content

Commit

Permalink
Optimize config handling for SG and ACL
Browse files Browse the repository at this point in the history
Follow up to commit
b4af4d6

On any change or link add/delete to a SG, we are invoking IFNodeToReq
for all connected VMI. Fix this by registering link handler for SG and
invoke IFNodeToReq only for peer VMI

On any change or link add/delete to a ACL, we are invoking IFNodeToReq
for all connected SG and VN. Fix this by registering link handler for ACL
and invoke IFNodeToReq only for peer SG / VN

Change-Id: I078866f63489db8f3b1fa24b0f907fda7a51ad03
  • Loading branch information
praveenkv committed Feb 24, 2015
1 parent 0ffb7cf commit 0d33ec1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/vnsw/agent/cfg/cfg_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ void AgentConfig::RegisterDBClients(DB *db) {
("virtual-network", agent_->vn_table());
cfg_listener_->LinkRegister
("routing-instance", agent_->vrf_table());
cfg_listener_->LinkRegister
("security-group", agent_->sg_table());
cfg_listener_->LinkRegister
("access-control-list", agent_->acl_table());

cfg_vm_interface_table_ = (static_cast<IFMapAgentTable *>
(IFMapTable::FindTable(agent_->db(), "virtual-machine-interface")));
Expand Down
17 changes: 17 additions & 0 deletions src/vnsw/agent/filter/acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,23 @@ bool AclTable::IFNodeToReq(IFMapNode *node, DBRequest &req) {
return false;
}

bool AclTable::IFLinkToReq(IFMapLink *link, IFMapNode *node,
const std::string &peer_type, IFMapNode *peer,
DBRequest &req) {
if (peer && peer->table() == agent()->cfg()->cfg_vn_table()) {
DBRequest vn_req;
req.oper = DBRequest::DB_ENTRY_ADD_CHANGE;
agent()->vn_table()->IFNodeToReq(peer, vn_req);
}

if (peer && peer->table() == agent()->cfg()->cfg_sg_table()) {
DBRequest sg_req;
req.oper = DBRequest::DB_ENTRY_ADD_CHANGE;
agent()->sg_table()->IFNodeToReq(peer, sg_req);
}
return false;
}

// ACL methods
void AclDBEntry::SetAclEntries(AclEntries &entries)
{
Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/filter/acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ class AclTable : public AgentDBTable {

virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req);
virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u);
virtual bool IFLinkToReq(IFMapLink *link, IFMapNode *node,
const std::string &peer_type, IFMapNode *peer,
DBRequest &req);

static DBTableBase *CreateTable(DB *db, const std::string &name);
TrafficAction::Action ConvertActionString(std::string action) const;
Expand Down
22 changes: 22 additions & 0 deletions src/vnsw/agent/oper/sg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,28 @@ bool SgTable::IFNodeToReq(IFMapNode *node, DBRequest &req) {
return false;
}

bool SgTable::IFLinkToReq(IFMapLink *link, IFMapNode *node,
const std::string &peer_type, IFMapNode *peer,
DBRequest &req) {
// Add/Delete of link other than VMInterface will most likely need re-eval
// of VN.
if (peer_type != "virtual-machine-interface") {
return IFNodeToReq(node, req);
}

// If peer is VMI, invoke re-eval if peer node is present
if (peer && peer->table() == agent()->cfg()->cfg_vm_interface_table()) {
DBRequest vmi_req;
if (agent()->interface_table()->IFNodeToReq(peer, vmi_req) == true) {
LOG(DEBUG, "SG change sync for Port " << peer->name());
agent()->interface_table()->Enqueue(&vmi_req);
}
return false;
}

return false;
}

bool SgEntry::DBEntrySandesh(Sandesh *sresp, std::string &name) const {
SgListResp *resp = static_cast<SgListResp *>(sresp);
std::string str_uuid = UuidToString(GetSgUuid());
Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/oper/sg.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ class SgTable : public AgentDBTable {

virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req);
virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u);
virtual bool IFLinkToReq(IFMapLink *link, IFMapNode *node,
const std::string &peer_type, IFMapNode *peer,
DBRequest &req);

static DBTableBase *CreateTable(DB *db, const std::string &name);
static SgTable *GetInstance() {return sg_table_;};
Expand Down

0 comments on commit 0d33ec1

Please sign in to comment.