Bruce Simpson wrote:
Hi all,
I'm still looking at the XRL replacement since I got back from
holiday, which is why I've been mostly silent on lists.
Something came up in analysis, which broadly relates to Ben
Greear's work on reducing Router Manager startup times, etc. and some
of the questions Li Zhao has been asking in other threads on this list.
@Ben: It would be interesting to know what difference omitting the
XRLDB code makes to your Router Manager startup times.
* The XRLDB seems to exist pretty much to validate what's in the
template files and how the Router Manager uses them, although this is
done completely at run time.
* I wonder if disabling this code would make a difference to performance.
* To do this, I'd hack rtrmgr/template_commands.cc, and comment out
the calls to the XRLdb methods.
* The rtrmgr/xrldb.cc is the only place in the whole system where the
'*.xrls' files are parsed and used. They are used only to validate the
syntax and structure of potential XRL method calls.
* It would mean that there is no up-front validation of the XRLs, but
in practice, this validation step is probably only of interest to
people developing XORP, to catch problems with template files.
* It's probably best folded under a compile-time #define for developer
use.
Something like the attached patch?
Thanks,
Ben
--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com
diff --git a/SConstruct b/SConstruct
index 7bc73c1..97210e3 100644
--- a/SConstruct
+++ b/SConstruct
@@ -44,6 +44,9 @@ Help("""
Default is "obj/<arch>-<os>-<rel>".
prefix=<some path> to specify a different install directory.
Default is "/usr/local/xorp".
+ enable_xrldb_validation=true if you want XRLdb runtime validation enabled..
+ This is not normally required unless you are developing and making changes
+ to the XRL template files. XRLdb validation increases startup time.
enable_olsr=true if you want to build OLSR.
enable_tests=true if you want to build test programs.
""")
@@ -75,6 +78,7 @@ vars.AddVariables(
BoolVariable('debug_msg', 'Build with debug messages', False),
BoolVariable('debug_fn', 'Build with function names in debug_msg output', False),
BoolVariable('debug_cb', 'Build with callback debugging', False),
+ BoolVariable('enable_xrldb_validation', 'Enable Runtime XRLdb Validation', False),
BoolVariable('enable_olsr', 'Build OLSR', False),
BoolVariable('enable_tests', 'Build Test Programs', False),
)
@@ -150,6 +154,9 @@ print 'Debug messages: ', env['debug_msg']
print 'Debug function names: ', env['debug_fn']
print 'Debug callbacks: ', env['debug_cb']
+env['VALIDATE_XRLDB'] = ARGUMENTS.get('enable_xrldb_validation', False)
+print 'Enable XRLdb Validation: ', env['enable_xrldb_validation']
+
env['WITH_OLSR'] = ARGUMENTS.get('enable_olsr', False)
print 'Enable OLSR: ', env['enable_olsr']
@@ -394,6 +401,14 @@ if env['debug_cb']:
'-DDEBUG_CALLBACKS',
])
+if env['VALIDATE_XRLDB']:
+ env.AppendUnique(CFLAGS = [
+ '-DVALIDATE_XRLDB',
+ ])
+ env.AppendUnique(CXXFLAGS = [
+ '-DVALIDATE_XRLDB',
+ ])
+
env.AppendUnique(RPATH = [
'$libdir',
])
diff --git a/rtrmgr/template_commands.cc b/rtrmgr/template_commands.cc
index 6f0823b..868bef9 100644
--- a/rtrmgr/template_commands.cc
+++ b/rtrmgr/template_commands.cc
@@ -271,12 +271,15 @@ XrlAction::expand_action(string& error_msg)
return false;
}
+#ifdef VALIDATE_XRLDB
if (check_xrl_is_valid(_action, _xrldb, error_msg) != true)
return false;
+#endif
return true;
}
+#ifdef VALIDATE_XRLDB
bool
XrlAction::check_xrl_is_valid(const list<string>& action, const XRLdb& xrldb,
string& error_msg)
@@ -479,6 +482,7 @@ XrlAction::check_xrl_is_valid(const list<string>& action, const XRLdb& xrldb,
return true;
}
+#endif
int
XrlAction::execute(const MasterConfigTreeNode& ctn,
diff --git a/rtrmgr/template_commands.hh b/rtrmgr/template_commands.hh
index 736422f..7cca80f 100644
--- a/rtrmgr/template_commands.hh
+++ b/rtrmgr/template_commands.hh
@@ -79,8 +79,10 @@ public:
string affected_module() const;
private:
+#ifdef VALIDATE_XRLDB
bool check_xrl_is_valid(const list<string>& action,
const XRLdb& xrldb, string& error_msg);
+#endif
template<class TreeNode> bool expand_vars(const TreeNode& tn,
const string& s,
string& result) const;
diff --git a/rtrmgr/xrldb.cc b/rtrmgr/xrldb.cc
index ccf1d31..4365ab8 100644
--- a/rtrmgr/xrldb.cc
+++ b/rtrmgr/xrldb.cc
@@ -160,6 +160,7 @@ XRLtarget::str() const
XRLdb::XRLdb(const string& xrldir, bool verbose) throw (InitError)
: _verbose(verbose)
{
+#ifdef VALIDATE_XRLDB
string errmsg;
list<string> files;
@@ -200,8 +201,15 @@ XRLdb::XRLdb(const string& xrldir, bool verbose) throw (InitError)
debug_msg("XRLdb initialized\n");
debug_msg("%s\n", str().c_str());
+ XLOG_WARNING("XRLdb validation is enabled.");
+#else
+ UNUSED(xrldir);
+ XLOG_WARNING("XRLdb validation is disabled (this is good, unless you are un-sure of"
+ " the syntax of your XRL template files).");
+#endif
}
+#ifdef VALIDATE_XRLDB
bool
XRLdb::check_xrl_syntax(const string& xrlstr) const
{
@@ -257,6 +265,7 @@ XRLdb::check_xrl_exists(const string& xrlstr) const
}
return failure_type;
}
+#endif
string
XRLdb::str() const
diff --git a/rtrmgr/xrldb.hh b/rtrmgr/xrldb.hh
index e37d845..9bbfb47 100644
--- a/rtrmgr/xrldb.hh
+++ b/rtrmgr/xrldb.hh
@@ -65,8 +65,10 @@ private:
class XRLdb {
public:
XRLdb(const string& xrldir, bool verbose) throw (InitError);
+#ifdef VALIDATE_XRLDB
bool check_xrl_syntax(const string& xrl) const;
XRLMatchType check_xrl_exists(const string& xrl) const;
+#endif
string str() const;
private:
_______________________________________________
Xorp-hackers mailing list
[email protected]
http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers