Skip to content

Commit

Permalink
Merge "* Fix bug in flow dbclient such that all states are cleared If…
Browse files Browse the repository at this point in the history
… route 0.0.0.0/0 is the last route to be deleted then flow dbclient would unregister from route table even before all states were cleared, replace upperbound by lowerbound such that 0.0.0.0/0 route is also conidered for vrf deleting Test case for same. Add safe to avoid adding route with 0.0.0.0/32. Closes-bug:#1521879,#1531346"
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jan 11, 2016
2 parents b515dbf + 64d107f commit b983f69
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/vnsw/agent/oper/vm_interface.cc
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions src/vnsw/agent/pkt/flow_mgmt.cc
Expand Up @@ -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;

Expand Down Expand Up @@ -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<InetRouteFlowMgmtKey *>(UpperBound(&key));
next_key = static_cast<InetRouteFlowMgmtKey *>(LowerBound(&key));
} else {
InetRouteFlowMgmtKey key(vrf, Ip6Address(), 0);
next_key = static_cast<InetRouteFlowMgmtKey *>(UpperBound(&key));
next_key = static_cast<InetRouteFlowMgmtKey *>(LowerBound(&key));
}

if (next_key == NULL)
Expand Down Expand Up @@ -1394,7 +1394,7 @@ bool BridgeRouteFlowMgmtTree::HasVrfFlows(uint32_t vrf,
Agent::RouteTableType type) {
BridgeRouteFlowMgmtKey key(vrf, MacAddress::ZeroMac());
BridgeRouteFlowMgmtKey *next_key = static_cast<BridgeRouteFlowMgmtKey *>
(UpperBound(&key));
(LowerBound(&key));
if (next_key == false)
return false;

Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/pkt/flow_mgmt.h
Expand Up @@ -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);
Expand Down
29 changes: 29 additions & 0 deletions src/vnsw/agent/pkt/test/test_flow_mgmt_route.cc
Expand Up @@ -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;

Expand Down

0 comments on commit b983f69

Please sign in to comment.