|
From: <pra...@or...> - 2015-01-23 09:00:39
|
osaf/services/saf/amf/amfd/csi.cc | 15 +++++++++------
osaf/services/saf/amf/amfd/si.cc | 19 ++++++++++++++++++-
2 files changed, 27 insertions(+), 7 deletions(-)
AMFD crashes when a user to tries to modify si rank and csi deps
with empty values.
Patch fixes issues by:
1)Reverting to the default value for SI rank.
2)By returning BAD_OPERATION for csi deps.
diff --git a/osaf/services/saf/amf/amfd/csi.cc b/osaf/services/saf/amf/amfd/csi.cc
--- a/osaf/services/saf/amf/amfd/csi.cc
+++ b/osaf/services/saf/amf/amfd/csi.cc
@@ -564,6 +564,14 @@ static SaAisErrorT csi_ccb_completed_mod
goto done;
}
} else if (!strcmp(attr_mod->modAttr.attrName, "saAmfCSIDependencies")) {
+ //Reject replacement of CSI deps, only deletion and addition are supported.
+ if (attr_mod->modType == SA_IMM_ATTR_VALUES_REPLACE) {
+ report_ccb_validation_error(opdata,
+ "'%s' - replacement of CSI dependency is not supported",
+ opdata->objectName.value);
+ goto done;
+
+ }
const SaNameT *required_dn = (SaNameT*) attr_mod->modAttr.attrValues[0];
const AVD_CSI *required_csi = csi_db->find(Amf::to_string(required_dn));
@@ -626,12 +634,7 @@ static SaAisErrorT csi_ccb_completed_mod
report_ccb_validation_error(opdata, "only one dep can be removed at a time");
goto done;
}
- } else {
- report_ccb_validation_error(opdata,
- "'%s' - change of CSI dependency is not supported",
- opdata->objectName.value);
- goto done;
- }
+ }
} else {
report_ccb_validation_error(opdata, "Modification of attribute '%s' not supported",
attr_mod->modAttr.attrName);
diff --git a/osaf/services/saf/amf/amfd/si.cc b/osaf/services/saf/amf/amfd/si.cc
--- a/osaf/services/saf/amf/amfd/si.cc
+++ b/osaf/services/saf/amf/amfd/si.cc
@@ -713,6 +713,7 @@ static SaAisErrorT si_ccb_completed_modi
AVD_SI *si;
const SaImmAttrModificationT_2 *attr_mod;
int i = 0;
+ bool value_is_deleted;
TRACE_ENTER2("CCB ID %llu, '%s'", opdata->ccbId, opdata->objectName.value);
@@ -722,6 +723,16 @@ static SaAisErrorT si_ccb_completed_modi
/* Modifications can only be done for these attributes. */
while ((attr_mod = opdata->param.modify.attrMods[i++]) != NULL) {
const SaImmAttrValuesT_2 *attribute = &attr_mod->modAttr;
+ //void *value = NULL;
+
+ if ((attr_mod->modType == SA_IMM_ATTR_VALUES_DELETE) || (attribute->attrValues == NULL)) {
+ /* Attribute value is deleted, revert to default value */
+ value_is_deleted = true;
+ } else {
+ /* Attribute value is modified */
+ value_is_deleted = false;
+ //value = attribute->attrValues[0];
+ }
if (!strcmp(attribute->attrName, "saAmfSIPrefActiveAssignments")) {
if (si->sg_of_si->sg_fsm_state != AVD_SG_FSM_STABLE) {
@@ -751,6 +762,9 @@ static SaAisErrorT si_ccb_completed_modi
break;
}
} else if (!strcmp(attribute->attrName, "saAmfSIRank")) {
+ if (value_is_deleted == true)
+ continue;
+
SaUint32T sirank = *(SaUint32T*)attribute->attrValues[0];
if (si->saAmfSIRank == (sirank == 0 ? ~0U : sirank)) {
@@ -1178,7 +1192,10 @@ static void si_ccb_apply_modify_hdlr(Ccb
TRACE("Modified saAmfSINumCurrStandbyAssignments is '%u'", si->saAmfSINumCurrStandbyAssignments);
si->update_ass_state();
} else if (!strcmp(attribute->attrName, "saAmfSIRank")) {
- si->update_sirank(*((SaUint32T *)attr_mod->modAttr.attrValues[0]));
+ if (value_is_deleted == true)
+ si->update_sirank(0);
+ else
+ si->update_sirank(*((SaUint32T *)attr_mod->modAttr.attrValues[0]));
TRACE("Modified saAmfSIRank is '%u'", si->saAmfSIRank);
} else {
osafassert(0);
|