Skip to content

Commit

Permalink
Merge "Set static preference field only if local preference field is …
Browse files Browse the repository at this point in the history
…initialized" into R2.1
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 16, 2015
2 parents f911f48 + 1550065 commit c6ea9ac
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/vnsw/agent/oper/test/test_aap.cc
Expand Up @@ -528,6 +528,24 @@ TEST_F(TestAap, StaticMachine_11) {
EXPECT_TRUE(path->path_preference().static_preference() == false);
}

//Verify that static preference is not populated
//when preference value is set to 0
TEST_F(TestAap, StateMachine_12) {
AddStaticPreference("intf1", 1, 0);
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() == PathPreference::LOW);
EXPECT_TRUE(path->path_preference().ecmp() == false);
EXPECT_TRUE(path->path_preference().wait_for_traffic() == true);
EXPECT_TRUE(path->path_preference().static_preference() == false);
}


int main(int argc, char *argv[]) {
GETUSERARGS();
client = TestInit(init_file, ksync_init);
Expand Down
12 changes: 9 additions & 3 deletions src/vnsw/agent/oper/vm_interface.cc
Expand Up @@ -634,9 +634,15 @@ static void BuildAttributes(Agent *agent, IFMapNode *node,
//Extract the local preference
if (cfg->IsPropertySet(VirtualMachineInterface::PROPERTIES)) {
autogen::VirtualMachineInterfacePropertiesType prop = cfg->properties();
data->local_preference_ = VmInterface::LOW;
if (prop.local_preference == VmInterface::HIGH) {
data->local_preference_ = VmInterface::HIGH;
//Service instance also would have VirtualMachineInterface
//properties field set, pick up local preference
//value only when it has been initialized to proper
//value, if its 0, ignore the local preference
if (prop.local_preference) {
data->local_preference_ = VmInterface::LOW;
if (prop.local_preference == VmInterface::HIGH) {
data->local_preference_ = VmInterface::HIGH;
}
}
}

Expand Down

0 comments on commit c6ea9ac

Please sign in to comment.