Skip to content

Commit

Permalink
Merge "* Delete short flow if vrouter operation fails If a flow is ma…
Browse files Browse the repository at this point in the history
…rked as short flow and vrouter index allocation fails trigger ksync entry deletion if flow is marked for delete. Closes-bug:#1565572" into R3.0
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Apr 9, 2016
2 parents c42729f + 8d6a3f0 commit 0b22387
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/vnsw/agent/pkt/test/test_pkt_flow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,41 @@ TEST_F(FlowTest, Flow_return_error) {
sock->SetKSyncError(KSyncSockTypeMap::KSYNC_FLOW_ENTRY_TYPE, 0);
}

//Create short-flow and delete the flow entry
//before vrouter sends a response for flow
//verify flow gets cleaned up
TEST_F(FlowTest, Flow_return_error_1) {
KSyncSockTypeMap *sock = KSyncSockTypeMap::GetKSyncSockTypeMap();
EXPECT_EQ(0U, get_flow_proto()->FlowCount());
client->WaitForIdle();

//Create short flow
TestFlow flow[] = {
{
TestFlowPkt(Address::INET, vm1_ip, remote_vm1_ip, 1, 0, 0, "vrf5",
flow0->id()),
{new ShortFlow()}
}
};

sock->SetBlockMsgProcessing(true);
/* Failure to allocate reverse flow index, convert to short flow and age */
sock->SetKSyncError(KSyncSockTypeMap::KSYNC_FLOW_ENTRY_TYPE, -ENOSPC);
flow[0].pkt_.set_allow_wait_for_idle(false);
CreateFlow(flow, 1);

uint32_t vrf_id = VrfGet("vrf5")->vrf_id();
FlowEntry *fe = FlowGet(vrf_id, vm1_ip, remote_vm1_ip, 1, 0, 0,
GetFlowKeyNH(input[0].intf_id));

client->EnqueueFlowAge();
WAIT_FOR(1000, 1000, (fe->deleted() == true));
sock->SetBlockMsgProcessing(false);
client->WaitForIdle();
EXPECT_TRUE(FlowTableWait(0));
sock->SetKSyncError(KSyncSockTypeMap::KSYNC_FLOW_ENTRY_TYPE, 0);
}

//Test for subnet broadcast flow
TEST_F(FlowTest, Subnet_broadcast_Flow) {
IpamInfo ipam_info[] = {
Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/vrouter/ksync/ksync_flow_index_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ void KSyncFlowIndexEntry::IndexUnassignedSm(KSyncFlowIndexManager *manager,
case VROUTER_ERROR:
if (flow->flow_handle() == FlowEntry::kInvalidFlowHandle) {
state_ = INDEX_FAILED;
if (flow->deleted()) {
KSyncDelete(manager, flow);
}
break;
}

Expand Down

0 comments on commit 0b22387

Please sign in to comment.