---
 src/amf/amfnd/avnd_comp.h |  16 +---
 src/amf/amfnd/avnd_err.h  |   6 +-
 src/amf/amfnd/avnd_su.h   | 119 ++++++++++++--------------
 src/amf/amfnd/avnd_tmr.h  |  10 +--
 src/amf/amfnd/avnd_util.h |   3 +
 src/amf/amfnd/clc.cc      |   7 +-
 src/amf/amfnd/comp.cc     |   4 +-
 src/amf/amfnd/compdb.cc   |  32 ++-----
 src/amf/amfnd/err.cc      |  29 ++-----
 src/amf/amfnd/su.cc       | 100 ++++++++++++----------
 src/amf/amfnd/sudb.cc     |  30 ++-----
 src/amf/amfnd/susm.cc     | 206 +++++++++++++++-------------------------------
 src/amf/amfnd/tmr.cc      |   6 +-
 src/amf/amfnd/util.cc     |  10 +++
 14 files changed, 221 insertions(+), 357 deletions(-)

diff --git a/src/amf/amfnd/avnd_comp.h b/src/amf/amfnd/avnd_comp.h
index 68de4cc8e..a2fc22691 100644
--- a/src/amf/amfnd/avnd_comp.h
+++ b/src/amf/amfnd/avnd_comp.h
@@ -36,7 +36,7 @@
 
 struct avnd_cb_tag;
 struct avnd_su_si_rec;
-struct avnd_su_tag;
+class AVND_SU;
 struct avnd_srm_req_tag;
 
 /***************************************************************************
@@ -323,9 +323,6 @@ enum UsedComptypeAttrs {
 
 class AVND_COMP {
  public:
-  // TODO(uabhano) replace the NCS_DB_LINK_LIST_NODE with C++ STL. Now 
su_dll_node must be first in AVND_COMP
-  // as the macro m_AVND_COMP_SU_DLL_NODE_OFFSET depends on the offset. 
offsetof is to be avoided in classes.
-  NCS_DB_LINK_LIST_NODE su_dll_node {}; /* su dll node (key is inst-level) */
   AVND_COMP() {}
   ~AVND_COMP() {}
 
@@ -386,7 +383,7 @@ class AVND_COMP {
 
   NCS_DB_LINK_LIST csi_list {}; /* csi list */
 
-  struct avnd_su_tag *su {}; /* back ptr to parent SU */
+  AVND_SU *su {}; /* back ptr to parent SU */
 
   AVND_COMP *pxy_comp {}; /* ptr to the proxy comp (if any) */
 
@@ -627,13 +624,6 @@ class AVND_COMP {
 /* macro to determine if the pre-configured proxied comp has any proxy comp */
 #define m_AVND_COMP_IS_PROXIED(x) ((x)->proxy_comp)
 
-/* macro to retrieve component ptr from su dll node ptr */
-/* TODO(uabhano) remove these macros */
-#define m_AVND_COMP_SU_DLL_NODE_OFFSET 0
-
-#define m_AVND_COMP_FROM_SU_DLL_NODE_GET(x) \
-  ((x) ? ((AVND_COMP *)(((uint8_t *)(x)) - m_AVND_COMP_SU_DLL_NODE_OFFSET)) : 
0)
-
 /* macro to retrieve csi ptr from comp-csi dll node ptr */
 #define m_AVND_CSI_COMP_DLL_NODE_OFFSET                  \
   ((uint8_t *)&(AVND_COMP_CSI_REC_NULL->comp_dll_node) - \
@@ -987,7 +977,7 @@ extern uint32_t avnd_comp_oper_req(struct avnd_cb_tag *cb,
                                    AVSV_PARAM_INFO *param);
 extern uint32_t avnd_comptype_oper_req(struct avnd_cb_tag *cb,
                                        AVSV_PARAM_INFO *param);
-extern unsigned int avnd_comp_config_get_su(struct avnd_su_tag *su);
+extern unsigned int avnd_comp_config_get_su(AVND_SU *su);
 extern int avnd_comp_config_reinit(AVND_COMP *comp);
 extern void avnd_comp_delete(AVND_COMP *comp);
 extern void avnd_comp_pres_state_set(const struct avnd_cb_tag *cb,
diff --git a/src/amf/amfnd/avnd_err.h b/src/amf/amfnd/avnd_err.h
index 17e236d80..76f968927 100644
--- a/src/amf/amfnd/avnd_err.h
+++ b/src/amf/amfnd/avnd_err.h
@@ -114,11 +114,11 @@ typedef struct avnd_err_tag {
 
 struct avnd_cb_tag;
 class AVND_COMP;
-struct avnd_su_tag;
+class AVND_SU;
 
 extern uint32_t avnd_err_process(struct avnd_cb_tag *, AVND_COMP *,
                                  AVND_ERR_INFO *);
-extern uint32_t avnd_err_su_repair(struct avnd_cb_tag *, struct avnd_su_tag *);
-extern bool is_no_assignment_due_to_escalations(struct avnd_su_tag *);
+extern uint32_t avnd_err_su_repair(struct avnd_cb_tag *, AVND_SU *);
+extern bool is_no_assignment_due_to_escalations(AVND_SU *);
 
 #endif  // AMF_AMFND_AVND_ERR_H_
diff --git a/src/amf/amfnd/avnd_su.h b/src/amf/amfnd/avnd_su.h
index 69124ed95..c7ba25718 100644
--- a/src/amf/amfnd/avnd_su.h
+++ b/src/amf/amfnd/avnd_su.h
@@ -34,6 +34,12 @@
 #ifndef AMF_AMFND_AVND_SU_H_
 #define AMF_AMFND_AVND_SU_H_
 
+#include <vector>
+#include <algorithm>
+
+#include "avnd_comp.h"
+#include "avnd_util.h"
+
 struct avnd_cb_tag;
 
 /***************************************************************************
@@ -53,7 +59,7 @@ typedef AVSV_D2N_COMPCSI_ASSIGN_MSG_INFO 
AVND_COMP_CSI_PARAMS_INFO;
 
 /* declaration clc event handler */
 typedef uint32_t (*AVND_SU_PRES_FSM_FN)(struct avnd_cb_tag *,
-                                        struct avnd_su_tag *, AVND_COMP *);
+                                        AVND_SU *, AVND_COMP *);
 
 /* su presence state fsm events */
 typedef enum avnd_su_pres_fsm_ev {
@@ -97,7 +103,7 @@ typedef struct avnd_su_si_rec {
   NCS_DB_LINK_LIST csi_list; /* ordered csi list (based on csi rank) */
 
   /* links to other entities */
-  struct avnd_su_tag *su;                 /* bk ptr to su */
+  AVND_SU *su;                 /* bk ptr to su */
   std::string su_name;                    /* For checkpointing su name */
   AVSV_SUSI_ACT single_csi_add_rem_in_si; /* To detect whether single csi
                                              addition/removal is going on.*/
@@ -115,37 +121,40 @@ typedef struct avnd_su_siq_rec {
 
 typedef AVSV_SU_INFO_MSG AVND_SU_PARAM;
 
-typedef struct avnd_su_tag {
-  std::string name; /* su name */
+class AVND_SU {
+ public:
+  AVND_SU() {}
+  ~AVND_SU() {}
+  std::string name {}; /* su name */
 
-  uint32_t su_hdl; /* hdl returned by hdl-mngr */
+  uint32_t su_hdl {}; /* hdl returned by hdl-mngr */
 
   /* su attributes */
-  uint32_t flag; /* su attributes */
+  uint32_t flag {}; /* su attributes */
 
   /* Update received flag, which will normally be false and will be
    * true if updates are received from the AVD on fail-over.*/
-  bool avd_updt_flag;
+  bool avd_updt_flag {};
 
   /* error recovery escalation params */
-  AVND_ERR_ESC_LEVEL su_err_esc_level; /* curr escalation level of this su */
-  SaTimeT comp_restart_prob; /* comp restart probation period (config) */
-  uint32_t comp_restart_max; /* max comp restart count (config) */
-  SaTimeT su_restart_prob;   /* su restart probation period (config) */
-  uint32_t su_restart_max;   /* max su restart count (config) */
-  uint32_t comp_restart_cnt; /* comp restart counts within comp-prob period */
-  uint32_t su_restart_cnt;   /* su restart counts within su-prob period */
-  AVND_TMR su_err_esc_tmr;   /* su err esc tmr */
+  AVND_ERR_ESC_LEVEL su_err_esc_level {}; /* curr escalation level of this su 
*/
+  SaTimeT comp_restart_prob {}; /* comp restart probation period (config) */
+  uint32_t comp_restart_max {}; /* max comp restart count (config) */
+  SaTimeT su_restart_prob {};   /* su restart probation period (config) */
+  uint32_t su_restart_max {};   /* max su restart count (config) */
+  uint32_t comp_restart_cnt {}; /* comp restart counts within comp-prob period 
*/
+  uint32_t su_restart_cnt {};   /* su restart counts within su-prob period */
+  AVND_TMR su_err_esc_tmr {};   /* su err esc tmr */
 
   /* su states */
-  SaAmfOperationalStateT oper; /* oper state of the su */
-  SaAmfPresenceStateT pres;    /* presence state of the su */
+  SaAmfOperationalStateT oper {}; /* oper state of the su */
+  SaAmfPresenceStateT pres {};    /* presence state of the su */
 
   /* statistical info */
-  uint32_t si_active_cnt;  /* no of active SIs assigned to this su */
-  uint32_t si_standby_cnt; /* no of standby SIs assigned to this su */
+  uint32_t si_active_cnt {};  /* no of active SIs assigned to this su */
+  uint32_t si_standby_cnt {}; /* no of standby SIs assigned to this su */
 
-  std::string suMaintenanceCampaign;
+  std::string suMaintenanceCampaign {};
 
   /*
    * Ordered comp list (based on inst level). Note that as the
@@ -153,22 +162,36 @@ typedef struct avnd_su_tag {
    * comparision (inst-level) are different, only a limited number
    * of DLL APIs can be used.
    */
-  NCS_DB_LINK_LIST comp_list;
+  std::vector<AVND_COMP*> comp_list {};
 
-  NCS_DB_LINK_LIST si_list; /* si list (si-name is the index) */
-  NCS_DB_LINK_LIST siq;     /* susi msg buf (no index) maintains fifo order */
+  NCS_DB_LINK_LIST si_list {}; /* si list (si-name is the index) */
+  NCS_DB_LINK_LIST siq {};     /* susi msg buf (no index) maintains fifo order 
*/
 
   /* To have the knowledge in AvND if this su belongs to NCS_SG */
-  bool is_ncs;
-  bool su_is_external; /*indicates if this SU is external */
+  bool is_ncs {};
+  bool su_is_external {}; /*indicates if this SU is external */
 
   /* To maintain saAmfSUFailover attribute of SU classs at Amfnd. */
-  bool sufailover; /* sufailover is enabled or not for the SU. */
-  SaAmfAdminOperationIdT admin_op_Id;  // flag to track admin operation on su.
+  bool sufailover {}; /* sufailover is enabled or not for the SU. */
+  SaAmfAdminOperationIdT admin_op_Id {};  // flag to track admin operation on 
su.
   bool avnd_su_check_sis_previous_assign_state(
       const AVND_SU_SI_ASSIGN_STATE prev_state) const;
 
-} AVND_SU;
+  // determine if all the comps in an su are operationally enabled
+  bool all_comps_enabled() const;
+
+  // remove a component from the su-comp list
+  void remove_comp(AVND_COMP *comp);
+
+  // determine if all the pi comps in an su are instantiated
+  bool all_pi_comps_instantiated() const;
+
+  void add_comp(AVND_COMP *comp);
+ private:
+  // disallow copy and assign
+  AVND_SU(const AVND_SU&) = delete;
+  void operator=(const AVND_SU&) = delete;
+};
 
 #define AVND_SU_NULL ((AVND_SU *)0)
 
@@ -222,37 +245,6 @@ typedef struct avnd_su_tag {
   ((SA_AMF_OPERATIONAL_DISABLED == (x)->oper))
 #define m_AVND_SU_OPER_STATE_SET(x, val) (((x)->oper = val))
 
-/* macro to determine if all the comps in an su are operationally enabled */
-#define m_AVND_SU_IS_ENABLED(su, is)                      \
-  {                                                       \
-    AVND_COMP *curr = 0;                                  \
-    (is) = true;                                          \
-    for (curr = m_AVND_COMP_FROM_SU_DLL_NODE_GET(         \
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));    \
-         curr && m_AVND_COMP_OPER_STATE_IS_ENABLED(curr); \
-         curr = m_AVND_COMP_FROM_SU_DLL_NODE_GET(         \
-             m_NCS_DBLIST_FIND_NEXT(&curr->su_dll_node))) \
-      ;                                                   \
-    if (curr) (is) = false;                               \
-  }
-
-/* macro to determine if all the pi comps in an su are instantiated */
-#define m_AVND_SU_IS_INSTANTIATED(su, is)                         \
-  {                                                               \
-    AVND_COMP *curr = 0;                                          \
-    (is) = true;                                                  \
-    for (curr = m_AVND_COMP_FROM_SU_DLL_NODE_GET(                 \
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));            \
-         curr; curr = m_AVND_COMP_FROM_SU_DLL_NODE_GET(           \
-                   m_NCS_DBLIST_FIND_NEXT(&curr->su_dll_node))) { \
-      if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr) &&            \
-          !m_AVND_COMP_PRES_STATE_IS_INSTANTIATED(curr)) {        \
-        (is) = false;                                             \
-        break;                                                    \
-      }                                                           \
-    }                                                             \
-  }
-
 /* macros to manage the presence state */
 #define m_AVND_SU_PRES_STATE_IS_INSTANTIATED(x) \
   (SA_AMF_PRESENCE_INSTANTIATED == (x)->pres)
@@ -341,14 +333,6 @@ typedef struct avnd_su_tag {
 
 #define m_AVND_SU_ERR_ESC_LEVEL_SET(x, val) ((x)->su_err_esc_level = (val))
 
-/* macro to add a component to the su-comp list */
-#define m_AVND_SUDB_REC_COMP_ADD(su, comp, rc) \
-  sudb_rec_comp_add(&su, &comp, &rc)
-
-/* macro to remove a component from the su-comp list */
-#define m_AVND_SUDB_REC_COMP_REM(su, comp) \
-  ncs_db_link_list_delink(&(su).comp_list, &(comp).su_dll_node)
-
 /* macro to add a si record to the su-si list */
 #define m_AVND_SUDB_REC_SI_ADD(su, si, rc)                         \
   {                                                                \
@@ -442,7 +426,6 @@ bool su_all_comps_restartable(const AVND_SU &su);
 void su_send_suRestart_recovery_msg(AVND_SU *su);
 bool pi_su_all_comps_uninstantiated(const AVND_SU &su);
 bool is_any_non_restartable_comp_assigned(const AVND_SU &su);
-bool su_all_pi_comps_instantiated(const AVND_SU *su);
 bool all_csis_in_assigned_state(const AVND_SU *su);
 bool isAdminRestarted(const AVND_SU *su);
 bool isFailed(const AVND_SU *su);
diff --git a/src/amf/amfnd/avnd_tmr.h b/src/amf/amfnd/avnd_tmr.h
index 0c0345d43..400b44c70 100644
--- a/src/amf/amfnd/avnd_tmr.h
+++ b/src/amf/amfnd/avnd_tmr.h
@@ -33,7 +33,7 @@
 #include "base/ncssysf_tmr.h"
 
 struct avnd_cb_tag;
-struct avnd_su_tag;
+class AVND_SU;
 
 /* timer type enums */
 typedef enum avnd_tmr_type {
@@ -115,16 +115,16 @@ typedef struct avnd_tmr {
 #define m_AVND_TMR_MSG_RESP_STOP(cb, rec) avnd_stop_tmr((cb), &(rec).resp_tmr);
 
 /* start the component-error-escalation timer */
-uint32_t tmr_comp_err_esc_start(avnd_cb_tag *cb, avnd_su_tag *su);
+uint32_t tmr_comp_err_esc_start(avnd_cb_tag *cb, AVND_SU *su);
 
 /* stop the component-error-escalation timer */
-void tmr_comp_err_esc_stop(avnd_cb_tag *cb, avnd_su_tag *su);
+void tmr_comp_err_esc_stop(avnd_cb_tag *cb, AVND_SU *su);
 
 /* start the su-error-escalation timer */
-uint32_t tmr_su_err_esc_start(avnd_cb_tag *cb, avnd_su_tag *su);
+uint32_t tmr_su_err_esc_start(avnd_cb_tag *cb, AVND_SU *su);
 
 /* stop the su-error-escalation timer */
-void tmr_su_err_esc_stop(avnd_cb_tag *cb, avnd_su_tag *su);
+void tmr_su_err_esc_stop(avnd_cb_tag *cb, AVND_SU *su);
 
 /* start the node-error-escalation timer */
 uint32_t tmr_node_err_esc_start(avnd_cb_tag *cb);
diff --git a/src/amf/amfnd/avnd_util.h b/src/amf/amfnd/avnd_util.h
index f32f448f8..687e69d54 100644
--- a/src/amf/amfnd/avnd_util.h
+++ b/src/amf/amfnd/avnd_util.h
@@ -30,6 +30,8 @@
 #ifndef AMF_AMFND_AVND_UTIL_H_
 #define AMF_AMFND_AVND_UTIL_H_
 
+#include <string>
+
 struct avnd_cb_tag;
 class AVND_COMP;
 enum avnd_comp_clc_cmd_type;
@@ -80,4 +82,5 @@ SaAisErrorT amf_saImmOmAccessorGet_o2(SaImmHandleT &immHandle,
 void amfnd_free_csi_attr_list(AVSV_CSI_ATTRS *attrs);
 void amfnd_copy_csi_attrs(AVSV_CSI_ATTRS *src_attrs,
                           AVSV_CSI_ATTRS *dest_attrs);
+int compare_sanamet(const std::string &lhs, const std::string &rhs);
 #endif  // AMF_AMFND_AVND_UTIL_H_
diff --git a/src/amf/amfnd/clc.cc b/src/amf/amfnd/clc.cc
index 13c9af614..b6db14ac8 100644
--- a/src/amf/amfnd/clc.cc
+++ b/src/amf/amfnd/clc.cc
@@ -915,7 +915,6 @@ uint32_t avnd_comp_clc_st_chng_prc(AVND_CB *cb, AVND_COMP 
*comp,
                                    SaAmfPresenceStateT final_st) {
   AVND_SU_PRES_FSM_EV ev = AVND_SU_PRES_FSM_EV_MAX;
   AVND_COMP_CSI_REC *csi = 0;
-  bool is_en;
   uint32_t rc = NCSCC_RC_SUCCESS;
   TRACE_ENTER2("Comp '%s', Prv_state '%s', Final_state '%s'",
                comp->name.c_str(), presence_state[prv_st],
@@ -1104,8 +1103,7 @@ uint32_t avnd_comp_clc_st_chng_prc(AVND_CB *cb, AVND_COMP 
*comp,
        */
       /* if(m_AVND_COMP_TYPE_IS_PROXIED(comp)) */
       if (m_AVND_SU_OPER_STATE_IS_DISABLED(comp->su)) {
-        m_AVND_SU_IS_ENABLED(comp->su, is_en);
-        if (true == is_en) {
+        if (comp->su->all_comps_enabled() == true) {
           /*Clear SU failed state as all components are enabled.*/
           m_AVND_SU_FAILED_RESET(comp->su);
           m_AVND_SU_OPER_STATE_SET(comp->su, SA_AMF_OPERATIONAL_ENABLED);
@@ -1201,8 +1199,7 @@ uint32_t avnd_comp_clc_st_chng_prc(AVND_CB *cb, AVND_COMP 
*comp,
           /* failed su is ready to take on si assignment.. inform avd */
           if (!comp->csi_list.n_nodes) {
             TRACE("Comp has no CSIs assigned");
-            m_AVND_SU_IS_ENABLED(comp->su, is_en);
-            if (true == is_en) {
+            if (comp->su->all_comps_enabled() == true) {
               m_AVND_SU_OPER_STATE_SET(comp->su, SA_AMF_OPERATIONAL_ENABLED);
               rc = avnd_di_oper_send(cb, comp->su, 0);
               if (NCSCC_RC_SUCCESS != rc) goto done;
diff --git a/src/amf/amfnd/comp.cc b/src/amf/amfnd/comp.cc
index 93aeddcf1..f052f9992 100644
--- a/src/amf/amfnd/comp.cc
+++ b/src/amf/amfnd/comp.cc
@@ -738,7 +738,6 @@ void avnd_comp_unreg_val(AVND_CB *cb, 
AVSV_AMF_COMP_UNREG_PARAM *unreg,
 ******************************************************************************/
 uint32_t avnd_comp_reg_prc(AVND_CB *cb, AVND_COMP *comp, AVND_COMP *pxy_comp,
                            AVSV_AMF_COMP_REG_PARAM *reg, MDS_DEST *dest) {
-  bool su_is_enabled;
   uint32_t rc = NCSCC_RC_SUCCESS;
   TRACE_ENTER2("comp: '%s'", comp->name.c_str());
 
@@ -778,8 +777,7 @@ uint32_t avnd_comp_reg_prc(AVND_CB *cb, AVND_COMP *comp, 
AVND_COMP *pxy_comp,
     if (NCSCC_RC_SUCCESS != rc) goto done;
 
     /* update su oper state */
-    m_AVND_SU_IS_ENABLED(comp->su, su_is_enabled);
-    if (true == su_is_enabled) {
+    if (comp->su->all_comps_enabled() == true) {
       m_AVND_SU_OPER_STATE_SET(comp->su, SA_AMF_OPERATIONAL_ENABLED);
 
       /* inform AvD */
diff --git a/src/amf/amfnd/compdb.cc b/src/amf/amfnd/compdb.cc
index 0774e920b..2d1ce2736 100644
--- a/src/amf/amfnd/compdb.cc
+++ b/src/amf/amfnd/compdb.cc
@@ -271,12 +271,7 @@ uint32_t avnd_compdb_rec_del(AVND_CB *cb, const 
std::string &name) {
   /*
    * Remove from the comp-list (maintained by su).
    */
-  rc = m_AVND_SUDB_REC_COMP_REM(*su, *comp);
-  if (NCSCC_RC_SUCCESS != rc) {
-    LOG_ER("%s: %s remove failed", __FUNCTION__, name.c_str());
-    rc = AVND_ERR_DLL;
-    goto done;
-  }
+  su->remove_comp(comp);
 
   /*
    * Remove from compdb
@@ -449,17 +444,10 @@ uint32_t avnd_comp_oper_req(AVND_CB *cb, AVSV_PARAM_INFO 
*param) {
           comp->inst_level = *(uint32_t *)(param->value);
 
           /* Remove from the comp-list (maintained by su) */
-          rc = m_AVND_SUDB_REC_COMP_REM(*su, *comp);
-          if (NCSCC_RC_SUCCESS != rc) {
-            LOG_ER("%s: %s remove failed", __FUNCTION__, comp->name.c_str());
-            goto done;
-          }
-
-          (&comp->su_dll_node)->prev = nullptr;
-          (&comp->su_dll_node)->next = nullptr;
+          su->remove_comp(comp);
 
           /* Add to the comp-list (maintained by su) */
-          m_AVND_SUDB_REC_COMP_ADD(*su, *comp, rc);
+          su->add_comp(comp);
 
           break;
         case saAmfCompRecoveryOnError_ID:
@@ -684,18 +672,10 @@ uint32_t avnd_comptype_oper_req(AVND_CB *cb, 
AVSV_PARAM_INFO *param) {
               if (comp->use_comptype_attr->test(CompInstantiationLevel)) {
                 comp->inst_level = *(SaUint32T *)(param->value);
                 /* Remove from the comp-list (maintained by su) */
-                rc = m_AVND_SUDB_REC_COMP_REM(*su, *comp);
-                if (NCSCC_RC_SUCCESS != rc) {
-                  LOG_ER("%s: %s remove failed", __FUNCTION__,
-                         comp->name.c_str());
-                  goto done;
-                }
-
-                (&comp->su_dll_node)->prev = nullptr;
-                (&comp->su_dll_node)->next = nullptr;
+                su->remove_comp(comp);
 
                 /* Add to the comp-list (maintained by su) */
-                m_AVND_SUDB_REC_COMP_ADD(*su, *comp, rc);
+                su->add_comp(comp);
                 TRACE("comp->inst_level modified to '%u'", comp->inst_level);
               }
               break;
@@ -1518,7 +1498,7 @@ static AVND_COMP *avnd_comp_create(const std::string 
&comp_name,
   osaf_mutex_unlock_ordie(&compdb_mutex);
 
   /* Add to the comp-list (maintained by su) */
-  m_AVND_SUDB_REC_COMP_ADD(*su, *comp, rc);
+  su->add_comp(comp);
 
   comp->su = su;
   comp->error_report_sent = false;
diff --git a/src/amf/amfnd/err.cc b/src/amf/amfnd/err.cc
index 2abaf2007..8da16bdc7 100644
--- a/src/amf/amfnd/err.cc
+++ b/src/amf/amfnd/err.cc
@@ -838,13 +838,9 @@ uint32_t avnd_err_rcvr_comp_failover(AVND_CB *cb, 
AVND_COMP *failed_comp) {
 
     // for now, just terminate all components in the SU
     if (cb->is_avd_down == true) {
-      AVND_COMP *comp;
       LOG_NO("Terminating components of '%s'(abruptly & unordered)",
              su->name.c_str());
-      for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-               m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-           comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                     m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+      for (const auto &comp : su->comp_list) {
         if (comp->su->su_is_external) continue;
         rc = avnd_comp_clc_fsm_run(cb, comp, 
AVND_COMP_CLC_PRES_FSM_EV_CLEANUP);
         if (NCSCC_RC_SUCCESS != rc) {
@@ -872,7 +868,6 @@ done:
  */
 uint32_t avnd_err_rcvr_su_failover(AVND_CB *cb, AVND_SU *su,
                                    AVND_COMP *failed_comp) {
-  AVND_COMP *comp;
   uint32_t rc = NCSCC_RC_SUCCESS;
 
   TRACE_ENTER2("'%s' '%s'", su->name.c_str(), failed_comp->name.c_str());
@@ -898,10 +893,7 @@ uint32_t avnd_err_rcvr_su_failover(AVND_CB *cb, AVND_SU 
*su,
   LOG_NO("Terminating components of '%s'(abruptly & unordered)",
          su->name.c_str());
   /* Unordered cleanup of components of failed SU */
-  for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su->comp_list) {
     if (comp->su->su_is_external) continue;
 
     rc = avnd_comp_clc_fsm_run(cb, comp, AVND_COMP_CLC_PRES_FSM_EV_CLEANUP);
@@ -934,7 +926,6 @@ done:
 uint32_t avnd_err_rcvr_node_switchover(AVND_CB *cb, AVND_SU *failed_su,
                                        AVND_COMP *failed_comp) {
   TRACE_ENTER();
-  AVND_COMP *comp;
   /* increase log level to info */
   setlogmask(LOG_UPTO(LOG_INFO));
 
@@ -998,10 +989,7 @@ uint32_t avnd_err_rcvr_node_switchover(AVND_CB *cb, 
AVND_SU *failed_su,
     LOG_NO("Terminating components of '%s'(abruptly & unordered)",
            failed_su->name.c_str());
     /* Unordered cleanup of components of failed SU */
-    for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_FIRST(&failed_su->comp_list));
-         comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                   m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+    for (const auto &comp : failed_su->comp_list) {
       if (comp->su->su_is_external) continue;
 
       rc = avnd_comp_clc_fsm_run(cb, comp, AVND_COMP_CLC_PRES_FSM_EV_CLEANUP);
@@ -1108,8 +1096,7 @@ uint32_t avnd_err_rcvr_node_failover(AVND_CB *cb, AVND_SU 
*failed_su,
   Notes         : None.
 ******************************************************************************/
 uint32_t avnd_err_su_repair(AVND_CB *cb, AVND_SU *su) {
-  AVND_COMP *comp = 0;
-  bool is_en, is_uninst = false, is_comp_insting = false;
+  bool is_uninst = false, is_comp_insting = false;
   uint32_t rc = NCSCC_RC_SUCCESS;
   TRACE_ENTER();
 
@@ -1123,10 +1110,7 @@ uint32_t avnd_err_su_repair(AVND_CB *cb, AVND_SU *su) {
   if (all_comps_terminated_in_su(su) == true) is_uninst = true;
 
   /* scan & instantiate failed pi comps */
-  for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su->comp_list) {
     if (m_AVND_COMP_IS_FAILED(comp)) {
       if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp)) {
         /* trigger comp-fsm */
@@ -1148,8 +1132,7 @@ uint32_t avnd_err_su_repair(AVND_CB *cb, AVND_SU *su) {
 
   /* if a mix pi su has all the comps enabled, inform AvD */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
-    m_AVND_SU_IS_ENABLED(su, is_en);
-    if (true == is_en) {
+    if (su->all_comps_enabled() == true) {
       m_AVND_SU_OPER_STATE_SET(su, SA_AMF_OPERATIONAL_ENABLED);
       rc = avnd_di_oper_send(cb, su, 0);
       if (NCSCC_RC_SUCCESS != rc) goto done;
diff --git a/src/amf/amfnd/su.cc b/src/amf/amfnd/su.cc
index 229b3f6c8..32596fb8a 100644
--- a/src/amf/amfnd/su.cc
+++ b/src/amf/amfnd/su.cc
@@ -169,11 +169,9 @@ uint32_t avnd_evt_avd_reg_su_evh(AVND_CB *cb, AVND_EVT 
*evt) {
        instantiating NPI component. In this case, anyway, SU will
        remain in instantiated state. NPI comp will get instantiated
        when corresponding csi is added. */
-    bool su_is_instantiated;
-    m_AVND_SU_IS_INSTANTIATED(su, su_is_instantiated);
 
     if ((su->pres == SA_AMF_PRESENCE_INSTANTIATED) &&
-        (su_is_instantiated == false)) {
+        (su->all_pi_comps_instantiated() == false)) {
       avnd_su_pres_state_set(cb, su, SA_AMF_PRESENCE_UNINSTANTIATED);
       rc = avnd_su_pres_fsm_run(cb, su, 0, AVND_SU_PRES_FSM_EV_INST);
     }
@@ -204,7 +202,6 @@ static uint32_t avnd_avd_su_update_on_fover(AVND_CB *cb,
                                             AVSV_D2N_REG_SU_MSG_INFO *info) {
   AVSV_SU_INFO_MSG *su_info = 0;
   AVND_SU *su = 0;
-  AVND_COMP *comp = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
 
   TRACE_ENTER();
@@ -246,8 +243,8 @@ static uint32_t avnd_avd_su_update_on_fover(AVND_CB *cb,
       /* First walk entire comp list of this SU and delete all the
        * component records which are there in the list.
        */
-      while ((comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                  m_NCS_DBLIST_FIND_FIRST(&su->comp_list)))) {
+      auto tmp_comp_list = su->comp_list;
+      for (const auto &comp : tmp_comp_list) {
         /* delete the record */
         rc = avnd_compdb_rec_del(cb, comp->name);
         if (NCSCC_RC_SUCCESS != rc) {
@@ -573,7 +570,6 @@ uint32_t avnd_su_si_reassign(AVND_CB *cb, AVND_SU *su) {
   Notes         : SIs associated with this SU are not deleted.
 ******************************************************************************/
 uint32_t avnd_su_curr_info_del(AVND_CB *cb, AVND_SU *su) {
-  AVND_COMP *comp = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
   TRACE_ENTER2("'%s'", su->name.c_str());
 
@@ -589,10 +585,7 @@ uint32_t avnd_su_curr_info_del(AVND_CB *cb, AVND_SU *su) {
   }
 
   /* scan & delete the current info store in each component */
-  for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su->comp_list) {
     rc = avnd_comp_curr_info_del(cb, comp);
     if (NCSCC_RC_SUCCESS != rc) goto done;
   }
@@ -634,16 +627,12 @@ uint32_t avnd_evt_su_admin_op_req(AVND_CB *cb, AVND_EVT 
*evt) {
 
   switch (info->oper_id) {
     case SA_AMF_ADMIN_REPAIRED: {
-      AVND_COMP *comp;
 
       /* SU has been repaired. Reset states and update AMF director 
accordingly.
        */
       LOG_NO("Repair request for '%s'", su->name.c_str());
 
-      for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-               m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-           comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                     m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+      for (const auto &comp : su->comp_list) {
         comp->admin_oper = false;
         m_AVND_COMP_STATE_RESET(comp);
         avnd_comp_pres_state_set(cb, comp, SA_AMF_PRESENCE_UNINSTANTIATED);
@@ -716,11 +705,7 @@ void avnd_su_pres_state_set(const AVND_CB *cb, AVND_SU *su,
  * @param su
  */
 void su_reset_restart_count_in_comps(const AVND_CB *cb, const AVND_SU *su) {
-  AVND_COMP *comp;
-  for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su->comp_list){
     comp_reset_restart_count(cb, comp);
   }
 }
@@ -769,10 +754,7 @@ void reset_suRestart_flag(AVND_SU *su) {
  * @return true/false.
  */
 bool su_all_comps_restartable(const AVND_SU &su) {
-  for (AVND_COMP *comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su.comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su.comp_list) {
     if (m_AVND_COMP_IS_RESTART_DIS(comp)) return false;
   }
   return true;
@@ -798,10 +780,7 @@ void su_send_suRestart_recovery_msg(AVND_SU *su) {
  * @return true/false.
  */
 bool pi_su_all_comps_uninstantiated(const AVND_SU &su) {
-  for (AVND_COMP *comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su.comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su.comp_list) {
     if ((comp->pres != SA_AMF_PRESENCE_UNINSTANTIATED) &&
         (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp)))
       return false;
@@ -816,10 +795,7 @@ bool pi_su_all_comps_uninstantiated(const AVND_SU &su) {
  * @return true/false.
  */
 bool is_any_non_restartable_comp_assigned(const AVND_SU &su) {
-  for (AVND_COMP *comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su.comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su.comp_list) {
     if ((m_AVND_COMP_IS_RESTART_DIS(comp)) && (comp->csi_list.n_nodes > 0))
       return true;
   }
@@ -827,16 +803,6 @@ bool is_any_non_restartable_comp_assigned(const AVND_SU 
&su) {
 }
 
 /**
- * @brief  Checks if all PI comps of SU are in INSTANTIATED state.
- * @return true/false
- */
-bool su_all_pi_comps_instantiated(const AVND_SU *su) {
-  bool su_is_instantiated;
-  m_AVND_SU_IS_INSTANTIATED(su, su_is_instantiated);
-  TRACE("All PI comps instantiated :'%u'", su_is_instantiated);
-  return su_is_instantiated;
-}
-/**
  * @brief Checks if RESTART admin op is going on SU.
  * @return true/false
  */
@@ -1034,3 +1000,51 @@ done:
   TRACE_LEAVE2("%u", rc);
   return rc;
 }
+
+// determine if all the comps in an su are operationally enabled
+bool AVND_SU::all_comps_enabled() const {
+  if (std::all_of(comp_list.begin(), comp_list.end(),
+                  [&](AVND_COMP *comp) -> bool {
+                    return comp->oper == SA_AMF_OPERATIONAL_ENABLED;
+                  })) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+// remove a component from the su-comp list
+void AVND_SU::remove_comp(AVND_COMP *comp) {
+  comp_list.erase(std::remove(comp_list.begin(), comp_list.end(), comp),
+                  comp_list.end());
+}
+
+// determine if all the pi comps in an su are instantiated
+bool AVND_SU::all_pi_comps_instantiated() const {
+  if (std::all_of(comp_list.begin(), comp_list.end(),
+                  [&](AVND_COMP *comp) -> bool {
+                    return ((comp->flag & AVND_COMP_TYPE_PREINSTANTIABLE) &&
+                            (comp->pres == SA_AMF_PRESENCE_INSTANTIATED));
+                  })) {
+    return true;
+  } else {
+    return false;
+  }
+}
+
+void AVND_SU::add_comp(AVND_COMP *comp) {
+//  osaf_mutex_lock_ordie(&sudb_mutex);
+  comp_list.push_back(comp);
+  std::sort(comp_list.begin(), comp_list.end(),
+            [](const AVND_COMP *c1, const AVND_COMP *c2) -> bool {
+              if (c1->inst_level < c2->inst_level)
+                return true;
+              if (c1->inst_level == c2->inst_level) {
+                if (compare_sanamet(c1->name, c2->name) < 0) {
+                  return true;
+                }
+              }
+              return false;
+            });
+//  osaf_mutex_unlock_ordie(&sudb_mutex);
+}
diff --git a/src/amf/amfnd/sudb.cc b/src/amf/amfnd/sudb.cc
index 071ee0c88..68cdfea84 100644
--- a/src/amf/amfnd/sudb.cc
+++ b/src/amf/amfnd/sudb.cc
@@ -61,7 +61,7 @@ AVND_SU *avnd_sudb_rec_add(AVND_CB *cb, AVND_SU_PARAM *info, 
uint32_t *rc) {
   }
 
   /* a fresh su... */
-  su = new AVND_SU();
+  su = new AVND_SU;
 
   /*
    * Update the config parameters.
@@ -89,13 +89,6 @@ AVND_SU *avnd_sudb_rec_add(AVND_CB *cb, AVND_SU_PARAM *info, 
uint32_t *rc) {
   su->avd_updt_flag = false;
 
   /*
-   * Initialize the comp-list.
-   */
-  su->comp_list.order = NCS_DBLIST_ASSCEND_ORDER;
-  su->comp_list.cmp_cookie = avsv_dblist_uns32_cmp;
-  su->comp_list.free_cookie = 0;
-
-  /*
    * Initialize the si-list.
    */
   su->si_list.order = NCS_DBLIST_ASSCEND_ORDER;
@@ -156,7 +149,7 @@ err:
 ******************************************************************************/
 uint32_t avnd_sudb_rec_del(AVND_CB *cb, const std::string &name) {
   uint32_t rc = NCSCC_RC_SUCCESS;
-  AVND_COMP *comp;
+  std::vector<AVND_COMP*> tmp_list;
 
   TRACE_ENTER2("%s", name.c_str());
 
@@ -169,14 +162,14 @@ uint32_t avnd_sudb_rec_del(AVND_CB *cb, const std::string 
&name) {
   }
 
   /* Delete all components */
-  while ((comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-              m_NCS_DBLIST_FIND_FIRST(&su->comp_list)))) {
+  tmp_list = su->comp_list;
+  for (const auto &comp : tmp_list) {
     rc = avnd_compdb_rec_del(cb, comp->name);
     if (rc != NCSCC_RC_SUCCESS) goto done;
   }
 
   /* SU should not have any comp or SI attached to it */
-  osafassert(su->comp_list.n_nodes == 0);
+  osafassert(su->comp_list.size() == 0);
   osafassert(su->si_list.n_nodes == 0);
 
   osaf_mutex_lock_ordie(&sudb_mutex);
@@ -287,16 +280,3 @@ done:
   osaf_mutex_unlock_ordie(&sudb_mutex);
   return su;
 }
-
-/**
- * This function adds comp to the comp-list
- * @param Pointer to SUDB.
- * @param Pointer to SU name.
- * @return Pointer to SU.
- */
-void sudb_rec_comp_add(AVND_SU *su, AVND_COMP *comp, uint32_t *rc) {
-  osaf_mutex_lock_ordie(&sudb_mutex);
-  comp->su_dll_node.key = (uint8_t *)&((comp)->inst_level);
-  *rc = ncs_db_link_list_add(&(su)->comp_list, &(comp)->su_dll_node);
-  osaf_mutex_unlock_ordie(&sudb_mutex);
-}
diff --git a/src/amf/amfnd/susm.cc b/src/amf/amfnd/susm.cc
index 52af63b83..9d0ed07a9 100644
--- a/src/amf/amfnd/susm.cc
+++ b/src/amf/amfnd/susm.cc
@@ -1480,12 +1480,8 @@ done:
  * @return bool
  */
 bool all_comps_terminated_in_su(const AVND_SU *su, bool all_final_pres_states) 
{
-  AVND_COMP *comp;
 
-  for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su->comp_list) {
     if ((all_final_pres_states == false) &&
         (comp->pres != SA_AMF_PRESENCE_UNINSTANTIATED)) {
       TRACE("'%s' not terminated, pres.st=%u", comp->name.c_str(), comp->pres);
@@ -1511,12 +1507,8 @@ static void perform_pending_nodeswitchover() {
       (avnd_cb->oper_state != SA_AMF_OPERATIONAL_DISABLED))
     return;
 
-  AVND_COMP *comp;
   AVND_SU *su = avnd_cb->failed_su;
-  for (comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (const auto &comp : su->comp_list) {
     if ((comp->pres == SA_AMF_PRESENCE_INSTANTIATING) ||
         (comp->pres == SA_AMF_PRESENCE_TERMINATING) ||
         (comp->pres == SA_AMF_PRESENCE_RESTARTING) ||
@@ -1675,10 +1667,8 @@ static uint32_t 
pi_su_instantiating_to_instantiated(AVND_SU *su) {
     }
     su->admin_op_Id = static_cast<SaAmfAdminOperationIdT>(0);
   } else {
-    bool is_en;
     /* determine the su oper state. if enabled, inform avd. */
-    m_AVND_SU_IS_ENABLED(su, is_en);
-    if (true == is_en) {
+    if (su->all_comps_enabled() == true) {
       TRACE("SU oper state is enabled");
       m_AVND_SU_OPER_STATE_SET(su, SA_AMF_OPERATIONAL_ENABLED);
       rc = avnd_di_oper_send(avnd_cb, su, 0);
@@ -1707,7 +1697,6 @@ uint32_t avnd_su_pres_st_chng_prc(AVND_CB *cb, AVND_SU 
*su,
                                   SaAmfPresenceStateT prv_st,
                                   SaAmfPresenceStateT final_st) {
   AVND_SU_SI_REC *si = 0;
-  bool is_en;
   uint32_t rc = NCSCC_RC_SUCCESS;
 
   TRACE_ENTER2("'%s' %s => %s", su->name.c_str(), presence_state[prv_st],
@@ -1720,7 +1709,7 @@ uint32_t avnd_su_pres_st_chng_prc(AVND_CB *cb, AVND_SU 
*su,
     if (((SA_AMF_PRESENCE_INSTANTIATING == prv_st) ||
          (SA_AMF_PRESENCE_RESTARTING == prv_st)) &&
         (SA_AMF_PRESENCE_INSTANTIATED == final_st) &&
-        (su_all_pi_comps_instantiated(su) == true)) {
+        (su->all_pi_comps_instantiated() == true)) {
       rc = pi_su_instantiating_to_instantiated(su);
       if (NCSCC_RC_SUCCESS != rc) goto done;
     }
@@ -1734,8 +1723,7 @@ uint32_t avnd_su_pres_st_chng_prc(AVND_CB *cb, AVND_SU 
*su,
       }
 
       /* determine su oper state. if enabled, inform avd. */
-      m_AVND_SU_IS_ENABLED(su, is_en);
-      if (true == is_en) {
+      if (su->all_comps_enabled() == true) {
         TRACE("SU oper state is enabled");
         m_AVND_SU_OPER_STATE_SET(su, SA_AMF_OPERATIONAL_ENABLED);
         rc = avnd_di_oper_send(cb, su, 0);
@@ -1861,10 +1849,7 @@ uint32_t avnd_su_pres_st_chng_prc(AVND_CB *cb, AVND_SU 
*su,
           avnd_su_si_del(avnd_cb, su->name);
         } else {
           // Some PI comps are still terminating. Try to terminate NPIs.
-          for (AVND_COMP *comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                   m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-               comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                         m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+          for (const auto &comp : su->comp_list) {
             if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp)) continue;
             rc = avnd_comp_clc_fsm_trigger(cb, comp,
                                            AVND_COMP_CLC_PRES_FSM_EV_TERM);
@@ -2066,7 +2051,6 @@ done:
 ******************************************************************************/
 uint32_t avnd_su_pres_uninst_suinst_hdler(AVND_CB *cb, AVND_SU *su,
                                           AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_SU_SI_REC *si = 0;
   AVND_COMP_CSI_REC *csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
@@ -2078,10 +2062,7 @@ uint32_t avnd_su_pres_uninst_suinst_hdler(AVND_CB *cb, 
AVND_SU *su,
    */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU:'%s'", su->name.c_str());
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+    for (const auto &curr_comp : su->comp_list) {
       /* instantiate the pi comp */
       TRACE("%s", curr_comp->name.c_str());
       if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp) &&
@@ -2147,7 +2128,6 @@ done:
 ******************************************************************************/
 uint32_t avnd_su_pres_insting_suterm_hdler(AVND_CB *cb, AVND_SU *su,
                                            AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
   TRACE_ENTER2("SU Terminate event in Instantiating state:'%s'",
                su->name.c_str());
@@ -2156,10 +2136,7 @@ uint32_t avnd_su_pres_insting_suterm_hdler(AVND_CB *cb, 
AVND_SU *su,
    * If pi su, pick all the instantiated/instantiating pi comps &
    * trigger their FSM with TermEv.
    */
-  for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                      m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+  for (const auto &curr_comp : su->comp_list) {
     /*
      * skip the npi comps.. as the su is yet to be instantiated,
      * there are no SIs assigned.
@@ -2220,9 +2197,7 @@ uint32_t avnd_su_pres_insting_surestart_hdler(AVND_CB 
*cb, AVND_SU *su,
 ******************************************************************************/
 uint32_t avnd_su_pres_insting_compinst_hdler(AVND_CB *cb, AVND_SU *su,
                                              AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_COMP_CSI_REC *curr_csi = 0;
-  bool is;
   uint32_t rc = NCSCC_RC_SUCCESS;
   const std::string compname = comp ? comp->name : "none";
   TRACE_ENTER2(
@@ -2239,10 +2214,11 @@ uint32_t avnd_su_pres_insting_compinst_hdler(AVND_CB 
*cb, AVND_SU *su,
     if (m_AVND_COMP_IS_FAILED(comp)) {
       m_AVND_COMP_FAILED_RESET(comp);
     } else {
-      for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-               m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node));
-           curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                          m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+      std::vector<AVND_COMP*>::iterator iter =
+        std::find(su->comp_list.begin(), su->comp_list.end(), comp);
+      if (iter != su->comp_list.end()) ++iter;
+      for (; iter != su->comp_list.end(); ++iter) {
+        AVND_COMP *curr_comp = *iter;
         /* instantiate the pi comp */
         if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) {
           TRACE("Running the component clc FSM");
@@ -2255,8 +2231,7 @@ uint32_t avnd_su_pres_insting_compinst_hdler(AVND_CB *cb, 
AVND_SU *su,
     }
 
     /* determine su presence state */
-    m_AVND_SU_IS_INSTANTIATED(su, is);
-    if (true == is) {
+    if (su->all_pi_comps_instantiated() == true) {
       avnd_su_pres_state_set(cb, su, SA_AMF_PRESENCE_INSTANTIATED);
     }
   }
@@ -2329,7 +2304,6 @@ done:
 ******************************************************************************/
 uint32_t avnd_su_pres_insting_compinstfail_hdler(AVND_CB *cb, AVND_SU *su,
                                                  AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_SU_SI_REC *si = 0;
   AVND_COMP_CSI_REC *curr_csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS, comp_count = 0;
@@ -2348,10 +2322,8 @@ uint32_t avnd_su_pres_insting_compinstfail_hdler(AVND_CB 
*cb, AVND_SU *su,
    */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU:'%s'", su->name.c_str());
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_LAST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+    for (auto iter = su->comp_list.rbegin(); iter != su->comp_list.rend(); 
++iter) {
+      AVND_COMP *curr_comp = *iter;
       /* skip the npi comps */
       if (!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) continue;
 
@@ -2435,7 +2407,6 @@ static AVND_COMP_CSI_REC *get_next_assigned_csi_from_end(
 ******************************************************************************/
 uint32_t avnd_su_pres_inst_suterm_hdler(AVND_CB *cb, AVND_SU *su,
                                         AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_SU_SI_REC *si = 0;
   AVND_COMP_CSI_REC *csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
@@ -2447,10 +2418,8 @@ uint32_t avnd_su_pres_inst_suterm_hdler(AVND_CB *cb, 
AVND_SU *su,
    */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU:'%s'", su->name.c_str());
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_LAST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+    for (auto iter = su->comp_list.rbegin(); iter != su->comp_list.rend(); 
++iter) {
+      AVND_COMP *curr_comp = *iter;
       if (curr_comp->pres == SA_AMF_PRESENCE_UNINSTANTIATED) continue;
 
       /* terminate the pi comp */
@@ -2538,10 +2507,7 @@ done:
  * @return  true/false.
  */
 bool su_evaluate_restarting_state(AVND_SU *su) {
-  for (AVND_COMP *comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+  for (auto const &comp : su->comp_list) {
     if (!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp)) continue;
     if (comp->pres != SA_AMF_PRESENCE_RESTARTING) {
       return false;
@@ -2593,7 +2559,6 @@ bool all_csis_in_restarting_state(const AVND_SU *su,
 ******************************************************************************/
 uint32_t avnd_su_pres_inst_surestart_hdler(AVND_CB *cb, AVND_SU *su,
                                            AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_SU_SI_REC *si = 0;
   AVND_COMP_CSI_REC *csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
@@ -2605,10 +2570,8 @@ uint32_t avnd_su_pres_inst_surestart_hdler(AVND_CB *cb, 
AVND_SU *su,
    */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU:'%s'", su->name.c_str());
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_LAST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+    for (auto iter = su->comp_list.rbegin(); iter != su->comp_list.rend(); 
++iter) {
+      AVND_COMP *curr_comp = *iter;
       if ((curr_comp->pres == SA_AMF_PRESENCE_RESTARTING) ||
           (curr_comp->pres == SA_AMF_PRESENCE_UNINSTANTIATED))
         continue;
@@ -2724,10 +2687,11 @@ uint32_t avnd_su_pres_inst_comprestart_hdler(AVND_CB 
*cb, AVND_SU *su,
                su->name.c_str(), compname.c_str());
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU");
-    for (AVND_COMP *curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_PREV(&comp->su_dll_node));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+    std::vector<AVND_COMP*>::reverse_iterator iter =
+      std::find(su->comp_list.rbegin(), su->comp_list.rend(), comp);
+    if (iter != su->comp_list.rend()) ++iter;
+    for (; iter != su->comp_list.rend(); ++iter) {
+      AVND_COMP *curr_comp = *iter;
       if (curr_comp->pres == SA_AMF_PRESENCE_RESTARTING) continue;
       if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) {
         TRACE("Running the component clc FSM");
@@ -2851,14 +2815,12 @@ uint32_t avnd_su_pres_terming_compinst_hdler(AVND_CB 
*cb, AVND_SU *su,
       su->name.c_str(), compname.c_str());
 
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
-    bool is;
     if (m_AVND_COMP_IS_FAILED(comp)) {
       m_AVND_COMP_FAILED_RESET(comp);
     }
 
     /* determine if su can be transitioned to instantiated state */
-    m_AVND_SU_IS_INSTANTIATED(su, is);
-    if (true == is) {
+    if (su->all_pi_comps_instantiated() == true) {
       avnd_su_pres_state_set(cb, su, SA_AMF_PRESENCE_INSTANTIATED);
     }
     if (m_AVND_SU_IS_RESTART(su)) {
@@ -2901,7 +2863,6 @@ uint32_t avnd_su_pres_terming_compinst_hdler(AVND_CB *cb, 
AVND_SU *su,
 ******************************************************************************/
 uint32_t avnd_su_pres_terming_comptermfail_hdler(AVND_CB *cb, AVND_SU *su,
                                                  AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_SU_SI_REC *si = 0;
   AVND_COMP_CSI_REC *curr_csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
@@ -2916,10 +2877,7 @@ uint32_t avnd_su_pres_terming_comptermfail_hdler(AVND_CB 
*cb, AVND_SU *su,
    */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU");
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+    for (const auto &curr_comp : su->comp_list) {
       /* skip the npi comps */
       if (!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) continue;
 
@@ -3035,7 +2993,7 @@ bool all_csis_in_assigned_state(const AVND_SU *su) {
 ******************************************************************************/
 uint32_t avnd_su_pres_terming_compuninst_hdler(AVND_CB *cb, AVND_SU *su,
                                                AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
+  AVND_COMP *curr_comp = nullptr;
   AVND_COMP_CSI_REC *curr_csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
   const std::string compname = comp ? comp->name : "none";
@@ -3052,10 +3010,8 @@ uint32_t avnd_su_pres_terming_compuninst_hdler(AVND_CB 
*cb, AVND_SU *su,
         avnd_su_pres_state_set(cb, su, SA_AMF_PRESENCE_UNINSTANTIATED);
 
       if (m_AVND_SU_IS_RESTART(su)) {
-        for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                 m_NCS_DBLIST_FIND_LAST(&su->comp_list));
-             curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                            m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+        for (auto iter = su->comp_list.rbegin(); iter != su->comp_list.rend(); 
++iter) {
+          curr_comp = *iter;
           if (curr_comp->pres == SA_AMF_PRESENCE_UNINSTANTIATED) continue;
           // Will pick up when terminating comp will move to uninstantiated
           // state.
@@ -3106,10 +3062,12 @@ uint32_t avnd_su_pres_terming_compuninst_hdler(AVND_CB 
*cb, AVND_SU *su,
       avnd_su_pres_state_set(cb, su, SA_AMF_PRESENCE_INSTANTIATING);
     } else {
       TRACE("Admin operation on SU");
-      for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-               m_NCS_DBLIST_FIND_PREV(&comp->su_dll_node));
-           curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                          m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+
+      std::vector<AVND_COMP*>::reverse_iterator iter =
+        std::find(su->comp_list.rbegin(), su->comp_list.rend(), comp);
+      if (iter != su->comp_list.rend()) ++iter;
+      for (; iter != su->comp_list.rend(); ++iter) {
+        curr_comp = *iter;
         TRACE_1("comp:'%s', Pres state:%u", curr_comp->name.c_str(),
                 curr_comp->pres);
         if ((curr_comp->pres == SA_AMF_PRESENCE_RESTARTING) ||
@@ -3257,7 +3215,6 @@ done:
 ******************************************************************************/
 uint32_t avnd_su_pres_restart_suterm_hdler(AVND_CB *cb, AVND_SU *su,
                                            AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
   const std::string compname = comp ? comp->name : "none";
   TRACE_ENTER2("SU Terminate event in the Restarting state:'%s' : '%s'",
@@ -3267,10 +3224,7 @@ uint32_t avnd_su_pres_restart_suterm_hdler(AVND_CB *cb, 
AVND_SU *su,
    * If pi su, pick all the instantiated/instantiating pi comps &
    * trigger their FSM with CleanupEv.
    */
-  for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                      m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+  for (const auto &curr_comp : su->comp_list) {
     /* terminate the non-uninstantiated pi comp */
     if ((!m_AVND_COMP_PRES_STATE_IS_UNINSTANTIATED(curr_comp)) &&
         (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp))) {
@@ -3325,10 +3279,11 @@ uint32_t avnd_su_pres_restart_comprestart_hdler(AVND_CB 
*cb, AVND_SU *su,
       marked restarting. Some NPI comps may remain instantiated, terminate them
       now.
      */
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_LAST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+    std::vector<AVND_COMP*>::reverse_iterator iter =
+      std::find(su->comp_list.rbegin(), su->comp_list.rend(), comp);
+    if (iter != su->comp_list.rend()) ++iter;
+    for (; iter != su->comp_list.rend(); ++iter) {
+      curr_comp = *iter;
       TRACE("%s", curr_comp->name.c_str());
       if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) continue;
       if ((!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) &&
@@ -3340,10 +3295,7 @@ uint32_t avnd_su_pres_restart_comprestart_hdler(AVND_CB 
*cb, AVND_SU *su,
     }
     /* It means last pi component got terminated,now instantiate the first
      * comp.*/
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+    for (const auto &curr_comp : su->comp_list) {
       TRACE("%s", curr_comp->name.c_str());
       if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp) &&
           (curr_comp->pres == SA_AMF_PRESENCE_RESTARTING)) {
@@ -3410,19 +3362,16 @@ uint32_t avnd_su_pres_restart_compinst_hdler(AVND_CB 
*cb, AVND_SU *su,
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU:'%s'", su->name.c_str());
     /* Mark SU instantiated if atleast one PI comp is in instantiated state.*/
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-         curr_comp && (su->pres != SA_AMF_PRESENCE_INSTANTIATED);
-         curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+    for (const auto &curr_comp : su->comp_list) {
       if ((curr_comp->pres == SA_AMF_PRESENCE_INSTANTIATED) &&
           (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)))
         avnd_su_pres_state_set(cb, su, SA_AMF_PRESENCE_INSTANTIATED);
     }
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+    std::vector<AVND_COMP*>::iterator iter =
+      std::find(su->comp_list.begin(), su->comp_list.end(), comp);
+    if (iter != su->comp_list.end()) ++iter;
+    for (; iter != su->comp_list.end(); ++iter) {
+      curr_comp = *iter;
       if (curr_comp->pres == SA_AMF_PRESENCE_INSTANTIATED) continue;
       if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp) &&
           (curr_comp->pres == SA_AMF_PRESENCE_RESTARTING) &&
@@ -3437,7 +3386,7 @@ uint32_t avnd_su_pres_restart_compinst_hdler(AVND_CB *cb, 
AVND_SU *su,
     /*If all comps are instantiated then reassign the SU execpt in a single 
comp
      * case.*/
     if ((pres_init == SA_AMF_PRESENCE_INSTANTIATED) &&
-        (su_all_pi_comps_instantiated(su) == true))
+        (su->all_pi_comps_instantiated() == true))
       rc = pi_su_instantiating_to_instantiated(su);
   }
 
@@ -3502,7 +3451,6 @@ done:
 ******************************************************************************/
 uint32_t avnd_su_pres_restart_compterming_hdler(AVND_CB *cb, AVND_SU *su,
                                                 AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
   const std::string compname = comp ? comp->name : "none";
   TRACE_ENTER2("SUTerminate event in the Instantiating state:'%s' : '%s'",
@@ -3523,10 +3471,7 @@ uint32_t avnd_su_pres_restart_compterming_hdler(AVND_CB 
*cb, AVND_SU *su,
    * If pi su, pick all the instantiated/instantiating pi comps &
    * trigger their FSM with TermEv.
    */
-  for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-           m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-       curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                      m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+  for (const auto &curr_comp : su->comp_list) {
     /* skip the npi comps */
     if (!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) continue;
 
@@ -3575,7 +3520,6 @@ done:
 ******************************************************************************/
 uint32_t avnd_su_pres_inst_compinstfail_hdler(AVND_CB *cb, AVND_SU *su,
                                               AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_SU_SI_REC *si = 0;
   AVND_COMP_CSI_REC *curr_csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
@@ -3594,10 +3538,8 @@ uint32_t avnd_su_pres_inst_compinstfail_hdler(AVND_CB 
*cb, AVND_SU *su,
    * trigger their FSM with TermEv.
    */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_LAST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+    for (auto iter = su->comp_list.rbegin(); iter != su->comp_list.rend(); 
++iter) {
+      AVND_COMP *curr_comp = *iter;
       /* skip the npi comps */
       if (!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) continue;
 
@@ -3673,7 +3615,6 @@ done:
 ******************************************************************************/
 uint32_t avnd_su_pres_instfailed_compuninst(AVND_CB *cb, AVND_SU *su,
                                             AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_SU_SIQ_REC *siq = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
   const std::string compname = comp ? comp->name : "none";
@@ -3683,10 +3624,7 @@ uint32_t avnd_su_pres_instfailed_compuninst(AVND_CB *cb, 
AVND_SU *su,
 
   /* check whether all pi comps are terminated  */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+    for (auto const &curr_comp : su->comp_list) {
       /* skip the npi comps */
       if (!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp)) continue;
 
@@ -3761,7 +3699,6 @@ bool sufailover_during_nodeswitchover(const AVND_SU *su) {
  */
 uint32_t avnd_su_pres_terming_surestart_hdler(AVND_CB *cb, AVND_SU *su,
                                               AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_SU_SI_REC *si = 0;
   AVND_COMP_CSI_REC *csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
@@ -3770,10 +3707,8 @@ uint32_t avnd_su_pres_terming_surestart_hdler(AVND_CB 
*cb, AVND_SU *su,
 
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU:'%s'", su->name.c_str());
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_LAST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+    for (auto iter = su->comp_list.rbegin(); iter != su->comp_list.rend(); 
++iter) {
+      AVND_COMP *curr_comp = *iter;
       if ((curr_comp->pres == SA_AMF_PRESENCE_RESTARTING) ||
           (curr_comp->pres == SA_AMF_PRESENCE_UNINSTANTIATED))
         continue;
@@ -3864,10 +3799,11 @@ uint32_t avnd_su_pres_terming_comprestart_hdler(AVND_CB 
*cb, AVND_SU *su,
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU");
     AVND_COMP *curr_comp = nullptr;
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_PREV(&comp->su_dll_node));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_PREV(&curr_comp->su_dll_node))) {
+    std::vector<AVND_COMP*>::reverse_iterator iter =
+      std::find(su->comp_list.rbegin(), su->comp_list.rend(), comp);
+    if (iter != su->comp_list.rend()) ++iter;
+    for (; iter != su->comp_list.rend(); ++iter) {
+      curr_comp = *iter;
       if ((curr_comp->pres == SA_AMF_PRESENCE_RESTARTING) ||
           (curr_comp->pres == SA_AMF_PRESENCE_UNINSTANTIATED))
         continue;
@@ -3916,10 +3852,7 @@ uint32_t avnd_su_pres_terming_suinst_hdler(AVND_CB *cb, 
AVND_SU *su,
    */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU:'%s'", su->name.c_str());
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+    for (const auto &curr_comp : su->comp_list) {
       /* instantiate the pi comp */
       TRACE("%s", curr_comp->name.c_str());
       if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp) &&
@@ -3983,7 +3916,6 @@ done:
  */
 uint32_t avnd_su_pres_inst_compinst_hdler(AVND_CB *cb, AVND_SU *su,
                                           AVND_COMP *comp) {
-  AVND_COMP *curr_comp = 0;
   AVND_COMP_CSI_REC *curr_csi = 0;
   uint32_t rc = NCSCC_RC_SUCCESS;
   const std::string compname = comp ? comp->name : "none";
@@ -3993,10 +3925,7 @@ uint32_t avnd_su_pres_inst_compinst_hdler(AVND_CB *cb, 
AVND_SU *su,
 
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     TRACE("PI SU");
-    for (curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node));
-         curr_comp; curr_comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                        m_NCS_DBLIST_FIND_NEXT(&curr_comp->su_dll_node))) {
+    for (const auto &curr_comp : su->comp_list) {
       if (curr_comp->pres == SA_AMF_PRESENCE_INSTANTIATED) continue;
       if (m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(curr_comp) &&
           (curr_comp->pres == SA_AMF_PRESENCE_RESTARTING) &&
@@ -4009,7 +3938,7 @@ uint32_t avnd_su_pres_inst_compinst_hdler(AVND_CB *cb, 
AVND_SU *su,
         break;
       }
     }
-    if (su_all_pi_comps_instantiated(su) == true)
+    if (su->all_pi_comps_instantiated() == true)
       rc = pi_su_instantiating_to_instantiated(su);
   }
 
@@ -4115,10 +4044,7 @@ uint32_t avnd_evt_ir_evh(struct avnd_cb_tag *cb, struct 
avnd_evt_tag *evt) {
   /* trigger su instantiation for pi su */
   if (m_AVND_SU_IS_PREINSTANTIABLE(su)) {
     /* Update the comp oper state. */
-    for (AVND_COMP *comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-             m_NCS_DBLIST_FIND_FIRST(&su->comp_list));
-         comp; comp = m_AVND_COMP_FROM_SU_DLL_NODE_GET(
-                   m_NCS_DBLIST_FIND_NEXT(&comp->su_dll_node))) {
+    for (const auto &comp : su->comp_list) {
       rc = avnd_comp_oper_state_avd_sync(avnd_cb, comp);
     }
     TRACE("SU instantiation for PI SUs, running the SU presence state 
FSM:'%s'",
diff --git a/src/amf/amfnd/tmr.cc b/src/amf/amfnd/tmr.cc
index 678e8cbf1..0e0e8e341 100644
--- a/src/amf/amfnd/tmr.cc
+++ b/src/amf/amfnd/tmr.cc
@@ -182,13 +182,13 @@ uint32_t tmr_comp_err_esc_start(AVND_CB *cb, AVND_SU *su) 
{
   return rc;
 }
 
-void tmr_comp_err_esc_stop(avnd_cb_tag *cb, avnd_su_tag *su) {
+void tmr_comp_err_esc_stop(avnd_cb_tag *cb, AVND_SU *su) {
   LOG_NO("'%s' component restart probation timer stopped", su->name.c_str());
 
   avnd_stop_tmr(cb, &su->su_err_esc_tmr);
 }
 
-uint32_t tmr_su_err_esc_start(avnd_cb_tag *cb, avnd_su_tag *su) {
+uint32_t tmr_su_err_esc_start(avnd_cb_tag *cb, AVND_SU *su) {
   uint32_t rc;
 
   LOG_NO("'%s' SU restart probation timer started (timeout: %lld ns)",
@@ -200,7 +200,7 @@ uint32_t tmr_su_err_esc_start(avnd_cb_tag *cb, avnd_su_tag 
*su) {
   return rc;
 }
 
-void tmr_su_err_esc_stop(avnd_cb_tag *cb, avnd_su_tag *su) {
+void tmr_su_err_esc_stop(avnd_cb_tag *cb, AVND_SU *su) {
   LOG_NO("'%s' SU restart probation timer stopped", su->name.c_str());
 
   avnd_stop_tmr(cb, &su->su_err_esc_tmr);
diff --git a/src/amf/amfnd/util.cc b/src/amf/amfnd/util.cc
index ed0905ce2..1b348177e 100644
--- a/src/amf/amfnd/util.cc
+++ b/src/amf/amfnd/util.cc
@@ -393,3 +393,13 @@ void amfnd_copy_csi_attrs(AVSV_CSI_ATTRS *src_attrs,
       dest_attrs->list[i].string_ptr = src_attrs->list[i].string_ptr;
   }
 }
+
+// this function emulates the behaviour of m_CMP_NORDER_SANAMET
+int compare_sanamet(const std::string &lhs, const std::string &rhs) {
+  if (lhs.length() > rhs.length())
+    return 1;
+  else if (lhs.length() < rhs.length())
+    return -1;
+  else
+    return lhs.compare(rhs);
+}
\ No newline at end of file
-- 
2.11.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to