From bb2c1200ef01ce92bc8e2377b0875ee1d3698b5b Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Mon, 23 Nov 2015 22:18:15 +0530 Subject: [PATCH] fix ToR-agent crash for stale timer cb 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 cd6bbe51d96d0ca31f48984a20946fb866004527) --- .../ovsdb_client/ha_stale_l2_route.cc | 35 +++++++++++-------- .../ovsdb_client/ha_stale_l2_route.h | 2 ++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.cc b/src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.cc index 8a1fb919405..10ca35cc8ad 100644 --- a/src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.cc +++ b/src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.cc @@ -46,6 +46,8 @@ bool HaStaleL2RouteEntry::Add() { static_cast(table_); ack_event_ = KSyncEntry::ADD_ACK; table->EnqueueExportEntry(this); + // Stop stale clear timer on add/change/delete req + StopStaleClearTimer(); return false; } @@ -54,6 +56,8 @@ bool HaStaleL2RouteEntry::Change() { static_cast(table_); ack_event_ = KSyncEntry::CHANGE_ACK; table->EnqueueExportEntry(this); + // Stop stale clear timer on add/change/delete req + StopStaleClearTimer(); return false; } @@ -62,9 +66,25 @@ bool HaStaleL2RouteEntry::Delete() { static_cast(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(table_); + HaStaleDevVnEntry *dev_vn = + static_cast(table->dev_vn_ref_.get()); + HaStaleDevVnTable *dev_vn_table = + static_cast(dev_vn->table()); + dev_vn_table->StaleClearDelEntry(time_stamp_, this); + time_stamp_ = 0; + } +} + void HaStaleL2RouteEntry::AddEvent() { HaStaleL2RouteTable *table = static_cast(table_); @@ -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(dev_vn->table()); - dev_vn_table->StaleClearDelEntry(time_stamp_, this); - time_stamp_ = 0; - } } void HaStaleL2RouteEntry::ChangeEvent() { @@ -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(dev_vn->table()); - dev_vn_table->StaleClearDelEntry(time_stamp_, this); - time_stamp_ = 0; - } } bool HaStaleL2RouteEntry::Sync(DBEntry *db_entry) { diff --git a/src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.h b/src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.h index c60da5c7839..b0a9050be4e 100644 --- a/src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.h +++ b/src/vnsw/agent/ovs_tor_agent/ovsdb_client/ha_stale_l2_route.h @@ -91,6 +91,8 @@ class HaStaleL2RouteEntry : public OvsdbDBEntry { void StaleClearCb(); + void StopStaleClearTimer(); + void AddEvent(); void ChangeEvent(); void DeleteEvent();