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 Nov 30, 2016
1 parent f73268a commit ae8971e
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 121 deletions.
1 change: 1 addition & 0 deletions src/vnsw/agent/oper/agent.sandesh
Expand Up @@ -704,6 +704,7 @@ traceobject sandesh PathPreferenceTrace {
4: i32 sequence;
5: string state;
6: i32 retry_timeout;
7: i32 flap_count;
}

request sandesh MirrorCreateReq {
Expand Down
33 changes: 20 additions & 13 deletions src/vnsw/agent/oper/path_preference.cc
Expand Up @@ -140,9 +140,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 @@ -244,6 +241,7 @@ PathPreferenceSM::PathPreferenceSM(Agent *agent, const Peer *peer,
flap_count_(0) {
initiate();
process_event(EvStart());
backoff_timer_fired_time_ = UTCTimestampUsec();
}

PathPreferenceSM::~PathPreferenceSM() {
Expand All @@ -256,6 +254,7 @@ PathPreferenceSM::~PathPreferenceSM() {

bool PathPreferenceSM::Retry() {
flap_count_ = 0;
backoff_timer_fired_time_ = UTCTimestampUsec();
process_event(EvWaitForTraffic());
return false;
}
Expand Down Expand Up @@ -293,30 +292,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 @@ -378,7 +384,8 @@ void PathPreferenceSM::Process() {

void PathPreferenceSM::Log(std::string state) {
PATH_PREFERENCE_TRACE(rt_->vrf()->GetName(), rt_->GetAddressString(),
preference(), sequence(), state, timeout());
preference(), sequence(), state, timeout(),
flap_count_);
}

void PathPreferenceSM::EnqueuePathChange() {
Expand Down
16 changes: 9 additions & 7 deletions src/vnsw/agent/oper/path_preference.h
Expand Up @@ -28,8 +28,8 @@ do { \
class PathPreferenceSM:
public sc::state_machine<PathPreferenceSM, Init> {
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);
Expand All @@ -40,8 +40,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 @@ -73,10 +73,11 @@ 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;
}

bool IsFlap() const;
bool seen() { return seen_; }
uint32_t max_sequence() const { return max_sequence_;}
void Process();
Expand All @@ -101,7 +102,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_;
};

Expand Down

0 comments on commit ae8971e

Please sign in to comment.