Skip to content

Commit

Permalink
* Delete short flow if vrouter operation fails
Browse files Browse the repository at this point in the history
If a flow is marked as short flow and vrouter index
allocation fails trigger ksync entry deletion if flow
is marked for delete.
Closes-bug:#1565572

Change-Id: I502a25bfe748caf0ea775b0987c6cb203aceef3f
  • Loading branch information
naveen-n committed Apr 4, 2016
1 parent 18f9c2d commit 5514f3c
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 5514f3c

Please sign in to comment.