diff --git a/src/vnsw/agent/oper/vm_interface.cc b/src/vnsw/agent/oper/vm_interface.cc index e8ab8b8ef0c..ce724efb848 100644 --- a/src/vnsw/agent/oper/vm_interface.cc +++ b/src/vnsw/agent/oper/vm_interface.cc @@ -426,6 +426,10 @@ static void BuildInstanceIp(Agent *agent, VmInterfaceConfigData *data, if (ip->secondary() != true) { is_primary = true; if (addr.is_v4()) { + if (addr == Ip4Address(0)) { + return; + } + if (data->addr_ == Ip4Address(0) || data->addr_ > addr.to_v4()) { data->addr_ = addr.to_v4(); @@ -436,6 +440,9 @@ static void BuildInstanceIp(Agent *agent, VmInterfaceConfigData *data, } } } else if (addr.is_v6()) { + if (addr == Ip6Address()) { + return; + } if (data->ip6_addr_ == Ip6Address() || data->ip6_addr_ > addr.to_v6()) { data->ip6_addr_ = addr.to_v6(); diff --git a/src/vnsw/agent/pkt/flow_mgmt.cc b/src/vnsw/agent/pkt/flow_mgmt.cc index 2716b9330fa..1498bdfcc8b 100644 --- a/src/vnsw/agent/pkt/flow_mgmt.cc +++ b/src/vnsw/agent/pkt/flow_mgmt.cc @@ -721,8 +721,8 @@ FlowMgmtEntry *FlowMgmtTree::Locate(FlowMgmtKey *key) { return entry; } -FlowMgmtKey *FlowMgmtTree::UpperBound(FlowMgmtKey *key) { - Tree::iterator it = tree_.upper_bound(key); +FlowMgmtKey *FlowMgmtTree::LowerBound(FlowMgmtKey *key) { + Tree::iterator it = tree_.lower_bound(key); if (it == tree_.end()) return NULL; @@ -1316,10 +1316,10 @@ bool InetRouteFlowMgmtTree::HasVrfFlows(uint32_t vrf, if (type == Agent::INET4_UNICAST) { InetRouteFlowMgmtKey key(vrf, Ip4Address(0), 0); - next_key = static_cast(UpperBound(&key)); + next_key = static_cast(LowerBound(&key)); } else { InetRouteFlowMgmtKey key(vrf, Ip6Address(), 0); - next_key = static_cast(UpperBound(&key)); + next_key = static_cast(LowerBound(&key)); } if (next_key == NULL) @@ -1394,7 +1394,7 @@ bool BridgeRouteFlowMgmtTree::HasVrfFlows(uint32_t vrf, Agent::RouteTableType type) { BridgeRouteFlowMgmtKey key(vrf, MacAddress::ZeroMac()); BridgeRouteFlowMgmtKey *next_key = static_cast - (UpperBound(&key)); + (LowerBound(&key)); if (next_key == false) return false; diff --git a/src/vnsw/agent/pkt/flow_mgmt.h b/src/vnsw/agent/pkt/flow_mgmt.h index 9b1130e279a..b921347736c 100644 --- a/src/vnsw/agent/pkt/flow_mgmt.h +++ b/src/vnsw/agent/pkt/flow_mgmt.h @@ -399,7 +399,7 @@ class FlowMgmtTree { FlowMgmtEntry *Locate(FlowMgmtKey *key); FlowMgmtEntry *Find(FlowMgmtKey *key); - FlowMgmtKey *UpperBound(FlowMgmtKey *key); + FlowMgmtKey *LowerBound(FlowMgmtKey *key); Tree &tree() { return tree_; } FlowMgmtManager *mgr() const { return mgr_; } static bool AddFlowMgmtKey(FlowMgmtKeyTree *tree, FlowMgmtKey *key); diff --git a/src/vnsw/agent/pkt/test/test_flow_mgmt_route.cc b/src/vnsw/agent/pkt/test/test_flow_mgmt_route.cc index 501334ef1fb..486a9bb566f 100644 --- a/src/vnsw/agent/pkt/test/test_flow_mgmt_route.cc +++ b/src/vnsw/agent/pkt/test/test_flow_mgmt_route.cc @@ -246,6 +246,35 @@ TEST_F(FlowMgmtRouteTest, RouteDelete_4) { client->WaitForIdle(10); } +TEST_F(FlowMgmtRouteTest, RouteDelete_5) { + VrfAddReq("vrf10"); + client->WaitForIdle(); + + boost::system::error_code ec; + Ip4Address remote_ip1 = Ip4Address::from_string("0.0.0.0", ec); + Ip4Address remote_compute = Ip4Address::from_string("1.1.1.1", ec); + char router_id[80]; + strcpy(router_id, Agent::GetInstance()->router_id().to_string().c_str()); + + string vn_name = "vn10"; + Inet4TunnelRouteAdd(agent_->local_peer(), "vrf10", remote_ip1, 0, + remote_compute, TunnelType::AllType(), 10, + vn_name, SecurityGroupList(), + PathPreference()); + Inet4TunnelRouteAdd(agent_->local_peer(), "vrf10", remote_compute, 24, + remote_compute, TunnelType::AllType(), 10, + vn_name, SecurityGroupList(), PathPreference()); + client->WaitForIdle(); + + VrfDelReq("vrf10"); + client->WaitForIdle(); + DeleteRoute("vrf10", "1.1.1.1", 24, agent_->local_peer()); + client->WaitForIdle(); + DeleteRoute("vrf10", "0.0.0.0", 0, agent_->local_peer()); + client->WaitForIdle(); +} + + int main(int argc, char *argv[]) { int ret = 0;