Skip to content

Commit

Permalink
fix ToR-agent crash for stale timer cb
Browse files Browse the repository at this point in the history
Issue:
------
Stale entry timer triggered delete on a deleted entry
causing invalid state machine event, ideally when an
Add/Change/Delete event happens it should have removed
entry from the stale entry tree. however along with
last change for sync DB request from a workqueue this
removal of entry from the stale entry tree got moved to
workqueue context causing issue.

Fix:
----
Move Stopping of stale entry timer to Add/Change/Delete
request context instead of workqueue context

Change-Id: I820c25d0462e2459aa7f0d6a84aee5626e8da4f2
Closes-Bug: 1518899
(cherry picked from commit cd6bbe5)
(cherry picked from commit bb2c120)
  • Loading branch information
Prabhjot Singh Sethi committed Nov 23, 2015
1 parent 998e58d commit cf70103
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.cc
Expand Up @@ -46,6 +46,8 @@ bool HaStaleL2RouteEntry::Add() {
static_cast<HaStaleL2RouteTable *>(table_);
ack_event_ = KSyncEntry::ADD_ACK;
table->EnqueueExportEntry(this);
// Stop stale clear timer on add/change/delete req
StopStaleClearTimer();
return false;
}

Expand All @@ -54,6 +56,8 @@ bool HaStaleL2RouteEntry::Change() {
static_cast<HaStaleL2RouteTable *>(table_);
ack_event_ = KSyncEntry::CHANGE_ACK;
table->EnqueueExportEntry(this);
// Stop stale clear timer on add/change/delete req
StopStaleClearTimer();
return false;
}

Expand All @@ -62,9 +66,25 @@ bool HaStaleL2RouteEntry::Delete() {
static_cast<HaStaleL2RouteTable *>(table_);
ack_event_ = KSyncEntry::DEL_ACK;
table->EnqueueExportEntry(this);
// Stop stale clear timer on add/change/delete req
StopStaleClearTimer();
return false;
}

void HaStaleL2RouteEntry::StopStaleClearTimer() {
// Cancel timer if running
if (time_stamp_ != 0) {
HaStaleL2RouteTable *table =
static_cast<HaStaleL2RouteTable *>(table_);
HaStaleDevVnEntry *dev_vn =
static_cast<HaStaleDevVnEntry *>(table->dev_vn_ref_.get());
HaStaleDevVnTable *dev_vn_table =
static_cast<HaStaleDevVnTable*>(dev_vn->table());
dev_vn_table->StaleClearDelEntry(time_stamp_, this);
time_stamp_ = 0;
}
}

void HaStaleL2RouteEntry::AddEvent() {
HaStaleL2RouteTable *table =
static_cast<HaStaleL2RouteTable *>(table_);
Expand All @@ -91,14 +111,6 @@ void HaStaleL2RouteEntry::AddEvent() {
table->vrf_->GetName() + ", VxlanId " +
integerToString(vxlan_id_) + ", MAC " + mac_ + ", dest ip " +
table->dev_ip_.to_string());

// Cancel timer if running
if (time_stamp_ != 0) {
HaStaleDevVnTable *dev_vn_table =
static_cast<HaStaleDevVnTable*>(dev_vn->table());
dev_vn_table->StaleClearDelEntry(time_stamp_, this);
time_stamp_ = 0;
}
}

void HaStaleL2RouteEntry::ChangeEvent() {
Expand All @@ -123,13 +135,6 @@ void HaStaleL2RouteEntry::DeleteEvent() {
integerToString(vxlan_id_) + ", MAC " + mac_);
dev_vn->route_peer()->DeleteOvsRoute(table->vrf_.get(), vxlan_id_,
MacAddress(mac_));

if (time_stamp_ != 0) {
HaStaleDevVnTable *dev_vn_table =
static_cast<HaStaleDevVnTable*>(dev_vn->table());
dev_vn_table->StaleClearDelEntry(time_stamp_, this);
time_stamp_ = 0;
}
}

bool HaStaleL2RouteEntry::Sync(DBEntry *db_entry) {
Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.h
Expand Up @@ -91,6 +91,8 @@ class HaStaleL2RouteEntry : public OvsdbDBEntry {

void StaleClearCb();

void StopStaleClearTimer();

void AddEvent();
void ChangeEvent();
void DeleteEvent();
Expand Down

0 comments on commit cf70103

Please sign in to comment.