Here's an example of not failing a commit because the network interface
isn't ready. Needs
a bit more testing, but this is the behaviour I'm trying to move
toward. Many of the other protocols
need similar work, but I'm just posting a single patch for comment now.
Thanks,
Ben
--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com
diff --git a/pim/pim_node.cc b/pim/pim_node.cc
index 068beb4..02d5ec1 100644
--- a/pim/pim_node.cc
+++ b/pim/pim_node.cc
@@ -906,8 +906,10 @@ PimNode::set_vif_flags(const string& vif_name,
if (pim_vif->is_pim_register())
_pim_register_vif_index = pim_vif->vif_index();
- if (is_changed)
+ if (is_changed) {
XLOG_INFO("Interface flags changed: %s", pim_vif->str().c_str());
+ pim_vif->notifyUpdated();
+ }
return (XORP_OK);
}
diff --git a/pim/pim_vif.cc b/pim/pim_vif.cc
index 73cf2ff..5d359b3 100644
--- a/pim/pim_vif.cc
+++ b/pim/pim_vif.cc
@@ -164,6 +164,7 @@ PimVif::PimVif(PimNode& pim_node, const Vif& vif)
//
_usage_by_pim_mre_task(0)
{
+ wants_to_be_started = false;
_buffer_send = BUFFER_MALLOC(BUF_SIZE_DEFAULT);
_buffer_send_hello = BUFFER_MALLOC(BUF_SIZE_DEFAULT);
_buffer_send_bootstrap = BUFFER_MALLOC(BUF_SIZE_DEFAULT);
@@ -265,6 +266,23 @@ PimVif::pim_mrt() const
return (_pim_node.pim_mrt());
}
+/** System detected some change. */
+void PimVif::notifyUpdated() {
+ if (wants_to_be_started) {
+ string err_msg;
+ int rv = start(err_msg);
+ if (rv == XORP_OK) {
+ XLOG_WARNING("notifyUpdated, successfully started pim_vif: %s",
+ name().c_str());
+ }
+ else {
+ XLOG_WARNING("notifyUpdated, tried to start vif: %s, but failed: %s",
+ name().c_str(), err_msg.c_str());
+ }
+ }
+}
+
+
/**
* PimVif::start:
* @error_msg: The error message (if error).
@@ -283,8 +301,10 @@ PimVif::start(string& error_msg)
return (XORP_OK);
if (! is_underlying_vif_up()) {
- error_msg = "underlying vif is not UP";
- return (XORP_ERROR);
+ wants_to_be_started = true;
+ XLOG_WARNING("WARNING: Delaying start of pim-vif: %s because underlying vif is not up.",
+ name().c_str());
+ return XORP_OK;
}
//
@@ -364,7 +384,8 @@ PimVif::start(string& error_msg)
XLOG_INFO("Interface started: %s%s",
this->str().c_str(), flags_string().c_str());
-
+
+ wants_to_be_started = false; //it worked
return (XORP_OK);
}
@@ -385,6 +406,7 @@ int
PimVif::stop(string& error_msg)
{
int ret_value = XORP_OK;
+ wants_to_be_started = false; //it worked
if (is_down())
return (XORP_OK);
diff --git a/pim/pim_vif.hh b/pim/pim_vif.hh
index 0fdaa19..3b4c618 100644
--- a/pim/pim_vif.hh
+++ b/pim/pim_vif.hh
@@ -100,6 +100,10 @@ public:
*/
int start(string& error_msg);
+ /** Attempt deferred start.
+ */
+ void notifyUpdated();
+
/**
* Gracefully stop PIM on a single virtual interface.
*
@@ -678,6 +682,7 @@ private:
const IPvX& source_addr,
const IPvX& group_addr,
uint8_t group_mask_len);
+ bool wants_to_be_started; // as soon as we can, ie if the interface appears.
};
//
_______________________________________________
Xorp-hackers mailing list
[email protected]
http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers