[Xorp-hackers] [PATCH 4/5] xorp: Remove protocol's tags from rib when it dies

igorm at etf.rs igorm at etf.rs
Wed Apr 11 09:26:20 PDT 2012


From: Igor Maravic <igorm at etf.rs>

Added new function in rib.xif to enable that. FilterManager calls it when protocol dies.

>From rib's tag map, all protocol's tags are removed.

Signed-off-by: Igor Maravic <igorm at etf.rs>
---
 xorp/policy/backend/policy_redist_map.cc |    6 ++++++
 xorp/policy/backend/policy_redist_map.hh |    7 +++++++
 xorp/policy/filter_manager.cc            |    6 ++++--
 xorp/rib/rib_manager.cc                  |    6 ++++++
 xorp/rib/rib_manager.hh                  |    8 ++++++++
 xorp/rib/xrl_target.cc                   |   13 +++++++++++++
 xorp/rib/xrl_target.hh                   |    6 ++++++
 xorp/xrl/interfaces/rib.xif              |    5 +++++
 8 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/xorp/policy/backend/policy_redist_map.cc b/xorp/policy/backend/policy_redist_map.cc
index 6829b44..ffb9074 100644
--- a/xorp/policy/backend/policy_redist_map.cc
+++ b/xorp/policy/backend/policy_redist_map.cc
@@ -33,6 +33,12 @@ PolicyRedistMap::~PolicyRedistMap() {
 }
 
 void
+PolicyRedistMap::remove(const string& protocol)
+{
+    _map.erase(protocol);
+}
+
+void
 PolicyRedistMap::insert(const string& protocol, const PolicyTags& tags) {
     PolicyTags* ptags;
 
diff --git a/xorp/policy/backend/policy_redist_map.hh b/xorp/policy/backend/policy_redist_map.hh
index 7bd876b..c8b984f 100644
--- a/xorp/policy/backend/policy_redist_map.hh
+++ b/xorp/policy/backend/policy_redist_map.hh
@@ -45,6 +45,13 @@ public:
     ~PolicyRedistMap();
 
     /**
+     * Remove route redistribution for a protocol.
+     *
+     * @param protocol protocol which tags should be removed.
+     */
+    void remove(const string& protocol);
+
+    /**
      * Configure redistribution to a protcol for these tags.
      *
      * @param protocol destination protocol for these tags.
diff --git a/xorp/policy/filter_manager.cc b/xorp/policy/filter_manager.cc
index 8c4d6c7..bfbd8bf 100644
--- a/xorp/policy/filter_manager.cc
+++ b/xorp/policy/filter_manager.cc
@@ -308,8 +308,10 @@ FilterManager::death(const string& protocol)
     delete_queue_protocol(_import_queue,protocol);
     _push_queue.erase(protocol);
 
-    // XXX: might want to delete policytags in rib... but the tagmap in rib is
-    // quite unflexible now.
+    // send out update
+    _rib.send_remove_policy_redist_tags(_rib_name.c_str(),
+		_pmap.xrl_target(protocol),
+		callback(this,&FilterManager::policy_backend_cb));
 
     debug_msg("[POLICY] Protocol death: %s\n",protocol.c_str());
 }
diff --git a/xorp/rib/rib_manager.cc b/xorp/rib/rib_manager.cc
index 1fe8c0f..6de144d 100644
--- a/xorp/rib/rib_manager.cc
+++ b/xorp/rib/rib_manager.cc
@@ -603,6 +603,12 @@ RibManager::reset_filter(const uint32_t& filter)
 }
 
 void
+RibManager::remove_policy_redist_tags(const string& protocol)
+{
+    _policy_redist_map.remove(protocol);
+}
+
+void
 RibManager::insert_policy_redist_tags(const string& protocol,
 				      const PolicyTags& tags)
 {
diff --git a/xorp/rib/rib_manager.hh b/xorp/rib/rib_manager.hh
index c3bdcfe..932a436 100644
--- a/xorp/rib/rib_manager.hh
+++ b/xorp/rib/rib_manager.hh
@@ -321,6 +321,14 @@ public:
 
 
     /**
+     * Remove policy-tags for a protocol.
+     *
+     *
+     * @param protocol protocol which tags should be removed.
+     */
+    void remove_policy_redist_tags(const string& protocol);
+
+    /**
      * Insert [old ones are kept] policy-tags for a protocol.
      *
      * All routes which contain at least one of these tags, will be
diff --git a/xorp/rib/xrl_target.cc b/xorp/rib/xrl_target.cc
index c7cfe44..a0c814a 100644
--- a/xorp/rib/xrl_target.cc
+++ b/xorp/rib/xrl_target.cc
@@ -954,6 +954,19 @@ XrlRibTarget::policy_backend_0_1_push_routes()
 }
 
 XrlCmdError
+XrlRibTarget::rib_0_1_remove_policy_redist_tags(const string& protocol)
+{
+    try {
+	_rib_manager->remove_policy_redist_tags(protocol);
+    } catch(const PolicyException& e) {
+	//this should not be posible
+	return XrlCmdError::COMMAND_FAILED("Remove policy redist tags failed: "
+					   + e.str());
+    }
+    return XrlCmdError::OKAY();
+}
+
+XrlCmdError
 XrlRibTarget::rib_0_1_insert_policy_redist_tags(const string& protocol,
 						const XrlAtomList& policytags)
 {
diff --git a/xorp/rib/xrl_target.hh b/xorp/rib/xrl_target.hh
index ce39eae..36b2a83 100644
--- a/xorp/rib/xrl_target.hh
+++ b/xorp/rib/xrl_target.hh
@@ -609,6 +609,12 @@ protected:
      */
     XrlCmdError policy_backend_0_1_push_routes();
 
+    /**
+     * Remove protocol's redistribution tags
+     */
+    XrlCmdError rib_0_1_remove_policy_redist_tags(
+	// Input values,
+	const string& protocol);
 
     /**
      * Redistribute to a protocol based on policy-tags.
diff --git a/xorp/xrl/interfaces/rib.xif b/xorp/xrl/interfaces/rib.xif
index 4b4d128..ebc79a5 100644
--- a/xorp/xrl/interfaces/rib.xif
+++ b/xorp/xrl/interfaces/rib.xif
@@ -322,6 +322,11 @@ interface rib/0.1 {
 	deregister_interest4 ?  target:txt & addr:ipv4 & prefix_len:u32;
 
 	/**
+	 * Remove protocol's redistribution tags
+	 */
+	remove_policy_redist_tags ? protocol:txt;
+
+	/**
 	 * Add policy tags for a specific protcol in the redistribution map.
 	 *
 	 * @param protocol The destination protocol of the redistribution.
-- 
1.7.5.4



More information about the Xorp-hackers mailing list