Hi Thang,

See my comment inline.

Best Regards,
ThuanTr

-----Original Message-----
From: thang.nguyen <[email protected]> 
Sent: Thursday, December 6, 2018 2:36 AM
To: [email protected]; [email protected]
Cc: [email protected]
Subject: [devel] [PATCH 1/1] amf: disallow delete csi that another csi is
dependent on [#2969]

Disallow delete a csi that another csi is dependent on. If allowing it
caused AMFD crashed or fallen in cyclic restart.
Allow if csi(s) are deleted in same ccb.
---
 src/amf/amfd/csi.cc | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/amf/amfd/csi.cc b/src/amf/amfd/csi.cc index
8282956..0a6c964 100644
--- a/src/amf/amfd/csi.cc
+++ b/src/amf/amfd/csi.cc
@@ -783,6 +783,7 @@ static SaAisErrorT csi_ccb_completed_delete_hdlr(
     CcbUtilOperationData_t *opdata) {
   SaAisErrorT rc = SA_AIS_ERR_BAD_OPERATION;
   AVD_CSI *csi;
+  AVD_CSI *t_csi;
   AVD_SU_SI_REL *t_sisu;
   const std::string object_name(Amf::to_string(&opdata->objectName));
 
@@ -851,6 +852,28 @@ static SaAisErrorT csi_ccb_completed_delete_hdlr(
     }
   }
 
+  t_csi = csi->si->list_of_csi;
+
+  while (t_csi) {
+    AVD_CSI_DEPS *csidep;
+    /* Verify that there are no CSI dependencies to this CSI  */
+    for (csidep = t_csi->saAmfCSIDependencies; csidep != nullptr;
+         csidep = csidep->csi_dep_next) {
+      if (csidep->csi_dep_name_value.compare(csi->name) == 0) {
+        SaNameT csidepDn;
+        osaf_extended_name_lend(csidep->csi_dep_name_value.c_str(),
&csidepDn);
+        if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &csidepDn) == nullptr)
{
[Thuan] in case of NOT null, we should check operation type is NOT "delete"
to reject this CCB. Because if both CSIs delete in same CCB, it should be
OK.
+          report_ccb_validation_error(
+                  opdata, "csi '%s' depends on  '%s'",
+                  t_csi->name.c_str(), csi->name.c_str());
+          rc = SA_AIS_ERR_BAD_OPERATION;
+          goto done;
+        }
+      }
+    }
+    t_csi = t_csi->si_list_of_csi_next;  } /*  while(t_csi) */
+
   rc = SA_AIS_OK;
   opdata->userData = csi; /* Save for later use in apply */
 done:
--
2.7.4



_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel



_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to