Skip to content

Commit

Permalink
* AAP back off changes
Browse files Browse the repository at this point in the history
1> If path toggles for 5 times within 4 seconds, the consider path
   is unstable and start backoff, max backoff timeout is 32 seconds
2> If path doesnt toggle for 5 times within 4 seconds, consider path
   to be stable and decrease backoff timeout from any value back to
   4s
Closes-bug:#1645508,#1645974

Change-Id: I7e7fe20979dcf7be08c9bce9410f2b7931326dc6
  • Loading branch information
naveen-n committed Jan 3, 2017
1 parent 1461a59 commit 4a3e100
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 120 deletions.
1 change: 1 addition & 0 deletions src/vnsw/agent/oper/agent.sandesh
Expand Up @@ -1022,6 +1022,7 @@ traceobject sandesh PathPreferenceTrace {
5: string state;
6: i32 retry_timeout;
7: string dependent_ip;
8: i32 flap_count;
}

/**
Expand Down
32 changes: 19 additions & 13 deletions src/vnsw/agent/oper/path_preference.cc
Expand Up @@ -141,9 +141,6 @@ struct TrafficSeen : sc::state<TrafficSeen, PathPreferenceSM> {
//Enqueue a route change
if (state_machine->wait_for_traffic() == true) {
state_machine->UpdateFlapTime();
if (state_machine->flap_count() == 0) {
state_machine->DecreaseRetryTimeout();
}
uint32_t seq = state_machine->max_sequence();
state_machine->set_wait_for_traffic(false);
seq++;
Expand Down Expand Up @@ -250,6 +247,7 @@ PathPreferenceSM::PathPreferenceSM(Agent *agent, const Peer *peer,
path_preference_ = pref;
initiate();
process_event(EvStart());
backoff_timer_fired_time_ = UTCTimestampUsec();
}

PathPreferenceSM::~PathPreferenceSM() {
Expand All @@ -269,6 +267,7 @@ PathPreferenceSM::~PathPreferenceSM() {

bool PathPreferenceSM::Retry() {
flap_count_ = 0;
backoff_timer_fired_time_ = UTCTimestampUsec();
process_event(EvWaitForTraffic());
return false;
}
Expand Down Expand Up @@ -306,30 +305,37 @@ void PathPreferenceSM::IncreaseRetryTimeout() {
}
}

bool PathPreferenceSM::IsFlap() const {
uint64_t time_sec = (UTCTimestampUsec() -
last_stable_high_priority_change_at_)/1000;
if (time_sec > kMinInterval) {
return false;
}
return true;
}

void PathPreferenceSM::DecreaseRetryTimeout() {
timeout_ = timeout_ / 2;
if (timeout_ < kMinInterval) {
uint64_t time_sec =
(UTCTimestampUsec() - backoff_timer_fired_time_)/1000;
if (time_sec > kMinInterval) {
timeout_ = kMinInterval;
}
}

void PathPreferenceSM::UpdateFlapTime() {
uint64_t time_sec = (UTCTimestampUsec() - last_high_priority_change_at_)/1000;

//Update last flap time
last_high_priority_change_at_ = UTCTimestampUsec();
if (time_sec < timeout_ + kMinInterval) {
if (IsFlap()) {
flap_count_++;
} else {
DecreaseRetryTimeout();
last_stable_high_priority_change_at_ = UTCTimestampUsec();
flap_count_ = 0;
}
}

bool PathPreferenceSM::IsPathFlapping() const {
if (flap_count_ >= kMaxFlapCount) {
if (flap_count_ >= kMaxFlapCount && IsFlap()) {
return true;
}

return false;
}

Expand Down Expand Up @@ -429,7 +435,7 @@ void PathPreferenceSM::Log(std::string state) {

PATH_PREFERENCE_TRACE(rt_->vrf()->GetName(), rt_->GetAddressString(),
preference(), sequence(), state, timeout(),
dependent_ip_str);
dependent_ip_str, flap_count_);
}

void PathPreferenceSM::EnqueuePathChange() {
Expand Down
16 changes: 9 additions & 7 deletions src/vnsw/agent/oper/path_preference.h
Expand Up @@ -29,8 +29,8 @@ class PathPreferenceSM:
public sc::state_machine<PathPreferenceSM, Init> {
typedef DependencyList<PathPreferenceSM, PathPreferenceSM> PathDependencyList;
public:
static const uint32_t kMinInterval = 5 * 1000;
static const uint32_t kMaxInterval = 100 * 1000;
static const uint32_t kMinInterval = 4 * 1000;
static const uint32_t kMaxInterval = 32 * 1000;
static const uint32_t kMaxFlapCount = 5;
PathPreferenceSM(Agent *agent, const Peer *peer,
AgentRoute *rt, bool dependent_rt,
Expand All @@ -42,8 +42,8 @@ class PathPreferenceSM:
bool ecmp() const {return path_preference_.ecmp();}
uint32_t timeout() const { return timeout_;}

uint64_t last_high_priority_change_at() const {
return last_high_priority_change_at_;
uint64_t last_stable_high_priority_change_at() const {
return last_stable_high_priority_change_at_;
}
uint32_t flap_count() const { return flap_count_;}

Expand Down Expand Up @@ -76,8 +76,8 @@ class PathPreferenceSM:
timeout_ = timeout;
}

void set_last_high_priority_change_at(uint64_t timestamp) {
last_high_priority_change_at_ = timestamp;
void set_last_stable_high_priority_change_at(uint64_t timestamp) {
last_stable_high_priority_change_at_ = timestamp;
}

void set_dependent_rt(PathPreferenceSM *sm) {
Expand All @@ -96,6 +96,7 @@ class PathPreferenceSM:
return path_preference_.dependent_ip();
}

bool IsFlap() const;
bool seen() { return seen_; }
uint32_t max_sequence() const { return max_sequence_;}
void Process();
Expand All @@ -121,7 +122,8 @@ class PathPreferenceSM:
bool seen_;
Timer *timer_;
uint32_t timeout_;
uint64_t last_high_priority_change_at_;
uint64_t last_stable_high_priority_change_at_;
uint64_t backoff_timer_fired_time_;
uint32_t flap_count_;
bool is_dependent_rt_;
DependencyRef<PathPreferenceSM, PathPreferenceSM> dependent_rt_;
Expand Down

0 comments on commit 4a3e100

Please sign in to comment.