Skip to content

Commit

Permalink
Set static preference field only if local preference field is
Browse files Browse the repository at this point in the history
initialized

In case of service instance, VMI would have VMI_property field
set, but the local preference value would not be assigned
in such cases also agent was not running mastership algorithm for
active path selection based on traffic.Set static preference only
if local preference is greater than 0, such that if AAP
address is assigned to service interface it works fine.
Test case for same.
Closes-bug:#1435689

Change-Id: If642ae574306cc6339ef03cb6783acb720092ac7
  • Loading branch information
naveen-n authored and praveenkv committed Jul 1, 2015
1 parent d924f27 commit 1550065
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 1550065

Please sign in to comment.