From 4567b9685726123fc41790c68cf4b3e8eea62d34 Mon Sep 17 00:00:00 2001 From: Manish Date: Tue, 19 Apr 2016 17:29:06 +0530 Subject: [PATCH] Double path delete request in succession. Problem: In stale path cleanup, if no stale path was found function used to clean last path seen. This resulted in not related path getting deleted. In case of OVS delete the path to be deleted was already gone because of bug and table deleted, resulting in ceash. Solution: Delete if relevant path is found. Closes-bug: #1571598 Change-Id: I25bd7cec4c0774d0a041286c15af99bc5a2d1ada --- src/vnsw/agent/oper/agent_route.cc | 5 ++- src/vnsw/agent/test/test_l2route.cc | 56 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/vnsw/agent/oper/agent_route.cc b/src/vnsw/agent/oper/agent_route.cc index a5e75f84bfb..801d14f29d8 100644 --- a/src/vnsw/agent/oper/agent_route.cc +++ b/src/vnsw/agent/oper/agent_route.cc @@ -568,12 +568,11 @@ void AgentRouteTable::SquashStalePaths(AgentRoute *route, if (path->is_stale() && (path != exception_path)) { // Since we squash stales, at any point of time there should be only // one stale other than exception_path in list - break; + DeletePathFromPeer(route->get_table_partition(), route, path); + return; } it++; } - DeletePathFromPeer(route->get_table_partition(), route, path); - return; } uint32_t AgentRoute::GetActiveLabel() const { diff --git a/src/vnsw/agent/test/test_l2route.cc b/src/vnsw/agent/test/test_l2route.cc index aab17ad2aaf..10104ef1970 100644 --- a/src/vnsw/agent/test/test_l2route.cc +++ b/src/vnsw/agent/test/test_l2route.cc @@ -1595,6 +1595,62 @@ TEST_F(RouteTest, StalePathDeleteRouteDelete) { client->WaitForIdle(); } +class SetupTask : public Task { + public: + SetupTask(RouteTest *test, std::string name) : + Task((TaskScheduler::GetInstance()-> + GetTaskId("db::DBTable")), 0), test_(test), + test_name_(name) { + } + + virtual bool Run() { + if (test_name_ == "SquashPathTest_1") { + char local_vm_mac_str_[100]; + MacAddress local_vm_mac_; + Ip4Address local_vm_ip4_; + char local_vm_ip4_str_[100]; + strcpy(local_vm_ip4_str_, "1.1.1.10"); + local_vm_ip4_ = Ip4Address::from_string(local_vm_ip4_str_); + strcpy(local_vm_mac_str_, "00:00:01:01:01:10"); + local_vm_mac_ = MacAddress::FromString(local_vm_mac_str_); + EvpnRouteEntry *rt = EvpnRouteGet("vrf1", + local_vm_mac_, + local_vm_ip4_, + 0); + const VrfEntry *vrf = VrfGet("vrf1"); + vrf->GetEvpnRouteTable()->SquashStalePaths(rt, NULL); + } + return true; + } + std::string Description() const { return "SetupTask"; } + private: + RouteTest *test_; + std::string test_name_; +}; + +//Bug# 1571598 +TEST_F(RouteTest, SquashPathTest_1) { + struct PortInfo input[] = { + {"vnet1", 1, "1.1.1.10", "00:00:01:01:01:10", 1, 1}, + }; + + client->Reset(); + CreateVmportEnv(input, 1); + client->WaitForIdle(); + + EvpnRouteEntry *rt = EvpnRouteGet("vrf1", local_vm_mac_, local_vm_ip4_, 0); + EXPECT_TRUE(rt != NULL); + EXPECT_TRUE(rt->GetActivePath() != NULL); + SetupTask * task = new SetupTask(this, "SquashPathTest_1"); + TaskScheduler::GetInstance()->Enqueue(task); + client->WaitForIdle(); + rt = EvpnRouteGet("vrf1", local_vm_mac_, local_vm_ip4_, 0); + EXPECT_TRUE(rt != NULL); + + DeleteVmportEnv(input, 1, true); + client->WaitForIdle(); +} + int main(int argc, char *argv[]) { ::testing::InitGoogleTest(&argc, argv); GETUSERARGS();