Skip to content

Commit

Permalink
Merge "* Stick new flows and mark only the dangling flow as short flo…
Browse files Browse the repository at this point in the history
…w" into R3.0.3.x
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Mar 6, 2017
2 parents 9d26289 + 81669c9 commit 139a481
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 121 deletions.
26 changes: 0 additions & 26 deletions src/vnsw/agent/pkt/flow_table.cc
Expand Up @@ -414,26 +414,6 @@ void FlowTable::DeleteAll() {
}
}

bool FlowTable::ValidFlowMove(const FlowEntry *new_flow,
const FlowEntry *old_flow) const {
if (!new_flow || !old_flow) {
return false;
}

if (new_flow->is_flags_set(FlowEntry::EcmpFlow) == false) {
return false;
}

if (new_flow->data().flow_source_vrf == old_flow->data().flow_source_vrf &&
new_flow->key().src_addr == old_flow->key().src_addr &&
new_flow->data().source_plen == old_flow->data().source_plen) {
//Check if both flow originate from same source route
return true;
}

return false;
}

void FlowTable::UpdateReverseFlow(FlowEntry *flow, FlowEntry *rflow) {
FlowEntry *flow_rev = flow->reverse_flow_entry();
FlowEntry *rflow_rev = NULL;
Expand All @@ -458,16 +438,10 @@ void FlowTable::UpdateReverseFlow(FlowEntry *flow, FlowEntry *rflow) {

if (flow_rev && (flow_rev->reverse_flow_entry() == NULL)) {
flow_rev->MakeShortFlow(FlowEntry::SHORT_NO_REVERSE_FLOW);
if (ValidFlowMove(rflow, flow_rev)== false) {
flow->MakeShortFlow(FlowEntry::SHORT_REVERSE_FLOW_CHANGE);
}
}

if (rflow_rev && (rflow_rev->reverse_flow_entry() == NULL)) {
rflow_rev->MakeShortFlow(FlowEntry::SHORT_NO_REVERSE_FLOW);
if (ValidFlowMove(flow, rflow_rev) == false) {
flow->MakeShortFlow(FlowEntry::SHORT_REVERSE_FLOW_CHANGE);
}
}

if (flow->reverse_flow_entry() == NULL) {
Expand Down
2 changes: 0 additions & 2 deletions src/vnsw/agent/pkt/flow_table.h
Expand Up @@ -190,8 +190,6 @@ class FlowTable {
// Test code only used method
void DeleteFlow(const AclDBEntry *acl, const FlowKey &key,
AclEntryIDList &id_list);
bool ValidFlowMove(const FlowEntry *new_flow,
const FlowEntry *old_flow) const;

// Accessor routines
Agent *agent() const { return agent_; }
Expand Down
44 changes: 44 additions & 0 deletions src/vnsw/agent/pkt/test/test_ecmp_mx.cc
Expand Up @@ -371,6 +371,50 @@ TEST_F(EcmpTest, EcmpTest_7) {
WAIT_FOR(1000, 1000, (get_flow_proto()->FlowCount() == 0));
}

//Flow move from remote destination to local compute node
//1> Initially flow are setup from MX to local source VM
//2> Move the flow from MX to local destination VM to local source VM
//3> Verify that old flow from MX would be marked as short flow
// and new set of local flows are marked as forward
TEST_F(EcmpTest, EcmpTest_8) {
struct PortInfo input[] = {
{"vnet2", 2, "1.1.1.100", "00:00:00:01:01:02", 1, 1},
};
CreateVmportWithEcmp(input, 1);
client->WaitForIdle();

AddRemoteEcmpRoute("vrf1", "1.1.1.100", 32, "vn1", 4);
TxIpMplsPacket(eth_intf_id, MX_0, router_id, vm1_label,
"1.1.1.100", "1.1.1.1", 1, 10);
client->WaitForIdle();

FlowEntry *entry = FlowGet(VrfGet("vrf1")->vrf_id(),
"1.1.1.1", "1.1.1.100", 1, 0, 0, GetFlowKeyNH(1));
FlowEntry *rev_entry = entry->reverse_flow_entry();

EXPECT_TRUE(entry != NULL);
EXPECT_TRUE(entry->IsShortFlow() == false);
EXPECT_TRUE(rev_entry->IsShortFlow() == false);

TxIpPacket(VmPortGetId(2), "1.1.1.100", "1.1.1.1", 1);
client->WaitForIdle();

entry = FlowGet(VrfGet("vrf1")->vrf_id(),
"1.1.1.1", "1.1.1.100", 1, 0, 0, GetFlowKeyNH(1));
EXPECT_TRUE(entry != NULL);
EXPECT_TRUE(entry->IsShortFlow() == false);
EXPECT_TRUE(rev_entry->IsShortFlow() == true);
EXPECT_TRUE(entry->reverse_flow_entry()->IsShortFlow() == false);

DeleteVmportEnv(input, 1, false);
client->WaitForIdle();

DeleteRoute("vrf1", "1.1.1.100", 32, bgp_peer);
client->WaitForIdle();

WAIT_FOR(1000, 1000, (get_flow_proto()->FlowCount() == 0));
}

int main(int argc, char *argv[]) {
GETUSERARGS();
client = TestInit(init_file, ksync_init, true, true, true, 100*1000);
Expand Down

0 comments on commit 139a481

Please sign in to comment.