diff --git a/src/vnsw/agent/oper/test/test_aap.cc b/src/vnsw/agent/oper/test/test_aap.cc index f621370b883..ec7f80c9792 100644 --- a/src/vnsw/agent/oper/test/test_aap.cc +++ b/src/vnsw/agent/oper/test/test_aap.cc @@ -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); diff --git a/src/vnsw/agent/oper/vm_interface.cc b/src/vnsw/agent/oper/vm_interface.cc index 9b35c571b04..18dbf008509 100644 --- a/src/vnsw/agent/oper/vm_interface.cc +++ b/src/vnsw/agent/oper/vm_interface.cc @@ -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; + } } }