Skip to content

Commit

Permalink
* Publish AAP route with high preference
Browse files Browse the repository at this point in the history
1> Handle AAP transition from active-backup to active-active
   and vice versa
2> For a same route if there are path with tracking IP and
   one with no tracking ip, and tracking IP route is not present
   this particular path used to cause continous evaluation
   of path for state machine change, fix the same by removing
   recursive call.
Closes-bug:#1634253,#1634252

Change-Id: I3dd1e36b727c9de3d78bd87433e32c01e03b2bdf
  • Loading branch information
naveen-n committed Oct 22, 2016
1 parent 3a0aef2 commit 54feff0
Show file tree
Hide file tree
Showing 9 changed files with 343 additions and 92 deletions.
6 changes: 4 additions & 2 deletions src/vnsw/agent/oper/agent_path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,7 @@ bool PathPreferenceData::AddChangePath(Agent *agent, AgentPath *path,

path_preference_.set_ecmp(path->path_preference().ecmp());
path_preference_.set_dependent_ip(path->path_preference().dependent_ip());
path_preference_.set_vrf(path->path_preference().vrf());
if (path &&
path->path_preference() != path_preference_) {
path->set_path_preference(path_preference_);
Expand Down Expand Up @@ -1236,8 +1237,9 @@ void AgentPath::SetSandeshData(PathSandeshData &pdata) const {
path_preference_data.set_wait_for_traffic(
path_preference_.wait_for_traffic());
if (path_preference_.dependent_ip().is_unspecified() == false) {
path_preference_data.set_dependent_ip(
path_preference_.dependent_ip().to_string());
std::ostringstream str;
str << path_preference_.vrf() << " : " <<path_preference_.dependent_ip().to_string();
path_preference_data.set_dependent_ip(str.str());
}
pdata.set_path_preference_data(path_preference_data);
pdata.set_active_label(GetActiveLabel());
Expand Down
56 changes: 32 additions & 24 deletions src/vnsw/agent/oper/path_preference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,14 @@ struct ActiveActiveState : sc::state<ActiveActiveState, PathPreferenceSM> {
ActiveActiveState(my_context ctx) : my_base(ctx) {
PathPreferenceSM *state_machine = &context<PathPreferenceSM>();
//Enqueue a route change
if (state_machine->preference() == PathPreference::LOW) {
state_machine->set_wait_for_traffic(false);
uint32_t seq = 0;
state_machine->set_max_sequence(seq);
state_machine->set_sequence(seq);
state_machine->set_preference(PathPreference::HIGH);
state_machine->EnqueuePathChange();
state_machine->UpdateDependentRoute();
state_machine->Log("Ecmp path");
}
state_machine->set_wait_for_traffic(false);
uint32_t seq = 0;
state_machine->set_max_sequence(seq);
state_machine->set_sequence(seq);
state_machine->set_preference(PathPreference::HIGH);
state_machine->EnqueuePathChange();
state_machine->UpdateDependentRoute();
state_machine->Log("Ecmp path");
}

sc::result react(const EvTrafficSeen &event) {
Expand Down Expand Up @@ -355,8 +353,10 @@ void PathPreferenceSM::Process() {
uint32_t max_sequence = 0;
const AgentPath *best_path = NULL;

const AgentPath *local_path = rt_->FindPath(peer_);
//Dont act on notification of derived routes
if (is_dependent_rt_) {
path_preference_.set_ecmp(local_path->path_preference().ecmp());
if (dependent_rt_.get()) {
if (dependent_rt_->path_preference_.preference() ==
PathPreference::HIGH) {
Expand All @@ -368,14 +368,21 @@ void PathPreferenceSM::Process() {
return;
}

const AgentPath *local_path = rt_->FindPath(peer_);
if (local_path->path_preference().ecmp() == true) {
path_preference_.set_ecmp(true);
//If a path is ecmp, just set the priority to HIGH
process_event(EvActiveActiveMode());
return;
}

if (path_preference_.ecmp() == true) {
path_preference_.set_ecmp(local_path->path_preference().ecmp());
//Route transition from ECMP to non ECMP,
//move to wait for traffic state
process_event(EvWaitForTraffic());
return;
}

//Check if BGP path is present
for (Route::PathList::iterator it = rt_->GetPathList().begin();
it != rt_->GetPathList().end(); ++it) {
Expand All @@ -398,14 +405,6 @@ void PathPreferenceSM::Process() {
return;
}

if (ecmp() == true) {
path_preference_.set_ecmp(local_path->path_preference().ecmp());
//Route transition from ECMP to non ECMP,
//move to wait for traffic state
process_event(EvWaitForTraffic());
return;
}

if (max_sequence > sequence()) {
process_event(EvSeqChange(max_sequence));
} else if (sequence() == max_sequence &&
Expand Down Expand Up @@ -727,7 +726,8 @@ PathPreferenceState::GetDependentPath(const AgentPath *path) const {
return state->GetSM(path->peer());
}

void PathPreferenceState::Process() {
bool PathPreferenceState::Process() {
bool should_resolve = false;
PathPreferenceModule *path_module =
agent_->oper_db()->route_preference_module();
//Set all the path as not seen, eventually when path is seen
Expand All @@ -751,6 +751,7 @@ void PathPreferenceState::Process() {
continue;
}

bool new_path_added = false;
PathPreferenceSM *path_preference_sm;
if (path_preference_peer_map_.find(path->peer()) ==
path_preference_peer_map_.end()) {
Expand All @@ -761,6 +762,7 @@ void PathPreferenceState::Process() {
path_preference_peer_map_.insert(
std::pair<const Peer *, PathPreferenceSM *>
(path->peer(), path_preference_sm));
new_path_added = true;
} else {
path_preference_sm =
path_preference_peer_map_.find(path->peer())->second;
Expand All @@ -786,9 +788,8 @@ void PathPreferenceState::Process() {
path_preference_sm->set_seen(true);
path_preference_sm->Process();

if (dependent_rt == false) {
//Resolve path which may not be resolved yet
path_module->Resolve();
if (dependent_rt == false && new_path_added) {
should_resolve = true;
}
}

Expand All @@ -802,6 +803,7 @@ void PathPreferenceState::Process() {
path_preference_peer_map_.erase(prev_it);
}
}
return should_resolve;
}

PathPreferenceSM* PathPreferenceState::GetSM(const Peer *peer) {
Expand Down Expand Up @@ -889,8 +891,14 @@ void PathPreferenceRouteListener::Notify(DBTablePartBase *partition,
if (!state) {
state = new PathPreferenceState(agent_, rt);
}
state->Process();
bool should_resolve = state->Process();
e->SetState(rt_table_, id_, state);

if (should_resolve) {
PathPreferenceModule *path_module =
agent_->oper_db()->route_preference_module();
path_module->Resolve();
}
}

PathPreferenceModule::PathPreferenceModule(Agent *agent):
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/oper/path_preference.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class PathPreferenceState: public DBState {
typedef std::map<const Peer *, PathPreferenceSM *> PeerPathPreferenceMap;
PathPreferenceState(Agent *agent, AgentRoute *rt_);
~PathPreferenceState();
void Process();
bool Process();
PathPreferenceSM *GetSM(const Peer *);
PathPreferenceSM* GetDependentPath(const AgentPath *path) const;
private:
Expand Down

0 comments on commit 54feff0

Please sign in to comment.