From igorm at etf.rs Mon Apr 2 08:10:57 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Mon, 2 Apr 2012 17:10:57 +0200 Subject: [Xorp-hackers] [PATCH 2/2] xorp: rtrmgr: Include new command %unique-in In-Reply-To: <1333379457-22498-1-git-send-email-igorm@etf.rs> References: <1333379457-22498-1-git-send-email-igorm@etf.rs> Message-ID: <1333379457-22498-2-git-send-email-igorm@etf.rs> From: Igor Maravic With %unique-in command we can set the scope in which our variables are unique. It takes only on parameter - one of variable parents (or some older ancestor). Before commit can start it will be checked if the variable is unique in given scope. If it isn't, error will be returned. It's only valid for leaf values. Example template file: grand-parent @: u32 { parent @: u32 { child: u32; } } grand-parent @: u32 { %create ... %update ... parent @: u32 { %create ... %update ... child { %unique-in: $(grand-parent.@); %set ... } } } This template file means that all child nodes in grand-parent's scope should have unique values. With this template file this is allowed configuration: grand-parent 2 { parent 2 { child: 3 } parent 3 { child: 4 } } grand-parent 3 { parent 2 { child: 4 } parent 4 { child: 5 } } This is not allowed configuration: grand-parent 2 { parent 2 { child: 4 } parent 3 { child: 4 } } grand-parent 3 { parent 2 { child: 5 } } Signed-off-by: Igor Maravic --- xorp/rtrmgr/conf_tree_node.cc | 129 ++++++++++++++++++++++++++++++++++++ xorp/rtrmgr/conf_tree_node.hh | 2 + xorp/rtrmgr/template_tree_node.cc | 130 ++++++++++++++++++++++++++++++++++++- xorp/rtrmgr/template_tree_node.hh | 6 ++ 4 files changed, 266 insertions(+), 1 deletions(-) diff --git a/xorp/rtrmgr/conf_tree_node.cc b/xorp/rtrmgr/conf_tree_node.cc index 7050ffa..ec2b649 100644 --- a/xorp/rtrmgr/conf_tree_node.cc +++ b/xorp/rtrmgr/conf_tree_node.cc @@ -666,6 +666,110 @@ ConfigTreeNode::check_config_tree(string& error_msg) const } // + // Check if this node should be unique + // + if ((!deleted()) && (_template_tree_node != NULL) && has_value() + && !_template_tree_node->unique_in_node().empty()) { + + VarType type = NONE; + const ConfigTreeNode *varname_node; + + /** + * Find root node in which this node should be unique + */ + varname_node = find_const_varname_node(_template_tree_node->unique_in_node(), type); + + if (varname_node) { + const list unique_path = _template_tree_node->get_path_to_be_unique_in(); + + list parent_list; // Presents list of direct parents of nodes + // that should be unique + + list::const_iterator list_iter; + parent_list.push_front(varname_node); // If unique_path is empty then we've already + // found our direct parent + + for (list_iter = unique_path.begin(); + list_iter != unique_path.end(); ++list_iter) { + /** + * In this for loop we are searching for children of nodes from parent_list, + * that match criteria from current element of unique_path list. + * + * Parent list is emptied at the beginning of each iteration, + * and it is going to be filled with all children that match certain criteria. + */ + list old_parent_list = parent_list; + parent_list.clear(); + + const string name = *list_iter; + list::const_iterator iter; + + for (iter = old_parent_list.begin(); iter != old_parent_list.end(); + ++iter) { + const ConfigTreeNode* child = *iter; + list founded_children; + + /** + * Children nodes could be matched based on their name (tag nodes), + * or according to their type (children of tag nodes). + */ + if (name.find("@:=") != string::npos) { + string type_str = name.substr(3); + child->get_children_with_type(founded_children, type_str); + } else { + child->get_children_with_name(founded_children, name); + } + /** + * Add children to the parent_list + */ + parent_list.merge(founded_children); + } + } + + list::const_iterator iter; + set values_to_check; + + /** + * Here we actually check if there are two same values in the defined scope + */ + for (iter = parent_list.begin(); + iter != parent_list.end(); ++iter) { + const ConfigTreeNode* parent = *iter; + list founded_children; + + parent->get_children_with_name(founded_children, _segname); + + if (founded_children.size() != 1) { + ostringstream oss; + oss << founded_children.size(); + XLOG_ERROR("Found %s occurrences of %s on node %s. Expected 1!\n", + oss.str().c_str(), _segname.c_str(), path().c_str()); + return false; + } + const ConfigTreeNode* child = *(founded_children.begin()); + + if (!child->deleted() && child->has_value()) { + string child_value = child->value(); + if (values_to_check.find(child_value) != values_to_check.end()) { + error_msg = c_format("Node \"%s\"\n must be unique in \"%s\"\n", + _path.c_str(), varname_node->path().c_str()); + return false; + } else { + values_to_check.insert(child_value); + } + } + + } + } else { + XLOG_ERROR("There is no node \"%s\"\n in which node \"%s\"\n" + "should be unique\n", _template_tree_node->unique_in_node().c_str(), + path().c_str()); + return false; + } + + } + + // // Verify the allowed configuration values // if (_template_tree_node != NULL) { @@ -910,6 +1014,31 @@ ConfigTreeNode::module_root_node() return _parent->module_root_node(); } +void +ConfigTreeNode::get_children_with_name(list& children_ret, + const string& name_str) const +{ + children_ret.clear(); + list::const_iterator iter; + for (iter = _children.begin(); iter != _children.end(); ++iter) { + ConfigTreeNode* child = *iter; + if (child->segname() == name_str) + children_ret.push_back(child); + } +} +void +ConfigTreeNode::get_children_with_type(list& children_ret, + const string& type_str) const +{ + children_ret.clear(); + list::const_iterator iter; + for (iter = _children.begin(); iter != _children.end(); ++iter) { + ConfigTreeNode* child = *iter; + if (child->typestr() == type_str) + children_ret.push_back(child); + } +} + string ConfigTreeNode::show_subtree(bool show_top, int depth, int indent, bool do_indent, bool numbered, bool annotate, diff --git a/xorp/rtrmgr/conf_tree_node.hh b/xorp/rtrmgr/conf_tree_node.hh index ebd8fe9..50834d1 100644 --- a/xorp/rtrmgr/conf_tree_node.hh +++ b/xorp/rtrmgr/conf_tree_node.hh @@ -141,6 +141,8 @@ public: const ConfigTreeNode* const_parent() const { return _parent; } ConfigTreeNode* module_root_node(); list& children() { return _children; } + void get_children_with_name(list& children_ret, const string& name) const; + void get_children_with_type(list& children_ret, const string& typestr) const; const list& const_children() const { return _children; } string show_subtree(bool show_top, int depth, int indent, bool do_indent, bool numbered, bool annotate, diff --git a/xorp/rtrmgr/template_tree_node.cc b/xorp/rtrmgr/template_tree_node.cc index 8af4396..c44afa9 100644 --- a/xorp/rtrmgr/template_tree_node.cc +++ b/xorp/rtrmgr/template_tree_node.cc @@ -55,6 +55,7 @@ TemplateTreeNode::TemplateTreeNode(TemplateTree& template_tree, _varname(varname), _has_default(false), _is_tag(false), + _unique_in_node(""), _order(ORDER_UNSORTED), _verbose(template_tree.verbose()), _is_deprecated(false), @@ -172,6 +173,60 @@ TemplateTreeNode::expand_template_tree(string& error_msg) } // + // Mark all referred unique variables + // + if (!unique_in_node().empty()) { + list inverted_path_to_unique; + const string& unique_node = unique_in_node(); + TemplateTreeNode* ttn; + + ttn = find_varname_node(unique_node); + if (ttn == NULL) { + error_msg = c_format("Invalid unique-in variable %s: " + "not found", unique_node.c_str()); + return (false); + } + + //Check if unique-in variable is from the same module as this variable + if (ttn->module_name() != module_name()) { + error_msg = c_format("Invalid unique-in variable %s: " + "should be from the module %s as %s", + unique_node.c_str(), module_name().c_str(), _segname.c_str()); + return (false); + } + + //Check if unique-in variable is parent for this variable + TemplateTreeNode* parent = _parent; + + do { + if (!parent) { + error_msg = c_format("Invalid unique-in variable %s:\n" + "it should be parent (or parent of parent, or parent of parent of parent...) of \"%s\"", + unique_node.c_str(), path().c_str()); + return (false); + } + if (parent == ttn) + break; + + /** + * Fill path to node in which it should be unique + * + * Write names of nodes for tag nodes, + * and write "@:="+type for children of tag nodes + */ + if (parent->segname() == "@") + inverted_path_to_unique.push_front( + parent->segname() + ":=" + parent->typestr()); + else + inverted_path_to_unique.push_front(parent->segname()); + + parent = parent->parent(); + } while (true); + + _unique_in_path = inverted_path_to_unique; + } + + // // Recursively expand all children nodes // list::iterator iter2; @@ -241,6 +296,54 @@ TemplateTreeNode::check_template_tree(string& error_msg) const } // + // Check all referred unique variables + // + if (!is_leaf_value() && !unique_in_node().empty()) { + error_msg = c_format("Found %%unique-in command in node \"%s\" that " + "doesn't expect value", + path().c_str()); + return false; + } + if (!unique_in_node().empty()) { + const string& unique_node = unique_in_node(); + const TemplateTreeNode* ttn; + + ttn = find_const_varname_node(unique_node); + if (ttn == NULL) { + error_msg = c_format("Invalid unique-in variable %s: " + "not found", + unique_node.c_str()); + return (false); + } + + //Check if unique-in variable is from the same module as this variable + if (ttn->module_name() != module_name()) { + error_msg = + c_format("Invalid unique-in variable %s: " + "should be from the module %s as %s", + unique_node.c_str(), module_name().c_str(), _segname.c_str()); + return (false); + } + + //Check if unique-in variable is parent for this variable + TemplateTreeNode* parent = _parent; + + do { + if (!parent) { + error_msg = c_format("Invalid unique-in variable %s: " + "it should be (grand)parent of %s", + unique_node.c_str(), _segname.c_str()); + return (false); + } + if (parent == ttn) + break; + + parent = parent->parent(); + } while (true); + } + + + // // Check specific commands for this node // // XXX: only leaf nodes should have %set command @@ -355,6 +458,14 @@ TemplateTreeNode::add_cmd(const string& cmd) throw (ParseError) command = new DummyBaseCommand(*this, cmd); _cmd_map[cmd] = command; } + } else if (cmd == "%unique-in") { + if (!is_leaf_value()) { + error_msg = c_format("Invalid command \"%s\".\n", cmd.c_str()); + error_msg += "This command only applies to leaf nodes that "; + error_msg += "have values and only if the value is allowed "; + error_msg += "to be changed.\n"; + xorp_throw(ParseError, error_msg); + } } else if (cmd == "%mandatory") { // Nothing to do } else { @@ -362,7 +473,7 @@ TemplateTreeNode::add_cmd(const string& cmd) throw (ParseError) error_msg += "Valid commands are %create, %delete, %set, %unset, "; error_msg += "%get, %default, %modinfo, %activate, %update, %allow, "; error_msg += "%allow-range, %mandatory, %deprecated, %user-hidden, "; - error_msg += "%read-only, %permanent, %order\n"; + error_msg += "%read-only, %permanent, %order, %unique-in\n"; xorp_throw(ParseError, error_msg); } } @@ -533,6 +644,23 @@ TemplateTreeNode::add_action(const string& cmd, _mandatory_config_nodes.push_back(varname); } } + } else if (cmd == "%unique-in") { + // Add all new variables + if (action_list.size() == 1) { + list::const_iterator li = action_list.begin(); + if (!_unique_in_node.empty()) { + error_msg = c_format("There can be only one declaration of %%unique-in argument" + "for node. Previous was %s in node \"%s\"", + _unique_in_node.c_str(), path().c_str()); + xorp_throw(ParseError, error_msg); + } + _unique_in_node = *li; + } else { + error_msg = c_format("Invalid number of %%unique-in arguments: " + "%u (expected 1)", + XORP_UINT_CAST(action_list.size())); + xorp_throw(ParseError, error_msg); + } } else { // the master tree will deal with these } diff --git a/xorp/rtrmgr/template_tree_node.hh b/xorp/rtrmgr/template_tree_node.hh index 106da1a..0f44485 100644 --- a/xorp/rtrmgr/template_tree_node.hh +++ b/xorp/rtrmgr/template_tree_node.hh @@ -112,6 +112,8 @@ public: bool is_module_root_node() const; bool is_leaf_value() const; + const list& get_path_to_be_unique_in() const { return _unique_in_path; } + list allowed_operators() const; #if 0 @@ -137,6 +139,7 @@ public: bool verify_variables(const ConfigTreeNode& ctn, string& error_msg) const; const list& mandatory_config_nodes() const { return _mandatory_config_nodes; } + const string& unique_in_node() const { return _unique_in_node; } const string& help() const; const string& help_long() const; @@ -222,6 +225,9 @@ private: list _mandatory_config_nodes; + string _unique_in_node; + list _unique_in_path; + int _child_number; TTSortOrder _order; -- 1.7.5.4 From igorm at etf.rs Mon Apr 2 08:10:56 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Mon, 2 Apr 2012 17:10:56 +0200 Subject: [Xorp-hackers] [PATCH 1/2] xorp: rtrmgr: Use node type, when searching for TemplateTreeNode In-Reply-To: References: Message-ID: <1333379457-22498-1-git-send-email-igorm@etf.rs> From: Igor Maravic Use node type when searching for template tree node. Problem was when we were searching for parent node that have "twin" node, of the same name and different type. This fix only affects those cases. Signed-off-by: Igor Maravic --- xorp/rtrmgr/template_tree_node.cc | 38 +++++++++++++++++++++++++++--------- xorp/rtrmgr/template_tree_node.hh | 4 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/xorp/rtrmgr/template_tree_node.cc b/xorp/rtrmgr/template_tree_node.cc index 1012fbc..8af4396 100644 --- a/xorp/rtrmgr/template_tree_node.cc +++ b/xorp/rtrmgr/template_tree_node.cc @@ -893,12 +893,13 @@ TemplateTreeNode::find_varname_node(const string& varname) } if (var_parts.front() == "@") { - return find_child_varname_node(var_parts); + return find_child_varname_node(var_parts, type()); } if (var_parts.size() > 1) { + TTNodeType _type = (_parent && _parent->segname() == "@") ? _parent->type() : NODE_VOID; // It's a parent node, or a child of a parent node - return find_parent_varname_node(var_parts); + return find_parent_varname_node(var_parts, _type); } // @@ -909,7 +910,7 @@ TemplateTreeNode::find_varname_node(const string& varname) } TemplateTreeNode* -TemplateTreeNode::find_parent_varname_node(const list& var_parts) +TemplateTreeNode::find_parent_varname_node(const list& var_parts, const TTNodeType& _type) { if (_parent == NULL) { // @@ -919,37 +920,42 @@ TemplateTreeNode::find_parent_varname_node(const list& var_parts) list::iterator iter; for (iter = _children.begin(); iter != _children.end(); ++iter) { TemplateTreeNode* found_child; - found_child = (*iter)->find_child_varname_node(var_parts); + found_child = (*iter)->find_child_varname_node(var_parts, NODE_VOID); if (found_child != NULL) return found_child; } return NULL; } + if (is_tag() || (type() == NODE_VOID)) { + // When naming a parent node variable, you must start with a tag if (_segname == var_parts.front()) { // We've found the right place to start - return find_child_varname_node(var_parts); + return find_child_varname_node(var_parts, (type() == NODE_VOID) ? _type : type()); } } - - return _parent->find_parent_varname_node(var_parts); + return _parent->find_parent_varname_node(var_parts, + (_parent && _parent->segname() == "@") ? _parent->type() : _type); } TemplateTreeNode* -TemplateTreeNode::find_child_varname_node(const list& var_parts) +TemplateTreeNode::find_child_varname_node(const list& var_parts, const TTNodeType& _type) { if ((var_parts.front() != "@") && (var_parts.front() != _segname)) { // varname doesn't match us return NULL; } - // The name might refer to this node if (var_parts.size() == 1) { if ((var_parts.front() == "@") || (var_parts.front() == _segname) || (var_parts.front() == "<>") || (var_parts.front() == "#")) { + if (_type != type() && _segname == "@") { + debug_msg("We are searching for node with different type. Skip this node.\n"); + return NULL; + } return this; } } @@ -960,6 +966,10 @@ TemplateTreeNode::find_child_varname_node(const list& var_parts) // The name refers to the default value of this node if (! has_default()) return NULL; // The template tree node has no default value + if (_type != type() && _segname == "@") { + debug_msg("We are searching for node with different type. Skip this node.\n"); + return NULL; + } return this; } } @@ -967,6 +977,10 @@ TemplateTreeNode::find_child_varname_node(const list& var_parts) // The name might refer to the operator value of this node if ((var_parts.size() == 2) && (var_parts.back() == "<>")) { if ((var_parts.front() == "@") || (var_parts.front() == _segname)) { + if (_type != type() && _segname == "@") { + debug_msg("We are searching for node with different type. Skip this node.\n"); + return NULL; + } return this; } } @@ -974,6 +988,10 @@ TemplateTreeNode::find_child_varname_node(const list& var_parts) // The name might refer to the node ID of this node if ((var_parts.size() == 2) && (var_parts.back() == "#")) { if ((var_parts.front() == "@") || (var_parts.front() == _segname)) { + if (_type != type() && _segname == "@") { + debug_msg("We are searching for node with different type. Skip this node.\n"); + return NULL; + } return this; } } @@ -985,7 +1003,7 @@ TemplateTreeNode::find_child_varname_node(const list& var_parts) list::iterator iter; for (iter = _children.begin(); iter != _children.end(); ++iter) { TemplateTreeNode* found_child; - found_child = (*iter)->find_child_varname_node(child_var_parts); + found_child = (*iter)->find_child_varname_node(child_var_parts, (type() == NODE_VOID) ? _type : type()); if (found_child != NULL) return found_child; } diff --git a/xorp/rtrmgr/template_tree_node.hh b/xorp/rtrmgr/template_tree_node.hh index f681fd5..106da1a 100644 --- a/xorp/rtrmgr/template_tree_node.hh +++ b/xorp/rtrmgr/template_tree_node.hh @@ -194,8 +194,8 @@ protected: private: bool split_up_varname(const string& varname, list& var_parts) const; - TemplateTreeNode* find_parent_varname_node(const list& var_parts); - TemplateTreeNode* find_child_varname_node(const list& var_parts); + TemplateTreeNode* find_parent_varname_node(const list& var_parts, const TTNodeType& type); + TemplateTreeNode* find_child_varname_node(const list& var_parts, const TTNodeType& type); TemplateTree& _template_tree; -- 1.7.5.4 From igorm at etf.rs Mon Apr 2 08:11:36 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Mon, 2 Apr 2012 17:11:36 +0200 Subject: [Xorp-hackers] [PATCH] xorp: rtrmgr: Fix searching for parents children In-Reply-To: References: Message-ID: <1333379496-22544-1-git-send-email-igorm@etf.rs> From: Igor Maravic Fixed searching for parent's children, so now children, that aren't multi-value nodes, of some parent could be accessed. Syntax for accessing parent's children is: parent.child1.child2.@ Please note that child1 can't be multi-value node! --- xorp/rtrmgr/template_tree_node.cc | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/xorp/rtrmgr/template_tree_node.cc b/xorp/rtrmgr/template_tree_node.cc index c44afa9..bd99d2d 100644 --- a/xorp/rtrmgr/template_tree_node.cc +++ b/xorp/rtrmgr/template_tree_node.cc @@ -1024,6 +1024,29 @@ TemplateTreeNode::find_varname_node(const string& varname) return find_child_varname_node(var_parts, type()); } + if (var_parts.back() == "@" && var_parts.size() > 2) { + /** + * If we entered here, we want to find children + * of some of our parents + */ + TTNodeType _type = (_parent && _parent->segname() == "@") ? _parent->type() : NODE_VOID; + list parent_node_parts; + + parent_node_parts.push_back(var_parts.front()); + parent_node_parts.push_back(var_parts.back()); + + var_parts.pop_front(); + var_parts.pop_back(); + var_parts.push_front("@"); + + TemplateTreeNode* parent = find_parent_varname_node(parent_node_parts, _type); + + if (parent) { + return parent->find_child_varname_node(var_parts, parent->type()); + } + return NULL; + } + if (var_parts.size() > 1) { TTNodeType _type = (_parent && _parent->segname() == "@") ? _parent->type() : NODE_VOID; // It's a parent node, or a child of a parent node -- 1.7.5.4 From igorm at etf.rs Mon Apr 2 08:12:49 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Mon, 2 Apr 2012 17:12:49 +0200 Subject: [Xorp-hackers] [PATCH 2/2] xorp: fea: Create input socket before registering multicast listener In-Reply-To: <1333379569-22602-1-git-send-email-igorm@etf.rs> References: <1333379569-22602-1-git-send-email-igorm@etf.rs> Message-ID: <1333379569-22602-2-git-send-email-igorm@etf.rs> From: Igor Maravic Enabled creation of input socket before calling the function join_multicast group(). This enable us to get packages from the interface even if we didn't registered multicast listener on if/vif. Signed-off-by: Igor Maravic --- xorp/fea/data_plane/io/io_ip_dummy.cc | 19 +++++++++++ xorp/fea/data_plane/io/io_ip_dummy.hh | 12 +++++++ xorp/fea/data_plane/io/io_ip_socket.cc | 32 ++++++++++++++++++ xorp/fea/data_plane/io/io_ip_socket.hh | 12 +++++++ xorp/fea/io_ip.hh | 12 +++++++ xorp/fea/io_ip_manager.cc | 55 ++++++++++++++++++++++++++++++++ xorp/fea/io_ip_manager.hh | 11 ++++++ 7 files changed, 153 insertions(+), 0 deletions(-) diff --git a/xorp/fea/data_plane/io/io_ip_dummy.cc b/xorp/fea/data_plane/io/io_ip_dummy.cc index b2f4656..44e1542 100644 --- a/xorp/fea/data_plane/io/io_ip_dummy.cc +++ b/xorp/fea/data_plane/io/io_ip_dummy.cc @@ -140,6 +140,25 @@ IoIpDummy::set_default_multicast_interface(const string& if_name, } int +IoIpDummy::create_input_socket(const string& if_name, + const string& vif_name, + string& error_msg) +{ + const IfTreeVif* vifp; + + // Find the vif + vifp = iftree().find_vif(if_name, vif_name); + if (vifp == NULL) { + error_msg = c_format("Creating input socket failed: " + "interface %s vif %s not found", + if_name.c_str(), + vif_name.c_str()); + return (XORP_ERROR); + } + return (XORP_OK); +} + +int IoIpDummy::join_multicast_group(const string& if_name, const string& vif_name, const IPvX& group, diff --git a/xorp/fea/data_plane/io/io_ip_dummy.hh b/xorp/fea/data_plane/io/io_ip_dummy.hh index 2708acd..fda6842 100644 --- a/xorp/fea/data_plane/io/io_ip_dummy.hh +++ b/xorp/fea/data_plane/io/io_ip_dummy.hh @@ -116,6 +116,18 @@ public: string& error_msg); /** + * Create input socket. + * + * @param if_name the name of the interface to listen on + * @param vif_name the name of the vif to listen on + * @error error_msg the error message (if error). + * @return XORP_OK on success, otherwise XORP_ERROR + */ + int create_input_socket(const string& if_name, + const string& vif_name, + string& error_msg); + + /** * Join a multicast group on an interface. * * @param if_name the name of the interface to join the multicast group. diff --git a/xorp/fea/data_plane/io/io_ip_socket.cc b/xorp/fea/data_plane/io/io_ip_socket.cc index a7f4a4d..c22ec0a 100644 --- a/xorp/fea/data_plane/io/io_ip_socket.cc +++ b/xorp/fea/data_plane/io/io_ip_socket.cc @@ -519,6 +519,38 @@ IoIpSocket::set_default_multicast_interface(const string& if_name, } int +IoIpSocket::create_input_socket(const string& if_name, + const string& vif_name, + string& error_msg) +{ + error_msg.clear(); + + if (!iftree().find_vif(if_name, vif_name)) { + error_msg += c_format("Creating of input socket failed: " + "interface %s vif %s not found", + if_name.c_str(), + vif_name.c_str()); + goto out_err; + } + + if (!findOrCreateInputSocket(if_name, vif_name, error_msg)) { + string em = c_format("ERROR: Could not find or create input socket, " + "if_name: %s vif_name: %s error_msg: %s", + if_name.c_str(), vif_name.c_str(), error_msg.c_str()); + XLOG_WARNING("%s", em.c_str()); + error_msg += em; + goto out_err; + } + return XORP_OK; + +out_err: + if (error_msg.size()) { + XLOG_ERROR("ERROR in %s: %s", __func__, error_msg.c_str()); + } + return XORP_ERROR; +} + +int IoIpSocket::join_multicast_group(const string& if_name, const string& vif_name, const IPvX& group, diff --git a/xorp/fea/data_plane/io/io_ip_socket.hh b/xorp/fea/data_plane/io/io_ip_socket.hh index 35714d7..841d1e7 100644 --- a/xorp/fea/data_plane/io/io_ip_socket.hh +++ b/xorp/fea/data_plane/io/io_ip_socket.hh @@ -123,6 +123,18 @@ public: string& error_msg); /** + * Create input socket. + * + * @param if_name the name of the interface to listen on + * @param vif_name the name of the vif to listen on + * @error error_msg the error message (if error). + * @return XORP_OK on success, otherwise XORP_ERROR + */ + int create_input_socket(const string& if_name, + const string& vif_name, + string& error_msg); + + /** * Join a multicast group on an interface. * * @param if_name the name of the interface to join the multicast group. diff --git a/xorp/fea/io_ip.hh b/xorp/fea/io_ip.hh index c6d6a68..635fc41 100644 --- a/xorp/fea/io_ip.hh +++ b/xorp/fea/io_ip.hh @@ -191,6 +191,18 @@ public: string& error_msg) = 0; /** + * Create input socket. + * + * @param if_name the name of the interface to listen on + * @param vif_name the name of the vif to listen on + * @error error_msg the error message (if error). + * @return XORP_OK on success, otherwise XORP_ERROR + */ + virtual int create_input_socket(const string& if_name, + const string& vif_name, + string& error_msg) = 0; + + /** * Join a multicast group on an interface. * * @param if_name the name of the interface to join the multicast group. diff --git a/xorp/fea/io_ip_manager.cc b/xorp/fea/io_ip_manager.cc index a599b9f..ddaae3f 100644 --- a/xorp/fea/io_ip_manager.cc +++ b/xorp/fea/io_ip_manager.cc @@ -384,6 +384,58 @@ IoIpComm::recv_system_multicast_upcall(const vector& payload) } } +void +IoIpComm::create_input_socket(const string& if_name, + const string& vif_name) +{ + bool err = false; + string error_msg; + + if (_io_ip_plugins.empty()) { + error_msg = c_format("No I/O IP plugin to create input socket " + "on interface %s vif %s protocol %u", + if_name.c_str(), vif_name.c_str(), + _ip_protocol); + goto error; + } + + // + // Check the arguments + // + if (if_name.empty()) { + error_msg = c_format("Cannot create input socket: empty interface name"); + goto error; + } + if (vif_name.empty()) { + error_msg = c_format("Cannot create input socket on interface %s: " + "empty vif name", if_name.c_str()); + goto error; + } + + do { + IoIpPlugins::iterator plugin_iter; + for (plugin_iter = _io_ip_plugins.begin(); + plugin_iter != _io_ip_plugins.end(); ++plugin_iter) { + IoIp* io_ip = plugin_iter->second; + if (io_ip->create_input_socket(if_name, vif_name, + error_msg) != XORP_OK) { + err = true; + if (!error_msg.empty()) + error_msg += " "; + error_msg += error_msg; + } + } + } while (0); //dummy loop to avoid compiler warning + + if (err) + goto error; + + return; +error: + XLOG_WARNING("%s\n", error_msg.c_str()); + return; +} + int IoIpComm::join_multicast_group(const string& if_name, const string& vif_name, @@ -932,6 +984,9 @@ IoIpManager::register_receiver(int family, // Add the filter to those associated with receiver_name filters.insert(FilterBag::value_type(receiver_name, filter)); + //Create input socket for if vif pair + io_ip_comm->create_input_socket(if_name, vif_name); + // Register interest in watching the receiver if (_fea_node.fea_io().add_instance_watch(receiver_name, this, error_msg) != XORP_OK) { diff --git a/xorp/fea/io_ip_manager.hh b/xorp/fea/io_ip_manager.hh index 3df7afa..04da094 100644 --- a/xorp/fea/io_ip_manager.hh +++ b/xorp/fea/io_ip_manager.hh @@ -373,6 +373,17 @@ public: virtual void recv_system_multicast_upcall(const vector& payload); /** + * Create input socket. + * + * @param if_name the name of the interface to listen on + * @param vif_name the name of the vif to listen on + * @error error_msg the error message (if error). + * @return XORP_OK on success, otherwise XORP_ERROR + */ + void create_input_socket(const string& if_name, + const string& vif_name); + + /** * Join an IP multicast group. * * @param if_name the interface through which packets should be accepted. -- 1.7.5.4 From igorm at etf.rs Mon Apr 2 08:12:48 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Mon, 2 Apr 2012 17:12:48 +0200 Subject: [Xorp-hackers] [PATCH 1/2] trivial: ws fixes In-Reply-To: References: Message-ID: <1333379569-22602-1-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/fea/data_plane/io/io_ip_dummy.cc | 10 +- xorp/fea/data_plane/io/io_ip_dummy.hh | 22 ++-- xorp/fea/data_plane/io/io_ip_socket.cc | 166 ++++++++++++++++---------------- xorp/fea/data_plane/io/io_ip_socket.hh | 36 ++++---- xorp/fea/io_ip.cc | 4 +- xorp/fea/io_ip.hh | 24 +++--- xorp/fea/io_ip_manager.cc | 4 +- xorp/fea/io_ip_manager.hh | 12 +- 8 files changed, 139 insertions(+), 139 deletions(-) diff --git a/xorp/fea/data_plane/io/io_ip_dummy.cc b/xorp/fea/data_plane/io/io_ip_dummy.cc index 4e6deb4..b2f4656 100644 --- a/xorp/fea/data_plane/io/io_ip_dummy.cc +++ b/xorp/fea/data_plane/io/io_ip_dummy.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -135,7 +135,7 @@ IoIpDummy::set_default_multicast_interface(const string& if_name, _default_multicast_interface = if_name; _default_multicast_vif = vif_name; - + return (XORP_OK); } @@ -157,7 +157,7 @@ IoIpDummy::join_multicast_group(const string& if_name, vif_name.c_str()); return (XORP_ERROR); } - + #if 0 // TODO: enable or disable the enabled() check? if (! vifp->enabled()) { error_msg = c_format("Cannot join group %s on interface %s vif %s: " @@ -194,7 +194,7 @@ IoIpDummy::leave_multicast_group(const string& if_name, vif_name.c_str()); return (XORP_ERROR); } - + #if 0 // TODO: enable or disable the enabled() check? if (! vifp->enabled()) { error_msg = c_format("Cannot leave group %s on interface %s vif %s: " diff --git a/xorp/fea/data_plane/io/io_ip_dummy.hh b/xorp/fea/data_plane/io/io_ip_dummy.hh index 6fe16a2..2708acd 100644 --- a/xorp/fea/data_plane/io/io_ip_dummy.hh +++ b/xorp/fea/data_plane/io/io_ip_dummy.hh @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -38,7 +38,7 @@ /** * @short A base class for Dummy I/O IP raw communication. - * + * * Each protocol 'registers' for I/O and gets assigned one object * of this class. */ @@ -46,7 +46,7 @@ class IoIpDummy : public IoIp { public: /** * Constructor for a given address family and protocol. - * + * * @param fea_data_plane_manager the corresponding data plane manager * (@ref FeaDataPlaneManager). * @param iftree the interface tree to use. @@ -64,7 +64,7 @@ public: /** * Start operation. - * + * * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. */ @@ -72,7 +72,7 @@ public: /** * Stop operation. - * + * * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. */ @@ -81,7 +81,7 @@ public: /** * Set the default TTL (or hop-limit in IPv6) for the outgoing multicast * packets. - * + * * @param ttl the desired IP TTL (a.k.a. hop-limit in IPv6) value. * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. @@ -103,7 +103,7 @@ public: /** * Set default interface for transmitting multicast packets. - * + * * @param if_name the name of the interface that would become the default * multicast interface. * @param vif_name the name of the vif that would become the default @@ -117,7 +117,7 @@ public: /** * Join a multicast group on an interface. - * + * * @param if_name the name of the interface to join the multicast group. * @param vif_name the name of the vif to join the multicast group. * @param group the multicast group to join. @@ -128,10 +128,10 @@ public: const string& vif_name, const IPvX& group, string& error_msg); - + /** * Leave a multicast group on an interface. - * + * * @param if_name the name of the interface to leave the multicast group. * @param vif_name the name of the vif to leave the multicast group. * @param group the multicast group to leave. diff --git a/xorp/fea/data_plane/io/io_ip_socket.cc b/xorp/fea/data_plane/io/io_ip_socket.cc index 5f7b202..a7f4a4d 100644 --- a/xorp/fea/data_plane/io/io_ip_socket.cc +++ b/xorp/fea/data_plane/io/io_ip_socket.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -141,7 +141,7 @@ typedef char *caddr_t; #endif #define CMSG_DATA(cmsg) \ - ((unsigned char *)(cmsg) + _ALIGN(sizeof(struct cmsghdr))) + ((unsigned char *)(cmsg) + _ALIGN(sizeof(struct cmsghdr))) #define CMSG_NXTHDR(mhdr, cmsg) \ (((char *)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \ _ALIGN(sizeof(struct cmsghdr)) > \ @@ -247,7 +247,7 @@ IoIpSocket::IoIpSocket(FeaDataPlaneManager& fea_data_plane_manager, memcpy(&ra_opt6[2], (caddr_t)&rtalert_code6, sizeof(rtalert_code6)); #endif // ! HAVE_RFC3542 #endif // HAVE_IPV6 - + // Allocate the buffers _rcvbuf = new uint8_t[IO_BUF_SIZE]; _sndbuf = new uint8_t[IO_BUF_SIZE]; @@ -359,7 +359,7 @@ IoIpSocket::set_multicast_ttl(int ttl, string& error_msg) case AF_INET: { u_char ip_ttl = ttl; // XXX: In IPv4 the value argument is 'u_char' - + if (setsockopt(_proto_socket_out, IPPROTO_IP, IP_MULTICAST_TTL, XORP_SOCKOPT_CAST(&ip_ttl), sizeof(ip_ttl)) < 0) { error_msg = c_format("setsockopt(IP_MULTICAST_TTL, %u) failed: %s", @@ -368,7 +368,7 @@ IoIpSocket::set_multicast_ttl(int ttl, string& error_msg) } } break; - + #ifdef HAVE_IPV6 case AF_INET6: { @@ -378,7 +378,7 @@ IoIpSocket::set_multicast_ttl(int ttl, string& error_msg) return (XORP_ERROR); #else int ip_ttl = ttl; - + if (setsockopt(_proto_socket_out, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, XORP_SOCKOPT_CAST(&ip_ttl), sizeof(ip_ttl)) < 0) { error_msg = c_format("setsockopt(IPV6_MULTICAST_HOPS, %u) failed: %s", @@ -389,13 +389,13 @@ IoIpSocket::set_multicast_ttl(int ttl, string& error_msg) } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); error_msg = c_format("Invalid address family %d", family()); return (XORP_ERROR); } - + return (XORP_OK); } @@ -406,7 +406,7 @@ IoIpSocket::enable_multicast_loopback(bool is_enabled, string& error_msg) case AF_INET: { u_char loop = is_enabled; - + if (setsockopt(_proto_socket_out, IPPROTO_IP, IP_MULTICAST_LOOP, XORP_SOCKOPT_CAST(&loop), sizeof(loop)) < 0) { error_msg = c_format("setsockopt(IP_MULTICAST_LOOP, %u) failed: %s", @@ -415,7 +415,7 @@ IoIpSocket::enable_multicast_loopback(bool is_enabled, string& error_msg) } } break; - + #ifdef HAVE_IPV6 case AF_INET6: { @@ -425,7 +425,7 @@ IoIpSocket::enable_multicast_loopback(bool is_enabled, string& error_msg) return (XORP_ERROR); #else uint loop6 = is_enabled; - + if (setsockopt(_proto_socket_out, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, XORP_SOCKOPT_CAST(&loop6), sizeof(loop6)) < 0) { error_msg = c_format("setsockopt(IPV6_MULTICAST_LOOP, %u) failed: %s", @@ -436,13 +436,13 @@ IoIpSocket::enable_multicast_loopback(bool is_enabled, string& error_msg) } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); error_msg = c_format("Invalid address family %d", family()); return (XORP_ERROR); } - + return (XORP_OK); } @@ -487,7 +487,7 @@ IoIpSocket::set_default_multicast_interface(const string& if_name, } } break; - + #ifdef HAVE_IPV6 case AF_INET6: { @@ -497,7 +497,7 @@ IoIpSocket::set_default_multicast_interface(const string& if_name, return (XORP_ERROR); #else u_int pif_index = vifp->pif_index(); - + if (setsockopt(_proto_socket_out, IPPROTO_IPV6, IPV6_MULTICAST_IF, XORP_SOCKOPT_CAST(&pif_index), sizeof(pif_index)) < 0) { error_msg = c_format("setsockopt(IPV6_MULTICAST_IF, %s/%s) failed: %s", @@ -508,13 +508,13 @@ IoIpSocket::set_default_multicast_interface(const string& if_name, } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); error_msg = c_format("Invalid address family %d", family()); return (XORP_ERROR); } - + return (XORP_OK); } @@ -547,7 +547,7 @@ IoIpSocket::join_multicast_group(const string& if_name, error_msg += em; goto out_err; } - + #if 0 // TODO: enable or disable the enabled() check? if (! vifp->enabled()) { error_msg += c_format("Cannot join group %s on interface %s vif %s: " @@ -558,7 +558,7 @@ IoIpSocket::join_multicast_group(const string& if_name, goto out_err; } #endif // 0/1 - + switch (family()) { case AF_INET: { @@ -576,7 +576,7 @@ IoIpSocket::join_multicast_group(const string& if_name, goto out_err; } const IfTreeAddr4& fa = *(ai->second); - + fa.addr().copy_out(in_addr); group.copy_out(mreq.imr_multiaddr); mreq.imr_interface.s_addr = in_addr.s_addr; @@ -597,7 +597,7 @@ IoIpSocket::join_multicast_group(const string& if_name, } } break; - + #ifdef HAVE_IPV6 case AF_INET6: { @@ -607,7 +607,7 @@ IoIpSocket::join_multicast_group(const string& if_name, goto out_err; #else struct ipv6_mreq mreq6; - + group.copy_out(mreq6.ipv6mr_multiaddr); mreq6.ipv6mr_interface = vifp->pif_index(); if (setsockopt(*_proto_socket_in, IPPROTO_IPV6, IPV6_JOIN_GROUP, @@ -628,13 +628,13 @@ IoIpSocket::join_multicast_group(const string& if_name, } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); error_msg += c_format("Invalid address family %d", family()); goto out_err; } - + return (XORP_OK); out_err: @@ -694,7 +694,7 @@ XorpFd* IoIpSocket::findExistingInputSocket(const string& if_name, const string& else { return i->second; } - + } @@ -726,7 +726,7 @@ IoIpSocket::leave_multicast_group(const string& if_name, vif_name.c_str()); return (XORP_ERROR); } - + #if 0 // TODO: enable or disable the enabled() check? if (! vifp->enabled()) { error_msg += c_format("Cannot leave group %s on interface %s vif %s: " @@ -737,7 +737,7 @@ IoIpSocket::leave_multicast_group(const string& if_name, return (XORP_ERROR); } #endif // 0/1 - + switch (family()) { case AF_INET: { @@ -775,7 +775,7 @@ IoIpSocket::leave_multicast_group(const string& if_name, } } break; - + #ifdef HAVE_IPV6 case AF_INET6: { @@ -785,7 +785,7 @@ IoIpSocket::leave_multicast_group(const string& if_name, return (XORP_ERROR); #else struct ipv6_mreq mreq6; - + group.copy_out(mreq6.ipv6mr_multiaddr); mreq6.ipv6mr_interface = vifp->pif_index(); if (setsockopt(*_proto_socket_in, IPPROTO_IPV6, IPV6_LEAVE_GROUP, @@ -801,13 +801,13 @@ IoIpSocket::leave_multicast_group(const string& if_name, } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); error_msg += c_format("Invalid address family %d\n", family()); return (XORP_ERROR); } - + return (XORP_OK); } @@ -900,9 +900,9 @@ int IoIpSocket::initializeInputSocket(XorpFd* rv, string& error_msg) { // Not supported on mingw, at least... if (ip_protocol() == IPPROTO_ICMPV6) { struct icmp6_filter filter; - + // Pass all ICMPv6 messages - ICMP6_FILTER_SETPASSALL(&filter); + ICMP6_FILTER_SETPASSALL(&filter); #ifdef HAVE_IPV6_MULTICAST_ROUTING #if 0 // TODO: XXX: used only for multicast routing purpose by MLD @@ -1001,7 +1001,7 @@ int IoIpSocket::initializeInputSocket(XorpFd* rv, string& error_msg) { memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_ANY); - + if (SOCKET_ERROR == bind(*rv, (sockaddr *)&sin, sizeof(sockaddr_in))) { XLOG_WARNING("bind() failed: %s\n", win_strerror(GetLastError())); @@ -1030,7 +1030,7 @@ IoIpSocket::open_proto_sockets(string& error_msg) // We will open input sockets as interfaces are registered (due to listening for mcast addrs) if (_proto_socket_out.is_valid()) return (XORP_OK); - + if (! _proto_socket_out.is_valid()) { _proto_socket_out = socket(family(), SOCK_RAW, ip_protocol()); if (!_proto_socket_out.is_valid()) { @@ -1103,7 +1103,7 @@ IoIpSocket::close_proto_sockets(string& error_msg) map::iterator i; for (i = _proto_sockets_in.begin(); i != _proto_sockets_in.end(); i++) { - + XorpFd* fd = i->second; cleanupXorpFd(fd); @@ -1156,8 +1156,8 @@ IoIpSocket::enable_ip_hdr_include(bool is_enabled, string& error_msg) { #ifdef IP_HDRINCL // XXX: the setsockopt() argument must be 'int' - int bool_flag = is_enabled; - + int bool_flag = is_enabled; + if (setsockopt(_proto_socket_out, IPPROTO_IP, IP_HDRINCL, XORP_SOCKOPT_CAST(&bool_flag), sizeof(bool_flag)) < 0) { @@ -1169,18 +1169,18 @@ IoIpSocket::enable_ip_hdr_include(bool is_enabled, string& error_msg) #endif // IP_HDRINCL } break; - + #ifdef HAVE_IPV6 case AF_INET6: break; // XXX #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); error_msg = c_format("Invalid address family %d", family()); return (XORP_ERROR); } - + return (XORP_OK); } @@ -1192,7 +1192,7 @@ IoIpSocket::enable_recv_pktinfo(XorpFd* input_fd, bool is_enabled, string& error { // XXX: the setsockopt() argument must be 'int' int bool_flag = is_enabled; - + // // Interface index // @@ -1225,7 +1225,7 @@ IoIpSocket::enable_recv_pktinfo(XorpFd* input_fd, bool is_enabled, string& error { // XXX: the setsockopt() argument must be 'int' int bool_flag = is_enabled; - + // // Interface index and address // @@ -1246,7 +1246,7 @@ IoIpSocket::enable_recv_pktinfo(XorpFd* input_fd, bool is_enabled, string& error return (XORP_ERROR); } #endif // ! IPV6_RECVPKTINFO - + // // Hop-limit field // @@ -1267,7 +1267,7 @@ IoIpSocket::enable_recv_pktinfo(XorpFd* input_fd, bool is_enabled, string& error } #endif #endif // ! IPV6_RECVHOPLIMIT - + // // Traffic class value // @@ -1279,7 +1279,7 @@ IoIpSocket::enable_recv_pktinfo(XorpFd* input_fd, bool is_enabled, string& error return (XORP_ERROR); } #endif // IPV6_RECVTCLASS - + // // Hop-by-hop options // @@ -1346,13 +1346,13 @@ IoIpSocket::enable_recv_pktinfo(XorpFd* input_fd, bool is_enabled, string& error } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); error_msg = c_format("Invalid address family %d", family()); return (XORP_ERROR); } - + return (XORP_OK); } @@ -1406,10 +1406,10 @@ void IoIpSocket::notifyDeletingVif(const string& ifn, const string& vn) { _proto_sockets_in.erase(key); cleanupXorpFd(fd); - + XLOG_INFO("Closed socket: %i on interface: %s:%s because it is being deleted, input sockets count: %i\n", _fd, ifn.c_str(), vn.c_str(), (int)(_proto_sockets_in.size())); - + } #else UNUSED(ifn); @@ -1462,7 +1462,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) XLOG_UNREACHABLE(); return; // Error } - + // Read from the socket nbytes = recvmsg(fd, &_rcvmh, 0); if (nbytes < 0) { @@ -1530,7 +1530,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) return; // Error } #endif // HOST_OS_WINDOWS - + // // Check whether this is a multicast forwarding related upcall from the // system to the user-level. @@ -1562,7 +1562,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) #endif // HAVE_IPV4_MULTICAST_ROUTING } break; - + #ifdef HAVE_IPV6 case AF_INET6: { @@ -1571,7 +1571,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) #ifdef HAVE_IPV6_MULTICAST_ROUTING if (nbytes < (ssize_t)sizeof(struct mrt6msg)) { - // Probably not a system upcall + // Probably not a system upcall break; } struct mrt6msg* mrt6msg; @@ -1600,12 +1600,12 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); return; // Error } - + // // Not a system upcall. Pass to the registered processing function. // @@ -1620,7 +1620,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) { IpHeader4 ip4(_rcvbuf); bool is_datalen_error = false; - + // Input check if (nbytes < (ssize_t)ip4.size()) { XLOG_WARNING("proto_socket_read() failed: " @@ -1641,7 +1641,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) if (ip_tos == IPTOS_PREC_INTERNETCONTROL) ip_internet_control = true; - + ip_hdr_len = ip4.ip_header_len(); #ifdef IPV4_RAW_INPUT_IS_RAW ip_data_len = ip4.ip_len() - ip_hdr_len; @@ -1740,7 +1740,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) } } #endif // ! HOST_OS_WINDOWS - + // // Check for Router Alert option // @@ -1765,15 +1765,15 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) test_ip_options_len -= option_len; option_p += option_len; } - + break; } while (false); } break; - + #ifdef HAVE_IPV6 case AF_INET6: - { + { src_address.copy_in(_from6); #ifndef HOST_OS_WINDOWS @@ -1797,7 +1797,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) XORP_UINT_CAST(sizeof(struct cmsghdr))); return; // Error } - + // // Get pif_index, hop limit, Router Alert option, etc. // @@ -1868,7 +1868,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) } #endif #endif // ! HAVE_RFC3542 - } + } break; #ifdef IPV6_TCLASS @@ -1929,12 +1929,12 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); return; // Error } - + // Various checks if (! (src_address.is_unicast() || src_address.is_zero())) { // XXX: Accept zero source addresses because of protocols like IGMPv3 @@ -1993,7 +1993,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) ifp = iftree().find_interface(vifp->ifname()); break; } - + if (dst_address.is_multicast()) { iftree().find_interface_vif_same_subnet_or_p2p(src_address, ifp, vifp); @@ -2002,7 +2002,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) } break; } while (false); - + if ((ifp == NULL) || (vifp == NULL)) { // No vif found. Ignore this packet. #ifdef USE_SOCKET_PER_IFACE @@ -2032,7 +2032,7 @@ IoIpSocket::proto_socket_read(XorpFd fd, IoEventType type) // This vif is down. Silently ignore this packet. return; // Error } - + // Process the result vector payload(nbytes - ip_hdr_len); memcpy(&payload[0], _rcvbuf + ip_hdr_len, nbytes - ip_hdr_len); @@ -2326,9 +2326,9 @@ IoIpSocket::send_packet(const string& if_name, // a work-around or not. --Ben #ifdef IP_PKTINFO int ctllen = 0; - + ctllen = CMSG_SPACE(sizeof(struct in_pktinfo)); - + XLOG_ASSERT(ctllen <= CMSG_BUF_SIZE); // XXX #ifndef HOST_OS_WINDOWS @@ -2339,10 +2339,10 @@ IoIpSocket::send_packet(const string& if_name, // source IP part. The pktinfo logic below make sure it uses the correct // local IP address. This fixes source-routing problems as well. // --Ben Aug 21, 2008 - + _sndmh.msg_controllen = ctllen; cmsgp = CMSG_FIRSTHDR(&_sndmh); - + // Add the IPV4_PKTINFO ancillary data cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo)); cmsgp->cmsg_level = SOL_IP; @@ -2490,7 +2490,7 @@ IoIpSocket::send_packet(const string& if_name, // XXX: unlikely IPv4, in IPv6 the 'header' is specified as // ancillary data. // - + // // First, estimate total length of ancillary data // @@ -2525,7 +2525,7 @@ IoIpSocket::send_packet(const string& if_name, } // Space for IPV6_TCLASS -#ifdef IPV6_TCLASS +#ifdef IPV6_TCLASS ctllen += CMSG_SPACE(sizeof(int)); #endif @@ -2546,7 +2546,7 @@ IoIpSocket::send_packet(const string& if_name, } ctllen += CMSG_SPACE(ext_headers_payload[i].size()); } - + #ifndef HOST_OS_WINDOWS // TODO: Implement IPv6 Ancillary data on windows/mingw // TODO: Implement IPV6_HOPLIMIT on windows/mingw?? @@ -2558,7 +2558,7 @@ IoIpSocket::send_packet(const string& if_name, XLOG_ASSERT(ctllen <= CMSG_BUF_SIZE); // XXX _sndmh.msg_controllen = ctllen; cmsgp = CMSG_FIRSTHDR(&_sndmh); - + // Add the IPV6_PKTINFO ancillary data cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); cmsgp->cmsg_level = IPPROTO_IPV6; @@ -2587,7 +2587,7 @@ IoIpSocket::send_packet(const string& if_name, #ifdef HAVE_RFC3542 int currentlen; void *hbhbuf, *optp = NULL; - + cmsgp->cmsg_len = CMSG_LEN(hbhlen); cmsgp->cmsg_level = IPPROTO_IPV6; cmsgp->cmsg_type = IPV6_HOPOPTS; @@ -2627,7 +2627,7 @@ IoIpSocket::send_packet(const string& if_name, } cmsgp = CMSG_NXTHDR(&_sndmh, cmsgp); #endif - + #endif // ! HAVE_RFC3542 } @@ -2640,7 +2640,7 @@ IoIpSocket::send_packet(const string& if_name, int_val = ip_ttl; embed_host_int(CMSG_DATA(cmsgp), int_val); cmsgp = CMSG_NXTHDR(&_sndmh, cmsgp); - + // // Set the TOS // @@ -2695,7 +2695,7 @@ IoIpSocket::send_packet(const string& if_name, } break; #endif // HAVE_IPV6 - + default: XLOG_UNREACHABLE(); error_msg = c_format("Invalid address family %d", family()); @@ -2780,7 +2780,7 @@ IoIpSocket::proto_socket_transmit(const IfTreeInterface* ifp, // Transmit the packet // -#ifndef HOST_OS_WINDOWS +#ifndef HOST_OS_WINDOWS // Set some sendmsg()-related fields if (_sndmh.msg_controllen == 0) diff --git a/xorp/fea/data_plane/io/io_ip_socket.hh b/xorp/fea/data_plane/io/io_ip_socket.hh index 5d956d7..35714d7 100644 --- a/xorp/fea/data_plane/io/io_ip_socket.hh +++ b/xorp/fea/data_plane/io/io_ip_socket.hh @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -45,7 +45,7 @@ /** * @short A base class for I/O IP raw socket communication. - * + * * Each protocol 'registers' for I/O and gets assigned one object * of this class. */ @@ -53,7 +53,7 @@ class IoIpSocket : public IoIp, public IfTreeListener { public: /** * Constructor for a given address family and protocol. - * + * * @param fea_data_plane_manager the corresponding data plane manager * (@ref FeaDataPlaneManager). * @param iftree the interface tree to use. @@ -71,7 +71,7 @@ public: /** * Start operation. - * + * * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. */ @@ -79,7 +79,7 @@ public: /** * Stop operation. - * + * * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. */ @@ -88,7 +88,7 @@ public: /** * Set the default TTL (or hop-limit in IPv6) for the outgoing multicast * packets. - * + * * @param ttl the desired IP TTL (a.k.a. hop-limit in IPv6) value. * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. @@ -110,7 +110,7 @@ public: /** * Set default interface for transmitting multicast packets. - * + * * @param if_name the name of the interface that would become the default * multicast interface. * @param vif_name the name of the vif that would become the default @@ -124,7 +124,7 @@ public: /** * Join a multicast group on an interface. - * + * * @param if_name the name of the interface to join the multicast group. * @param vif_name the name of the vif to join the multicast group. * @param group the multicast group to join. @@ -135,10 +135,10 @@ public: const string& vif_name, const IPvX& group, string& error_msg); - + /** * Leave a multicast group on an interface. - * + * * @param if_name the name of the interface to leave the multicast group. * @param vif_name the name of the vif to leave the multicast group. * @param group the multicast group to leave. @@ -217,10 +217,10 @@ public: private: /** * Open the protocol sockets. - * + * * The protocol sockets are specific to the particular protocol of * this entry. - * + * * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. */ @@ -238,7 +238,7 @@ private: /** * Close the protocol sockets. - * + * * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. */ @@ -253,7 +253,7 @@ private: /** * Enable/disable the "Header Included" option (for IPv4) on the outgoing * protocol socket. - * + * * If enabled, the IP header of a raw packet should be created * by the application itself, otherwise the kernel will build it. * Note: used only for IPv4. @@ -263,7 +263,7 @@ private: * was a flag, so for compatibility reasons we better not set it * here; instead, we will use sendmsg() to specify the header's field * values. - * + * * @param is_enabled if true, enable the option, otherwise disable it. * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. @@ -273,11 +273,11 @@ private: /** * Enable/disable receiving information about a packet received on the * incoming protocol socket. - * + * * If enabled, values such as interface index, destination address and * IP TTL (a.k.a. hop-limit in IPv6), and hop-by-hop options will be * received as well. - * + * * @param is_enabled if true, set the option, otherwise reset it. * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. diff --git a/xorp/fea/io_ip.cc b/xorp/fea/io_ip.cc index 126d1a5..b03579e 100644 --- a/xorp/fea/io_ip.cc +++ b/xorp/fea/io_ip.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net diff --git a/xorp/fea/io_ip.hh b/xorp/fea/io_ip.hh index ab6a2d3..c6d6a68 100644 --- a/xorp/fea/io_ip.hh +++ b/xorp/fea/io_ip.hh @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -44,7 +44,7 @@ class XorpFd; /** * @short A base class for I/O IP raw communication. - * + * * Each protocol 'registers' for I/O and gets assigned one object * of this class. */ @@ -52,7 +52,7 @@ class IoIp { public: /** * Constructor for a given address family and protocol. - * + * * @param fea_data_plane_manager the corresponding data plane manager * (@ref FeaDataPlaneManager). * @param iftree the interface tree to use. @@ -91,7 +91,7 @@ public: /** * Get the event loop. - * + * * @return the event loop. */ EventLoop& eventloop() { return (_eventloop); } @@ -105,14 +105,14 @@ public: /** * Get the address family. - * + * * @return the address family. */ virtual int family() const { return (_family); } /** * Get the IP protocol number. - * + * * @return the IP protocol number. */ virtual uint8_t ip_protocol() const { return (_ip_protocol); } @@ -155,7 +155,7 @@ public: /** * Set the default TTL (or hop-limit in IPv6) for the outgoing multicast * packets. - * + * * @param ttl the desired IP TTL (a.k.a. hop-limit in IPv6) value. * @param error_msg the error message (if error). * @return XORP_OK on success, otherwise XORP_ERROR. @@ -164,7 +164,7 @@ public: /** * Enable/disable multicast loopback when transmitting multicast packets. - * + * * If the multicast loopback is enabled, a transmitted multicast packet * will be delivered back to this host (assuming the host is a member of * the same multicast group). @@ -178,7 +178,7 @@ public: /** * Set default interface for transmitting multicast packets. - * + * * @param if_name the name of the interface that would become the default * multicast interface. * @param vif_name the name of the vif that would become the default @@ -192,7 +192,7 @@ public: /** * Join a multicast group on an interface. - * + * * @param if_name the name of the interface to join the multicast group. * @param vif_name the name of the vif to join the multicast group. * @param group the multicast group to join. @@ -206,7 +206,7 @@ public: /** * Leave a multicast group on an interface. - * + * * @param if_name the name of the interface to leave the multicast group. * @param vif_name the name of the vif to leave the multicast group. * @param group the multicast group to leave. diff --git a/xorp/fea/io_ip_manager.cc b/xorp/fea/io_ip_manager.cc index d6b2a70..a599b9f 100644 --- a/xorp/fea/io_ip_manager.cc +++ b/xorp/fea/io_ip_manager.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net diff --git a/xorp/fea/io_ip_manager.hh b/xorp/fea/io_ip_manager.hh index a150e05..3df7afa 100644 --- a/xorp/fea/io_ip_manager.hh +++ b/xorp/fea/io_ip_manager.hh @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -374,7 +374,7 @@ public: /** * Join an IP multicast group. - * + * * @param if_name the interface through which packets should be accepted. * @param vif_name the vif through which packets should be accepted. * @param group_address the multicast group address to join. @@ -390,7 +390,7 @@ public: /** * Leave an IP multicast group. - * + * * @param if_name the interface through which packets should not be * accepted. * @param vif_name the vif through which packets should not be accepted. @@ -407,7 +407,7 @@ public: /** * Leave all IP multicast groups on this interface. - * + * * @param if_name the interface through which packets should not be * accepted. * @param vif_name the vif through which packets should not be accepted. @@ -566,7 +566,7 @@ public: uint8_t ip_protocol, bool enable_multicast_loopback, string& error_msg); - + /** * Unregister to receive IP packets. * -- 1.7.5.4 From noreply at github.com Mon Apr 2 08:33:28 2012 From: noreply at github.com (GitHub) Date: Mon, 02 Apr 2012 08:33:28 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 5be4d5: xorp: rtrmgr: Use node type, when searching for Te... Message-ID: <4f79c6c82b04_68f43fd0927bcaf81058ae@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 5be4d5d4ebc71b724a8e2b82f429660ce8263479 https://github.com/greearb/xorp.ct/commit/5be4d5d4ebc71b724a8e2b82f429660ce8263479 Author: Igor Maravic Date: 2012-04-02 (Mon, 02 Apr 2012) Changed paths: M xorp/rtrmgr/template_tree_node.cc M xorp/rtrmgr/template_tree_node.hh Log Message: ----------- xorp: rtrmgr: Use node type, when searching for TemplateTreeNode Use node type when searching for template tree node. Problem was when we were searching for parent node that have "twin" node, of the same name and different type. This fix only affects those cases. Signed-off-by: Igor Maravic Commit: 6b706babfe4af9c2f21b18024306fb2e30f543e0 https://github.com/greearb/xorp.ct/commit/6b706babfe4af9c2f21b18024306fb2e30f543e0 Author: Igor Maravic Date: 2012-04-02 (Mon, 02 Apr 2012) Changed paths: M xorp/rtrmgr/conf_tree_node.cc M xorp/rtrmgr/conf_tree_node.hh M xorp/rtrmgr/template_tree_node.cc M xorp/rtrmgr/template_tree_node.hh Log Message: ----------- xorp: rtrmgr: Include new command %unique-in With %unique-in command we can set the scope in which our variables are unique. It takes only on parameter - one of variable parents (or some older ancestor). Before commit can start it will be checked if the variable is unique in given scope. If it isn't, error will be returned. It's only valid for leaf values. Example template file: grand-parent @: u32 { parent @: u32 { child: u32; } } grand-parent @: u32 { %create ... %update ... parent @: u32 { %create ... %update ... child { %unique-in: $(grand-parent.@); %set ... } } } This template file means that all child nodes in grand-parent's scope should have unique values. With this template file this is allowed configuration: grand-parent 2 { parent 2 { child: 3 } parent 3 { child: 4 } } grand-parent 3 { parent 2 { child: 4 } parent 4 { child: 5 } } This is not allowed configuration: grand-parent 2 { parent 2 { child: 4 } parent 3 { child: 4 } } grand-parent 3 { parent 2 { child: 5 } } Signed-off-by: Igor Maravic Commit: ee419281d34016998f9318c9843753d8c13e91de https://github.com/greearb/xorp.ct/commit/ee419281d34016998f9318c9843753d8c13e91de Author: Igor Maravic Date: 2012-04-02 (Mon, 02 Apr 2012) Changed paths: M xorp/rtrmgr/template_tree_node.cc Log Message: ----------- xorp: rtrmgr: Fix searching for parents children Fixed searching for parent's children, so now children, that aren't multi-value nodes, of some parent could be accessed. Syntax for accessing parent's children is: parent.child1.child2.@ Please note that child1 can't be multi-value node! Commit: 75b61ef9d809669b9ba706da5f35e7d14c350642 https://github.com/greearb/xorp.ct/commit/75b61ef9d809669b9ba706da5f35e7d14c350642 Author: Igor Maravic Date: 2012-04-02 (Mon, 02 Apr 2012) Changed paths: M xorp/fea/data_plane/io/io_ip_dummy.cc M xorp/fea/data_plane/io/io_ip_dummy.hh M xorp/fea/data_plane/io/io_ip_socket.cc M xorp/fea/data_plane/io/io_ip_socket.hh M xorp/fea/io_ip.cc M xorp/fea/io_ip.hh M xorp/fea/io_ip_manager.cc M xorp/fea/io_ip_manager.hh Log Message: ----------- trivial: ws fixes Signed-off-by: Igor Maravic Commit: 7890073e08d4cc50ed5ce309e7a843c48ba67896 https://github.com/greearb/xorp.ct/commit/7890073e08d4cc50ed5ce309e7a843c48ba67896 Author: Igor Maravic Date: 2012-04-02 (Mon, 02 Apr 2012) Changed paths: M xorp/fea/data_plane/io/io_ip_dummy.cc M xorp/fea/data_plane/io/io_ip_dummy.hh M xorp/fea/data_plane/io/io_ip_socket.cc M xorp/fea/data_plane/io/io_ip_socket.hh M xorp/fea/io_ip.hh M xorp/fea/io_ip_manager.cc M xorp/fea/io_ip_manager.hh Log Message: ----------- xorp: fea: Create input socket before registering multicast listener Enabled creation of input socket before calling the function join_multicast group(). This enable us to get packages from the interface even if we didn't registered multicast listener on if/vif. Signed-off-by: Igor Maravic Compare: https://github.com/greearb/xorp.ct/compare/135772b...7890073 From igorm at etf.rs Wed Apr 4 03:38:01 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 4 Apr 2012 12:38:01 +0200 Subject: [Xorp-hackers] [PATCH 1/2] trivial: fix trailing ws In-Reply-To: References: Message-ID: <1333535882-12438-1-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/ospf/packet.cc | 54 +++++++++++++++++++++++++------------------------- 1 files changed, 27 insertions(+), 27 deletions(-) diff --git a/xorp/ospf/packet.cc b/xorp/ospf/packet.cc index ae42106..2b8c772 100644 --- a/xorp/ospf/packet.cc +++ b/xorp/ospf/packet.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -65,7 +65,7 @@ uint16_t ipv6_pseudo_header_checksum(const IPv6& src, const IPv6& dst, size_t len, uint8_t protocol) { - uint8_t pseudo_header[16 /* Source address */ + uint8_t pseudo_header[16 /* Source address */ + 16 /* Destination address */ + 4 /* Upper-layer packet length */ + 3 /* Zero */ @@ -110,7 +110,7 @@ ipv6_checksum_verify(const IPv6& src, const IPv6& dst, memcpy(&temp[0], &data[0], len); uint16_t checksum_inpacket = extract_16(&temp[checksum_offset]); embed_16(&temp[checksum_offset], 0); - uint16_t checksum_computed = + uint16_t checksum_computed = inet_checksum_add(ipv6_pseudo_header_checksum(src, dst, len, protocol), checksum(temp, len)); @@ -305,7 +305,7 @@ Packet::decode_standard_header(uint8_t *ptr, size_t& len) throw(InvalidPacket) if (0 == checksum_inpacket && OspfTypes::CRYPTOGRAPHIC_AUTHENTICATION == get_auth_type()) return get_standard_header_length(); - + if (checksum_inpacket != checksum_actual) xorp_throw(InvalidPacket, c_format("Checksum mismatch expected %#x received %#x", @@ -338,7 +338,7 @@ Packet::encode_standard_header(uint8_t *ptr, size_t len) embed_16(&ptr[Packet::LEN_OFFSET], len); embed_32(&ptr[Packet::ROUTER_ID_OFFSET], get_router_id()); embed_32(&ptr[Packet::AREA_ID_OFFSET], get_area_id()); - + switch(version) { case OspfTypes::V2: embed_16(&ptr[Packet::AUTH_TYPE_OFFSET], get_auth_type()); @@ -363,7 +363,7 @@ Packet::encode_standard_header(uint8_t *ptr, size_t len) #ifdef DEBUG_RAW_PACKETS debug_msg("\n%s", dump_packet(ptr, len).c_str()); -#endif +#endif return get_standard_header_length(); } @@ -372,7 +372,7 @@ string Packet::standard() const { string output; - + output = c_format("\tVersion %u\n", get_version()); output += c_format("\tType %u\n", get_type()); output += "\tRouter ID " + pr_id(get_router_id()) + "\n"; @@ -478,11 +478,11 @@ PacketDecoder::decode(uint8_t *ptr, size_t len) throw(InvalidPacket) packet = i->second; break; } - + if (packet == NULL) xorp_throw(InvalidPacket, c_format("OSPF Version %u Unknown Type %u", version, type)); - + return packet->decode(ptr, len); } @@ -496,7 +496,7 @@ HelloPacket::decode(uint8_t *ptr, size_t len) const throw(InvalidPacket) HelloPacket *packet = new HelloPacket(version); size_t offset = packet->decode_standard_header(ptr, len); - + // Verify that this packet is large enough, up to but not including // any neighbours. if ((len - offset) < MINIMUM_LENGTH) @@ -537,7 +537,7 @@ HelloPacket::decode(uint8_t *ptr, size_t len) const throw(InvalidPacket) packet->set_designated_router(extract_32(&ptr[offset + HelloPacket::DESIGNATED_ROUTER_OFFSET])); - packet->set_backup_designated_router(extract_32(&ptr[offset + + packet->set_backup_designated_router(extract_32(&ptr[offset + HelloPacket::BACKUP_DESIGNATED_ROUTER_OFFSET])); // If there is any more space in the packet extract the neighbours. @@ -607,7 +607,7 @@ HelloPacket::encode(vector& pkt) for(size_t index = 0; i != li.end(); i++, index += 4) { embed_32(&ptr[offset + 20 + index], *i); } - + if (offset != encode_standard_header(ptr, len)) { XLOG_ERROR("Encode of %s failed", str().c_str()); return false; @@ -625,7 +625,7 @@ HelloPacket::str() const // Standard Header output += standard() + "\n"; // Hello Packet Specifics - + switch(get_version()) { case OspfTypes::V2: output += c_format("\tNetwork Mask %#x\n", get_network_mask()); @@ -650,7 +650,7 @@ HelloPacket::str() const for(; i != li.end(); i++) { output += "\n\tNeighbour: " + pr_id(*i); } - + return output; } @@ -665,7 +665,7 @@ DataDescriptionPacket::decode(uint8_t *ptr, size_t len) const throw(InvalidPacke DataDescriptionPacket *packet = new DataDescriptionPacket(version); size_t offset = packet->decode_standard_header(ptr, len); - + // Verify that this packet is large enough, up to but not including // any neighbours. if ((len - offset) < minimum_length()) @@ -776,7 +776,7 @@ DataDescriptionPacket::encode(vector& pkt) for(size_t index = 0; i != li.end(); i++, index += Lsa_header::length()) { (*i).copy_out(&ptr[lsa_offset + index]); } - + if (offset != encode_standard_header(ptr, len)) { XLOG_ERROR("Encode of %s failed", str().c_str()); return false; @@ -822,7 +822,7 @@ LinkStateRequestPacket::decode(uint8_t *ptr, size_t len) const throw(InvalidPack LinkStateRequestPacket *packet = new LinkStateRequestPacket(version); size_t offset = packet->decode_standard_header(ptr, len); - + Ls_request ls(version); // Verify that this packet is large enough, a standard header plus @@ -872,7 +872,7 @@ LinkStateRequestPacket::encode(vector& pkt) for(size_t index = 0; i != li.end(); i++, index += ls.length()) { (*i).copy_out(&ptr[offset + index]); } - + if (offset != encode_standard_header(ptr, len)) { XLOG_ERROR("Encode of %s failed", str().c_str()); return false; @@ -911,7 +911,7 @@ LinkStateUpdatePacket::decode(uint8_t *ptr, size_t len) const throw(InvalidPacke _lsa_decoder); size_t offset = packet->decode_standard_header(ptr, len); - + // Verify that this packet is large enough to hold the smallest // LSA that we are aware of. size_t min_length = _lsa_decoder.min_length(); @@ -959,11 +959,11 @@ LinkStateUpdatePacket::encode(vector& pkt, uint16_t inftransdelay) // the packet. size_t n_lsas = 0; size_t len = offset + 4; // 4 == # LSAs - + list &lsas = get_lsas(); list::iterator i = lsas.begin(); for(; i != lsas.end(); i++, n_lsas++) { - // Don't encode the LSA it should already be encoded. + // Don't encode the LSA it should already be encoded. // If this is a self originating LSA then we will have encoded // the LSA. If we received it from a neighbour then we are not // supposed to mess with it apart from updating the age field. @@ -994,12 +994,12 @@ LinkStateUpdatePacket::encode(vector& pkt, uint16_t inftransdelay) Lsa::update_age_inftransdelay(&ptr[offset], inftransdelay); offset += lsa_len; } - + if (header_offset != encode_standard_header(ptr, len)) { XLOG_ERROR("Encode of %s failed", str().c_str()); return false; } - + return true; } @@ -1030,11 +1030,11 @@ LinkStateAcknowledgementPacket::decode(uint8_t *ptr, size_t len) const { OspfTypes::Version version = get_version(); - LinkStateAcknowledgementPacket *packet = + LinkStateAcknowledgementPacket *packet = new LinkStateAcknowledgementPacket(version); size_t offset = packet->decode_standard_header(ptr, len); - + // Verify that this packet is large enough to hold the at least // one LSA header. if ((len - offset) < Lsa_header::length()) @@ -1084,7 +1084,7 @@ LinkStateAcknowledgementPacket::encode(vector& pkt) for(size_t index = 0; i != li.end(); i++, index += Lsa_header::length()) { (*i).copy_out(&ptr[lsa_offset + index]); } - + if (offset != encode_standard_header(ptr, len)) { XLOG_ERROR("Encode of %s failed", str().c_str()); return false; -- 1.7.5.4 From igorm at etf.rs Wed Apr 4 03:38:02 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 4 Apr 2012 12:38:02 +0200 Subject: [Xorp-hackers] [PATCH 2/2] xorp: ospf: Make checksumming more efficient In-Reply-To: <1333535882-12438-1-git-send-email-igorm@etf.rs> References: <1333535882-12438-1-git-send-email-igorm@etf.rs> Message-ID: <1333535882-12438-2-git-send-email-igorm@etf.rs> From: Igor Maravic Instead of getting checksum out of OSPF header, zeroing checksum location, calculating checksum and comparing if computed and received checksum are equal, just checksum received packet and see if result is equal to 0. Based on: http://en.wikipedia.org/wiki/Header_checksum In case the received checksum is invalid, calculate it and print it out in exception message. Signed-off-by: Igor Maravic --- xorp/ospf/packet.cc | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xorp/ospf/packet.cc b/xorp/ospf/packet.cc index 2b8c772..af29f94 100644 --- a/xorp/ospf/packet.cc +++ b/xorp/ospf/packet.cc @@ -288,9 +288,8 @@ Packet::decode_standard_header(uint8_t *ptr, size_t& len) throw(InvalidPacket) // Extract the checksum and check the packet. uint16_t checksum_inpacket = extract_16(&ptr[Packet::CHECKSUM_OFFSET]); - // Zero the checksum location. - embed_16(&ptr[Packet::CHECKSUM_OFFSET], 0); - uint16_t checksum_actual = checksum(ptr, len); + + uint16_t verify_checksum = checksum(ptr, len); // Restore the zero'd fields. switch(version) { @@ -300,17 +299,22 @@ Packet::decode_standard_header(uint8_t *ptr, size_t& len) throw(InvalidPacket) case OspfTypes::V3: break; } - embed_16(&ptr[Packet::CHECKSUM_OFFSET], checksum_inpacket); if (0 == checksum_inpacket && OspfTypes::CRYPTOGRAPHIC_AUTHENTICATION == get_auth_type()) return get_standard_header_length(); - if (checksum_inpacket != checksum_actual) + if (verify_checksum != 0) { + //Calculate valid checksum for debugging purposes + + // Zero the checksum location. + embed_16(&ptr[Packet::CHECKSUM_OFFSET], 0); + uint16_t checksum_actual = checksum(ptr, len); xorp_throw(InvalidPacket, c_format("Checksum mismatch expected %#x received %#x", checksum_actual, checksum_inpacket)); + } // Return the offset at which continued processing can take place. return get_standard_header_length(); -- 1.7.5.4 From noreply at github.com Wed Apr 4 11:15:18 2012 From: noreply at github.com (GitHub) Date: Wed, 04 Apr 2012 11:15:18 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] f4ef5b: trivial: fix trailing ws Message-ID: <4f7c8fb667fe4_b923f846a966af812811f@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: f4ef5ba56416c880553d86c4bdfb1a2a8eae2d1f https://github.com/greearb/xorp.ct/commit/f4ef5ba56416c880553d86c4bdfb1a2a8eae2d1f Author: Igor Maravic Date: 2012-04-04 (Wed, 04 Apr 2012) Changed paths: M xorp/ospf/packet.cc Log Message: ----------- trivial: fix trailing ws Signed-off-by: Igor Maravic Commit: 8ad7d8fd2d17f4ef570ad588810bed98c5b231d3 https://github.com/greearb/xorp.ct/commit/8ad7d8fd2d17f4ef570ad588810bed98c5b231d3 Author: Igor Maravic Date: 2012-04-04 (Wed, 04 Apr 2012) Changed paths: M xorp/ospf/packet.cc Log Message: ----------- xorp: ospf: Make checksumming more efficient Instead of getting checksum out of OSPF header, zeroing checksum location, calculating checksum and comparing if computed and received checksum are equal, just checksum received packet and see if result is equal to 0. Based on: http://en.wikipedia.org/wiki/Header_checksum In case the received checksum is invalid, calculate it and print it out in exception message. Signed-off-by: Igor Maravic Compare: https://github.com/greearb/xorp.ct/compare/7890073...8ad7d8f From ddavidson72 at gmx.com Wed Apr 4 12:25:10 2012 From: ddavidson72 at gmx.com (David Davidson) Date: Wed, 04 Apr 2012 15:25:10 -0400 Subject: [Xorp-hackers] Unable to compile on Gentoo stage3 x86 virtual machine Message-ID: <20120404192510.4330@gmx.com> Hi Folks, Thank you - yes this flag allowed it to compile. If there is something that I left out that I could send to you that would help, then please let me know. Thank you again! David ----- Original Message ----- From: igorm at etf.rs Sent: 03/23/12 12:26 AM To: Ben Greear Subject: Re: [Xorp-hackers] Unable to compile on Gentoo stage3 x86 virtual machine I think that the good solution would be to automatically generate lex and yacc files here as well. BR Igor ????? 22. ???? 2012. 17.59, Ben Greear ?? ???????/??: > On 03/21/2012 03:44 PM, David Davidson wrote: >> Hi, >> >> Thank you so much for your work and dedication to the XORP project! I am so pleased with this work and I wanted to say that I think it's the best routing >> software one can get in the free world, and it rivals commercial routing in a big way, hands-down. My hat is off to those developers and maintainers that are >> supporting this project and again, many kind thanks for working on this exciting project. >> >> I am hoping that somebody will be able to give me some help or point me in the right direction to get a problem fixed that I am seeing. I am trying to get XORP >> v.1.8.5 compiled on a recent Gentoo GNU/Linux virtual machine instance but I am unable to get it compiled. I am running the following command fr om the root of >> the source release: >> >> >> scons prefix=/usr sysconfdir=/etc/xorp localstatedir=/var/lib/xorp >> >> >> I am getting the following error message and then compilation terminates: >> >> ################################################ >> g++ -o obj/i686-pc-linux-gnu/policy/backend/lex.yy_policy_backend_parser.os -c -O2 -g3 -Werror -W -Wall -Wwrite-strings -Wcast-qual -Wpointer-arith -Wcast-align >> -Woverloaded-virtual -ftemplate-depth-25 -pipe -DXORP_BUILDINFO -fPIC -DXRL_PF=120 -DXORP_VERSION=1.8.5 -Iobj/i686-pc-linux-gnu -I. -I. >> policy/backend/lex.yy_policy_backend_parser.cc >> cc1plus: warnings being treated as errors >> backend.l: In function 'int yy_policy_backend_parserlex()': >> backend.l:96:5: error: ignoring return value of 'size_t fwrite(const void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result >> scons: *** [obj/i686-pc-linux-gnu/policy/backend/lex.yy_policy_backend_parser.os] Error 1 >> scons: building terminated becaus e of errors. >> ################################################ > > We probably just need to find everywhere that calls fwrite and check it's > return value. > > In the git tree, there is an option: scons disable_werror=true > > that should let it compile, but we should fix the root cause as well. > > Thanks, > Ben > > -- > Ben Greear > Candela Technologies Inc http://www.candelatech.com > > _______________________________________________ > Xorp-hackers mailing list > Xorp-hackers at icir.org > http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/xorp-hackers -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120404/e2c31059/attachment.html From igorm at etf.rs Tue Apr 10 05:57:24 2012 From: igorm at etf.rs (=?ISO-8859-2?Q?Igor_Maravi=E6?=) Date: Tue, 10 Apr 2012 14:57:24 +0200 Subject: [Xorp-hackers] Route Redist between RIP and OSPF - working? Message-ID: Hi all, I think that I found solution to this problem :) I started looking where Steve stopped (PolicyRedistTable::replace_policytags function). It was just the tip of the iceberg. Problem was that protocol's existing EXPORT_SOURCE match policies weren't refreshed when new export filter is created. In this case problem was with exporting to "connected" protocol. New protocol always has accurate policy tags for route lookup. It always searches routes that has no tag, or older protocol tags or it's tags. If it finds them it prepends it's tag. Older protocols are searching routes that has no tags, or have older tags. If it finds such a route it prepends it's tag. EXPORT_SOURCEMATCH policies are executed in order that depends on protocol name. If newer protocol has lower letter (for example ospf's policies are executed before rip's, because "o" precedes "r"), new protocol prepends new tags, that are unrecognizable to older protocol, to routes that it has found. Because older protocol is unaware of new tags, it concludes that routes are deleted and it deletes them. This is not what we are expecting. If older protocol is executed first, it prepends it's tag to routes that it has found. Because old tag is recognizable by newer protocol new tags are also prepended to routes. This case works as expected. Solution - refresh tags for all protocol's EXPORT_SOURCEMATCH routes when new export filter is created. I'm sending patch to xorp-hackers list. I tested it for simple solutions, so it does need more testing :) It would be nice if someone would post more complicated policies to test this issue. BR Igor From igorm at etf.rs Tue Apr 10 05:59:02 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 10 Apr 2012 14:59:02 +0200 Subject: [Xorp-hackers] [PATCH 2/2] xorp: policy: Fix problem with route distribution In-Reply-To: <1334062742-18187-1-git-send-email-igorm@etf.rs> References: <1334062742-18187-1-git-send-email-igorm@etf.rs> Message-ID: <1334062742-18187-2-git-send-email-igorm@etf.rs> From: Igor Maravic Problem was that protocol's existing EXPORT_SOURCE match policies weren't refreshed when new export filter is created. New protocol always has accurate policy tags for route lookup. It always searches routes that has no tag, or older protocol tags or it's tags. If it finds them it prepends it's tag. Older protocols are searching routes that has no tags, or have older tags. If it finds such a route it prepends it's tag. EXPORT_SOURCEMATCH policies are executed in order that depends on protocol name. If newer protocol has lower letter (for example ospf's policies are executed before rip's, because "o" precedes "r"), new protocol prepends new tags, that are unrecognizable to older protocol, to routes that it has found. Because older protocol is unaware of new tags, it concludes that routes are deleted and it deletes them. This is not what we are expecting. If older protocol is executed first, it prepends it's tag to routes that it has found. Because old tag is recognizable by newer protocol new tags are also prepended to routes. This case works as expected. Solution - refresh tags for all protocol's EXPORT_SOURCEMATCH routes when new export filter is created. Reported-by: Steve Dickey Signed-off-by: Igor Maravic --- xorp/policy/code.cc | 47 ++++++++++++++++++++++++++++ xorp/policy/code.hh | 19 +++++++++++ xorp/policy/code_list.cc | 8 +++++ xorp/policy/code_list.hh | 8 +++++ xorp/policy/configuration.cc | 6 +++ xorp/policy/policy_list.cc | 2 +- xorp/policy/source_match_code_generator.cc | 5 +++ 7 files changed, 94 insertions(+), 1 deletions(-) diff --git a/xorp/policy/code.cc b/xorp/policy/code.cc index ce8593c..280cbfd 100644 --- a/xorp/policy/code.cc +++ b/xorp/policy/code.cc @@ -23,6 +23,7 @@ #include "policy_module.h" #include "libxorp/xorp.h" #include "policy/common/policy_utils.hh" +#include "policy/common/elem_set.hh" #include "code.hh" bool @@ -143,6 +144,52 @@ Code::operator+=(const Code& rhs) } void +Code::set_redistribution_tags(const TagSet& redist_tags) +{ + TagSet::iterator iter; + + for (iter = _redist_tags.begin(); iter != _redist_tags.end(); ++iter) { + _all_tags.erase(*iter); + } + _redist_tags.clear(); + + _redist_tags = redist_tags; + _all_tags.insert(_redist_tags.begin(), _redist_tags.end()); +} + +void +Code::refresh_sm_redistribution_tags(const Code& accurate_code) +{ + if (!(_target == accurate_code._target && _target.filter() == filter::EXPORT_SOURCEMATCH)) + return; + + TagSet::iterator iter; + + if (_redist_tags != accurate_code.redist_tags()) { + + set_redistribution_tags(accurate_code.redist_tags()); + + ElemSetU32 element_set; + for (set::const_iterator iter = _redist_tags.begin(); + iter != _redist_tags.end(); ++iter) { + ElemU32 e(*iter); + element_set.insert(e); + } + + string policy_set_str("PUSH set_u32 "); + string::size_type position; + for (position = _code.find(policy_set_str); position != string::npos; + position = _code.find(policy_set_str, position)) { + position += policy_set_str.size(); + string::size_type num_chars = _code.find("\n", position) - position; + + _code.replace(position, num_chars, element_set.str()); + } + + } +} + +void Code::add_subr(const string& policy, const string& code) { _subr[policy] = code; diff --git a/xorp/policy/code.hh b/xorp/policy/code.hh index 8189857..5a9e6d9 100644 --- a/xorp/policy/code.hh +++ b/xorp/policy/code.hh @@ -239,6 +239,25 @@ public: _redist_tags.insert(tag); } + /** + * Sets _redist_tags with provided set + * + * This function empties _redist_tags and its elements from _all_tags. + * @param redist_tags the redistribution tags to add. + */ + void set_redistribution_tags(const TagSet& redist_tags); + + /** + * Refreshes redistribution tags if this is code for + * EXPORT_SOURCEMATCH filter. Accurate redistribution + * tags are provided via Code reference in function argument. + * + * It also replaces tags inside policy code. + * + * @param accurate_code Code with accurate redistribution tags. + */ + void refresh_sm_redistribution_tags(const Code& accurate_code); + void add_subr(const string& policy, const string& code); const SUBR& subr() const; diff --git a/xorp/policy/code_list.cc b/xorp/policy/code_list.cc index 7057ac6..4f8af4c 100644 --- a/xorp/policy/code_list.cc +++ b/xorp/policy/code_list.cc @@ -56,6 +56,14 @@ CodeList::str() const } void +CodeList::refresh_sm_redistribution_tags(Code& c) +{ + for (ListCode::iterator i = _codes.begin(); i != _codes.end(); ++i) { + (*i)->refresh_sm_redistribution_tags(c); + } +} + +void CodeList::link_code(Code& c) const { // go through all the code we have, and link it to c. diff --git a/xorp/policy/code_list.hh b/xorp/policy/code_list.hh index 2ae2d9f..460673b 100644 --- a/xorp/policy/code_list.hh +++ b/xorp/policy/code_list.hh @@ -61,6 +61,14 @@ public: string str() const; /** + * Refresh redistribution tags to all codes with + * EXPORT_SOURCEMATCH filter and with the same type as c + * + * @param c code with accurate redistribution tags + */ + void refresh_sm_redistribution_tags(Code& c); + + /** * Links all code in the code list to c. * The code is basically added to c. * diff --git a/xorp/policy/configuration.cc b/xorp/policy/configuration.cc index 00b524e..a0e951e 100644 --- a/xorp/policy/configuration.cc +++ b/xorp/policy/configuration.cc @@ -354,6 +354,9 @@ Configuration::link_sourcematch_code(const Code::Target& target) Code* code = new Code(); code->set_target(target); + // set accurate redistribution tags + code->set_redistribution_tags(_protocol_tags[target.protocol()]); + // only export statements have source match code. // go through all of them and link. _exports.link_code(*code); @@ -512,6 +515,9 @@ Configuration::link_code(const Code::Target& target, Code* code = new Code(); code->set_target(target); + // set accurate redistribution tags + code->set_redistribution_tags(_protocol_tags[target.protocol()]); + // link the code iemap.link_code(target.protocol(), *code); diff --git a/xorp/policy/policy_list.cc b/xorp/policy/policy_list.cc index d08b02d..b50ec66 100644 --- a/xorp/policy/policy_list.cc +++ b/xorp/policy/policy_list.cc @@ -256,9 +256,9 @@ PolicyList::link_code(Code& ret) CodeList* cl = (*i).second; + cl->refresh_sm_redistribution_tags(ret); // because of target set in ret, only relevant code will be linked. cl->link_code(ret); - } } diff --git a/xorp/policy/source_match_code_generator.cc b/xorp/policy/source_match_code_generator.cc index e9309ba..3d7a537 100644 --- a/xorp/policy/source_match_code_generator.cc +++ b/xorp/policy/source_match_code_generator.cc @@ -88,6 +88,9 @@ SourceMatchCodeGenerator::addTerm() term->set_target_filter(filter::EXPORT_SOURCEMATCH); term->set_referenced_set_names(_code.referenced_set_names()); + //add redistribution tags to code + term->set_redistribution_tags(_protocol_tags[_protocol]); + // see if we have code for this target already CodeMap::iterator i = _codes.find(_protocol); @@ -95,6 +98,8 @@ SourceMatchCodeGenerator::addTerm() if (i != _codes.end()) { Code* existing = (*i).second; + existing->refresh_sm_redistribution_tags(*term); + // link "raw" code string s = _os.str(); -- 1.7.5.4 From igorm at etf.rs Tue Apr 10 05:59:01 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Tue, 10 Apr 2012 14:59:01 +0200 Subject: [Xorp-hackers] [PATCH 1/2] trivial: ws fixes In-Reply-To: References: Message-ID: <1334062742-18187-1-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/policy/backend/policy_redist_map.cc | 10 +- xorp/policy/backend/single_varrw.cc | 8 +- xorp/policy/code.cc | 4 +- xorp/policy/code.hh | 6 +- xorp/policy/code_list.cc | 4 +- xorp/policy/code_list.hh | 4 +- xorp/policy/configuration.cc | 116 ++++++++++++++-------------- xorp/policy/filter_manager.cc | 88 +++++++++++----------- xorp/policy/policy_list.cc | 62 ++++++++-------- xorp/policy/source_match_code_generator.cc | 26 +++--- xorp/rib/rt_tab_pol_conn.cc | 38 +++++----- xorp/rib/rt_tab_pol_redist.cc | 30 ++++---- xorp/rib/xrl_target.cc | 12 ++-- 13 files changed, 204 insertions(+), 204 deletions(-) diff --git a/xorp/policy/backend/policy_redist_map.cc b/xorp/policy/backend/policy_redist_map.cc index 1f8bf37..6829b44 100644 --- a/xorp/policy/backend/policy_redist_map.cc +++ b/xorp/policy/backend/policy_redist_map.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -35,7 +35,7 @@ PolicyRedistMap::~PolicyRedistMap() { void PolicyRedistMap::insert(const string& protocol, const PolicyTags& tags) { PolicyTags* ptags; - + Map::iterator i = _map.find(protocol); // create new policytags [first time we insert] @@ -44,7 +44,7 @@ PolicyRedistMap::insert(const string& protocol, const PolicyTags& tags) { _map[protocol] = ptags; return; } - + ptags = (*i).second; // just append the tags @@ -62,7 +62,7 @@ PolicyRedistMap::get_protocols(set& out, const PolicyTags& tags) { // XXX: maybe caller would like to control this out.clear(); - + // go through all our tags. for(Map::iterator i = _map.begin(); i != _map.end(); ++i) { PolicyTags* ptags = (*i).second; diff --git a/xorp/policy/backend/single_varrw.cc b/xorp/policy/backend/single_varrw.cc index 4937020..5cf3cc7 100644 --- a/xorp/policy/backend/single_varrw.cc +++ b/xorp/policy/backend/single_varrw.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -125,7 +125,7 @@ SingleVarRW::sync() // clear cache memset(&_elems, 0, sizeof(_elems)); - + // delete all garbage for (unsigned i = 0; i < _trashc; i++) delete _trash[i]; @@ -152,7 +152,7 @@ SingleVarRW::initialize(const Id& id, Element* e) // particular case]. if(!e) e = new ElemNull(); - + _elems[id] = e; // we own the pointers. diff --git a/xorp/policy/code.cc b/xorp/policy/code.cc index ce80f70..ce8593c 100644 --- a/xorp/policy/code.cc +++ b/xorp/policy/code.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net diff --git a/xorp/policy/code.hh b/xorp/policy/code.hh index f3bda5c..8189857 100644 --- a/xorp/policy/code.hh +++ b/xorp/policy/code.hh @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -65,7 +65,7 @@ public: * * @return true if target is less than argument * @param rhs target to compare with - */ + */ bool operator<(const Target& rhs) const; bool operator==(const Target& rhs) const; diff --git a/xorp/policy/code_list.cc b/xorp/policy/code_list.cc index 80a12a2..7057ac6 100644 --- a/xorp/policy/code_list.cc +++ b/xorp/policy/code_list.cc @@ -7,13 +7,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net diff --git a/xorp/policy/code_list.hh b/xorp/policy/code_list.hh index 15062cf..2ae2d9f 100644 --- a/xorp/policy/code_list.hh +++ b/xorp/policy/code_list.hh @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net diff --git a/xorp/policy/configuration.cc b/xorp/policy/configuration.cc index c61392b..00b524e 100644 --- a/xorp/policy/configuration.cc +++ b/xorp/policy/configuration.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -30,7 +30,7 @@ using namespace policy_utils; -Configuration::Configuration(ProcessWatchBase& pw) : +Configuration::Configuration(ProcessWatchBase& pw) : _currtag(0), _varmap(pw), _filter_manager(NULL) { } @@ -53,15 +53,15 @@ Configuration::~Configuration() // _policies.clear(); } - -Term& + +Term& Configuration::find_term(const string& policy, const string& term) { const PolicyStatement& ps = _policies.find(policy); return ps.find_term(term); } -void +void Configuration::delete_term(const string& policy, const string& term) { PolicyStatement& ps = _policies.find(policy); @@ -71,12 +71,12 @@ Configuration::delete_term(const string& policy, const string& term) policy_modified(policy); return; - } + } xorp_throw(ConfError, "TERM NOT FOUND " + policy + " " + term); } - -void + +void Configuration::update_term_block(const string& policy, const string& term, const uint32_t& block, @@ -91,9 +91,9 @@ Configuration::update_term_block(const string& policy, string err = "In policy " + policy + ": " + e.why(); xorp_throw(ConfError, err); } -} +} -void +void Configuration::create_term(const string& policy, const ConfigNodeId& order, const string& term) { @@ -117,7 +117,7 @@ Configuration::create_policy(const string& policy) _modified_policies.insert(policy); } -void +void Configuration::delete_policy(const string& policy) { _policies.delete_policy(policy); @@ -126,27 +126,27 @@ Configuration::delete_policy(const string& policy) _modified_policies.erase(policy); } -void +void Configuration::create_set(const string& set) { _sets.create(set); -} +} -void -Configuration::update_set(const string& type, const string& set, +void +Configuration::update_set(const string& type, const string& set, const string& elements) { // policies affected will be marked as modified. _sets.update_set(type, set, elements, _modified_policies); -} +} -void +void Configuration::delete_set(const string& set) { // if we manage to delete a set, it is not in use, so no updates are // necessary to filters / configuration. _sets.delete_set(set); -} +} void Configuration::add_to_set(const string& type, const string& set, @@ -164,7 +164,7 @@ Configuration::delete_from_set(const string& type, const string& set, _sets.delete_from_set(type, set, element, _modified_policies); } -void +void Configuration::update_imports(const string& protocol, const POLICIES& imports, const string& mod) { @@ -176,8 +176,8 @@ Configuration::update_imports(const string& protocol, const POLICIES& imports, _modified_targets.insert(Code::Target(protocol, filter::IMPORT)); } -void -Configuration::update_exports(const string& protocol, +void +Configuration::update_exports(const string& protocol, const POLICIES& exports, const string& mod) { @@ -224,8 +224,8 @@ Configuration::clear_exports(const string& protocol) _modified_targets.insert(Code::Target(protocol, filter::EXPORT)); } -string -Configuration::str() +string +Configuration::str() { ostringstream conf; /* @@ -233,7 +233,7 @@ for(PolicyMap::iterator i = _policies.begin(); i != _policies.end(); ++i) { conf += ((*i).second)->str(); -} +} for(SetMap::iterator i = _sets.begin(); i != _sets.end(); ++i) { @@ -280,7 +280,7 @@ return conf; return conf.str(); } -void +void Configuration::update_dependencies(PolicyStatement& policy) { // check if used sets & policies exist, and mark dependencies. @@ -289,7 +289,7 @@ Configuration::update_dependencies(PolicyStatement& policy) policy.accept(dep); } -void +void Configuration::compile_policy(const string& name) { PolicyStatement& policy = _policies.find(name); @@ -301,7 +301,7 @@ Configuration::compile_policy(const string& name) update_dependencies(policy); // save old tag to check for integer overflow - tag_t old_currtag = _currtag; + tag_t old_currtag = _currtag; // go through all the import statements _imports.compile(policy, _modified_targets, _currtag, _protocol_tags); @@ -315,11 +315,11 @@ Configuration::compile_policy(const string& name) XLOG_FATAL("The un-avoidable occurred: We ran out of policy tags"); } -void +void Configuration::compile_policies() { // integer overflow check - tag_t old_currtag = _currtag; + tag_t old_currtag = _currtag; // compile all modified policies for (PolicySet::iterator i = _modified_policies.begin(); @@ -345,7 +345,7 @@ Configuration::compile_policies() } } -void +void Configuration::link_sourcematch_code(const Code::Target& target) { // create empty code but only with target set. @@ -367,14 +367,14 @@ Configuration::link_sourcematch_code(const Code::Target& target) // if there is nothing, keep it deleted and empty. - if(code->code() == "") + if(code->code() == "") delete code; else { _sourcematch_filters[target.protocol()] = code; - } + } } -void +void Configuration::update_tagmap(const string& protocol) { // delete previous tags if present @@ -397,7 +397,7 @@ Configuration::update_tagmap(const string& protocol) delete tagset; } -void +void Configuration::link_code() { // go through all modified targets and relink them. @@ -410,11 +410,11 @@ Configuration::link_code() case filter::IMPORT: link_code(t,_imports,_import_filters); break; - + case filter::EXPORT_SOURCEMATCH: link_sourcematch_code(t); break; - + case filter::EXPORT: link_code(t,_exports,_export_filters); // export policies produce tags, update them. @@ -432,7 +432,7 @@ Configuration::link_code() } -void +void Configuration::commit(uint32_t msec) { // recompile and link @@ -446,10 +446,10 @@ Configuration::commit(uint32_t msec) _filter_manager->flush_updates(msec); } -void +void Configuration::add_varmap(const string& protocol, const string& variable, const string& type, const string& access, - const VarRW::Id& id) + const VarRW::Id& id) { // figure out access... VarMap::Access acc = VarMap::READ; @@ -462,26 +462,26 @@ Configuration::add_varmap(const string& protocol, const string& variable, acc = VarMap::WRITE; else xorp_throw(PolicyException, - "Unknown access (" + access + ") for protocol: " + "Unknown access (" + access + ") for protocol: " + protocol + " variable: " + variable); - _varmap.add_protocol_variable(protocol, - new VarMap::Variable(variable, type, acc, id)); + _varmap.add_protocol_variable(protocol, + new VarMap::Variable(variable, type, acc, id)); } void Configuration::set_filter_manager(FilterManagerBase& fm) -{ +{ // cannot reassign XLOG_ASSERT(!_filter_manager); _filter_manager = &fm; } -void -Configuration::update_ie(const string& protocol, - const POLICIES& policies, - IEMap& iemap, +void +Configuration::update_ie(const string& protocol, + const POLICIES& policies, + IEMap& iemap, PolicyList::PolicyType pt, const string& mod) { @@ -494,7 +494,7 @@ Configuration::update_ie(const string& protocol, i != policies.end(); ++i) { pl->push_back(*i); - } + } // if there were policies, get their targets [no longer have policies] iemap.get_targets(protocol, mod, _modified_targets); @@ -503,9 +503,9 @@ Configuration::update_ie(const string& protocol, iemap.insert(protocol, mod, pl); } -void -Configuration::link_code(const Code::Target& target, - IEMap& iemap, +void +Configuration::link_code(const Code::Target& target, + IEMap& iemap, CodeMap& codemap) { // create new code and set target, so code may be linked properly @@ -520,23 +520,23 @@ Configuration::link_code(const Code::Target& target, if(iter != codemap.end()) { delete (*iter).second; codemap.erase(iter); - } + } // if code is empty [no-op filter] just erase it, and keep no entry. - if(code->code() == "") + if(code->code() == "") delete code; - else + else codemap[target.protocol()] = code; } - -string + +string Configuration::codemap_str(CodeMap& cm) { string ret = ""; for(CodeMap::iterator i = cm.begin(); i != cm.end(); ++i) { - + Code* c= (*i).second; ret += "PROTO: " + (*i).first + "\n"; diff --git a/xorp/policy/filter_manager.cc b/xorp/policy/filter_manager.cc index d22e380..8c4d6c7 100644 --- a/xorp/policy/filter_manager.cc +++ b/xorp/policy/filter_manager.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -29,28 +29,28 @@ #include "backend/policytags.hh" #include "filter_manager.hh" -FilterManager::FilterManager(const CodeMap& imp, - const CodeMap& sm, +FilterManager::FilterManager(const CodeMap& imp, + const CodeMap& sm, const CodeMap& exp, - const SetMap& sets, - const TagMap& tagmap, - XrlStdRouter& rtr, + const SetMap& sets, + const TagMap& tagmap, + XrlStdRouter& rtr, ProcessWatch& pw, ProtocolMap& pmap) : - _import(imp), _sourcematch(sm), _export(exp), - _sets(sets), _tagmap(tagmap), + _import(imp), _sourcematch(sm), _export(exp), + _sets(sets), _tagmap(tagmap), _eventloop(rtr.eventloop()), _push_timeout(2000), - _process_watch(pw), - _policy_backend(&rtr), + _process_watch(pw), + _policy_backend(&rtr), _rib(&rtr), _rib_name("rib"), // FIXME: rib name hardcoded _pmap(pmap) { } -void +void FilterManager::update_filter(const Code::Target& t) { switch (t.filter()) { @@ -68,25 +68,25 @@ FilterManager::update_filter(const Code::Target& t) } } -void +void FilterManager::update_import_filter(const string& protocol) { update_queue(protocol,_import,_import_queue); } - -void + +void FilterManager::update_sourcematch_filter(const string& protocol) { update_queue(protocol,_sourcematch,_sourcematch_queue); } -void +void FilterManager::update_export_filter(const string& protocol) { update_queue(protocol,_export,_export_queue); } -void +void FilterManager::update_tagmap(const string& protocol) { TagMap::const_iterator i = _tagmap.find(protocol); @@ -101,7 +101,7 @@ FilterManager::update_tagmap(const string& protocol) PolicyTags pt; for (TagSet::const_iterator iter = ts->begin(); iter != ts->end(); ++iter) - pt.insert(*iter); + pt.insert(*iter); XrlAtomList al = pt.xrl_atomlist(); @@ -114,7 +114,7 @@ FilterManager::update_tagmap(const string& protocol) callback(this,&FilterManager::policy_backend_cb)); } -void +void FilterManager::policy_backend_cb(const XrlError& e) { string error_msg; @@ -125,10 +125,10 @@ FilterManager::policy_backend_cb(const XrlError& e) e.str().c_str()); XLOG_ERROR("%s", error_msg.c_str()); // xorp_throw(FMException, error_msg); // XXX: what else can we do ? - } + } } -void +void FilterManager::flush_export_queue() { debug_msg("[POLICY] Flushing export filter queue...\n"); @@ -148,12 +148,12 @@ FilterManager::flush_export_queue() _policy_backend.send_reset(_pmap.xrl_target(protocol).c_str(), filter::EXPORT,callback(this,&FilterManager::policy_backend_cb)); } - // else configure it + // else configure it else { - _policy_backend.send_configure(_pmap.xrl_target(protocol).c_str(), + _policy_backend.send_configure(_pmap.xrl_target(protocol).c_str(), filter::EXPORT, conf, callback(this, &FilterManager::policy_backend_cb)); - } + } // export filters may change tagmap update_tagmap(protocol); @@ -165,7 +165,7 @@ FilterManager::flush_export_queue() _export_queue.clear(); } -void +void FilterManager::flush_queue(ConfQueue& queue, filter::Filter f) { debug_msg("[POLICY] Flushing %s queue...\n", @@ -183,10 +183,10 @@ FilterManager::flush_queue(ConfQueue& queue, filter::Filter f) if(!conf.length()) { _policy_backend.send_reset(_pmap.xrl_target(protocol).c_str(), f, callback(this,&FilterManager::policy_backend_cb)); - } - // else configure filter normally. + } + // else configure filter normally. else { - _policy_backend.send_configure(_pmap.xrl_target(protocol).c_str(), + _policy_backend.send_configure(_pmap.xrl_target(protocol).c_str(), f, conf, callback(this,&FilterManager::policy_backend_cb)); } // need to push routes for protocol [filters changed]. @@ -204,7 +204,7 @@ FilterManager::push_routes_now() { for(set::iterator i = _push_queue.begin(); i != _push_queue.end(); ++i) { - + const string& proto = *i; debug_msg("[POLICY] Pushing routes for %s\n", @@ -217,7 +217,7 @@ FilterManager::push_routes_now() _push_queue.clear(); } -void +void FilterManager::flush_updates_now() { // flush all queues @@ -230,7 +230,7 @@ FilterManager::flush_updates_now() callback(this,&FilterManager::push_routes_now)); } -void +void FilterManager::flush_updates(uint32_t msec) { // delayed flush @@ -238,7 +238,7 @@ FilterManager::flush_updates(uint32_t msec) callback(this,&FilterManager::flush_updates_now)); } -void +void FilterManager::birth(const string& protocol) { debug_msg("[POLICY] Protocol born: %s\n",protocol.c_str()); @@ -248,12 +248,12 @@ FilterManager::birth(const string& protocol) update_sourcematch_filter(protocol); update_import_filter(protocol); - + // FIXME: need a mechanism to make routes from RIB reach the new born // process. Consider if source match filter was setup before the export // filter was alive... the routes will be sitting in the RIB, and never go // to the process. - + // This is a HACK [as this problem was discovered quite late]. So it looks // ugly on purpose. CodeMap::const_iterator cmi = _export.find(protocol); @@ -265,10 +265,10 @@ FilterManager::birth(const string& protocol) i != export_code->source_protocols().end(); ++i) { const string& push_proto = *i; - + if(push_proto == protocol) continue; - + if(!_process_watch.alive(push_proto)) continue; @@ -278,12 +278,12 @@ FilterManager::birth(const string& protocol) XLOG_WARNING("XXX HACK: PUSHING ROUTES OF %s FOR %s", push_proto.c_str(),protocol.c_str()); - + _push_queue.insert(push_proto); } } // EOH [end of hack] - + // perhaps we can delay the flush. Consider boot-time. A lot of processes // are coming up, so we will always be flushing. At boot, the commit is // delayed by ~2 seconds I think, so if we delay the flush ~2 seconds here @@ -299,7 +299,7 @@ FilterManager::birth(const string& protocol) // rather than overloading the meaning of route push. } -void +void FilterManager::death(const string& protocol) { // do not send any updates to dead process. @@ -314,8 +314,8 @@ FilterManager::death(const string& protocol) debug_msg("[POLICY] Protocol death: %s\n",protocol.c_str()); } -void -FilterManager::delete_queue_protocol(ConfQueue& queue, +void +FilterManager::delete_queue_protocol(ConfQueue& queue, const string& protocol) { ConfQueue::iterator i = queue.find(protocol); @@ -323,11 +323,11 @@ FilterManager::delete_queue_protocol(ConfQueue& queue, if(i == queue.end()) return; - queue.erase(i); + queue.erase(i); } -void -FilterManager::update_queue(const string& protocol, +void +FilterManager::update_queue(const string& protocol, const CodeMap& cm, ConfQueue& queue) { diff --git a/xorp/policy/policy_list.cc b/xorp/policy/policy_list.cc index ab0651d..d08b02d 100644 --- a/xorp/policy/policy_list.cc +++ b/xorp/policy/policy_list.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -32,7 +32,7 @@ uint32_t PolicyList::_pe = 0; -PolicyList::PolicyList(const string& p, PolicyType pt, +PolicyList::PolicyList(const string& p, PolicyType pt, PolicyMap& pmap, SetMap& smap, VarMap& vmap, string mod) : _protocol(p), _type(pt), _pmap(pmap), @@ -68,7 +68,7 @@ PolicyList::create_mod(Term::BLOCKS block) PolicyList::~PolicyList() { - for (PolicyCodeList::iterator i = _policies.begin(); + for (PolicyCodeList::iterator i = _policies.begin(); i != _policies.end(); ++i) { PolicyCode& pc = *i; @@ -86,7 +86,7 @@ PolicyList::~PolicyList() delete _mod_term_export; } -void +void PolicyList::push_back(const string& policyname) { if (!policyname.empty() && policyname.at(0) == '(') { @@ -159,8 +159,8 @@ PolicyList::add_policy_expression(const string& exp) push_back(name); } -void -PolicyList::compile_policy(PolicyStatement& ps,Code::TargetSet& mod, +void +PolicyList::compile_policy(PolicyStatement& ps,Code::TargetSet& mod, uint32_t& tagstart, map >& ptags) { @@ -179,10 +179,10 @@ PolicyList::compile_policy(PolicyStatement& ps,Code::TargetSet& mod, break; } } - } + } } -void +void PolicyList::compile(Code::TargetSet& mod, uint32_t& tagstart, map >& ptags) { // go throw all policies in the list @@ -193,35 +193,35 @@ PolicyList::compile(Code::TargetSet& mod, uint32_t& tagstart, mapget_targets(targets); } } -void +void PolicyList::get_redist_tags(const string& protocol, Code::TagSet& ts) { // go through all policies and return tags associated with the requested // protocol. for(PolicyCodeList::iterator i = _policies.begin(); i != _policies.end(); ++i) { - + CodeList* cl = (*i).second; cl->get_redist_tags(protocol,ts); - } + } } -void -PolicyList::semantic_check(PolicyStatement& ps, +void +PolicyList::semantic_check(PolicyStatement& ps, VisitorSemantic::PolicyType type) { - // check if policy makes sense with this instantiation + // check if policy makes sense with this instantiation // [i.e. protocol and import/export pair]. SemanticVarRW varrw(_varmap); @@ -311,8 +311,8 @@ PolicyList::semantic_check(PolicyStatement& ps, ps.accept(sem_check); } -void -PolicyList::compile_import(PolicyCodeList::iterator& iter, +void +PolicyList::compile_import(PolicyCodeList::iterator& iter, PolicyStatement& ps, Code::TargetSet& modified_targets) { @@ -350,9 +350,9 @@ PolicyList::compile_import(PolicyCodeList::iterator& iter, modified_targets.insert(code->target()); } -void -PolicyList::compile_export(PolicyCodeList::iterator& iter, PolicyStatement& ps, - Code::TargetSet& modified_targets, +void +PolicyList::compile_export(PolicyCodeList::iterator& iter, PolicyStatement& ps, + Code::TargetSet& modified_targets, uint32_t& tagstart, map >& ptags) { @@ -363,7 +363,7 @@ PolicyList::compile_export(PolicyCodeList::iterator& iter, PolicyStatement& ps, // generate source match code SourceMatchCodeGenerator smcg(tagstart, _varmap, _pmap, ptags); - + // check modifier [a bit of a hack] if (_mod_term) _mod_term->accept(smcg); diff --git a/xorp/policy/source_match_code_generator.cc b/xorp/policy/source_match_code_generator.cc index 3b68cf3..e9309ba 100644 --- a/xorp/policy/source_match_code_generator.cc +++ b/xorp/policy/source_match_code_generator.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -28,13 +28,13 @@ SourceMatchCodeGenerator::SourceMatchCodeGenerator(uint32_t tagstart, const VarMap& varmap, PolicyMap& pmap, - map > & ptags) + map > & ptags) : CodeGenerator(varmap, pmap), _currtag(tagstart), _protocol_tags(ptags) { } -const Element* +const Element* SourceMatchCodeGenerator::visit_policy(PolicyStatement& policy) { PolicyStatement::TermContainer& terms = policy.terms(); @@ -78,7 +78,7 @@ SourceMatchCodeGenerator::visit_policy(PolicyStatement& policy) return NULL; } -void +void SourceMatchCodeGenerator::addTerm() { // copy the code for the term @@ -178,7 +178,7 @@ SourceMatchCodeGenerator::do_term(Term& term) _protocol_statement = false; (i->second)->accept(*this); - + // if it was a protocol statement, no need for "ONFALSE_EXIT", if its // any other statement, then yes. The protocol is not read as a variable // by the backend filters... it is only used by the policy manager. @@ -187,8 +187,8 @@ SourceMatchCodeGenerator::do_term(Term& term) } // XXX: we can assume _protocol = PROTOCOL IN EXPORT STATEMENT - if(_protocol == "") - xorp_throw(NoProtoSpec, "No protocol specified in term " + term.name() + + if(_protocol == "") + xorp_throw(NoProtoSpec, "No protocol specified in term " + term.name() + " in export policy source match"); // ignore any destination block [that is dealt with in the export code @@ -244,12 +244,12 @@ SourceMatchCodeGenerator::do_term(Term& term) _currtag++; } -const Element* +const Element* SourceMatchCodeGenerator::visit_proto(NodeProto& node) { // check for protocol redifinition if(_protocol != "") { - ostringstream err; + ostringstream err; err << "PROTOCOL REDEFINED FROM " << _protocol << " TO " << node.proto() << " AT LINE " << node.line(); xorp_throw(ProtoRedefined, err.str()); @@ -261,10 +261,10 @@ SourceMatchCodeGenerator::visit_proto(NodeProto& node) return NULL; } -vector& +vector& SourceMatchCodeGenerator::codes() -{ - return _codes_vect; +{ + return _codes_vect; } const SourceMatchCodeGenerator::Tags& diff --git a/xorp/rib/rt_tab_pol_conn.cc b/xorp/rib/rt_tab_pol_conn.cc index 7ac9e9e..57db978 100644 --- a/xorp/rib/rt_tab_pol_conn.cc +++ b/xorp/rib/rt_tab_pol_conn.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -65,12 +65,12 @@ PolicyConnectedTable::~PolicyConnectedTable () template int -PolicyConnectedTable::add_route(const IPRouteEntry& route, +PolicyConnectedTable::add_route(const IPRouteEntry& route, RouteTable* caller) { XLOG_ASSERT(caller == _parent); - debug_msg("[RIB] PolicyConnectedTable ADD ROUTE: %s\n", + debug_msg("[RIB] PolicyConnectedTable ADD ROUTE: %s\n", route.str().c_str()); @@ -80,19 +80,19 @@ PolicyConnectedTable::add_route(const IPRouteEntry& route, // make a copy so we may modify it IPRouteEntry route_copy(*original); - do_filtering(route_copy); - - + do_filtering(route_copy); + + RouteTable* next = this->next_table(); XLOG_ASSERT(next); // Send the possibly modified route down return next->add_route(route_copy, this); -} +} template -int -PolicyConnectedTable::delete_route(const IPRouteEntry* route, +int +PolicyConnectedTable::delete_route(const IPRouteEntry* route, RouteTable* caller) { XLOG_ASSERT(caller == _parent); @@ -116,14 +116,14 @@ PolicyConnectedTable::delete_route(const IPRouteEntry* route, // make a copy so we may modify it (e.g., by setting its policy tags) IPRouteEntry route_copy(*route); - do_filtering(route_copy); + do_filtering(route_copy); // propagate the delete return next->delete_route(&route_copy, this); } template -const IPRouteEntry* +const IPRouteEntry* PolicyConnectedTable::lookup_route(const IPNet& net) const { XLOG_ASSERT(_parent); @@ -134,13 +134,13 @@ PolicyConnectedTable::lookup_route(const IPNet& net) const // check if we have route [we should have same routes as origin table]. if (i == _route_table.end()) return _parent->lookup_route(net); // should return null probably - + return i.payload(); } template -const IPRouteEntry* +const IPRouteEntry* PolicyConnectedTable::lookup_route(const A& addr) const { XLOG_ASSERT(_parent); @@ -157,7 +157,7 @@ PolicyConnectedTable::lookup_route(const A& addr) const template -RouteRange* +RouteRange* PolicyConnectedTable::lookup_route_range(const A& addr) const { XLOG_ASSERT(_parent); @@ -169,13 +169,13 @@ PolicyConnectedTable::lookup_route_range(const A& addr) const template void -PolicyConnectedTable::replumb(RouteTable* old_parent, +PolicyConnectedTable::replumb(RouteTable* old_parent, RouteTable* new_parent) { XLOG_ASSERT(old_parent == _parent); _parent = new_parent; -} +} template @@ -190,7 +190,7 @@ void PolicyConnectedTable::push_routes() { debug_msg("[RIB] PolicyConnectedTable PUSH ROUTES\n"); - + RouteTable* next = this->next_table(); XLOG_ASSERT(next); @@ -227,7 +227,7 @@ PolicyConnectedTable::push_routes() IPRouteEntry* route = *i; _route_table.erase(route->net()); _route_table.insert(route->net(), route); - } + } } diff --git a/xorp/rib/rt_tab_pol_redist.cc b/xorp/rib/rt_tab_pol_redist.cc index a0be9aa..0ffd6a7 100644 --- a/xorp/rib/rt_tab_pol_redist.cc +++ b/xorp/rib/rt_tab_pol_redist.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -42,7 +42,7 @@ PolicyRedistTable::PolicyRedistTable(RouteTable* parent, XrlRouter& rtr, bool multicast) : RouteTable(table_name), _parent(parent), - _xrl_router(rtr), + _xrl_router(rtr), _eventloop(_xrl_router.eventloop()), _redist_map(rmap), _redist4_client(&_xrl_router), @@ -59,7 +59,7 @@ PolicyRedistTable::PolicyRedistTable(RouteTable* parent, XrlRouter& rtr, template int -PolicyRedistTable::add_route(const IPRouteEntry& route, +PolicyRedistTable::add_route(const IPRouteEntry& route, RouteTable* caller) { XLOG_ASSERT(caller == _parent); @@ -79,11 +79,11 @@ PolicyRedistTable::add_route(const IPRouteEntry& route, XLOG_ASSERT(next != NULL); return next->add_route(route, this); -} +} template -int -PolicyRedistTable::delete_route(const IPRouteEntry* route, +int +PolicyRedistTable::delete_route(const IPRouteEntry* route, RouteTable* caller) { XLOG_ASSERT(caller == _parent); @@ -107,7 +107,7 @@ PolicyRedistTable::delete_route(const IPRouteEntry* route, } template -const IPRouteEntry* +const IPRouteEntry* PolicyRedistTable::lookup_route(const IPNet& net) const { XLOG_ASSERT(_parent != NULL); @@ -117,7 +117,7 @@ PolicyRedistTable::lookup_route(const IPNet& net) const template -const IPRouteEntry* +const IPRouteEntry* PolicyRedistTable::lookup_route(const A& addr) const { XLOG_ASSERT(_parent != NULL); @@ -127,7 +127,7 @@ PolicyRedistTable::lookup_route(const A& addr) const template -RouteRange* +RouteRange* PolicyRedistTable::lookup_route_range(const A& addr) const { XLOG_ASSERT(_parent != NULL); @@ -138,13 +138,13 @@ PolicyRedistTable::lookup_route_range(const A& addr) const template void -PolicyRedistTable::replumb(RouteTable* old_parent, +PolicyRedistTable::replumb(RouteTable* old_parent, RouteTable* new_parent) { XLOG_ASSERT(old_parent == _parent); _parent = new_parent; -} +} template @@ -157,7 +157,7 @@ PolicyRedistTable::str() const template void -PolicyRedistTable::add_redist(const IPRouteEntry& route, +PolicyRedistTable::add_redist(const IPRouteEntry& route, const Set& protos) { // send a redistribution request for all protocols in the set. @@ -184,7 +184,7 @@ PolicyRedistTable::xrl_cb(const XrlError& e, string action) { if (e != XrlError::OKAY()) { XLOG_WARNING("Unable to complete XRL: %s", action.c_str()); } -} +} template <> void @@ -246,7 +246,7 @@ PolicyRedistTable::replace_policytags(const IPRouteEntry& route, del_redist(route, del_protos); if (!add_protos.empty()) add_redist(route, add_protos); -} +} template class PolicyRedistTable; diff --git a/xorp/rib/xrl_target.cc b/xorp/rib/xrl_target.cc index c8af7fe..c7cfe44 100644 --- a/xorp/rib/xrl_target.cc +++ b/xorp/rib/xrl_target.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -285,7 +285,7 @@ XrlRibTarget::rib_0_1_add_route4(const string& protocol, network.str().c_str(), nexthop.str().c_str(), XORP_UINT_CAST(metric)); - + #ifndef XORP_DISABLE_PROFILE if (_rib_manager->profile().enabled(profile_route_ribin)) { _rib_manager->profile().log(profile_route_ribin, @@ -298,7 +298,7 @@ XrlRibTarget::rib_0_1_add_route4(const string& protocol, XORP_UINT_CAST(metric))); } #endif - + if (unicast && _urib4.add_route(protocol, network, nexthop, "", "", metric, policytags) != XORP_OK) { @@ -1012,7 +1012,7 @@ XrlRibTarget::profile_0_1_disable(const string& pname) } -XrlCmdError +XrlCmdError XrlRibTarget::profile_0_1_get_entries(const string& pname, const string& instance_name) { @@ -1055,7 +1055,7 @@ XrlCmdError XrlRibTarget::profile_0_1_list(string& info) { debug_msg("\n"); - + info = _rib_manager->profile().get_list(); return XrlCmdError::OKAY(); } -- 1.7.5.4 From noreply at github.com Tue Apr 10 09:05:59 2012 From: noreply at github.com (GitHub) Date: Tue, 10 Apr 2012 09:05:59 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 990a47: trivial: ws fixes Message-ID: <4f845a67a9dd3_ad41586af0601d2@sh2.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 990a47939c0f41acd7f39a263169ce4b87889a88 https://github.com/greearb/xorp.ct/commit/990a47939c0f41acd7f39a263169ce4b87889a88 Author: Igor Maravic Date: 2012-04-10 (Tue, 10 Apr 2012) Changed paths: M xorp/policy/backend/policy_redist_map.cc M xorp/policy/backend/single_varrw.cc M xorp/policy/code.cc M xorp/policy/code.hh M xorp/policy/code_list.cc M xorp/policy/code_list.hh M xorp/policy/configuration.cc M xorp/policy/filter_manager.cc M xorp/policy/policy_list.cc M xorp/policy/source_match_code_generator.cc M xorp/rib/rt_tab_pol_conn.cc M xorp/rib/rt_tab_pol_redist.cc M xorp/rib/xrl_target.cc Log Message: ----------- trivial: ws fixes Signed-off-by: Igor Maravic Commit: a67f53be240ae7f7438fd48e3be3d7ffe74be969 https://github.com/greearb/xorp.ct/commit/a67f53be240ae7f7438fd48e3be3d7ffe74be969 Author: Igor Maravic Date: 2012-04-10 (Tue, 10 Apr 2012) Changed paths: M xorp/policy/code.cc M xorp/policy/code.hh M xorp/policy/code_list.cc M xorp/policy/code_list.hh M xorp/policy/configuration.cc M xorp/policy/policy_list.cc M xorp/policy/source_match_code_generator.cc Log Message: ----------- xorp: policy: Fix problem with route distribution Problem was that protocol's existing EXPORT_SOURCE match policies weren't refreshed when new export filter is created. New protocol always has accurate policy tags for route lookup. It always searches routes that has no tag, or older protocol tags or it's tags. If it finds them it prepends it's tag. Older protocols are searching routes that has no tags, or have older tags. If it finds such a route it prepends it's tag. EXPORT_SOURCEMATCH policies are executed in order that depends on protocol name. If newer protocol has lower letter (for example ospf's policies are executed before rip's, because "o" precedes "r"), new protocol prepends new tags, that are unrecognizable to older protocol, to routes that it has found. Because older protocol is unaware of new tags, it concludes that routes are deleted and it deletes them. This is not what we are expecting. If older protocol is executed first, it prepends it's tag to routes that it has found. Because old tag is recognizable by newer protocol new tags are also prepended to routes. This case works as expected. Solution - refresh tags for all protocol's EXPORT_SOURCEMATCH routes when new export filter is created. Reported-by: Steve Dickey Signed-off-by: Igor Maravic Compare: https://github.com/greearb/xorp.ct/compare/8ad7d8f...a67f53b From greearb at candelatech.com Tue Apr 10 09:06:29 2012 From: greearb at candelatech.com (Ben Greear) Date: Tue, 10 Apr 2012 09:06:29 -0700 Subject: [Xorp-hackers] [PATCH 2/2] xorp: policy: Fix problem with route distribution In-Reply-To: <1334062742-18187-2-git-send-email-igorm@etf.rs> References: <1334062742-18187-1-git-send-email-igorm@etf.rs> <1334062742-18187-2-git-send-email-igorm@etf.rs> Message-ID: <4F845A85.5030309@candelatech.com> On 04/10/2012 05:59 AM, igorm at etf.rs wrote: > From: Igor Maravic > > Problem was that protocol's existing EXPORT_SOURCE match policies weren't refreshed when new export filter is created. > > New protocol always has accurate policy tags for route lookup. It always searches routes that has no tag, or > older protocol tags or it's tags. If it finds them it prepends it's tag. > Older protocols are searching routes that has no tags, or have older tags. If it finds such a route it prepends it's tag. > > EXPORT_SOURCEMATCH policies are executed in order that depends on protocol name. > If newer protocol has lower letter (for example ospf's policies are executed before rip's, because "o" precedes "r"), > new protocol prepends new tags, that are unrecognizable to older protocol, to routes that it has found. > Because older protocol is unaware of new tags, it concludes that routes are deleted and it deletes them. > This is not what we are expecting. > > If older protocol is executed first, it prepends it's tag to routes that it has found. Because old tag is recognizable by > newer protocol new tags are also prepended to routes. This case works as expected. > > Solution - refresh tags for all protocol's EXPORT_SOURCEMATCH routes when new export filter is created. Thanks for working on this! I've just applied and pushed the patches, so anyone who wants to test can just pull down the latest and give it a try. Thanks, Ben -- Ben Greear Candela Technologies Inc http://www.candelatech.com From igorm at etf.rs Wed Apr 11 09:26:18 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 11 Apr 2012 18:26:18 +0200 Subject: [Xorp-hackers] [PATCH 2/5] xorp: policy: Fix behaviour on protocol death In-Reply-To: <1334161582-13443-1-git-send-email-igorm@etf.rs> References: <1334161582-13443-1-git-send-email-igorm@etf.rs> Message-ID: <1334161582-13443-2-git-send-email-igorm@etf.rs> From: Igor Maravic When protocol dies clear export and import protocol policies just like the user deleted them manually. Old way crashed XORP when protocol was deleted, and then re-added with new export/import policies. Signed-off-by: Igor Maravic --- xorp/policy/policy_target.cc | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/xorp/policy/policy_target.cc b/xorp/policy/policy_target.cc index f73863b..76f6daa 100644 --- a/xorp/policy/policy_target.cc +++ b/xorp/policy/policy_target.cc @@ -191,8 +191,9 @@ PolicyTarget::death(const string& tclass, const string& /* tinstance */) // Remove the "import" and "export" dependencies for the protocol string protocol = _pmap.protocol(tclass); - _conf.clear_imports(protocol); - _conf.clear_exports(protocol); + //delete all export and import filters + update_export(protocol, "", ""); + update_import(protocol, "", ""); _process_watch.death(tclass); } -- 1.7.5.4 From igorm at etf.rs Wed Apr 11 09:26:20 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 11 Apr 2012 18:26:20 +0200 Subject: [Xorp-hackers] [PATCH 4/5] xorp: Remove protocol's tags from rib when it dies In-Reply-To: <1334161582-13443-1-git-send-email-igorm@etf.rs> References: <1334161582-13443-1-git-send-email-igorm@etf.rs> Message-ID: <1334161582-13443-4-git-send-email-igorm@etf.rs> From: Igor Maravic Added new function in rib.xif to enable that. FilterManager calls it when protocol dies. >From rib's tag map, all protocol's tags are removed. Signed-off-by: Igor Maravic --- xorp/policy/backend/policy_redist_map.cc | 6 ++++++ xorp/policy/backend/policy_redist_map.hh | 7 +++++++ xorp/policy/filter_manager.cc | 6 ++++-- xorp/rib/rib_manager.cc | 6 ++++++ xorp/rib/rib_manager.hh | 8 ++++++++ xorp/rib/xrl_target.cc | 13 +++++++++++++ xorp/rib/xrl_target.hh | 6 ++++++ xorp/xrl/interfaces/rib.xif | 5 +++++ 8 files changed, 55 insertions(+), 2 deletions(-) diff --git a/xorp/policy/backend/policy_redist_map.cc b/xorp/policy/backend/policy_redist_map.cc index 6829b44..ffb9074 100644 --- a/xorp/policy/backend/policy_redist_map.cc +++ b/xorp/policy/backend/policy_redist_map.cc @@ -33,6 +33,12 @@ PolicyRedistMap::~PolicyRedistMap() { } void +PolicyRedistMap::remove(const string& protocol) +{ + _map.erase(protocol); +} + +void PolicyRedistMap::insert(const string& protocol, const PolicyTags& tags) { PolicyTags* ptags; diff --git a/xorp/policy/backend/policy_redist_map.hh b/xorp/policy/backend/policy_redist_map.hh index 7bd876b..c8b984f 100644 --- a/xorp/policy/backend/policy_redist_map.hh +++ b/xorp/policy/backend/policy_redist_map.hh @@ -45,6 +45,13 @@ public: ~PolicyRedistMap(); /** + * Remove route redistribution for a protocol. + * + * @param protocol protocol which tags should be removed. + */ + void remove(const string& protocol); + + /** * Configure redistribution to a protcol for these tags. * * @param protocol destination protocol for these tags. diff --git a/xorp/policy/filter_manager.cc b/xorp/policy/filter_manager.cc index 8c4d6c7..bfbd8bf 100644 --- a/xorp/policy/filter_manager.cc +++ b/xorp/policy/filter_manager.cc @@ -308,8 +308,10 @@ FilterManager::death(const string& protocol) delete_queue_protocol(_import_queue,protocol); _push_queue.erase(protocol); - // XXX: might want to delete policytags in rib... but the tagmap in rib is - // quite unflexible now. + // send out update + _rib.send_remove_policy_redist_tags(_rib_name.c_str(), + _pmap.xrl_target(protocol), + callback(this,&FilterManager::policy_backend_cb)); debug_msg("[POLICY] Protocol death: %s\n",protocol.c_str()); } diff --git a/xorp/rib/rib_manager.cc b/xorp/rib/rib_manager.cc index 1fe8c0f..6de144d 100644 --- a/xorp/rib/rib_manager.cc +++ b/xorp/rib/rib_manager.cc @@ -603,6 +603,12 @@ RibManager::reset_filter(const uint32_t& filter) } void +RibManager::remove_policy_redist_tags(const string& protocol) +{ + _policy_redist_map.remove(protocol); +} + +void RibManager::insert_policy_redist_tags(const string& protocol, const PolicyTags& tags) { diff --git a/xorp/rib/rib_manager.hh b/xorp/rib/rib_manager.hh index c3bdcfe..932a436 100644 --- a/xorp/rib/rib_manager.hh +++ b/xorp/rib/rib_manager.hh @@ -321,6 +321,14 @@ public: /** + * Remove policy-tags for a protocol. + * + * + * @param protocol protocol which tags should be removed. + */ + void remove_policy_redist_tags(const string& protocol); + + /** * Insert [old ones are kept] policy-tags for a protocol. * * All routes which contain at least one of these tags, will be diff --git a/xorp/rib/xrl_target.cc b/xorp/rib/xrl_target.cc index c7cfe44..a0c814a 100644 --- a/xorp/rib/xrl_target.cc +++ b/xorp/rib/xrl_target.cc @@ -954,6 +954,19 @@ XrlRibTarget::policy_backend_0_1_push_routes() } XrlCmdError +XrlRibTarget::rib_0_1_remove_policy_redist_tags(const string& protocol) +{ + try { + _rib_manager->remove_policy_redist_tags(protocol); + } catch(const PolicyException& e) { + //this should not be posible + return XrlCmdError::COMMAND_FAILED("Remove policy redist tags failed: " + + e.str()); + } + return XrlCmdError::OKAY(); +} + +XrlCmdError XrlRibTarget::rib_0_1_insert_policy_redist_tags(const string& protocol, const XrlAtomList& policytags) { diff --git a/xorp/rib/xrl_target.hh b/xorp/rib/xrl_target.hh index ce39eae..36b2a83 100644 --- a/xorp/rib/xrl_target.hh +++ b/xorp/rib/xrl_target.hh @@ -609,6 +609,12 @@ protected: */ XrlCmdError policy_backend_0_1_push_routes(); + /** + * Remove protocol's redistribution tags + */ + XrlCmdError rib_0_1_remove_policy_redist_tags( + // Input values, + const string& protocol); /** * Redistribute to a protocol based on policy-tags. diff --git a/xorp/xrl/interfaces/rib.xif b/xorp/xrl/interfaces/rib.xif index 4b4d128..ebc79a5 100644 --- a/xorp/xrl/interfaces/rib.xif +++ b/xorp/xrl/interfaces/rib.xif @@ -322,6 +322,11 @@ interface rib/0.1 { deregister_interest4 ? target:txt & addr:ipv4 & prefix_len:u32; /** + * Remove protocol's redistribution tags + */ + remove_policy_redist_tags ? protocol:txt; + + /** * Add policy tags for a specific protcol in the redistribution map. * * @param protocol The destination protocol of the redistribution. -- 1.7.5.4 From igorm at etf.rs Wed Apr 11 09:26:17 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 11 Apr 2012 18:26:17 +0200 Subject: [Xorp-hackers] [PATCH 1/5] trivial: ws fixes In-Reply-To: References: Message-ID: <1334161582-13443-1-git-send-email-igorm@etf.rs> From: Igor Maravic Signed-off-by: Igor Maravic --- xorp/policy/backend/policy_redist_map.hh | 4 +- xorp/policy/common/policy_utils.cc | 14 ++-- xorp/policy/configuration.hh | 34 +++++----- xorp/policy/policy_target.cc | 14 ++-- xorp/policy/process_watch.cc | 26 ++++---- xorp/policy/xrl_target.cc | 98 +++++++++++++++--------------- xorp/rib/rib_manager.cc | 18 +++--- xorp/rib/rib_manager.hh | 8 +- xorp/rib/xrl_target.hh | 8 +- 9 files changed, 112 insertions(+), 112 deletions(-) diff --git a/xorp/policy/backend/policy_redist_map.hh b/xorp/policy/backend/policy_redist_map.hh index afc7f62..7bd876b 100644 --- a/xorp/policy/backend/policy_redist_map.hh +++ b/xorp/policy/backend/policy_redist_map.hh @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net diff --git a/xorp/policy/common/policy_utils.cc b/xorp/policy/common/policy_utils.cc index 2aa23ed..92d105f 100644 --- a/xorp/policy/common/policy_utils.cc +++ b/xorp/policy/common/policy_utils.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -38,7 +38,7 @@ namespace policy_utils { -void +void str_to_list(const string& in, list& out) { string::size_type pos1 = 0; // beginning of token @@ -58,7 +58,7 @@ str_to_list(const string& in, list& out) out.push_back(token); return; } - + // grab token [delimiter found]. token = in.substr(pos1,pos2-pos1); out.push_back(token); @@ -66,7 +66,7 @@ str_to_list(const string& in, list& out) } } -void +void str_to_set(const string& in, set& out) { list tmp; @@ -122,7 +122,7 @@ read_file(const string& fname, string& out) return; } -unsigned +unsigned count_nl(const char* x) { const char* end = &x[strlen(x)]; @@ -141,7 +141,7 @@ regex(const string& str, const string& reg) // compile the regex regex_t re; int res = regcomp(&re, reg.c_str(), REG_EXTENDED); - + if (res) { char tmp[128]; string err; diff --git a/xorp/policy/configuration.hh b/xorp/policy/configuration.hh index 1b046c6..3b5ffc3 100644 --- a/xorp/policy/configuration.hh +++ b/xorp/policy/configuration.hh @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -91,14 +91,14 @@ public: typedef map CodeMap; typedef map TagMap; - + /** * @short Exception thrown on configuration error */ class ConfError : public PolicyException { public: - ConfError(const char* file, size_t line, const string& init_why = "") - : PolicyException("ConfError", file, line, init_why) {} + ConfError(const char* file, size_t line, const string& init_why = "") + : PolicyException("ConfError", file, line, init_why) {} }; @@ -108,7 +108,7 @@ public: */ Configuration(ProcessWatchBase& pw); ~Configuration(); - + /** * Throws an exception on failure. * Checks for non-existant policy/term conditions. @@ -136,7 +136,7 @@ public: const uint32_t& block, const ConfigNodeId& order, const string& statement); - + /** * Append a term to a policy. * @@ -149,7 +149,7 @@ public: */ void create_term(const string& policy, const ConfigNodeId& order, const string& term); - + /** * Throws an exception on failure. * Checks if policy already exists. @@ -157,7 +157,7 @@ public: * @param policy policy which should be created. */ void create_policy(const string& policy); - + /** * Throws an exception on failure. * Checks if policy is in use [instantiated by an export/import directive.] @@ -182,7 +182,7 @@ public: * @param set name of the set to be updated. * @param elements comma separated elements to be replaced in set. */ - void update_set(const string& type, const string& set, + void update_set(const string& type, const string& set, const string& elements); /** @@ -203,7 +203,7 @@ public: * @param name name of the set. * @param element the element to add. */ - void add_to_set(const string& type, const string& name, + void add_to_set(const string& type, const string& name, const string& element); /** @@ -216,9 +216,9 @@ public: * @param name name of the set. * @param element the element to delete. */ - void delete_from_set(const string& type, const string& name, + void delete_from_set(const string& type, const string& name, const string& element); - + /** * Throws an exception on failure. * Checks if policies exist. @@ -243,7 +243,7 @@ public: * @return string representation of configuration */ string str(); - + /** * Commit all configuration changes. * This will compile all needed policies and link them. @@ -365,20 +365,20 @@ private: * @param target target for which code should be linked. */ void link_sourcematch_code(const Code::Target& target); - + /** * Update the policytags used by a protocol. * * @param protocol protocol for which to update policytags. */ void update_tagmap(const string& protocol); - + /** * Link code for updated targets. */ void link_code(); - void update_ie(const string& protocol, const POLICIES& policies, + void update_ie(const string& protocol, const POLICIES& policies, IEMap& iemap, PolicyList::PolicyType pt, const string& mod); void link_code(const Code::Target& target, IEMap& iemap, CodeMap& codemap); diff --git a/xorp/policy/policy_target.cc b/xorp/policy/policy_target.cc index b4baa11..f73863b 100644 --- a/xorp/policy/policy_target.cc +++ b/xorp/policy/policy_target.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -30,7 +30,7 @@ string PolicyTarget::policy_target_name = "policy"; PolicyTarget::PolicyTarget(XrlStdRouter& rtr) : - _running(true), _commit_delay(2000), + _running(true), _commit_delay(2000), _process_watch(rtr, _pmap), _conf(_process_watch), _filter_manager(_conf.import_filters(), @@ -102,7 +102,7 @@ PolicyTarget::create_set(const string& name) } void -PolicyTarget::update_set(const string& type, const string& name, +PolicyTarget::update_set(const string& type, const string& name, const string& element) { _conf.update_set(type, name, element); @@ -115,14 +115,14 @@ PolicyTarget::delete_set(const string& name) } void -PolicyTarget::add_to_set(const string& type, const string& name, +PolicyTarget::add_to_set(const string& type, const string& name, const string& element) { _conf.add_to_set(type, name, element); } void -PolicyTarget::delete_from_set(const string& type, const string& name, +PolicyTarget::delete_from_set(const string& type, const string& name, const string& element) { _conf.delete_from_set(type, name, element); @@ -324,7 +324,7 @@ PolicyTarget::cli_command(const string& cmd) { string command; string arg; - + string::size_type i = cmd.find(' '); if (i == string::npos) command = cmd; diff --git a/xorp/policy/process_watch.cc b/xorp/policy/process_watch.cc index dedd489..8f4823a 100644 --- a/xorp/policy/process_watch.cc +++ b/xorp/policy/process_watch.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -31,14 +31,14 @@ ProcessWatch::ProcessWatch(XrlStdRouter& rtr, ProtocolMap& pmap) : _pmap(pmap), - _finder(&rtr), + _finder(&rtr), _instance_name(rtr.instance_name()), _notifier(NULL), _finder_name("finder") // FIXME: hardcoded value { } -void +void ProcessWatch::register_cb(const XrlError& err) { string error_msg; @@ -50,8 +50,8 @@ ProcessWatch::register_cb(const XrlError& err) } } -void -ProcessWatch::add_interest(const string& proc) +void +ProcessWatch::add_interest(const string& proc) { // check if we already added interested, if so do nothing if (_watching.find(proc) != _watching.end()) @@ -68,8 +68,8 @@ ProcessWatch::add_interest(const string& proc) callback(this,&ProcessWatch::register_cb)); } -void -ProcessWatch::birth(const string& proto) +void +ProcessWatch::birth(const string& proto) { const string& p = _pmap.protocol(proto); _alive.insert(p); @@ -80,8 +80,8 @@ ProcessWatch::birth(const string& proto) } -void -ProcessWatch::death(const string& proto) +void +ProcessWatch::death(const string& proto) { const string& p = _pmap.protocol(proto); _alive.erase(p); @@ -90,8 +90,8 @@ ProcessWatch::death(const string& proto) _notifier->death(p); } -bool -ProcessWatch::alive(const string& proto) +bool +ProcessWatch::alive(const string& proto) { if (_watching.find(proto) == _watching.end()) xorp_throw(PWException, "Not watching protocol: " + proto); @@ -100,7 +100,7 @@ ProcessWatch::alive(const string& proto) } void -ProcessWatch::set_notifier(PWNotifier& notifier) +ProcessWatch::set_notifier(PWNotifier& notifier) { // old notifier is lost... it is a feature, not a bug. _notifier = ¬ifier; diff --git a/xorp/policy/xrl_target.cc b/xorp/policy/xrl_target.cc index 40902aa..18823db 100644 --- a/xorp/policy/xrl_target.cc +++ b/xorp/policy/xrl_target.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -32,36 +32,36 @@ using namespace policy_utils; -XrlPolicyTarget::XrlPolicyTarget(XrlStdRouter* r, PolicyTarget& ptarget) : +XrlPolicyTarget::XrlPolicyTarget(XrlStdRouter* r, PolicyTarget& ptarget) : XrlPolicyTargetBase(r), _policy_target(ptarget) { } -XrlCmdError +XrlCmdError XrlPolicyTarget::common_0_1_get_target_name( // Output values, - string& name) + string& name) { name = PolicyTarget::policy_target_name; return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::common_0_1_get_version( // Output values, string& version) { version = "0.1"; return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::common_0_1_get_status( // Output values, uint32_t& status, - string& reason) + string& reason) { if(_policy_target.running()) { status = PROC_READY; @@ -73,9 +73,9 @@ XrlPolicyTarget::common_0_1_get_status( } return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::common_0_1_shutdown() { _policy_target.shutdown(); @@ -83,7 +83,7 @@ XrlPolicyTarget::common_0_1_shutdown() } -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_create_term(const string& policy, const string& order, const string& term) @@ -106,9 +106,9 @@ XrlPolicyTarget::policy_0_1_create_term(const string& policy, return XrlCmdError::COMMAND_FAILED("create_term failed: " + e.str()); } return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_delete_term(const string& policy, const string& term) { @@ -117,12 +117,12 @@ XrlPolicyTarget::policy_0_1_delete_term(const string& policy, } catch(const PolicyException& e) { return XrlCmdError::COMMAND_FAILED("delete_term failed: " + e.str()); } - + return XrlCmdError::OKAY(); -} - +} + -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_update_term_block(const string& policy, const string& term, const uint32_t& block, @@ -150,12 +150,12 @@ XrlPolicyTarget::policy_0_1_update_term_block(const string& policy, } return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_create_policy(const string& policy) { - + try { _policy_target.create_policy(policy); } catch(const PolicyException& e) { @@ -163,9 +163,9 @@ XrlPolicyTarget::policy_0_1_create_policy(const string& policy) } return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_delete_policy(const string& policy) { @@ -176,9 +176,9 @@ XrlPolicyTarget::policy_0_1_delete_policy(const string& policy) } return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_create_set(const string& set) { @@ -189,9 +189,9 @@ XrlPolicyTarget::policy_0_1_create_set(const string& set) } return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_update_set(const string& type, const string& set, const string& elements) @@ -203,9 +203,9 @@ XrlPolicyTarget::policy_0_1_update_set(const string& type, } return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_delete_set(const string& set) { @@ -216,7 +216,7 @@ XrlPolicyTarget::policy_0_1_delete_set(const string& set) } return XrlCmdError::OKAY(); -} +} XrlCmdError XrlPolicyTarget::policy_0_1_add_to_set( @@ -250,7 +250,7 @@ XrlPolicyTarget::policy_0_1_delete_from_set( return XrlCmdError::OKAY(); } -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_done_global_policy_conf() { try { @@ -263,22 +263,22 @@ XrlPolicyTarget::policy_0_1_done_global_policy_conf() return XrlCmdError::OKAY(); } -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_import(const string& protocol, const string& policies, - const string& modifier) + const string& modifier) { try { _policy_target.update_import(protocol, policies, modifier); } catch (const PolicyException& e) { - return XrlCmdError::COMMAND_FAILED("Import of " + protocol + + return XrlCmdError::COMMAND_FAILED("Import of " + protocol + " failed: " + e.str()); } return XrlCmdError::OKAY(); -} - -XrlCmdError +} + +XrlCmdError XrlPolicyTarget::policy_0_1_export(const string& protocol, const string& policies, const string& modifier) @@ -286,7 +286,7 @@ XrlPolicyTarget::policy_0_1_export(const string& protocol, try { _policy_target.update_export(protocol, policies, modifier); } catch (const PolicyException& e) { - return XrlCmdError::COMMAND_FAILED("Export of " + protocol + + return XrlCmdError::COMMAND_FAILED("Export of " + protocol + " failed: " + e.str()); } @@ -303,7 +303,7 @@ XrlPolicyTarget::policy_0_1_add_varmap(const string& protocol, try { _policy_target.add_varmap(protocol, variable, type, access, id); } catch(const PolicyException& e) { - return XrlCmdError::COMMAND_FAILED("Adding varmap failed for protocol: " + return XrlCmdError::COMMAND_FAILED("Adding varmap failed for protocol: " + protocol + " var: " + variable + " :" + e.str()); } @@ -312,17 +312,17 @@ XrlPolicyTarget::policy_0_1_add_varmap(const string& protocol, } -XrlCmdError +XrlCmdError XrlPolicyTarget::policy_0_1_dump_state(const uint32_t& id, string& state) { try { state = _policy_target.dump_state(id); } catch(const PolicyException& e) { - return XrlCmdError::COMMAND_FAILED("Unable to dump state, id: " + return XrlCmdError::COMMAND_FAILED("Unable to dump state, id: " + to_str(id)); } return XrlCmdError::OKAY(); -} +} XrlCmdError XrlPolicyTarget::policy_0_1_set_proto_target(const string& protocol, @@ -333,7 +333,7 @@ XrlPolicyTarget::policy_0_1_set_proto_target(const string& protocol, } -XrlCmdError +XrlCmdError XrlPolicyTarget::finder_event_observer_0_1_xrl_target_birth( const string& target_class, const string& target_instance) @@ -341,15 +341,15 @@ XrlPolicyTarget::finder_event_observer_0_1_xrl_target_birth( try { _policy_target.birth(target_class,target_instance); } catch(const PolicyException& e) { - return XrlCmdError::COMMAND_FAILED("Birth announce of " + + return XrlCmdError::COMMAND_FAILED("Birth announce of " + target_class + " failed: " + e.str()); } return XrlCmdError::OKAY(); -} +} -XrlCmdError +XrlCmdError XrlPolicyTarget::finder_event_observer_0_1_xrl_target_death( const string& target_class, const string& target_instance) @@ -357,13 +357,13 @@ XrlPolicyTarget::finder_event_observer_0_1_xrl_target_death( try { _policy_target.death(target_class,target_instance); } catch(const PolicyException& e) { - return XrlCmdError::COMMAND_FAILED("Death announce of " + + return XrlCmdError::COMMAND_FAILED("Death announce of " + target_class + " failed: " + e.str()); } return XrlCmdError::OKAY(); -} +} XrlCmdError XrlPolicyTarget::cli_processor_0_1_process_command( diff --git a/xorp/rib/rib_manager.cc b/xorp/rib/rib_manager.cc index a8fc052..1fe8c0f 100644 --- a/xorp/rib/rib_manager.cc +++ b/xorp/rib/rib_manager.cc @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -164,7 +164,7 @@ RibManager::status_updater() return ret; } - + template static int add_rib_vif(RIB& rib, const string& vifname, const Vif& vif, string& err) @@ -225,7 +225,7 @@ RibManager::delete_vif(const string& vifname, string& err) ); } - + template static int set_rib_vif_flags(RIB& rib, const string& vifname, bool is_p2p, @@ -267,7 +267,7 @@ RibManager::set_vif_flags(const string& vifname, return XORP_OK; } - + template int add_vif_address_to_ribs(RIB& urib, @@ -330,7 +330,7 @@ RibManager::delete_vif_address(const string& vifn, return delete_vif_address_from_ribs(_urib4, _mrib4, vifn, addr, err); } - + void RibManager::make_errors_fatal() { @@ -484,7 +484,7 @@ redist_enable_xrl_output(EventLoop& eventloop, cookie) ); } else { - redist->set_output(new RedistXrlOutput(redist, rtr, + redist->set_output(new RedistXrlOutput(redist, rtr, profile, protocol, to_xrl_target, @@ -585,7 +585,7 @@ RibManager::push_routes() _urib4.push_routes(); _mrib4.push_routes(); #ifdef HAVE_IPV6 - _urib6.push_routes(); + _urib6.push_routes(); _mrib6.push_routes(); #endif } @@ -607,7 +607,7 @@ RibManager::insert_policy_redist_tags(const string& protocol, const PolicyTags& tags) { _policy_redist_map.insert(protocol, tags); -} +} void RibManager::reset_policy_redist_tags() diff --git a/xorp/rib/rib_manager.hh b/xorp/rib/rib_manager.hh index b5ec3de..c3bdcfe 100644 --- a/xorp/rib/rib_manager.hh +++ b/xorp/rib/rib_manager.hh @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -128,7 +128,7 @@ public: /** * Set the vif flags of a configured vif. - * + * * @param vifname the name of the vif. * @param is_pim_register true if the vif is a PIM Register interface. * @param is_p2p true if the vif is point-to-point interface. @@ -329,7 +329,7 @@ public: * @param protocol Destination protocol for redistribution. * @param tags Policy-tags of routes which need to be redistributed. */ - void insert_policy_redist_tags(const string& protocol, + void insert_policy_redist_tags(const string& protocol, const PolicyTags& tags); /** diff --git a/xorp/rib/xrl_target.hh b/xorp/rib/xrl_target.hh index 4e16872..ce39eae 100644 --- a/xorp/rib/xrl_target.hh +++ b/xorp/rib/xrl_target.hh @@ -8,13 +8,13 @@ // 1991 as published by the Free Software Foundation. Redistribution // and/or modification of this program under the terms of any other // version of the GNU General Public License is not permitted. -// +// // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, // see the GNU General Public License, Version 2, a copy of which can be // found in the XORP LICENSE.gpl file. -// +// // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; // http://xorp.net @@ -594,7 +594,7 @@ protected: // Input values, const uint32_t& filter, const string& conf); - + /** * Reset a policy filter. * @@ -609,7 +609,7 @@ protected: */ XrlCmdError policy_backend_0_1_push_routes(); - + /** * Redistribute to a protocol based on policy-tags. * -- 1.7.5.4 From igorm at etf.rs Wed Apr 11 09:26:21 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 11 Apr 2012 18:26:21 +0200 Subject: [Xorp-hackers] [PATCH 5/5] xorp: policy: common: Strip ws from string when creating list of strings In-Reply-To: <1334161582-13443-1-git-send-email-igorm@etf.rs> References: <1334161582-13443-1-git-send-email-igorm@etf.rs> Message-ID: <1334161582-13443-5-git-send-email-igorm@etf.rs> From: Igor Maravic Strip ws from string, so in export/import statements we could write ws betwen "," and policy name. Signed-off-by: Igor Maravic --- xorp/policy/common/policy_utils.cc | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/xorp/policy/common/policy_utils.cc b/xorp/policy/common/policy_utils.cc index 92d105f..2536868 100644 --- a/xorp/policy/common/policy_utils.cc +++ b/xorp/policy/common/policy_utils.cc @@ -39,28 +39,38 @@ namespace policy_utils { void +strip_ws(string& in) +{ + in.erase(std::remove_if(in.begin(), in.end(), (int(*)(int))isspace), in.end()); +} + +void str_to_list(const string& in, list& out) { string::size_type pos1 = 0; // beginning of token - string::size_type pos2 = 0; // end of token - string::size_type len = in.length(); + string::size_type pos2 = 0; // end of token + + string in_copy(in); + strip_ws(in_copy); + + string::size_type len = in_copy.length(); string token; while(pos1 < len) { // find delimiter - pos2 = in.find(",",pos1); + pos2 = in_copy.find(",",pos1); // none found, so treat end of string as delim if(pos2 == string::npos) { - token = in.substr(pos1,len-pos1); + token = in_copy.substr(pos1,len-pos1); out.push_back(token); return; } // grab token [delimiter found]. - token = in.substr(pos1,pos2-pos1); + token = in_copy.substr(pos1,pos2-pos1); out.push_back(token); pos1 = pos2+1; } -- 1.7.5.4 From igorm at etf.rs Wed Apr 11 09:26:19 2012 From: igorm at etf.rs (igorm at etf.rs) Date: Wed, 11 Apr 2012 18:26:19 +0200 Subject: [Xorp-hackers] [PATCH 3/5] xorp: policy: Remove tags from _protocol_tags when removing tags from _tagmap In-Reply-To: <1334161582-13443-1-git-send-email-igorm@etf.rs> References: <1334161582-13443-1-git-send-email-igorm@etf.rs> Message-ID: <1334161582-13443-3-git-send-email-igorm@etf.rs> From: Igor Maravic If we don't remove them here they're just going to pile up. Signed-off-by: Igor Maravic --- xorp/policy/configuration.cc | 32 ++++++++++++++++++++++++++++++-- xorp/policy/configuration.hh | 7 +++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/xorp/policy/configuration.cc b/xorp/policy/configuration.cc index a0e951e..d6736bc 100644 --- a/xorp/policy/configuration.cc +++ b/xorp/policy/configuration.cc @@ -189,10 +189,11 @@ Configuration::update_exports(const string& protocol, TagMap::iterator i = _tagmap.find(protocol); if(i != _tagmap.end()) { TagSet* ts = (*i).second; + _tagmap.erase(i); - delete ts; + clear_protocol_tags(*ts); - _tagmap.erase(i); + delete ts; } update_ie(protocol, exports, _exports, PolicyList::EXPORT, mod); @@ -203,6 +204,33 @@ Configuration::update_exports(const string& protocol, } void +Configuration::clear_protocol_tags(const TagSet& ts) +{ + // check if some ts element already exists in _tagmap + // if they do, don't remove them from the _protocol_tags + TagSet::const_iterator ts_iter; + for (ts_iter = ts.begin(); ts_iter != ts.end(); ts_iter++) { + bool skip = false; + + for (TagMap::const_iterator iter = _tagmap.begin(); iter != _tagmap.end(); ++iter) { + if (iter->second->find(*ts_iter) != iter->second->end()) { + skip = true; + break; + } + } + + if (!skip) { + map >::iterator pt_iter; + for (pt_iter = _protocol_tags.begin(); pt_iter != _protocol_tags.end(); pt_iter++) { + pt_iter->second.erase(*ts_iter); + if (pt_iter->second.empty()) + _protocol_tags.erase(pt_iter); + } + } + } +} + +void Configuration::clear_imports(const string& protocol) { // check if protocol exists diff --git a/xorp/policy/configuration.hh b/xorp/policy/configuration.hh index 3b5ffc3..61f474f 100644 --- a/xorp/policy/configuration.hh +++ b/xorp/policy/configuration.hh @@ -318,6 +318,13 @@ public: */ string dump_state(uint32_t id); + /** + * Clear tags specified with ts from _protocol_tags + * + * @param ts tags to erase from _protocol_tags + */ + void clear_protocol_tags(const TagSet& ts); + void clear_imports(const string& protocol); void clear_exports(const string& protocol); bool test_policy(const string& policy, const RATTR& attrs, RATTR& mods); -- 1.7.5.4 From mass3mass at gmail.com Wed Apr 11 14:28:26 2012 From: mass3mass at gmail.com (MAS .) Date: Wed, 11 Apr 2012 21:28:26 +0000 Subject: [Xorp-hackers] XORP : Embedded Platform Software requirements Message-ID: Hi all, I have compiled XORP and installed on x86 machine then its working fine. But I need to put it on embedded board with ARM processor so I cross-compiled it and put it on the board. Now problem is that its not working fine, even its not printing any error messages on terminal. I don't know what is wrong. Can anyone help me. Is there any software package requirements i.e. do I need to install any softwares on board in order to XORP to work? Basically my board only has Linux running on it without any spacial packages. Thanks and regards, MAS -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120411/7b6b4556/attachment.html From mass3mass at gmail.com Wed Apr 11 15:11:48 2012 From: mass3mass at gmail.com (MAS .) Date: Wed, 11 Apr 2012 22:11:48 +0000 Subject: [Xorp-hackers] [Xorp-users] XORP : Embedded Platform Software requirements In-Reply-To: <20120411215254.GF19718@excalibur.hozed.org> References: <20120411215254.GF19718@excalibur.hozed.org> Message-ID: Hi Thanks for the reply Troy, I am student and we have designed ARM board with marvell switch chip 88E6065 in our lab. Actually I want to manage L2 functionality of switch chip using XorPlus, which is another derivative of XORP with L2 functionality. Board has Linux-2.6.30 kernel version running on it and Uboot-1.3.4.. we also have gcc, gdb nothing more. I cross-compiled Xorplus and put it on the board but its literally doing nothing, no logs, no error messages. Same XorPlus is running fine on x86 machine. For trial purpose I executed xorp_rtrmgr on x86 and board without any configuration. On x86 machine atleast its printing error messages but on board its doing nothing? I thought may be xorp needed some packages other than xorp libreary. thanks and regards, MAS. On 11 April 2012 21:52, Troy Benjegerdes wrote: > This would probably depend on what embedded linux distribution the > board is running and what board it is, and how you cross-compiled > the package. > > If you can give us more details, we might be able to help. > > I'm going to attempt to build it on my debian-arm install, > and see what happens. > > If you have some constraints (or ndas) so you can't provide more > details about what board and distro, there are probably several > of us (including myself) that would be happy to do a consulting > contract to help you out as well. > > On Wed, Apr 11, 2012 at 09:28:26PM +0000, MAS . wrote: > > Hi all, > > > > I have compiled XORP and installed on x86 machine then its working fine. > > But I need to put it on embedded board with ARM processor so I > > cross-compiled it and put it on the board. > > > > Now problem is that its not working fine, even its not printing any error > > messages on terminal. I don't know what is wrong. Can anyone help me. Is > > there any software package requirements i.e. do I need to install > > any softwares on board in order to XORP to work? Basically my board only > > has Linux running on it without any spacial packages. > > > > > > Thanks and regards, > > MAS > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mailman.ICSI.Berkeley.EDU/pipermail/xorp-hackers/attachments/20120411/5b983957/attachment.html From noreply at github.com Thu Apr 12 10:55:41 2012 From: noreply at github.com (GitHub) Date: Thu, 12 Apr 2012 10:55:41 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] f55e0e: trivial: ws fixes Message-ID: <4f87171dea968_3ec23fd60b43aaf010787c@sh1.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: f55e0e26f32e736b4a2b58eb9d94a3eb6e418c41 https://github.com/greearb/xorp.ct/commit/f55e0e26f32e736b4a2b58eb9d94a3eb6e418c41 Author: Igor Maravic Date: 2012-04-12 (Thu, 12 Apr 2012) Changed paths: M xorp/policy/backend/policy_redist_map.hh M xorp/policy/common/policy_utils.cc M xorp/policy/configuration.hh M xorp/policy/policy_target.cc M xorp/policy/process_watch.cc M xorp/policy/xrl_target.cc M xorp/rib/rib_manager.cc M xorp/rib/rib_manager.hh M xorp/rib/xrl_target.hh Log Message: ----------- trivial: ws fixes Signed-off-by: Igor Maravic Commit: e2e485a1f4776b0fdad94bd14891488a5ec31117 https://github.com/greearb/xorp.ct/commit/e2e485a1f4776b0fdad94bd14891488a5ec31117 Author: Igor Maravic Date: 2012-04-12 (Thu, 12 Apr 2012) Changed paths: M xorp/policy/policy_target.cc Log Message: ----------- xorp: policy: Fix behaviour on protocol death When protocol dies clear export and import protocol policies just like the user deleted them manually. Old way crashed XORP when protocol was deleted, and then re-added with new export/import policies. Signed-off-by: Igor Maravic Commit: 099fe362c5786b339bbbe6691c4da2a71a822ab8 https://github.com/greearb/xorp.ct/commit/099fe362c5786b339bbbe6691c4da2a71a822ab8 Author: Igor Maravic Date: 2012-04-12 (Thu, 12 Apr 2012) Changed paths: M xorp/policy/configuration.cc M xorp/policy/configuration.hh Log Message: ----------- xorp: policy: Remove tags from _protocol_tags when removing tags from _tagmap If we don't remove them here they're just going to pile up. Signed-off-by: Igor Maravic Commit: eaee556718a8955fcb23acd851b163dbc48f729e https://github.com/greearb/xorp.ct/commit/eaee556718a8955fcb23acd851b163dbc48f729e Author: Igor Maravic Date: 2012-04-12 (Thu, 12 Apr 2012) Changed paths: M xorp/policy/backend/policy_redist_map.cc M xorp/policy/backend/policy_redist_map.hh M xorp/policy/filter_manager.cc M xorp/rib/rib_manager.cc M xorp/rib/rib_manager.hh M xorp/rib/xrl_target.cc M xorp/rib/xrl_target.hh M xorp/xrl/interfaces/rib.xif Log Message: ----------- xorp: Remove protocol's tags from rib when it dies Added new function in rib.xif to enable that. FilterManager calls it when protocol dies. >From rib's tag map, all protocol's tags are removed. Signed-off-by: Igor Maravic Commit: 08cde50c77260ecfa38aaa3c3b529f323d4e7246 https://github.com/greearb/xorp.ct/commit/08cde50c77260ecfa38aaa3c3b529f323d4e7246 Author: Igor Maravic Date: 2012-04-12 (Thu, 12 Apr 2012) Changed paths: M xorp/policy/common/policy_utils.cc Log Message: ----------- xorp: policy: common: Strip ws from string when creating list of strings Strip ws from string, so in export/import statements we could write ws betwen "," and policy name. Signed-off-by: Igor Maravic Compare: https://github.com/greearb/xorp.ct/compare/a67f53b...08cde50 From noreply at github.com Fri Apr 27 15:03:33 2012 From: noreply at github.com (GitHub) Date: Fri, 27 Apr 2012 15:03:33 -0700 Subject: [Xorp-hackers] [greearb/xorp.ct] 393967: Update LF version in .deb makefile. Message-ID: <4f9b17b52f3f2_41461ba2aec82970@sh3.rs.github.com.mail> Branch: refs/heads/master Home: https://github.com/greearb/xorp.ct Commit: 39396757ad54ab62f8dfce316bf6a9fd615a2977 https://github.com/greearb/xorp.ct/commit/39396757ad54ab62f8dfce316bf6a9fd615a2977 Author: Ben Greear Date: 2012-04-27 (Fri, 27 Apr 2012) Changed paths: M xorp/Makefile.deb Log Message: ----------- Update LF version in .deb makefile. From esj at cs.fiu.edu Fri Apr 27 15:42:12 2012 From: esj at cs.fiu.edu (Eric S. Johnson) Date: Fri, 27 Apr 2012 18:42:12 -0400 Subject: [Xorp-hackers] ospfv3 for IPv6 ospf - oddity Message-ID: <20120427224212.6432F3680006@cheetah.cs.fiu.edu> I started playing vith ospf for v6 recently. I have noticed an oddity. I am curious if I have something miss-configured or I have found a bug. OSPFv3 for ipv6 has a couple new link-state adv types. The one I am running into interoperability issues with is the Intra-area prefix type. It appears that xorp is sending these out with a cost of zero. No matter what the config file cost setting is. This causes all the other ospf3 impelmentations it talks to (well, ok, cisco IOS and quagga are the only ones I have tested) to count the cost to that network as zero. xorp sends the ole fashioned router lsa's with the appropriate costs. But not the new fangled intra-area prefix costs. xorp also seems to send a /128 IA prefix LSA with the address of the interface also with metric of 0. This doesn't impact things as much as the network prefixs being 0, but seems odd too. I have verified with wireshark that it is sending the IA prefix lsa's with cost 0. Below are relavant snips of my configs. Xorp showing this behavior is 1.8.5 and git pulled on 2012-04-19 Running on centos 5.6 (RHEL 5). Linux test-router 2.6.18-164.6.1.el5 #1 SMP Tue Nov 3 16:18:27 EST 2009 i686 i686 i386 GNU/Linux Am I missing something? Or is this a bug? E -- ospf6 0 { ip-router-alert: false area 0.0.0.1 { area-type: "normal" interface "eth0.16" { link-type: "broadcast" vif "eth0.16" { priority: 128 hello-interval: 10 router-dead-interval: 40 interface-cost: 70 retransmit-interval: 5 transit-delay: 1 passive: false disable: false } } interface "eth0.2128" { link-type: "broadcast" vif "eth0.2128" { priority: 128 hello-interval: 10 router-dead-interval: 40 interface-cost: 70 retransmit-interval: 5 transit-delay: 1 passive: false disable: false } } } } interface "eth0.16" { description: "" disable: false discard: false unreachable: false management: false vif "eth0.16" { disable: false address fe80::206:5bff:fe88:84c6 { prefix-length: 64 disable: false } address 2001:468:701:4000::5 { prefix-length: 64 disable: false } } } interface "eth0.2128" { description: "" disable: false discard: false unreachable: false management: false vif "eth0.2128" { disable: false address fe80::206:5bff:fe88:84c6 { prefix-length: 64 disable: false } address 2001:468:701:4001:206:5bff:fe88:84c6 { prefix-length: 64 disable: false } } }