Skip to content

Commit

Permalink
Merge "Update dest_vrf when there there is no nat translation."
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Aug 4, 2015
2 parents cc87335 + 6283032 commit 9bcd167
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/vnsw/agent/pkt/flow_table.cc
Expand Up @@ -1510,8 +1510,13 @@ void FlowEntry::InitRevFlow(const PktFlowInfo *info, const PktInfo *pkt,
data_.flow_dest_vrf = info->flow_source_vrf;
data_.flow_source_plen_map = info->flow_dest_plen_map;
data_.flow_dest_plen_map = info->flow_source_plen_map;
data_.dest_vrf = info->nat_dest_vrf;
data_.vrf = info->dest_vrf;

if (!info->nat_done) {
data_.dest_vrf = info->flow_source_vrf;
} else {
data_.dest_vrf = info->nat_dest_vrf;
}
if (info->ecmp) {
set_flags(FlowEntry::EcmpFlow);
} else {
Expand Down
29 changes: 29 additions & 0 deletions src/vnsw/agent/pkt/test/test_flow_util.h
Expand Up @@ -343,6 +343,35 @@ class VerifyVrf : public FlowVerify {
std::string dest_vrf_;
};

class VerifyDestVrf : public FlowVerify {
public:
VerifyDestVrf(std::string src_vrf, std::string dest_vrf):
src_vrf_(src_vrf), dest_vrf_(dest_vrf) {};
virtual ~VerifyDestVrf() {};

void Verify(FlowEntry *fe) {
const VrfEntry *src_vrf =
Agent::GetInstance()->vrf_table()->FindVrfFromName(src_vrf_);
EXPECT_TRUE(src_vrf != NULL);

const VrfEntry *dest_vrf =
Agent::GetInstance()->vrf_table()->FindVrfFromName(dest_vrf_);
EXPECT_TRUE(dest_vrf != NULL);

EXPECT_TRUE(fe->data().flow_source_vrf == dest_vrf->vrf_id());

if (true) {
FlowEntry *rev = fe->reverse_flow_entry();
EXPECT_TRUE(rev != NULL);
EXPECT_TRUE(rev->data().flow_source_vrf == src_vrf->vrf_id());
}
};

private:
std::string src_vrf_;
std::string dest_vrf_;
};

struct VerifyNat : public FlowVerify {
public:
VerifyNat(std::string nat_sip, std::string nat_dip, uint32_t proto,
Expand Down
12 changes: 8 additions & 4 deletions src/vnsw/agent/pkt/test/test_pkt_flow.cc
Expand Up @@ -579,29 +579,33 @@ TEST_F(FlowTest, FlowAdd_1) {
flow0->id()),
{
new VerifyVn("vn5", "vn5"),
new VerifyVrf("vrf5", "vrf5")
new VerifyVrf("vrf5", "vrf5"),
new VerifyDestVrf("vrf5", "vrf5")
}
},
{ TestFlowPkt(Address::INET, vm2_ip, vm1_ip, 1, 0, 0, "vrf5",
flow1->id()),
{
new VerifyVn("vn5", "vn5"),
new VerifyVrf("vrf5", "vrf5")
new VerifyVrf("vrf5", "vrf5"),
new VerifyDestVrf("vrf5", "vrf5")
}
},
//Add a TCP forward and reverse flow
{ TestFlowPkt(Address::INET, vm1_ip, vm2_ip, IPPROTO_TCP, 1000, 200,
"vrf5", flow0->id()),
{
new VerifyVn("vn5", "vn5"),
new VerifyVrf("vrf5", "vrf5")
new VerifyVrf("vrf5", "vrf5"),
new VerifyDestVrf("vrf5", "vrf5")
}
},
{ TestFlowPkt(Address::INET, vm2_ip, vm1_ip, IPPROTO_TCP, 200, 1000,
"vrf5", flow1->id()),
{
new VerifyVn("vn5", "vn5"),
new VerifyVrf("vrf5", "vrf5")
new VerifyVrf("vrf5", "vrf5"),
new VerifyDestVrf("vrf5", "vrf5")
}
}
};
Expand Down

0 comments on commit 9bcd167

Please sign in to comment.