Skip to content

Commit

Permalink
Merge "* Update SG-id in SG upon change Test case for same. Closes-bu…
Browse files Browse the repository at this point in the history
…g:#1558933" into R2.21.x
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Mar 21, 2016
2 parents a915d24 + 5a6e679 commit cfa6bf3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/vnsw/agent/oper/agent.sandesh
Expand Up @@ -346,6 +346,10 @@ objectlog sandesh SgObjectLog {
1: SgObjectLogInfo sg;
}

traceobject sandesh SgObjectTrace {
1: SgObjectLogInfo sg;
}

request sandesh SgListReq {
1: string name;
}
Expand Down
8 changes: 6 additions & 2 deletions src/vnsw/agent/oper/sg.cc
Expand Up @@ -53,9 +53,7 @@ std::auto_ptr<DBEntry> SgTable::AllocEntry(const DBRequestKey *k) const {

DBEntry *SgTable::Add(const DBRequest *req) {
SgKey *key = static_cast<SgKey *>(req->key.get());
SgData *data = static_cast<SgData *>(req->data.get());
SgEntry *sg = new SgEntry(key->sg_uuid_);
sg->sg_id_ = data->sg_id_;
ChangeHandler(sg, req);
sg->SendObjectLog(AgentLogEvent::ADD);
return sg;
Expand All @@ -73,6 +71,11 @@ bool SgTable::ChangeHandler(DBEntry *entry, const DBRequest *req) {
SgEntry *sg = static_cast<SgEntry *>(entry);
SgData *data = static_cast<SgData *>(req->data.get());

if (sg->sg_id_ != data->sg_id_) {
sg->sg_id_ = data->sg_id_;
ret = true;
}

AclKey key(data->egress_acl_id_);
AclDBEntry *acl = static_cast<AclDBEntry *>(Agent::GetInstance()->acl_table()->FindActiveEntry(&key));
if (sg->egress_acl_ != acl) {
Expand Down Expand Up @@ -262,6 +265,7 @@ void SgEntry::SendObjectLog(AgentLogEvent::type event) const {
}
info.set_ref_count(GetRefCount());
SG_OBJECT_LOG_LOG("AgentSg", SandeshLevel::SYS_INFO, info);
SG_OBJECT_TRACE_TRACE(OperDBTraceBuf, info);
}

void SgListReq::HandleRequest() const {
Expand Down
4 changes: 1 addition & 3 deletions src/vnsw/agent/test/test_vmport_cfg.cc
Expand Up @@ -1523,16 +1523,14 @@ TEST_F(CfgTest, SecurityGroup_ignore_invalid_sgid_1) {
EXPECT_TRUE(sg_entry != NULL);
EXPECT_TRUE(sg_entry->GetSgId() == 2);

// Try modifying with another sg id for same uuid and it should not happen
// in oper. Old sgid i.e. 2 shud be retained.
AddSg("sg1", 1, 3);
client->WaitForIdle();
key = new SgKey(MakeUuid(1));
sg_entry = static_cast<const SgEntry *>(Agent::GetInstance()->sg_table()->
FindActiveEntry(key));

EXPECT_TRUE(sg_entry != NULL);
EXPECT_TRUE(sg_entry->GetSgId() == 2);
EXPECT_TRUE(sg_entry->GetSgId() == 3);

DelLink("virtual-network", "vn1", "access-control-list", "acl1");
DelLink("virtual-machine-interface", "vnet1", "access-control-list", "acl1");
Expand Down

0 comments on commit cfa6bf3

Please sign in to comment.