Hi Vu,

it is not dead code as it is executed and "aborts" the broadcast, which is the bug here.

But the check may be removed as it is already seems done above, I prefer to remove this in

a separate refactoring ticket though.

/BR HansN


On 05/29/2018 08:13 AM, Vu Minh Nguyen wrote:
Hi Hans,

Ack with one question, started with [Vu]. Thanks!

Regards, Vu

-----Original Message-----
From: Hans Nordeback <hans.nordeb...@ericsson.com>
Sent: Monday, May 28, 2018 6:18 PM
To: vu.m.ngu...@dektech.com.au
Cc: opensaf-devel@lists.sourceforge.net; Hans Nordeback
<hans.nordeb...@ericsson.com>
Subject: [PATCH 1/1] mds: return success at failure in case of using
broadcast
send type [#2866]

---
  src/mds/apitest/mdstipc.h     |   2 +
  src/mds/apitest/mdstipc_api.c | 130
++++++++++++++++++++++++++++++++++
  src/mds/mds_dt_tipc.c         |   2 +-
  3 files changed, 133 insertions(+), 1 deletion(-)

diff --git a/src/mds/apitest/mdstipc.h b/src/mds/apitest/mdstipc.h
index 01b58c405..07cf55696 100644
--- a/src/mds/apitest/mdstipc.h
+++ b/src/mds/apitest/mdstipc.h
@@ -361,6 +361,8 @@ void tet_broadcast_to_svc_tp_3(void);
  void tet_broadcast_to_svc_tp_4(void);
  void tet_broadcast_to_svc_tp_5(void);
  void tet_broadcast_to_svc_tp_6(void);
+void tet_broadcast_to_svc_tp_7(void);
+void tet_broadcast_to_svc_tp_8(void);
  void tet_direct_just_send_tp_1(void);
  void tet_direct_just_send_tp_2(void);
  void tet_direct_just_send_tp_3(void);
diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c
index de166d11d..e320e094e 100644
--- a/src/mds/apitest/mdstipc_api.c
+++ b/src/mds/apitest/mdstipc_api.c
@@ -7479,6 +7479,130 @@ void tet_broadcast_to_svc_tp_6()
        test_validate(FAIL, 0);
  }

+void tet_broadcast_to_svc_tp_7()
+{
+       int FAIL = 0;
+       MDS_SVC_ID svcids[] = {NCSMDS_SVC_ID_EXTERNAL_MIN};
+
+       // Test broadcast of large message
+       char tmp[65220] = " Hi All ";
+       TET_MDS_MSG *mesg;
+       mesg = (TET_MDS_MSG *)malloc(sizeof(TET_MDS_MSG));
+       memset(mesg, 0, sizeof(TET_MDS_MSG));
+       memcpy(mesg->send_data, tmp, sizeof(tmp));
+       mesg->send_len = sizeof(tmp);
+
+       /*Start up*/
+       if (tet_initialise_setup(false)) {
+               printf("\nSetup Initialisation has Failed \n");
+               FAIL = 1;
+       } else {
+
/*--------------------------------------------------------------------*/
+               printf(
+                   "\nCase 1: Svc INTMIN on VDEST=200 Broadcasting a LOW
Priority message to Svc EXTMIN\n");
+               if (mds_service_subscribe(gl_tet_vdest[1].mds_pwe1_hdl,
+                                         NCSMDS_SVC_ID_INTERNAL_MIN,
+                                         NCSMDS_SCOPE_NONE, 1,
+                                         svcids) != NCSCC_RC_SUCCESS) {
+                       printf("\nFail\n");
+                       FAIL = 1;
+               }
+               if (mds_service_retrieve(gl_tet_vdest[1].mds_pwe1_hdl,
+                                        NCSMDS_SVC_ID_INTERNAL_MIN,
+                                        SA_DISPATCH_ALL) !=
NCSCC_RC_SUCCESS) {
+                       printf("\nFail\n");
+                       FAIL = 1;
+               }
+               if (mds_broadcast_to_svc(
+                       gl_tet_vdest[1].mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_INTERNAL_MIN,
NCSMDS_SVC_ID_EXTERNAL_MIN,
+                       NCSMDS_SCOPE_NONE, MDS_SEND_PRIORITY_LOW,
+                       mesg) != NCSCC_RC_SUCCESS) {
+                       printf("\nFail\n");
+                       FAIL = 1;
+               } else
+                       printf("\nSuccess\n");
+               if (mds_service_cancel_subscription(
+                       gl_tet_vdest[1].mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_INTERNAL_MIN, 1,
+                       svcids) != NCSCC_RC_SUCCESS) {
+                       printf("\nFail\n");
+                       FAIL = 1;
+               }
+       }
+
/*---------------------------------------------------------------------*/
+       /*clean up*/
+       if (tet_cleanup_setup()) {
+               printf("\nSetup Clean Up has Failed \n");
+               FAIL = 1;
+       }
+
+       free(mesg);
+       test_validate(FAIL, 0);
+}
+
+void tet_broadcast_to_svc_tp_8()
+{
+       int FAIL = 0;
+       MDS_SVC_ID svcids[] = {NCSMDS_SVC_ID_EXTERNAL_MIN};
+
+       // Test broadcast of large message
+       char tmp[66000] = " Hi All ";
+       TET_MDS_MSG *mesg;
+       mesg = (TET_MDS_MSG *)malloc(sizeof(TET_MDS_MSG));
+       memset(mesg, 0, sizeof(TET_MDS_MSG));
+       memcpy(mesg->send_data, tmp, sizeof(tmp));
+       mesg->send_len = sizeof(tmp);
+
+       /*Start up*/
+       if (tet_initialise_setup(false)) {
+               printf("\nSetup Initialisation has Failed \n");
+               FAIL = 1;
+       } else {
+
/*--------------------------------------------------------------------*/
+               printf(
+                   "\nCase 1: Svc INTMIN on VDEST=200 Broadcasting a LOW
Priority message to Svc EXTMIN\n");
+               if (mds_service_subscribe(gl_tet_vdest[1].mds_pwe1_hdl,
+                                         NCSMDS_SVC_ID_INTERNAL_MIN,
+                                         NCSMDS_SCOPE_NONE, 1,
+                                         svcids) != NCSCC_RC_SUCCESS) {
+                       printf("\nFail\n");
+                       FAIL = 1;
+               }
+               if (mds_service_retrieve(gl_tet_vdest[1].mds_pwe1_hdl,
+                                        NCSMDS_SVC_ID_INTERNAL_MIN,
+                                        SA_DISPATCH_ALL) !=
NCSCC_RC_SUCCESS) {
+                       printf("\nFail\n");
+                       FAIL = 1;
+               }
+               if (mds_broadcast_to_svc(
+                       gl_tet_vdest[1].mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_INTERNAL_MIN,
NCSMDS_SVC_ID_EXTERNAL_MIN,
+                       NCSMDS_SCOPE_NONE, MDS_SEND_PRIORITY_LOW,
+                       mesg) != NCSCC_RC_SUCCESS) {
+                       printf("\nFail\n");
+                       FAIL = 1;
+               } else
+                       printf("\nSuccess\n");
+               if (mds_service_cancel_subscription(
+                       gl_tet_vdest[1].mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_INTERNAL_MIN, 1,
+                       svcids) != NCSCC_RC_SUCCESS) {
+                       printf("\nFail\n");
+                       FAIL = 1;
+               }
+       }
+
/*---------------------------------------------------------------------*/
+       /*clean up*/
+       if (tet_cleanup_setup()) {
+               printf("\nSetup Clean Up has Failed \n");
+               FAIL = 1;
+       }
+
+       free(mesg);
+       test_validate(FAIL, 0);
+}
+
  /*---------------- DIRECT SEND TEST
CASES--------------------------------*/
  void tet_direct_just_send_tp_1()
@@ -13422,6 +13546,12 @@ __attribute__((constructor)) static void
mdsTipcAPI_constructor(void)
        test_case_add(
            12, tet_broadcast_to_svc_tp_6,
            "Svc INTMIN on VDEST=200 Broadcasting a VERY HIGH Priority
message (>MDS_DIRECT_BUF_MAXSIZE) to Svc EXTMIN");
+       test_case_add(
+           12, tet_broadcast_to_svc_tp_7,
+           "Svc INTMIN on VDEST=200 Broadcasting a LOW Priority message
to Svc EXTMIN, large buffer near MDS_DIRECT_BUF_MAXSIZE");
+       test_case_add(
+           12, tet_broadcast_to_svc_tp_8,
+           "Svc INTMIN on VDEST=200 Broadcasting a LOW Priority message
to Svc EXTMIN, large buffer > MDS_DIRECT_BUF_MAXSIZE");

        test_suite_add(13, "Direct Just Send test cases");
        test_case_add(
diff --git a/src/mds/mds_dt_tipc.c b/src/mds/mds_dt_tipc.c
index 77141757b..a3abff5f7 100644
--- a/src/mds/mds_dt_tipc.c
+++ b/src/mds/mds_dt_tipc.c
@@ -2700,7 +2700,7 @@ uint32_t mds_mdtm_send_tipc(MDTM_SEND_REQ
*req)
                                            req->src_svc_id,
                                            get_svc_names(req->dest_svc_id),
                                            req->dest_svc_id);
-                                       if (len > MDS_DIRECT_BUF_MAXSIZE) {
+                                       if (len -
sum_mds_hdr_plus_mdtm_hdr_plus_len > MDS_DIRECT_BUF_MAXSIZE) {
[Vu] Seems this check is a dead code because it already has a check prior?
if (len > frag_size) {
        /* Packet needs to be fragmented and send */
        return mdtm_frag_and_send(req, frag_seq_num, tipc_id, frag_size);
}

        m_MMGR_FREE_BUFR_LIST(usrbuf);
                                                free(body);
                                                LOG_NO(
--
2.17.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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to