[Xorp-cvs] SF.net SVN: xorp:[11529] trunk/xorp

bms_fbsd at users.sourceforge.net bms_fbsd at users.sourceforge.net
Tue Sep 1 05:55:38 PDT 2009


Revision: 11529
          http://xorp.svn.sourceforge.net/xorp/?rev=11529&view=rev
Author:   bms_fbsd
Date:     2009-09-01 12:55:38 +0000 (Tue, 01 Sep 2009)

Log Message:
-----------
When reconfiguring bootstrap router zones in XORP's PIM implementation,
calling stop() followed by start() will blow away the Elected-BSR state if
the XORP router is the elected BSR for a given multicast zone.

Add an explicit apply_bsr_changes method to PIM's XRL RPC interface, but
do not instruct the Router Manager to use it yet, as this change still
requires more rigorous testing in the field.

Users are encouraged to test this change by uncommenting the %update
change in PIM's template file which will be committed in a forthcoming
revision.

Submitted by:	Samuel Lucas Vaz de Mello, Pavlin Radoslavov (with fixups)

Modified Paths:
--------------
    trunk/xorp/pim/pim_bsr.cc
    trunk/xorp/pim/pim_bsr.hh
    trunk/xorp/pim/pim_node.hh
    trunk/xorp/pim/xrl_pim_node.cc
    trunk/xorp/pim/xrl_pim_node.hh
    trunk/xorp/xrl/interfaces/pim.xif

Modified: trunk/xorp/pim/pim_bsr.cc
===================================================================
--- trunk/xorp/pim/pim_bsr.cc	2009-09-01 12:05:04 UTC (rev 11528)
+++ trunk/xorp/pim/pim_bsr.cc	2009-09-01 12:55:38 UTC (rev 11529)
@@ -316,6 +316,121 @@
     XLOG_INFO("Bootstrap mechanism disabled");
 }
 
+int
+PimBsr::apply_bsr_changes(string& error_msg)
+{
+    list<BsrZone*>::iterator iter;
+    list<BsrZone*> del_list;
+
+    if (! is_enabled())
+	return (XORP_OK);
+
+    //
+    // Preserve any elected BSR zones
+    //
+    for (iter = _active_bsr_zone_list.begin();
+	 iter != _active_bsr_zone_list.end(); iter++) {
+	BsrZone* tmp_zone = *iter;
+	// If the BSR zone is not elected BSR, just remove it
+	if (tmp_zone->bsr_zone_state() != BsrZone::STATE_ELECTED_BSR) {
+	    del_list.push_back(tmp_zone);
+	} else {
+	    //
+	    // It is an Elected BSR. We will keep the BSR zone in the list
+	    // but remove all Cand RPs. Some of them may have been deleted.
+	    // The Cand RPs that were not deleted will be added again below.
+	    //
+	    delete_pointers_list(tmp_zone->bsr_group_prefix_list());
+	}
+    }
+
+    for (iter = del_list.begin(); iter != del_list.end(); ++iter) {
+	_active_bsr_zone_list.remove(*iter);
+    }
+    delete_pointers_list(del_list);
+
+    //
+    // Clean up any deleted zone
+    //
+    for (iter = _active_bsr_zone_list.begin();
+	 iter != _active_bsr_zone_list.end(); ++iter) {
+	BsrZone *active_bsr_zone = *iter;
+	if (active_bsr_zone->bsr_zone_state() == BsrZone::STATE_ELECTED_BSR) {
+	    BsrZone *config_bsr_zone;
+	    config_bsr_zone = find_config_bsr_zone(active_bsr_zone->zone_id());
+	    if (config_bsr_zone == NULL) {
+		// Zone removed from config
+		del_list.push_back(active_bsr_zone);
+		continue;
+	    }
+
+	    //
+	    // Zone is no longer BSR candidate (i.e., removed from Cand-BSR but
+	    // still has some Cand-RP state).
+	    //
+	    // Remove it too, as the Cand-RP state is re-added below
+	    if (! config_bsr_zone->i_am_candidate_bsr()) {
+		del_list.push_back(active_bsr_zone);
+		continue;
+	    }
+	}
+    }
+
+    //
+    // Delete the vanished items
+    //
+    for (iter = del_list.begin(); iter != del_list.end(); ++iter) {
+	BsrZone *active_bsr_zone = *iter;
+	_active_bsr_zone_list.remove(active_bsr_zone);
+    }
+    delete_pointers_list(del_list);
+
+    //
+    // Activate all configured BSR zones
+    //
+    for (iter = _config_bsr_zone_list.begin();
+	 iter != _config_bsr_zone_list.end();
+	 ++iter) {
+	BsrZone *config_bsr_zone = *iter;
+
+	if (config_bsr_zone->i_am_candidate_bsr()) {
+	    if (add_active_bsr_zone(*config_bsr_zone, error_msg) == NULL) {
+		XLOG_ERROR("Cannot add configured Bootstrap zone %s: %s",
+			   cstring(config_bsr_zone->zone_id()),
+			   error_msg.c_str());
+		stop();
+		return (XORP_ERROR);
+	    }
+	}
+	config_bsr_zone->start_candidate_rp_advertise_timer();
+    }
+
+    //
+    // When restarting we want to keep any previously enabled BSR.
+    // Set it to PENDING and expire the bsr_timer immediately.
+    // As soon as the timer runs, it puts the zone back in the ELECTED
+    // state and run the needed actions (calculate RP-Set and send a
+    // BSR Message with the new RP-Set).
+    //
+    for (iter = _active_bsr_zone_list.begin();
+	 iter != _active_bsr_zone_list.end();
+	 ++iter) {
+	BsrZone *active_bsr_zone = *iter;
+	if (active_bsr_zone->bsr_zone_state() == BsrZone::STATE_ELECTED_BSR) {
+	    if (active_bsr_zone->i_am_candidate_bsr()) {
+		// zone was not changed
+		active_bsr_zone->set_bsr_zone_state(BsrZone::STATE_PENDING_BSR);
+	    } else {
+		// zone is no longer Cand-BSR, but contains Cand-RPs
+		active_bsr_zone->set_bsr_zone_state(BsrZone::STATE_ACCEPT_ANY);
+	    }
+	    active_bsr_zone->expire_bsr_timer();
+	}
+    }
+
+    return (XORP_OK);
+}
+
 // Unicast the Bootstrap message(s) to a (new) neighbor
 int
 PimBsr::unicast_pim_bootstrap(PimVif *pim_vif, const IPvX& nbr_addr) const

Modified: trunk/xorp/pim/pim_bsr.hh
===================================================================
--- trunk/xorp/pim/pim_bsr.hh	2009-09-01 12:05:04 UTC (rev 11528)
+++ trunk/xorp/pim/pim_bsr.hh	2009-09-01 12:55:38 UTC (rev 11529)
@@ -93,6 +93,14 @@
      */
     void	disable();
 
+    /**
+     * Apply BSR configuration changes.
+     *
+     * @param error_msg the error message (if error).
+     * @return XORP_OK on success, otherwise XORP_ERROR.
+     */
+    int		apply_bsr_changes(string& error_msg);
+
     PimNode&	pim_node()	const	{ return (_pim_node); }
     
     int		unicast_pim_bootstrap(PimVif *pim_vif,

Modified: trunk/xorp/pim/pim_node.hh
===================================================================
--- trunk/xorp/pim/pim_node.hh	2009-09-01 12:05:04 UTC (rev 11528)
+++ trunk/xorp/pim/pim_node.hh	2009-09-01 12:55:38 UTC (rev 11529)
@@ -872,7 +872,17 @@
      * @return XORP_OK on success, otherwise XORP_ERROR.
      */
     int		stop_bsr() { return (pim_bsr().stop()); }
-    
+
+    /**
+     * Apply BSR configuration changes.
+     *
+     * @param error_msg the error message (if error).
+     * @return XORP_OK on success, otherwise XORP_ERROR.
+     */
+    int		apply_bsr_changes(string& error_msg) {
+	return (pim_bsr().apply_bsr_changes(error_msg));
+    }
+
     //
     // Configuration methods
     //

Modified: trunk/xorp/pim/xrl_pim_node.cc
===================================================================
--- trunk/xorp/pim/xrl_pim_node.cc	2009-09-01 12:05:04 UTC (rev 11528)
+++ trunk/xorp/pim/xrl_pim_node.cc	2009-09-01 12:55:38 UTC (rev 11529)
@@ -3946,6 +3946,17 @@
     return XrlCmdError::OKAY();
 }
 
+XrlCmdError
+XrlPimNode::pim_0_1_apply_bsr_changes()
+{
+    string error_msg;
+    
+    if (PimNode::apply_bsr_changes(error_msg) != XORP_OK)
+	return XrlCmdError::COMMAND_FAILED(error_msg);
+
+    return XrlCmdError::OKAY();
+}
+
 //
 // PIM configuration
 //

Modified: trunk/xorp/pim/xrl_pim_node.hh
===================================================================
--- trunk/xorp/pim/xrl_pim_node.hh	2009-09-01 12:05:04 UTC (rev 11528)
+++ trunk/xorp/pim/xrl_pim_node.hh	2009-09-01 12:55:38 UTC (rev 11529)
@@ -709,6 +709,11 @@
     XrlCmdError pim_0_1_stop_bsr();
 
     /**
+     *  Apply BSR configuration changes.
+     */
+    XrlCmdError pim_0_1_apply_bsr_changes();
+
+    /**
      *  Add/delete scope zone.
      *  
      *  @param scope_zone_id the ID of the configured zone.

Modified: trunk/xorp/xrl/interfaces/pim.xif
===================================================================
--- trunk/xorp/xrl/interfaces/pim.xif	2009-09-01 12:05:04 UTC (rev 11528)
+++ trunk/xorp/xrl/interfaces/pim.xif	2009-09-01 12:55:38 UTC (rev 11529)
@@ -59,6 +59,11 @@
 	stop_bsr
 
 	/**
+	 * Apply BSR configuration changes.
+	 */
+	 apply_bsr_changes
+
+	/**
 	 * Add/delete scope zone.
 	 *
 	 * @param scope_zone_id the ID of the configured zone.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Xorp-cvs mailing list