diff --git a/src/vnsw/agent/oper/inet_unicast_route.cc b/src/vnsw/agent/oper/inet_unicast_route.cc index 0763ea59a3c..d7167bd5c39 100644 --- a/src/vnsw/agent/oper/inet_unicast_route.cc +++ b/src/vnsw/agent/oper/inet_unicast_route.cc @@ -476,7 +476,7 @@ bool InetUnicastRouteEntry::EcmpDeletePath(AgentPath *path) { * gateway without having Ipam path, then search continues further */ bool InetUnicastRouteEntry::IpamSubnetRouteAvailable() const { - if (IsHostRoute()) + if ((IsHostRoute() == true) || (plen_ == 0)) return false; //Local path present means that this route itself was programmed @@ -490,6 +490,7 @@ bool InetUnicastRouteEntry::IpamSubnetRouteAvailable() const { //and retain flood flag from that path. uint16_t plen = plen_ - 1; while (plen != 0) { + assert(plen < plen_); InetUnicastRouteEntry key(NULL, addr_, plen, false); InetUnicastRouteEntry *supernet_rt = table->FindRouteUsingKey(key); diff --git a/src/vnsw/agent/test/test_route.cc b/src/vnsw/agent/test/test_route.cc index c8334a1a9d5..024c45db4d7 100644 --- a/src/vnsw/agent/test/test_route.cc +++ b/src/vnsw/agent/test/test_route.cc @@ -1634,6 +1634,20 @@ TEST_F(RouteTest, SubnetRoute_Flood_2) { client->WaitForIdle(); } +TEST_F(RouteTest, null_ip_subnet_add) { + Ip4Address null_subnet_ip; + null_subnet_ip = Ip4Address::from_string("0.0.0.0"); + AddRemoteVmRoute(null_subnet_ip, fabric_gw_ip_, 0, MplsTable::kStartLabel); + + EXPECT_TRUE(RouteFind(vrf_name_, null_subnet_ip, 0)); + InetUnicastRouteEntry *rt = RouteGet(vrf_name_, null_subnet_ip, 0); + EXPECT_TRUE(rt->GetActiveNextHop()->GetType() == NextHop::TUNNEL); + EXPECT_FALSE(rt->ipam_subnet_route()); + + DeleteRoute(NULL, vrf_name_, null_subnet_ip, 0); + EXPECT_FALSE(RouteFind(vrf_name_, null_subnet_ip, 0)); +} + int main(int argc, char *argv[]) { ::testing::InitGoogleTest(&argc, argv); GETUSERARGS();