osaf/services/saf/amf/amfd/nodegroup.cc | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-)
At present a node can be added in a nodegroup many times. AMF is not checking if node is already present in saAmfNGNodeList of nodegroup and hence not rejecting the ccb operation. Patch adds to check to avoid duplicate addition of a node in a nodegroup. diff --git a/osaf/services/saf/amf/amfd/nodegroup.cc b/osaf/services/saf/amf/amfd/nodegroup.cc --- a/osaf/services/saf/amf/amfd/nodegroup.cc +++ b/osaf/services/saf/amf/amfd/nodegroup.cc @@ -24,6 +24,7 @@ #include <imm.h> AmfDb<std::string, AVD_AMF_NG> *nodegroup_db = 0; +static AVD_AMF_NG *ng_create(SaNameT *dn, const SaImmAttrValuesT_2 **attributes); /** * Lookup object in db using dn @@ -86,6 +87,29 @@ static int is_config_valid(const SaNameT } } + /* Check for duplicate entries in nodelist of this nodegroup at the time of + creation of nodegroup. This check is applicable: + -when AMFD is reading the configuration from IMM at OpenSAF start or + -nodegroup creation using CCB operation. + */ + + AVD_AMF_NG *tmp_ng = ng_create((SaNameT *)dn, attributes); + if (tmp_ng == NULL) + return 0; + for (uint32_t i = 0; i<tmp_ng->number_nodes; i++) { + int duplicate = 0; + for (uint32_t j = 0; j<tmp_ng->number_nodes; j++) { + if (memcmp(&tmp_ng->saAmfNGNodeList[i].value, &tmp_ng->saAmfNGNodeList[j].value, + tmp_ng->saAmfNGNodeList[i].length) == 0) + duplicate++; + } + if (duplicate > 1) { + LOG_ER("Duplicate nodes in saAmfNGNodeList of '%s'",tmp_ng->name.value); + delete tmp_ng; + return 0; + } + } + delete tmp_ng; return 1; } @@ -351,6 +375,15 @@ static SaAisErrorT ng_ccb_completed_modi TRACE("ADD %s", ((SaNameT *)mod->modAttr.attrValues[j])->value); } + + for (j = 0; j < mod->modAttr.attrValuesNumber; j++) { + if (node_in_nodegroup((SaNameT *)mod->modAttr.attrValues[j], ng) == true) { + report_ccb_validation_error(opdata, "'%s' already exists in" + " the nodegroup", + ((SaNameT *)mod->modAttr.attrValues[j])->value); + goto done; + } + } } } ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel