Hi all,

This is just a quick patch I wrote to expose the XRL class list within the Finder for debugging purposes. The Finder itself is currently excluded from its output.

Some background:
If a routing process needs to restart, there may be dependent processes requiring its services. Currently, this dependency is expressed as a set of process watches within the Finder itself. Every process contains at least one XRL target. When this target is registered with the Finder by class XrlRouter, it is provided a class name (e.g. "rib", "fea") and an MD5 HMAC of some other salt is appended to form the instance name. The process watches are implemented as watches on both 'class' and 'instance'. For example, the RIB can register with the Finder to ask when a specific instance of the FEA (e.g. the one it's currently talking to) has gone away, and when other FEAs arrive on the scene (e.g. if the process is restarted by the Router Manager).

By invoking the new XRLs from the command line, using the call_xrl tool, you can interrogate the Finder to find out which XRL process classes are currently registered, and which XRL targets (instances) implement those classes. The new XRLs are named 'get_xrl_classes' and 'get_xrl_class_instances'.

Please see my posting yesterday about fixing the 'static Xrl*' leak, about using call_xrl for debugging purposes.

cheers,
BMS
Index: libxipc/finder.hh
===================================================================
--- libxipc/finder.hh   (revision 11574)
+++ libxipc/finder.hh   (working copy)
@@ -109,6 +109,10 @@
     bool fill_targets_xrl_list(const string& target,
                               list<string>& xrl_list) const;
 
+    bool fill_class_list(list<string>& class_list) const;
+    bool fill_class_target_list(const string& classname,
+                               list<string>& tgt_list) const;
+
 protected:
     /**
      * Buffer event of instance becoming externally visible.
Index: libxipc/finder_xrl_target.cc
===================================================================
--- libxipc/finder_xrl_target.cc        (revision 11574)
+++ libxipc/finder_xrl_target.cc        (working copy)
@@ -436,6 +436,38 @@
 }
 
 XrlCmdError
+FinderXrlTarget::finder_0_2_get_xrl_classes(XrlAtomList& xal)
+{
+    list<string> clss;
+
+    _finder.fill_class_list(clss);
+
+    for (list<string>::const_iterator i = clss.begin(); i != clss.end(); i++) {
+       xal.append(XrlAtom(*i));
+    }
+
+    return XrlCmdError::OKAY();
+}
+
+XrlCmdError
+FinderXrlTarget::finder_0_2_get_xrl_class_instances(const string& class_name,
+                                                   XrlAtomList&  target_names)
+{
+    list<string> tgts;
+
+    // is the finder a special case?
+    if (_finder.fill_class_target_list(class_name, tgts) == false) {
+       return
+           XrlCmdError::COMMAND_FAILED
+           (c_format("No such class \"%s\"", class_name.c_str()));
+    }
+    for (list<string>::const_iterator i = tgts.begin(); i != tgts.end(); i++) {
+       target_names.append(XrlAtom(*i));
+    }
+    return XrlCmdError::OKAY();
+}
+
+XrlCmdError
 FinderXrlTarget::finder_event_notifier_0_1_register_class_event_interest(
                                                 const string& who,
                                                 const string& class_name
Index: libxipc/finder.cc
===================================================================
--- libxipc/finder.cc   (revision 11574)
+++ libxipc/finder.cc   (working copy)
@@ -751,6 +751,34 @@
     return true;
 }
 
+bool
+Finder::fill_class_list(list<string>& class_list) const
+{
+    ClassTable::const_iterator ci;
+    for (ci = _classes.begin(); ci != _classes.end(); ++ci) {
+       class_list.push_back(ci->first);
+    }
+    return true;
+}
+
+bool
+Finder::fill_class_target_list(const string& classname,
+                              list<string>& tgt_list) const
+{
+    ClassTable::const_iterator ci = _classes.find(classname);
+    if (_classes.end() == ci) {
+       return false;
+    }
+
+    const list<string>& instances = ci->second.instances();
+    for (list<string>::const_iterator ii = instances.begin();
+        ii != instances.end(); ii++) {
+       tgt_list.push_back(*ii);
+    }
+
+    return true;
+}
+
 void
 Finder::start_hello_timer()
 {
Index: libxipc/finder_xrl_target.hh
===================================================================
--- libxipc/finder_xrl_target.hh        (revision 11574)
+++ libxipc/finder_xrl_target.hh        (working copy)
@@ -107,6 +107,17 @@
     XrlCmdError finder_0_2_get_ipv6_permitted_nets(XrlAtomList&  ipv6nets);
 
     /**
+     *  Get list of registered Xrl classes
+     */
+    XrlCmdError finder_0_2_get_xrl_classes(XrlAtomList&        class_names);
+
+    /**
+     *  Get list of targets implementing class
+     */
+    XrlCmdError finder_0_2_get_xrl_class_instances(const string& class_name,
+                                                 XrlAtomList&  target_names);
+
+    /**
      * Event notifier interface.
      */
     XrlCmdError finder_event_notifier_0_1_register_class_event_interest(
Index: xrl/interfaces/finder.xif
===================================================================
--- xrl/interfaces/finder.xif   (revision 11574)
+++ xrl/interfaces/finder.xif   (working copy)
@@ -87,4 +87,14 @@
           * from.
           */
           get_ipv6_permitted_nets -> ipv6nets:list
+
+         /**
+          * Get list of registered Xrl classes 
+          */
+         get_xrl_classes -> class_names:list
+
+         /**
+          * Get list of instances implementing class.
+          */
+         get_xrl_class_instances ? class_name:txt -> target_names:list
 }
_______________________________________________
Xorp-hackers mailing list
[email protected]
http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers

Reply via email to