Skip to content

Commit

Permalink
Fix issue of VN reference not being removed from InterfaceUveTable::U…
Browse files Browse the repository at this point in the history
…veInterfaceState

InterfaceUveTable::UveInterfaceState has floating_ip_list which has reference to VN. If interface delete from Nova has not come and config delete for that interface comes (which includes removal of floating IPs), we were not cleaning the floating_ip_list from InterfaceUveTable::UveInterfaceState.

Closes-Bug: #1466176
(cherry picked from commit 4aba564)

Change-Id: I0220edeecb4ad1f65c5b8e58a474f7b9e6888ecc
  • Loading branch information
ashoksr committed Jun 22, 2015
1 parent 3bd5523 commit e228d3c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/vnsw/agent/uve/interface_uve_table.cc
Expand Up @@ -274,7 +274,7 @@ void InterfaceUveTable::InterfaceNotify(DBTablePartBase *partition,
delete state;
} else {
VmInterface::FloatingIpSet old_list;
if (vm_port->cfg_name().empty()) {
if (!state && vm_port->cfg_name().empty()) {
/* Skip Add/change notifications if the config_name is empty */
return;
}
Expand All @@ -289,8 +289,11 @@ void InterfaceUveTable::InterfaceNotify(DBTablePartBase *partition,
if (state->cfg_name_ != vm_port->cfg_name()) {
InterfaceDeleteHandler(state->cfg_name_);
state->cfg_name_ = vm_port->cfg_name();
old_list.clear();
}
if (!vm_port->cfg_name().empty()) {
InterfaceAddHandler(vm_port, old_list);
}
InterfaceAddHandler(vm_port, old_list);
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/vnsw/agent/uve/test/interface_uve_table_test.cc
Expand Up @@ -71,3 +71,13 @@ const InterfaceUveTable::FloatingIp *InterfaceUveTableTest::GetVmIntfFip
}
return NULL;
}

InterfaceUveTable::UveInterfaceEntry*
InterfaceUveTableTest::GetUveInterfaceEntry(const string &name) {
InterfaceMap::iterator it = interface_tree_.find(name);
if (it == interface_tree_.end()) {
return NULL;
}
InterfaceUveTable::UveInterfaceEntry* entry = it->second.get();
return entry;
}
2 changes: 2 additions & 0 deletions src/vnsw/agent/uve/test/interface_uve_table_test.h
Expand Up @@ -21,6 +21,8 @@ class InterfaceUveTableTest : public InterfaceUveStatsTable {
const InterfaceUveTable::FloatingIp *GetVmIntfFip(const VmInterface* intf,
const string &fip, const string &vn);
const UveVMInterfaceAgent &last_sent_uve() const { return uve_; }
InterfaceUveTable::UveInterfaceEntry* GetUveInterfaceEntry
(const std::string &name);
private:
uint32_t send_count_;
uint32_t delete_count_;
Expand Down
49 changes: 49 additions & 0 deletions src/vnsw/agent/uve/test/test_interface_uve.cc
Expand Up @@ -484,6 +484,55 @@ TEST_F(InterfaceUveTest, VmIntfAddDel_2) {
vmut->ClearCount();
}

TEST_F(InterfaceUveTest, VmIntfAddDel_3) {
struct PortInfo input[] = {
{"vnet1", 1, "1.1.1.1", "00:00:00:01:01:01", 1, 1},
};

InterfaceUveTableTest *vmut = static_cast<InterfaceUveTableTest *>
(Agent::GetInstance()->uve()->interface_uve_table());
vmut->ClearCount();
EXPECT_EQ(0U, vmut->InterfaceUveCount());

// Nova Port add message
util_.NovaPortAdd(input);

//Verify that entry for interface is not added to our tree until config is
//received.
EXPECT_EQ(0U, vmut->InterfaceUveCount());

// Config Port add
util_.ConfigPortAdd(input);
client->WaitForIdle();

//Verify that entry for interface is added to our tree after config is
//received.
WAIT_FOR(1000, 500, ((vmut->InterfaceUveCount() == 1U)));
EXPECT_EQ(1U, vmut->InterfaceUveCount());

// Config Port delete
DelNode("virtual-machine-interface", "vnet1");
client->WaitForIdle();

//Verify that on deletion of interface config, the entry is marked for
//delete in our tree.
InterfaceUveTable::UveInterfaceEntry* entry = vmut->GetUveInterfaceEntry
("vnet1");
EXPECT_TRUE(entry->deleted_);

// Nova port delete
IntfCfgDel(input, 0);
client->WaitForIdle();

util_.EnqueueSendVmiUveTask();
client->WaitForIdle();
WAIT_FOR(1000, 500, ((vmut->InterfaceUveCount() == 0U)));

//clear counters at the end of test case
client->Reset();
vmut->ClearCount();
}

TEST_F(InterfaceUveTest, FipStats_1) {
InterfaceUveTableTest *vmut = static_cast<InterfaceUveTableTest *>
(Agent::GetInstance()->uve()->interface_uve_table());
Expand Down

0 comments on commit e228d3c

Please sign in to comment.