Skip to content

Commit

Permalink
Prioritize static preference over act-active flag
Browse files Browse the repository at this point in the history
If static preference is configured on interface then publish the
route with that preference even if active-active flags is configured
on instance-ip or AAP. Test case for same.

Conflicts:
	src/vnsw/agent/oper/vm_interface.cc

Change-Id: I6368e50e4fa8a431f454a7fe3b97c830a2d94f7f
Closes-bug:#1674408
  • Loading branch information
naveen-n authored and haripk committed Jul 16, 2017
1 parent c818f27 commit 24ee634
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
20 changes: 19 additions & 1 deletion src/vnsw/agent/oper/agent_path.h
Expand Up @@ -45,7 +45,15 @@ class PathPreference {
}

bool is_ecmp() const {
if (ecmp_ == true || (preference_ == HIGH && sequence_ == 0)) {
if ((preference_ == HIGH && sequence_ == 0)) {
return true;
}

if (static_preference_) {
return false;
}

if (ecmp_ == true) {
return true;
}
return false;
Expand Down Expand Up @@ -105,6 +113,16 @@ class PathPreference {
return false;
}

bool operator==(const PathPreference &rhs) const {
if (preference_ == rhs.preference_ &&
sequence_ == rhs.sequence_) {
return true;
}

return false;
}


//Check if any configuration values have changed
//ecmp flag and static preference are updated from
//configuration, if static preference flag is set,
Expand Down
34 changes: 34 additions & 0 deletions src/vnsw/agent/oper/test/test_aap.cc
Expand Up @@ -1404,6 +1404,40 @@ TEST_F(TestAap, ServiceIpTrackingIp_4) {

}

TEST_F(TestAap, StaticPreference1) {
AddStaticPreference("intf1", 1, 150);
Ip4Address ip = Ip4Address::from_string("1.1.1.1");
EXPECT_TRUE(RouteFind("vrf1", ip, 32));

InetUnicastRouteEntry *rt =
RouteGet("vrf1", ip, 32);
const AgentPath *path = rt->GetActivePath();
EXPECT_TRUE(path->path_preference().sequence() == 0);
EXPECT_TRUE(path->path_preference().preference() == 150);
EXPECT_TRUE(path->path_preference().ecmp() == false);
EXPECT_TRUE(path->path_preference().wait_for_traffic() == true);
EXPECT_TRUE(path->path_preference().static_preference() == true);

AddActiveActiveInstanceIp("instance1", 1, "1.1.1.1");
client->WaitForIdle();

EXPECT_TRUE(path->path_preference().sequence() == 0);
EXPECT_TRUE(path->path_preference().preference() == 150);
EXPECT_TRUE(path->path_preference().ecmp() == true);
EXPECT_TRUE(path->path_preference().wait_for_traffic() == true);
EXPECT_TRUE(path->path_preference().static_preference() == true);

AddStaticPreference("intf1", 1, 100);
client->WaitForIdle();
EXPECT_TRUE(path->path_preference().sequence() == 0);
EXPECT_TRUE(path->path_preference().preference() == 100);

AddInstanceIp("instance1", 1, "1.1.1.1");
client->WaitForIdle();
EXPECT_TRUE(path->path_preference().sequence() == 0);
EXPECT_TRUE(path->path_preference().preference() == 100);
}

int main(int argc, char *argv[]) {
GETUSERARGS();
client = TestInit(init_file, ksync_init);
Expand Down
6 changes: 3 additions & 3 deletions src/vnsw/agent/oper/vm_interface_utils.cc
Expand Up @@ -323,9 +323,7 @@ void VmInterface::SetPathPreference(PathPreference *pref, bool ecmp,
if (local_preference_ != 0) {
pref->set_static_preference(true);
pref->set_preference(local_preference_);
}
// Override user defined local preference with HIGH for ECMP
if (ecmp == true) {
} else if (ecmp == true) {
pref->set_preference(PathPreference::HIGH);
}
pref->set_dependent_ip(dependent_ip);
Expand Down Expand Up @@ -372,6 +370,8 @@ void VmInterface::SetServiceVlanPathPreference(PathPreference *pref,
if (local_preference_ != 0) {
pref->set_static_preference(true);
pref->set_preference(local_preference_);
} else if (ecmp_mode == true) {
pref->set_preference(PathPreference::HIGH);
}

pref->set_dependent_ip(dependent_ip);
Expand Down

0 comments on commit 24ee634

Please sign in to comment.