[Xorp-hackers] [PATCH 3/8] xorp: rtrmgr: When adding child node, remove named variable with same name

igorm at etf.rs igorm at etf.rs
Tue Mar 20 10:02:42 PDT 2012


From: Igor Maravic <igorm at etf.rs>

When adding child node, remove named variable with same name. If we wouldn't
do that, we couldn't set value for child node, in function ConfigTreeNode::set_variable(),
because we would always find named variable first.

Signed-off-by: Igor Maravic <igorm at etf.rs>
---
 xorp/rtrmgr/conf_tree_node.cc |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/xorp/rtrmgr/conf_tree_node.cc b/xorp/rtrmgr/conf_tree_node.cc
index bb8fd25..c26d2a9 100644
--- a/xorp/rtrmgr/conf_tree_node.cc
+++ b/xorp/rtrmgr/conf_tree_node.cc
@@ -222,6 +222,15 @@ ConfigTreeNode::is_same(const ConfigTreeNode& them, bool ignore_node_id) const
 void
 ConfigTreeNode::add_child(ConfigTreeNode* child)
 {
+    map<string, string>::iterator iter;
+
+    iter = _variables.find(child->segname());
+    if (iter != _variables.end()) {
+	debug_msg("Remove conflicting named variable %s on %s",
+		iter->first.c_str(), _segname.c_str());
+	_variables.erase(iter);
+    }
+
     _children.push_back(child);
     list<ConfigTreeNode *> sorted_children = _children;
     sort_by_template(sorted_children);
-- 
1.7.5.4



More information about the Xorp-hackers mailing list