Re: [devel] [PATCH 1/1] amfd: fix coredump during downgrade if delayed failover is enabled [#3078]

2019-09-10 Thread Minh Hon Chau

Hi Gary,

The patch works fine in the reported scenario, no coredump in amfd.

But after downgrade succeeds (meaning the sc1 is active and running old 
software, the sc2 is standby running latest software + #3078), I 
continue another switchover to make sc2 back to active, I got error


Thanks

Minh

2019-09-11 14:31:58.633 SC-2 osafamfd[280]: WA 
avsv_validate_reo_type_in_csync: unknown type 52
2019-09-11 14:31:58.674 SC-2 osafimmnd[234]: NO Implementer (applier) 
connected: 43 (@OpenSafImmReplicatorB) <0, 2010f>
2019-09-11 14:31:59.496 SC-2 osafimmnd[234]: NO Implementer disconnected 
35 <0, 2010f> (safAmfService)
2019-09-11 14:31:59.500 SC-2 osafimmnd[234]: NO Implementer (applier) 
connected: 44 (@safAmfService2010f) <0, 2010f>
2019-09-11 14:31:59.524 SC-2 osafamfd[280]: NO Switching StandBy --> 
Active State
2019-09-11 14:31:59.526 SC-2 osafamfd[280]: ER Switch Standby --> Active 
FAILED, Standby OUT OF SYNC
2019-09-11 14:31:59.526 SC-2 osafamfd[280]: ER avd_role_change role 
change failure
2019-09-11 14:31:59.544 SC-2 osafimmd[223]: NO MDS event from svc_id 24 
(change:7, dest:13)
2019-09-11 14:31:59.547 SC-2 osafimmd[223]: NO MDS event from svc_id 24 
(change:7, dest:13)

2019-09-11 14:31:59.551 SC-2 osafamfnd[290]: NO AVD NEW_ACTIVE, adest:1
2019-09-11 14:31:59.563 SC-2 osafimmnd[234]: NO Implementer disconnected 
44 <0, 2010f> (@safAmfService2010f)
2019-09-11 14:31:59.566 SC-2 osafimmnd[234]: NO Implementer connected: 
45 (safAmfService) <0, 2010f>
2019-09-11 14:31:59.580 SC-2 osafamfd[280]: WA 
avsv_validate_reo_type_in_csync: unknown type 52
2019-09-11 14:32:09.626 SC-2 osafamfd[280]: message repeated 4 times: [ 
WA avsv_validate_reo_type_in_csync: unknown type 52]
2019-09-11 14:32:59.775 SC-2 osafimmd[223]: NO MDS event from svc_id 25 
(change:4, dest:564114788998701)
2019-09-11 14:32:59.775 SC-2 osafimmd[223]: NO MDS event from svc_id 24 
(change:1, dest:13)
2019-09-11 14:32:59.776 SC-2 osafimmd[223]: NO MDS event from svc_id 24 
(change:6, dest:13)

2019-09-11 14:32:59.777 SC-2 osaffmd[213]: NO IMMND down on: 2010f
2019-09-11 14:32:59.777 SC-2 osafimmnd[234]: WA DISCARD DUPLICATE FEVS 
message:2334
2019-09-11 14:32:59.778 SC-2 osafimmnd[234]: WA Error code 2 returned 
for message type 82 - ignoring
2019-09-11 14:32:59.778 SC-2 osafimmd[223]: WA IMMD lost contact with 
peer IMMD (NCSMDS_RED_DOWN)
2019-09-11 14:32:59.780 SC-2 osaffmd[213]: NO Node Down event for node 
id 2010f:

2019-09-11 14:32:59.780 SC-2 osafrded[204]: NO Peer down on node 0x2010f
2019-09-11 14:32:59.782 SC-2 osaffmd[213]: NO AMFND down on: 2010f
2019-09-11 14:32:59.783 SC-2 osaffmd[213]: NO FM down on: 2010f
2019-09-11 14:32:59.784 SC-2 osafamfd[280]: NO Node 'SC-1' is down. 
Start failover delay timer

2019-09-11 14:32:59.784 SC-2 osaffmd[213]: NO IMMD down on: 2010f
2019-09-11 14:32:59.788 SC-2 osaffmd[213]: NO AVD down on: 2010f
2019-09-11 14:32:59.788 SC-2 osaffmd[213]: NO Core services went down on 
node_id: 2010f

2019-09-11 14:32:59.788 SC-2 osaffmd[213]: NO Current role: STANDBY
2019-09-11 14:32:59.788 SC-2 osaffmd[213]: Rebooting OpenSAF NodeId = 
131343 EE Name = , Reason: Received Node Down for peer controller, 
OwnNodeId = 131599, SupervisionTime = 60
2019-09-11 14:32:59.789 SC-2 osafclmd[270]: NO Node 131343 went down. 
Not sending track callback for agents on that node
2019-09-11 14:32:59.792 SC-2 osafclmd[270]: message repeated 4 times: [ 
NO Node 131343 went down. Not sending track callback for agents on that 
node]
2019-09-11 14:32:59.792 SC-2 osafclmd[270]: NO saflog write 
"safNode=SC-1,safCluster=myClmCluster LEFT, init view=9, cluster 
view=10" FAILED: SA_AIS_ERR_TRY_AGAIN (6)

2019-09-11 14:32:59.792 SC-2 osafamfd[280]: NO Start timer for '2010f'
2019-09-11 14:32:59.808 SC-2 opensaf_reboot: Rebooting remote node in 
the absence of PLM is outside the scope of OpenSAF
2019-09-11 14:32:59.809 SC-2 osaffmd[213]: NO Controller Failover: 
Setting role to ACTIVE

2019-09-11 14:32:59.809 SC-2 osafrded[204]: NO RDE role set to ACTIVE
2019-09-11 14:32:59.810 SC-2 osafrded[204]: NO Running 
'/usr/local/lib/opensaf/opensaf_sc_active' with 0 argument(s)

2019-09-11 14:32:59.812 SC-2 osafamfd[280]: NO FAILOVER StandBy --> Active
2019-09-11 14:32:59.812 SC-2 osafamfd[280]: ER FAILOVER StandBy --> 
Active FAILED, Standby OUT OF SYNC
2019-09-11 14:32:59.812 SC-2 osafamfd[280]: Rebooting OpenSAF NodeId = 0 
EE Name = No EE Mapped, Reason: FAILOVER failed, OwnNodeId = 131599, 
SupervisionTime = 60


2019-09-11 14:31:58.181 SC-1 osafamfd[273]: NO ROLE SWITCH Active --> 
Quiesced
2019-09-11 14:31:58.675 SC-1 osafimmnd[233]: NO Implementer (applier) 
connected: 43 (@OpenSafImmReplicatorB) <269, 2010f>

2019-09-11 14:31:58.676 SC-1 osafntfimcnd[471]: NO Started
2019-09-11 14:31:59.496 SC-1 osafimmnd[233]: NO Implementer disconnected 
35 <97, 2010f> (safAmfService)
2019-09-11 14:31:59.501 SC-1 osafimmnd[233]: NO Implementer (applier) 
connected: 44 (@safAmfService2010f) <97, 2010f>
2019-09-11 14:31:59.525 SC-1 

Re: [devel] [PATCH 3/9] mds: Add implementation for TIPC buffer overflow solution [#1960]

2019-09-10 Thread Minh Hon Chau

Hi Gary,

Thanks for the review, please find comments with [M].

/Minh

On 10/9/19 6:02 pm, Gary Lee wrote:

Hi Minh & Thuan

Some minor comments marked with [GL].

On 14/8/19 4:38 pm, Minh Chau wrote:

This is a collaborative patch of two participants:Thuan, Minh.

Main changes:
- Add mds_tipc_fctrl_intf.h, mds_tipc_fctrl_intf.cc: These two files
introduce new functions which are called in mds_dt_tipc.c if the flow
control is enabled
- Add mds_tipc_fctrl_portid.h, mds_tipc_fctrl_portid.cc: These files
implements the tipc portid instance, which supports the sliding window,
mds msg queue
- Add mds_tipc_fctrl_msg.h, mds_tipc_fctrl_msg.cc: These files define
the event and messages which are used for this solution.
---
  src/mds/Makefile.am  |  10 +-
  src/mds/mds_dt.h |   8 +-
  src/mds/mds_dt_tipc.c    | 188 +---
  src/mds/mds_tipc_fctrl_intf.cc   | 376 
+++

  src/mds/mds_tipc_fctrl_intf.h    |  47 +
  src/mds/mds_tipc_fctrl_msg.cc    | 142 +++
  src/mds/mds_tipc_fctrl_msg.h | 129 ++
  src/mds/mds_tipc_fctrl_portid.cc | 261 +++
  src/mds/mds_tipc_fctrl_portid.h  |  87 +
  9 files changed, 1184 insertions(+), 64 deletions(-)
  create mode 100644 src/mds/mds_tipc_fctrl_intf.cc
  create mode 100644 src/mds/mds_tipc_fctrl_intf.h
  create mode 100644 src/mds/mds_tipc_fctrl_msg.cc
  create mode 100644 src/mds/mds_tipc_fctrl_msg.h
  create mode 100644 src/mds/mds_tipc_fctrl_portid.cc
  create mode 100644 src/mds/mds_tipc_fctrl_portid.h

diff --git a/src/mds/Makefile.am b/src/mds/Makefile.am
index 2d7b652..d849e8f 100644
--- a/src/mds/Makefile.am
+++ b/src/mds/Makefile.am
@@ -48,10 +48,16 @@ lib_libopensaf_core_la_SOURCES += \
  if ENABLE_TIPC_TRANSPORT
  noinst_HEADERS += src/mds/mds_dt_tipc.h \
  src/mds/mds_tipc_recvq_stats.h \
-    src/mds/mds_tipc_recvq_stats_impl.h
+    src/mds/mds_tipc_recvq_stats_impl.h \
+    src/mds/mds_tipc_fctrl_intf.h \
+    src/mds/mds_tipc_fctrl_portid.h \
+    src/mds/mds_tipc_fctrl_msg.h
  lib_libopensaf_core_la_SOURCES += src/mds/mds_dt_tipc.c \
  src/mds/mds_tipc_recvq_stats.cc \
-    src/mds/mds_tipc_recvq_stats_impl.cc
+    src/mds/mds_tipc_recvq_stats_impl.cc \
+    src/mds/mds_tipc_fctrl_intf.cc \
+    src/mds/mds_tipc_fctrl_portid.cc \
+    src/mds/mds_tipc_fctrl_msg.cc
  endif
    if ENABLE_TESTS
diff --git a/src/mds/mds_dt.h b/src/mds/mds_dt.h
index b645bb4..d9e8633 100644
--- a/src/mds/mds_dt.h
+++ b/src/mds/mds_dt.h
@@ -162,7 +162,7 @@ uint32_t mdtm_del_from_ref_tbl(MDS_SUBTN_REF_VAL 
ref);

  uint32_t mds_tmr_mailbox_processing(void);
  uint32_t mdtm_get_from_ref_tbl(MDS_SUBTN_REF_VAL ref, MDS_SVC_HDL 
*svc_hdl);
  uint32_t mdtm_add_frag_hdr(uint8_t *buf_ptr, uint16_t len, uint32_t 
seq_num,

-   uint16_t frag_byte);
+   uint16_t frag_byte, uint16_t fctrl_seq_num);
  uint32_t mdtm_free_reassem_msg_mem(MDS_ENCODED_MSG *msg);
  uint32_t mdtm_process_recv_data(uint8_t *buf, uint16_t len, 
uint64_t tipc_id,

  uint32_t *buff_dump);
@@ -240,9 +240,13 @@ bool mdtm_mailbox_mbx_cleanup(NCSCONTEXT arg, 
NCSCONTEXT msg);

    #define MDS_PROT 0xA0
  #define MDS_VERSION 0x08
-#define MDS_PROT_VER_MASK (MDS_PROT | MDS_VERSION)
+#define MDS_PROT_VER_MASK 0xFC
  #define MDTM_PRI_MASK 0x3
  +/* MDS protocol/version for flow control */
+#define MDS_PROT_FCTRL (0xB0 | MDS_VERSION)
+#define MDS_PROT_FCTRL_ID 0x00AC13F5
+
  /* Added for the subscription changes */
  #define MDS_NCS_CHASSIS_ID (m_NCS_GET_NODE_ID & 0x00ff)
  #define MDS_TIPC_COMMON_ID 0x01001000
diff --git a/src/mds/mds_dt_tipc.c b/src/mds/mds_dt_tipc.c
index 86b52bb..fef1c50 100644
--- a/src/mds/mds_dt_tipc.c
+++ b/src/mds/mds_dt_tipc.c
@@ -47,6 +47,7 @@
  #include "mds_dt_tipc.h"
  #include "mds_dt_tcp_disc.h"
  #include "mds_core.h"
+#include "mds_tipc_fctrl_intf.h"
  #include "mds_tipc_recvq_stats.h"
  #include "base/osaf_utility.h"
  #include "base/osaf_poll.h"
@@ -165,20 +166,22 @@ NCS_PATRICIA_TREE mdtm_reassembly_list;
  uint32_t mdtm_global_frag_num;
    const unsigned int MAX_RECV_THRESHOLD = 30;
+uint8_t gl_mds_pro_ver = MDS_PROT | MDS_VERSION;
  -static bool get_tipc_port_id(int sock, uint32_t* port_id) {
+static bool get_tipc_port_id(int sock, struct tipc_portid* port_id) {
  struct sockaddr_tipc addr;
  socklen_t sz = sizeof(addr);
    memset(, 0, sizeof(addr));
-    *port_id = 0;
+    port_id->node = 0;
+    port_id->ref = 0;
  if (0 > getsockname(sock, (struct sockaddr *), )) {
  syslog(LOG_ERR, "MDTM:TIPC Failed to get socket name, err: 
%s",

 strerror(errno));
  return false;
  }
  -    *port_id = addr.addr.id.ref;
+    *port_id = addr.addr.id;
  return true;
  }
  @@ -240,12 +243,13 @@ uint32_t mdtm_tipc_init(NODE_ID nodeid, 
uint32_t *mds_tipc_ref)

  }
    /* Code for getting the self tipc random 

Re: [devel] [PATCH 1/1] evtd: handle CLM-API errors during SC absence [#3081]

2019-09-10 Thread Mathi N P
About the patch, I have no clue why the indentation looks strange.
I just have a question below, otherwise ack:
+while (true) {
+/* Say Hello */
+rc = saClmInitialize_4(>clm_hdl, _cbk, _version);
+if (rc == SA_AIS_OK)
+break;
+else if (rc == SA_AIS_ERR_TRY_AGAIN ||
+rc == SA_AIS_ERR_UNAVAILABLE) {
+osaf_nanosleep();
+continue;

IMM utils implement a global retry counter. I haven't thought through the
big picture yet, so leaving it to you to decide whether
such a retry counter makes sense here?

Thanks,
Mathi.

On Thu, Sep 5, 2019 at 9:21 PM Jones, Alex  wrote:

> Handle CLM-API errors during SC absence.
> ---
> src/evt/common/edsv_defs.h | 2 +-
> src/evt/evtd/eds_amf.c | 71 ++
> src/evt/evtd/eds_amf.h | 11 --
> src/evt/evtd/eds_cb.c | 6 +++-
> 4 files changed, 72 insertions(+), 18 deletions(-)
>
> diff --git a/src/evt/common/edsv_defs.h b/src/evt/common/edsv_defs.h
> index 8372ce8a8..24604927c 100644
> --- a/src/evt/common/edsv_defs.h
> +++ b/src/evt/common/edsv_defs.h
> @@ -82,7 +82,7 @@
>
> #define m_EDSV_GET_CLM_VER(amf_ver) \
> amf_ver.releaseCode = 'B'; \
> - amf_ver.majorVersion = 0x01; \
> + amf_ver.majorVersion = 0x04; \
> amf_ver.minorVersion = 0x01;
>
> /* Define our limits */
> diff --git a/src/evt/evtd/eds_amf.c b/src/evt/evtd/eds_amf.c
> index fe90a6c62..97b71a5bd 100644
> --- a/src/evt/evtd/eds_amf.c
> +++ b/src/evt/evtd/eds_amf.c
> @@ -26,6 +26,7 @@ DESCRIPTION:
> This include file contains AMF interaction logic for health-check and other
> stuff.
>
> ***/
> +#include "base/osaf_time.h"
> #include "eds.h"
> #include "eds_dl_api.h"
>
> @@ -622,9 +623,9 @@ uint32_t eds_amf_register(EDS_CB *eds_cb)
> SaAisErrorT eds_clm_init(EDS_CB *cb)
> {
> SaVersionT clm_version;
> -SaClmCallbacksT clm_cbk;
> -SaClmClusterNodeT cluster_node;
> -SaClmClusterNotificationBufferT notify_buff;
> +SaClmCallbacksT_4 clm_cbk;
> +SaClmClusterNodeT_4 cluster_node;
> +SaClmClusterNotificationBufferT_4 notify_buff;
> SaAisErrorT rc = SA_AIS_OK;
> SaTimeT timeout = EDSV_CLM_TIMEOUT;
> TRACE_ENTER();
> @@ -639,13 +640,22 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> clm_cbk.saClmClusterNodeGetCallback = NULL;
> clm_cbk.saClmClusterTrackCallback = eds_clm_cluster_track_cbk;
>
> -/* Say Hello */
> -rc = saClmInitialize(>clm_hdl, _cbk, _version);
> -if (rc != SA_AIS_OK) {
> -LOG_ER("saClmInitialize failed with error: %d", rc);
> -TRACE_LEAVE();
> -return rc;
> +while (true) {
> +/* Say Hello */
> +rc = saClmInitialize_4(>clm_hdl, _cbk, _version);
> +if (rc == SA_AIS_OK)
> +break;
> +else if (rc == SA_AIS_ERR_TRY_AGAIN ||
> +rc == SA_AIS_ERR_UNAVAILABLE) {
> +osaf_nanosleep();
> +continue;
> +} else {
> +LOG_ER("saClmInitialize_4 failed with error: %d", rc);
> +TRACE_LEAVE();
> +return rc;
> +}
> }
> +
> /* Get the FD */
> if (SA_AIS_OK !=
> (rc = saClmSelectionObjectGet(cb->clm_hdl, >clm_sel_obj))) {
> @@ -654,10 +664,10 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> return rc;
> }
> /* Get your own node id */
> -rc = saClmClusterNodeGet(cb->clm_hdl, SA_CLM_LOCAL_NODE_ID, timeout,
> +rc = saClmClusterNodeGet_4(cb->clm_hdl, SA_CLM_LOCAL_NODE_ID, timeout,
> _node);
> if (rc != SA_AIS_OK) {
> -LOG_ER("saClmClusterNodeGet failed with error: %d", rc);
> +LOG_ER("saClmClusterNodeGet_4 failed with error: %d", rc);
> TRACE_LEAVE();
> return rc;
> }
> @@ -665,7 +675,7 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> cb->node_id = cluster_node.nodeId;
>
> notify_buff.notification = NULL;
> -rc = saClmClusterTrack(cb->clm_hdl,
> +rc = saClmClusterTrack_4(cb->clm_hdl,
> (SA_TRACK_CURRENT | SA_TRACK_CHANGES), NULL);
> if (rc != SA_AIS_OK)
> LOG_ER("saClmClusterTrack failed with error: %d", rc);
> @@ -674,6 +684,33 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> return rc;
> }
>
> +static void * eds_clm_init_thread(void *arg) {
> + TRACE_ENTER();
> + EDS_CB *cb = (EDS_CB *)(arg);
> +
> + eds_clm_init(cb);
> +
> + TRACE_LEAVE();
> + return 0;
> +}
> +
> +SaAisErrorT eds_clm_reinit_bg(EDS_CB *cb)
> +{
> +pthread_t thread;
> +pthread_attr_t attr;
> +pthread_attr_init();
> +pthread_attr_setdetachstate(, PTHREAD_CREATE_DETACHED);
> +
> +if (pthread_create(, , eds_clm_init_thread, cb) != 0) {
> +LOG_ER("pthread_create FAILED: %s", strerror(errno));
> +exit(EXIT_FAILURE);
> +}
> +
> +pthread_attr_destroy();
> +
> +return SA_AIS_OK;
> +}
> +
> /**
> * Function: eds_clm_cluster_track_cbk
> *
> @@ -700,8 +737,14 @@ SaAisErrorT eds_clm_init(EDS_CB *cb)
> **/
>
> void eds_clm_cluster_track_cbk(
> - const SaClmClusterNotificationBufferT *notificationBuffer,
> - SaUint32T numberOfMembers, SaAisErrorT error)
> +const SaClmClusterNotificationBufferT_4 *notificationBuffer,
> +SaUint32T numberOfMembers,
> +SaInvocationT invocation,
> +const SaNameT *rootCauseEntity,
> +const SaNtfCorrelationIdsT *correlationIds,
> 

Re: [devel] [PATCH 3/9] mds: Add implementation for TIPC buffer overflow solution [#1960]

2019-09-10 Thread Gary Lee

Please ignore the Encode/Decode comment.

On 10/9/19 6:02 pm, Gary Lee wrote:

Hi Minh & Thuan

Some minor comments marked with [GL].

On 14/8/19 4:38 pm, Minh Chau wrote:

This is a collaborative patch of two participants:Thuan, Minh.

Main changes:
- Add mds_tipc_fctrl_intf.h, mds_tipc_fctrl_intf.cc: These two files
introduce new functions which are called in mds_dt_tipc.c if the flow
control is enabled
- Add mds_tipc_fctrl_portid.h, mds_tipc_fctrl_portid.cc: These files
implements the tipc portid instance, which supports the sliding window,
mds msg queue
- Add mds_tipc_fctrl_msg.h, mds_tipc_fctrl_msg.cc: These files define
the event and messages which are used for this solution.
---
  src/mds/Makefile.am  |  10 +-
  src/mds/mds_dt.h |   8 +-
  src/mds/mds_dt_tipc.c    | 188 +---
  src/mds/mds_tipc_fctrl_intf.cc   | 376 
+++

  src/mds/mds_tipc_fctrl_intf.h    |  47 +
  src/mds/mds_tipc_fctrl_msg.cc    | 142 +++
  src/mds/mds_tipc_fctrl_msg.h | 129 ++
  src/mds/mds_tipc_fctrl_portid.cc | 261 +++
  src/mds/mds_tipc_fctrl_portid.h  |  87 +
  9 files changed, 1184 insertions(+), 64 deletions(-)
  create mode 100644 src/mds/mds_tipc_fctrl_intf.cc
  create mode 100644 src/mds/mds_tipc_fctrl_intf.h
  create mode 100644 src/mds/mds_tipc_fctrl_msg.cc
  create mode 100644 src/mds/mds_tipc_fctrl_msg.h
  create mode 100644 src/mds/mds_tipc_fctrl_portid.cc
  create mode 100644 src/mds/mds_tipc_fctrl_portid.h

diff --git a/src/mds/Makefile.am b/src/mds/Makefile.am
index 2d7b652..d849e8f 100644
--- a/src/mds/Makefile.am
+++ b/src/mds/Makefile.am
@@ -48,10 +48,16 @@ lib_libopensaf_core_la_SOURCES += \
  if ENABLE_TIPC_TRANSPORT
  noinst_HEADERS += src/mds/mds_dt_tipc.h \
  src/mds/mds_tipc_recvq_stats.h \
-    src/mds/mds_tipc_recvq_stats_impl.h
+    src/mds/mds_tipc_recvq_stats_impl.h \
+    src/mds/mds_tipc_fctrl_intf.h \
+    src/mds/mds_tipc_fctrl_portid.h \
+    src/mds/mds_tipc_fctrl_msg.h
  lib_libopensaf_core_la_SOURCES += src/mds/mds_dt_tipc.c \
  src/mds/mds_tipc_recvq_stats.cc \
-    src/mds/mds_tipc_recvq_stats_impl.cc
+    src/mds/mds_tipc_recvq_stats_impl.cc \
+    src/mds/mds_tipc_fctrl_intf.cc \
+    src/mds/mds_tipc_fctrl_portid.cc \
+    src/mds/mds_tipc_fctrl_msg.cc
  endif
    if ENABLE_TESTS
diff --git a/src/mds/mds_dt.h b/src/mds/mds_dt.h
index b645bb4..d9e8633 100644
--- a/src/mds/mds_dt.h
+++ b/src/mds/mds_dt.h
@@ -162,7 +162,7 @@ uint32_t mdtm_del_from_ref_tbl(MDS_SUBTN_REF_VAL 
ref);

  uint32_t mds_tmr_mailbox_processing(void);
  uint32_t mdtm_get_from_ref_tbl(MDS_SUBTN_REF_VAL ref, MDS_SVC_HDL 
*svc_hdl);
  uint32_t mdtm_add_frag_hdr(uint8_t *buf_ptr, uint16_t len, uint32_t 
seq_num,

-   uint16_t frag_byte);
+   uint16_t frag_byte, uint16_t fctrl_seq_num);
  uint32_t mdtm_free_reassem_msg_mem(MDS_ENCODED_MSG *msg);
  uint32_t mdtm_process_recv_data(uint8_t *buf, uint16_t len, 
uint64_t tipc_id,

  uint32_t *buff_dump);
@@ -240,9 +240,13 @@ bool mdtm_mailbox_mbx_cleanup(NCSCONTEXT arg, 
NCSCONTEXT msg);

    #define MDS_PROT 0xA0
  #define MDS_VERSION 0x08
-#define MDS_PROT_VER_MASK (MDS_PROT | MDS_VERSION)
+#define MDS_PROT_VER_MASK 0xFC
  #define MDTM_PRI_MASK 0x3
  +/* MDS protocol/version for flow control */
+#define MDS_PROT_FCTRL (0xB0 | MDS_VERSION)
+#define MDS_PROT_FCTRL_ID 0x00AC13F5
+
  /* Added for the subscription changes */
  #define MDS_NCS_CHASSIS_ID (m_NCS_GET_NODE_ID & 0x00ff)
  #define MDS_TIPC_COMMON_ID 0x01001000
diff --git a/src/mds/mds_dt_tipc.c b/src/mds/mds_dt_tipc.c
index 86b52bb..fef1c50 100644
--- a/src/mds/mds_dt_tipc.c
+++ b/src/mds/mds_dt_tipc.c
@@ -47,6 +47,7 @@
  #include "mds_dt_tipc.h"
  #include "mds_dt_tcp_disc.h"
  #include "mds_core.h"
+#include "mds_tipc_fctrl_intf.h"
  #include "mds_tipc_recvq_stats.h"
  #include "base/osaf_utility.h"
  #include "base/osaf_poll.h"
@@ -165,20 +166,22 @@ NCS_PATRICIA_TREE mdtm_reassembly_list;
  uint32_t mdtm_global_frag_num;
    const unsigned int MAX_RECV_THRESHOLD = 30;
+uint8_t gl_mds_pro_ver = MDS_PROT | MDS_VERSION;
  -static bool get_tipc_port_id(int sock, uint32_t* port_id) {
+static bool get_tipc_port_id(int sock, struct tipc_portid* port_id) {
  struct sockaddr_tipc addr;
  socklen_t sz = sizeof(addr);
    memset(, 0, sizeof(addr));
-    *port_id = 0;
+    port_id->node = 0;
+    port_id->ref = 0;
  if (0 > getsockname(sock, (struct sockaddr *), )) {
  syslog(LOG_ERR, "MDTM:TIPC Failed to get socket name, err: 
%s",

 strerror(errno));
  return false;
  }
  -    *port_id = addr.addr.id.ref;
+    *port_id = addr.addr.id;
  return true;
  }
  @@ -240,12 +243,13 @@ uint32_t mdtm_tipc_init(NODE_ID nodeid, 
uint32_t *mds_tipc_ref)

  }
    /* Code for getting the self tipc random number */
-    if 

Re: [devel] [PATCH 3/9] mds: Add implementation for TIPC buffer overflow solution [#1960]

2019-09-10 Thread Gary Lee

Hi Minh & Thuan

Some minor comments marked with [GL].

On 14/8/19 4:38 pm, Minh Chau wrote:

This is a collaborative patch of two participants:Thuan, Minh.

Main changes:
- Add mds_tipc_fctrl_intf.h, mds_tipc_fctrl_intf.cc: These two files
introduce new functions which are called in mds_dt_tipc.c if the flow
control is enabled
- Add mds_tipc_fctrl_portid.h, mds_tipc_fctrl_portid.cc: These files
implements the tipc portid instance, which supports the sliding window,
mds msg queue
- Add mds_tipc_fctrl_msg.h, mds_tipc_fctrl_msg.cc: These files define
the event and messages which are used for this solution.
---
  src/mds/Makefile.am  |  10 +-
  src/mds/mds_dt.h |   8 +-
  src/mds/mds_dt_tipc.c| 188 +---
  src/mds/mds_tipc_fctrl_intf.cc   | 376 +++
  src/mds/mds_tipc_fctrl_intf.h|  47 +
  src/mds/mds_tipc_fctrl_msg.cc| 142 +++
  src/mds/mds_tipc_fctrl_msg.h | 129 ++
  src/mds/mds_tipc_fctrl_portid.cc | 261 +++
  src/mds/mds_tipc_fctrl_portid.h  |  87 +
  9 files changed, 1184 insertions(+), 64 deletions(-)
  create mode 100644 src/mds/mds_tipc_fctrl_intf.cc
  create mode 100644 src/mds/mds_tipc_fctrl_intf.h
  create mode 100644 src/mds/mds_tipc_fctrl_msg.cc
  create mode 100644 src/mds/mds_tipc_fctrl_msg.h
  create mode 100644 src/mds/mds_tipc_fctrl_portid.cc
  create mode 100644 src/mds/mds_tipc_fctrl_portid.h

diff --git a/src/mds/Makefile.am b/src/mds/Makefile.am
index 2d7b652..d849e8f 100644
--- a/src/mds/Makefile.am
+++ b/src/mds/Makefile.am
@@ -48,10 +48,16 @@ lib_libopensaf_core_la_SOURCES += \
  if ENABLE_TIPC_TRANSPORT
  noinst_HEADERS += src/mds/mds_dt_tipc.h \
src/mds/mds_tipc_recvq_stats.h \
-   src/mds/mds_tipc_recvq_stats_impl.h
+   src/mds/mds_tipc_recvq_stats_impl.h \
+   src/mds/mds_tipc_fctrl_intf.h \
+   src/mds/mds_tipc_fctrl_portid.h \
+   src/mds/mds_tipc_fctrl_msg.h
  lib_libopensaf_core_la_SOURCES += src/mds/mds_dt_tipc.c \
src/mds/mds_tipc_recvq_stats.cc \
-   src/mds/mds_tipc_recvq_stats_impl.cc
+   src/mds/mds_tipc_recvq_stats_impl.cc \
+   src/mds/mds_tipc_fctrl_intf.cc \
+   src/mds/mds_tipc_fctrl_portid.cc \
+   src/mds/mds_tipc_fctrl_msg.cc
  endif
  
  if ENABLE_TESTS

diff --git a/src/mds/mds_dt.h b/src/mds/mds_dt.h
index b645bb4..d9e8633 100644
--- a/src/mds/mds_dt.h
+++ b/src/mds/mds_dt.h
@@ -162,7 +162,7 @@ uint32_t mdtm_del_from_ref_tbl(MDS_SUBTN_REF_VAL ref);
  uint32_t mds_tmr_mailbox_processing(void);
  uint32_t mdtm_get_from_ref_tbl(MDS_SUBTN_REF_VAL ref, MDS_SVC_HDL *svc_hdl);
  uint32_t mdtm_add_frag_hdr(uint8_t *buf_ptr, uint16_t len, uint32_t seq_num,
-   uint16_t frag_byte);
+   uint16_t frag_byte, uint16_t fctrl_seq_num);
  uint32_t mdtm_free_reassem_msg_mem(MDS_ENCODED_MSG *msg);
  uint32_t mdtm_process_recv_data(uint8_t *buf, uint16_t len, uint64_t tipc_id,
  uint32_t *buff_dump);
@@ -240,9 +240,13 @@ bool mdtm_mailbox_mbx_cleanup(NCSCONTEXT arg, NCSCONTEXT 
msg);
  
  #define MDS_PROT 0xA0

  #define MDS_VERSION 0x08
-#define MDS_PROT_VER_MASK (MDS_PROT | MDS_VERSION)
+#define MDS_PROT_VER_MASK 0xFC
  #define MDTM_PRI_MASK 0x3
  
+/* MDS protocol/version for flow control */

+#define MDS_PROT_FCTRL (0xB0 | MDS_VERSION)
+#define MDS_PROT_FCTRL_ID 0x00AC13F5
+
  /* Added for the subscription changes */
  #define MDS_NCS_CHASSIS_ID (m_NCS_GET_NODE_ID & 0x00ff)
  #define MDS_TIPC_COMMON_ID 0x01001000
diff --git a/src/mds/mds_dt_tipc.c b/src/mds/mds_dt_tipc.c
index 86b52bb..fef1c50 100644
--- a/src/mds/mds_dt_tipc.c
+++ b/src/mds/mds_dt_tipc.c
@@ -47,6 +47,7 @@
  #include "mds_dt_tipc.h"
  #include "mds_dt_tcp_disc.h"
  #include "mds_core.h"
+#include "mds_tipc_fctrl_intf.h"
  #include "mds_tipc_recvq_stats.h"
  #include "base/osaf_utility.h"
  #include "base/osaf_poll.h"
@@ -165,20 +166,22 @@ NCS_PATRICIA_TREE mdtm_reassembly_list;
  uint32_t mdtm_global_frag_num;
  
  const unsigned int MAX_RECV_THRESHOLD = 30;

+uint8_t gl_mds_pro_ver = MDS_PROT | MDS_VERSION;
  
-static bool get_tipc_port_id(int sock, uint32_t* port_id) {

+static bool get_tipc_port_id(int sock, struct tipc_portid* port_id) {
struct sockaddr_tipc addr;
socklen_t sz = sizeof(addr);
  
  	memset(, 0, sizeof(addr));

-   *port_id = 0;
+   port_id->node = 0;
+   port_id->ref = 0;
if (0 > getsockname(sock, (struct sockaddr *), )) {
syslog(LOG_ERR, "MDTM:TIPC Failed to get socket name, err: %s",
   strerror(errno));
return false;
}
  
-	*port_id = addr.addr.id.ref;

+   *port_id = addr.addr.id;
return true;
  }
  
@@ -240,12 +243,13 @@ uint32_t mdtm_tipc_init(NODE_ID nodeid, uint32_t *mds_tipc_ref)

}
  
  	/* Code for getting the self tipc random number */

-   if