|
From: Zoran M. <zor...@er...> - 2016-07-15 21:54:22
|
Summary: clm: add support for long RDN [#1906]
Review request for Trac Ticket(s): 1906
Peer Reviewer(s): Mathi
Pull request to: Zoran
Affected branch(es): default(5.1)
Development branch: default(5.1)
--------------------------------
Impacted area Impact y/n
--------------------------------
Docs n
Build system n
RPM/packaging n
Configuration files n
Startup scripts n
SAF services y
OpenSAF services n
Core libraries n
Samples n
Tests n
Other n
Comments (indicate scope for each "y" above):
---------------------------------------------
changeset 7ebdd0d9fdca85fc6eb6604aed3c76f2db6a7fc2
Author: Zoran Milinkovic <zor...@er...>
Date: Fri, 15 Jul 2016 23:51:02 +0200
clm: add support for long RDN for clm service [#1906]
Add support for long RDN to support RDN values longer than 64 bytes
Complete diffstat:
------------------
osaf/services/saf/clmsv/clms/clms_imm.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
osaf/services/saf/clmsv/clms/clms_main.c | 5 +++++
osaf/services/saf/clmsv/clms/clms_util.c | 7 +++++++
3 files changed, 75 insertions(+), 10 deletions(-)
Testing Commands:
-----------------
<<LIST THE COMMAND LINE TOOLS/STEPS TO TEST YOUR CHANGES>>
Testing, Expected Results:
--------------------------
Test that CLM support RDNs longer than 64 bytes
Conditions of Submission:
-------------------------
Ack from Mathi
Arch Built Started Linux distro
-------------------------------------------
mips n n
mips64 n n
x86 n n
x86_64 n n
powerpc n n
powerpc64 n n
Reviewer Checklist:
-------------------
[Submitters: make sure that your review doesn't trigger any checkmarks!]
Your checkin has not passed review because (see checked entries):
___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.
___ You have failed to nominate the proper persons for review and push.
___ Your patches do not have proper short+long header
___ You have grammar/spelling in your header that is unacceptable.
___ You have exceeded a sensible line length in your headers/comments/text.
___ You have failed to put in a proper Trac Ticket # into your commits.
___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)
___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.
___ You have ^M present in some of your files. These have to be removed.
___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.
___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.
___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.
___ You have extraneous garbage in your review (merge commits etc)
___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.
___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.
___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.
___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.
___ You have a misconfigured ~/.hgrc file (i.e. username, email etc)
___ Your computer have a badly configured date and time; confusing the
the threaded patch review.
___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.
___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.
|
|
From: Zoran M. <zor...@er...> - 2016-07-15 21:57:34
|
Summary: clm: add support for long RDN [#1906]
Review request for Trac Ticket(s): 1906
Peer Reviewer(s): Mathi
Pull request to: Zoran
Affected branch(es): default(5.1)
Development branch: default(5.1)
--------------------------------
Impacted area Impact y/n
--------------------------------
Docs n
Build system n
RPM/packaging n
Configuration files n
Startup scripts n
SAF services y
OpenSAF services n
Core libraries n
Samples n
Tests n
Other n
Comments (indicate scope for each "y" above):
---------------------------------------------
changeset 95f06964c2a6117d839fd33e1b334cd01ee803a9
Author: Zoran Milinkovic <zor...@er...>
Date: Fri, 15 Jul 2016 23:50:34 +0200
clm: add support for long RDN for clm library [#1906]
Add support for long RDN to support RDN values longer than 64 bytes
changeset 7ebdd0d9fdca85fc6eb6604aed3c76f2db6a7fc2
Author: Zoran Milinkovic <zor...@er...>
Date: Fri, 15 Jul 2016 23:51:02 +0200
clm: add support for long RDN for clm service [#1906]
Add support for long RDN to support RDN values longer than 64 bytes
Complete diffstat:
------------------
osaf/libs/agents/saf/clma/clma_api.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------
osaf/libs/agents/saf/clma/clma_util.c | 14 ++++++++++++++
osaf/libs/common/clmsv/clmsv_enc_dec.c | 32 ++++++++++++++++++++------------
osaf/services/saf/clmsv/clms/clms_imm.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
osaf/services/saf/clmsv/clms/clms_main.c | 5 +++++
osaf/services/saf/clmsv/clms/clms_util.c | 7 +++++++
6 files changed, 171 insertions(+), 45 deletions(-)
Testing Commands:
-----------------
<<LIST THE COMMAND LINE TOOLS/STEPS TO TEST YOUR CHANGES>>
Testing, Expected Results:
--------------------------
Test that long RDN is supported in CLM
Conditions of Submission:
-------------------------
Ack from Mathi
Arch Built Started Linux distro
-------------------------------------------
mips n n
mips64 n n
x86 n n
x86_64 n n
powerpc n n
powerpc64 n n
Reviewer Checklist:
-------------------
[Submitters: make sure that your review doesn't trigger any checkmarks!]
Your checkin has not passed review because (see checked entries):
___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.
___ You have failed to nominate the proper persons for review and push.
___ Your patches do not have proper short+long header
___ You have grammar/spelling in your header that is unacceptable.
___ You have exceeded a sensible line length in your headers/comments/text.
___ You have failed to put in a proper Trac Ticket # into your commits.
___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)
___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.
___ You have ^M present in some of your files. These have to be removed.
___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.
___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.
___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.
___ You have extraneous garbage in your review (merge commits etc)
___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.
___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.
___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.
___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.
___ You have a misconfigured ~/.hgrc file (i.e. username, email etc)
___ Your computer have a badly configured date and time; confusing the
the threaded patch review.
___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.
___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.
|
|
From: Zoran M. <zor...@er...> - 2016-07-15 21:57:36
|
osaf/libs/agents/saf/clma/clma_api.c | 85 ++++++++++++++++++++++++---------
osaf/libs/agents/saf/clma/clma_util.c | 14 +++++
osaf/libs/common/clmsv/clmsv_enc_dec.c | 32 ++++++++----
3 files changed, 96 insertions(+), 35 deletions(-)
Add support for long RDN to support RDN values longer than 64 bytes
diff --git a/osaf/libs/agents/saf/clma/clma_api.c b/osaf/libs/agents/saf/clma/clma_api.c
--- a/osaf/libs/agents/saf/clma/clma_api.c
+++ b/osaf/libs/agents/saf/clma/clma_api.c
@@ -31,6 +31,7 @@
#include "clma.h"
#include "ncs_main_papi.h"
+#include "osaf_extended_name.h"
#define CLMS_WAIT_TIME 1000
#define CLM_API_MIN_TIMEOUT 10 /* ten milli seconds */
@@ -84,10 +85,7 @@ void clma_fill_node_from_node4(SaClmClus
clusterNode->nodeAddress.length = clusterNode_4.nodeAddress.length;
(void)memcpy(clusterNode->nodeAddress.value, clusterNode_4.nodeAddress.value, clusterNode->nodeAddress.length);
clusterNode->nodeName.length = clusterNode_4.nodeName.length;
- (void)memcpy(clusterNode->nodeName.value, clusterNode_4.nodeName.value, clusterNode->nodeName.length);
- clusterNode->nodeName.value[clusterNode->nodeName.length <
- SA_MAX_NAME_LENGTH ? clusterNode->nodeName.length :
- SA_MAX_NAME_LENGTH - 1] = '\0';
+ osaf_extended_name_alloc(osaf_extended_name_borrow(&clusterNode_4.nodeName), &clusterNode->nodeName);
clusterNode->member = clusterNode_4.member;
clusterNode->bootTimestamp = clusterNode_4.bootTimestamp;
clusterNode->initialViewNumber = clusterNode_4.initialViewNumber;
@@ -119,8 +117,17 @@ static SaAisErrorT clma_validate_flags_b
/* validate the notify buffer */
if ((flags & SA_TRACK_CURRENT) && buf && buf->notification) {
+ uint32_t i;
+
if (!buf->numberOfItems)
return SA_AIS_ERR_INVALID_PARAM;
+
+ // Check that nodeName is not longer than 255
+ for(i=0; i<buf->numberOfItems; i++) {
+ if(osaf_extended_name_length(&buf->notification[i].clusterNode.nodeName) >= SA_MAX_NAME_LENGTH) {
+ return SA_AIS_ERR_INVALID_PARAM;
+ }
+ }
}
/* Validate if flag is TRACK_CURRENT and no callback and no buffer provided */
@@ -160,10 +167,24 @@ static SaAisErrorT clma_validate_flags_b
/* validate the notify buffer */
if ((flags & SA_TRACK_CURRENT) && buf && buf->notification) {
+ uint32_t i;
+
if (!buf->numberOfItems) {
TRACE_LEAVE();
return SA_AIS_ERR_INVALID_PARAM;
}
+
+ // Check that nodeName and EE are not longer than 255
+ for(i=0; i<buf->numberOfItems; i++) {
+ if(osaf_extended_name_length(&buf->notification[i].clusterNode.nodeName) >= SA_MAX_NAME_LENGTH) {
+ TRACE_LEAVE();
+ return SA_AIS_ERR_INVALID_PARAM;
+ }
+ if(osaf_extended_name_length(&buf->notification[i].clusterNode.executionEnvironment) >= SA_MAX_NAME_LENGTH) {
+ TRACE_LEAVE();
+ return SA_AIS_ERR_INVALID_PARAM;
+ }
+ }
}
/* Validate if flag is TRACK_CURRENT and no callback and no buffer provided */
@@ -228,16 +249,18 @@ static SaAisErrorT clma_fill_cluster_ntf
return SA_AIS_ERR_NO_MEMORY;
if (buf_4->notification != NULL &&
- (buf_4->numberOfItems >= msg_rsp->info.api_resp_info.param.track.notify_info->numberOfItems)) {
+ (buf_4->numberOfItems >= msg_rsp->info.api_resp_info.param.track.notify_info->numberOfItems)) {
/* Overwrite the numberOfItems and copy it to buffer */
buf_4->numberOfItems = msg_rsp->info.api_resp_info.param.track.notify_info->numberOfItems;
buf_4->viewNumber = msg_rsp->info.api_resp_info.param.track.notify_info->viewNumber;
memset(buf_4->notification, 0, sizeof(SaClmClusterNotificationT_4) * buf_4->numberOfItems);
memcpy(buf_4->notification, msg_rsp->info.api_resp_info.param.track.notify_info->notification,
- sizeof(SaClmClusterNotificationT_4) * buf_4->numberOfItems);
- } else if(buf_4->notification != NULL &&
- (buf_4->numberOfItems < msg_rsp->info.api_resp_info.param.track.notify_info->numberOfItems)) {
+ sizeof(SaClmClusterNotificationT_4) * buf_4->numberOfItems);
+
+ /* TODO: Code for copying long DNs for nodeName and EE when full long DN support is implemented. */
+ } else if(buf_4->notification != NULL &&
+ (buf_4->numberOfItems < msg_rsp->info.api_resp_info.param.track.notify_info->numberOfItems)) {
return SA_AIS_ERR_NO_SPACE;
} else {
/* we need to ignore the numberOfItems and allocate the space
@@ -250,6 +273,7 @@ static SaAisErrorT clma_fill_cluster_ntf
memcpy(buf_4->notification, msg_rsp->info.api_resp_info.param.track.notify_info->notification,
sizeof(SaClmClusterNotificationT_4) * buf_4->numberOfItems);
+ /* TODO: Code for copying long DNs for nodeName and EE when full long DN support is implemented. */
}
return SA_AIS_OK;
}
@@ -470,10 +494,8 @@ void clma_fill_clusterbuf_from_buf_4(SaC
(void)memcpy(buf->notification[i].clusterNode.nodeAddress.value,
buf_4->notification[i].clusterNode.nodeAddress.value,
buf->notification[i].clusterNode.nodeAddress.length);
- buf->notification[i].clusterNode.nodeName.length = buf_4->notification[i].clusterNode.nodeName.length;
- (void)memcpy(buf->notification[i].clusterNode.nodeName.value,
- buf_4->notification[i].clusterNode.nodeName.value,
- buf->notification[i].clusterNode.nodeName.length);
+ osaf_extended_name_alloc(osaf_extended_name_borrow(&buf_4->notification[i].clusterNode.nodeName),
+ &buf->notification[i].clusterNode.nodeName);
buf->notification[i].clusterNode.member = buf_4->notification[i].clusterNode.member;
buf->notification[i].clusterNode.bootTimestamp = buf_4->notification[i].clusterNode.bootTimestamp;
buf->notification[i].clusterNode.initialViewNumber =
@@ -1311,11 +1333,11 @@ static SaAisErrorT clmaclusternodeget(Sa
}
}
- if((hdl_rec->is_configured == false) && (!clma_validate_version(hdl_rec->version))) {
- TRACE("Node is unconfigured");
- rc = SA_AIS_ERR_UNAVAILABLE;
- goto done_give_hdl;
- }
+ if((hdl_rec->is_configured == false) && (!clma_validate_version(hdl_rec->version))) {
+ TRACE("Node is unconfigured");
+ rc = SA_AIS_ERR_UNAVAILABLE;
+ goto done_give_hdl;
+ }
if((hdl_rec->is_member == false) && (!clma_validate_version(hdl_rec->version))) {
TRACE("Node is not a member");
@@ -1351,12 +1373,25 @@ static SaAisErrorT clmaclusternodeget(Sa
} else
rc = SA_AIS_ERR_NO_RESOURCES;
+ if (rc == SA_AIS_OK
+ && osaf_extended_name_length(&o_msg->info.api_resp_info.param.node_get.nodeName) >= SA_MAX_NAME_LENGTH) {
+ TRACE("nodeName is longer than 255");
+ rc = SA_AIS_ERR_NO_RESOURCES;
+ }
+
if (rc == SA_AIS_OK) {
if (clma_validate_version(hdl_rec->version)) {
clma_fill_node_from_node4(cluster_node, o_msg->info.api_resp_info.param.node_get);
- } else {
+ } else if(osaf_extended_name_length(&o_msg->info.api_resp_info.param.node_get.executionEnvironment) < SA_MAX_NAME_LENGTH) {
memset(cluster_node_4, 0, sizeof(SaClmClusterNodeT_4));
memcpy(cluster_node_4, &o_msg->info.api_resp_info.param.node_get, sizeof(SaClmClusterNodeT_4));
+ /* TODO: When full long DN support is implemented, remove comment to ensure that long DN is safely copied.
+ * Now it's overhead for copying the same data. */
+ //osaf_extended_name_alloc(osaf_extended_name_borrow(&o_msg->info.api_resp_info.param.node_get.nodeName), &cluster_node_4->nodeName);
+ //osaf_extended_name_alloc(osaf_extended_name_borrow(&o_msg->info.api_resp_info.param.node_get.executionEnvironment), &cluster_node_4->executionEnvironment);
+ } else {
+ TRACE("executionEnvironment is longer than 255");
+ rc = SA_AIS_ERR_NO_RESOURCES;
}
}
@@ -1512,11 +1547,15 @@ SaAisErrorT saClmClusterNotificationFree
goto done_give_hdl;
}
- if((hdl_rec->is_configured == false) && (!clma_validate_version(hdl_rec->version))) {
- TRACE("Node is unconfigured");
- rc = SA_AIS_ERR_UNAVAILABLE;
- goto done_give_hdl;
- }
+ if((hdl_rec->is_configured == false) && (!clma_validate_version(hdl_rec->version))) {
+ TRACE("Node is unconfigured");
+ rc = SA_AIS_ERR_UNAVAILABLE;
+ goto done_give_hdl;
+ }
+
+ // Free allocated memory for long DN
+ osaf_extended_name_free(¬ification->clusterNode.nodeName);
+ osaf_extended_name_free(¬ification->clusterNode.executionEnvironment);
free(notification);
diff --git a/osaf/libs/agents/saf/clma/clma_util.c b/osaf/libs/agents/saf/clma/clma_util.c
--- a/osaf/libs/agents/saf/clma/clma_util.c
+++ b/osaf/libs/agents/saf/clma/clma_util.c
@@ -659,6 +659,13 @@ void clma_msg_destroy(CLMSV_MSG * msg)
if (msg->evt_type == CLMSV_CLMS_TO_CLMA_API_RESP_MSG) {
if (msg->info.api_resp_info.type == CLMSV_TRACK_CURRENT_RESP) {
+ /* TODO: if long DN longer than 255 characters is fully implemented
+ * then freeing of each SaNameT in notification list must be done
+ * msg->info.api_resp_info.param.track.notify_info->notification->clusterNode.nodeName
+ * and
+ * msg->info.api_resp_info.param.track.notify_info->notification->clusterNode.executionEnvironment
+ * must be done here
+ */
if (msg->info.api_resp_info.param.track.notify_info->numberOfItems)
free(msg->info.api_resp_info.param.track.notify_info->notification);
@@ -666,6 +673,13 @@ void clma_msg_destroy(CLMSV_MSG * msg)
}
} else if (msg->evt_type == CLMSV_CLMS_TO_CLMA_CBK_MSG) {
if (msg->info.cbk_info.type == CLMSV_TRACK_CBK) {
+ /* TODO: if long DN longer than 255 characters is fully implemented
+ * then freeing of each SaNameT in notification list
+ * msg->info.cbk_info.param.track.buf_info.notification->clusterNode.nodeName
+ * and
+ * msg->info.cbk_info.param.track.buf_info.notification->clusterNode.executionEnvironment
+ * must be done here
+ */
if (msg->info.cbk_info.param.track.buf_info.numberOfItems)
free(msg->info.cbk_info.param.track.buf_info.notification);
diff --git a/osaf/libs/common/clmsv/clmsv_enc_dec.c b/osaf/libs/common/clmsv/clmsv_enc_dec.c
--- a/osaf/libs/common/clmsv/clmsv_enc_dec.c
+++ b/osaf/libs/common/clmsv/clmsv_enc_dec.c
@@ -17,26 +17,32 @@
#include <ncsencdec_pub.h>
#include "clmsv_enc_dec.h"
#include "clmsv_msg.h"
+#include "osaf_extended_name.h"
uint32_t clmsv_decodeSaNameT(NCS_UBAID *uba, SaNameT *name)
{
uint8_t local_data[2];
uint8_t *p8 = NULL;
uint32_t total_bytes = 0;
+ uint16_t length;
+ char valueBuffer[256];
+ char *value = valueBuffer;
p8 = ncs_dec_flatten_space(uba, local_data, 2);
- name->length = ncs_decode_16bit(&p8);
- if (name->length > SA_MAX_NAME_LENGTH) {
- LOG_ER("SaNameT length too long: %hd", name->length);
+ length = ncs_decode_16bit(&p8);
+ if (!osaf_is_extended_names_enabled() && length >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("SaNameT length too long: %hd", length);
/* this should not happen */
osafassert(0);
}
+ if(length >= SA_MAX_NAME_LENGTH) {
+ value = (char *)calloc(1, length + 1);
+ }
ncs_dec_skip_space(uba, 2);
total_bytes += 2;
- ncs_decode_n_octets_from_uba(uba, name->value, (uint32_t)name->length);
- name->value[name->length < SA_MAX_NAME_LENGTH ? name->length :
- SA_MAX_NAME_LENGTH - 1] = '\0';
- total_bytes += name->length;
+ ncs_decode_n_octets_from_uba(uba, (uint8_t *)value, (uint32_t)length);
+ osaf_extended_name_lend(value, name);
+ total_bytes += length;
return total_bytes;
}
@@ -63,7 +69,6 @@ uint32_t clmsv_decodeNodeAddressT(NCS_UB
ncs_decode_n_octets_from_uba(uba, nodeAddress->value, (uint32_t)nodeAddress->length);
total_bytes += nodeAddress->length;
return total_bytes;
-
}
uint32_t clmsv_encodeSaNameT(NCS_UBAID *uba, SaNameT *name)
@@ -71,20 +76,23 @@ uint32_t clmsv_encodeSaNameT(NCS_UBAID *
TRACE_ENTER();
uint8_t *p8 = NULL;
uint32_t total_bytes = 0;
+ size_t length;
+
p8 = ncs_enc_reserve_space(uba, 2);
if (!p8) {
TRACE("p8 NULL!!!");
return 0;
}
- if (name->length > SA_MAX_NAME_LENGTH) {
+ if (!osaf_is_extended_names_enabled() && name->length >= SA_MAX_NAME_LENGTH) {
LOG_ER("SaNameT length too long %hd", name->length);
osafassert(0);
}
- ncs_encode_16bit(&p8, name->length);
+ length = osaf_extended_name_length(name);
+ ncs_encode_16bit(&p8, length);
ncs_enc_claim_space(uba, 2);
total_bytes += 2;
- ncs_encode_n_octets_in_uba(uba, name->value, (uint32_t)name->length);
- total_bytes += (uint32_t)name->length;
+ ncs_encode_n_octets_in_uba(uba, (uint8_t *)osaf_extended_name_borrow(name), length);
+ total_bytes += (uint32_t)length;
TRACE_LEAVE();
return total_bytes;
}
|
|
From: Zoran M. <zor...@er...> - 2016-07-15 21:57:38
|
osaf/services/saf/clmsv/clms/clms_imm.c | 73 +++++++++++++++++++++++++++----
osaf/services/saf/clmsv/clms/clms_main.c | 5 ++
osaf/services/saf/clmsv/clms/clms_util.c | 7 +++
3 files changed, 75 insertions(+), 10 deletions(-)
Add support for long RDN to support RDN values longer than 64 bytes
diff --git a/osaf/services/saf/clmsv/clms/clms_imm.c b/osaf/services/saf/clmsv/clms/clms_imm.c
--- a/osaf/services/saf/clmsv/clms/clms_imm.c
+++ b/osaf/services/saf/clmsv/clms/clms_imm.c
@@ -18,6 +18,7 @@
#include <saImmOi.h>
#include "clms.h"
+#include "osaf_extended_name.h"
extern struct ImmutilWrapperProfile immutilWrapperProfile;
@@ -222,9 +223,17 @@ CLMS_CLUSTER_NODE *clms_node_new(SaNameT
} else if (!strcmp(attr->attrName, "saClmNodeEE")) {
SaNameT *name = (SaNameT *)value;
- TRACE("saClmNodeEE attribute name's length %d", name->length);
-
- if (name->length != 0) {
+ size_t nameLen = osaf_extended_name_length(name);
+
+ TRACE("saClmNodeEE attribute name's length %lu", nameLen);
+
+ if (nameLen != 0) {
+ if (nameLen >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("saClmNodeEE attribute name length is longer than 255");
+ free(node);
+ node = NULL;
+ goto done;
+ }
if (strncmp((const char *)name->value,"safEE=",6)){
LOG_ER("Please provide the saf compliant ee name");
free(node);
@@ -1383,8 +1392,19 @@ static SaAisErrorT clms_imm_ccb_obj_crea
uint32_t rt;
CcbUtilCcbData_t *ccb_util_ccb_data;
CcbUtilOperationData_t *operation = NULL;
-
- TRACE_ENTER2("CCB ID %llu, class %s, parent %s", ccbId, className, parentName->value);
+ size_t parentNameLen = 0;
+
+ TRACE_ENTER2("CCB ID %llu, class %s, parent %s", ccbId, className,
+ parentName ? osaf_extended_name_borrow(parentName) : "(null)");
+
+ if(parentName) {
+ parentNameLen = osaf_extended_name_length(parentName);
+ if(parentNameLen >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("Parent name is longer than 255");
+ rc = SA_AIS_ERR_BAD_OPERATION;
+ goto done;
+ }
+ }
if ((ccb_util_ccb_data = ccbutil_getCcbData(ccbId)) != NULL) {
int i = 0;
@@ -1406,17 +1426,30 @@ static SaAisErrorT clms_imm_ccb_obj_crea
} else if (!strncmp(attrValue->attrName, "safNode", 7)) {
if (attrValue->attrValueType == SA_IMM_ATTR_SASTRINGT) {
SaStringT rdnVal = *((SaStringT *)attrValue->attrValues[0]);
- if ((parentName != NULL) && (parentName->length > 0)) {
+ if ((parentName != NULL) && (parentNameLen > 0)
+ && (strlen(rdnVal) + parentNameLen + 1) < SA_MAX_NAME_LENGTH) {
operation->objectName.length =
- (SaUint16T)sprintf((char *)operation->objectName.value, "%s,%s",
- rdnVal, parentName->value);
+ (SaUint16T)sprintf((char *)operation->objectName.value, "%s,%s",
+ rdnVal, parentName->value);
} else {
+ if(!parentName || parentNameLen == 0) {
+ LOG_ER("Node DN name is incorrect. Parent is NULL or empty");
+ } else {
+ LOG_ER("Node DN name is incorrect. DN is longer than 255");
+ }
rc = SA_AIS_ERR_BAD_OPERATION;
+ goto done;
}
}
TRACE("Operation's object Name %s", operation->objectName.value);
-
+ } else if (!strncmp(attrValue->attrName, "saClmNodeEE", 11) && attrValue->attrValuesNumber == 1) {
+ SaNameT *name = (SaNameT *)attrValue->attrValues[0];
+ if(osaf_extended_name_length(name) >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("saClmNodeEE is longer than 255");
+ rc = SA_AIS_ERR_BAD_OPERATION;
+ goto done;
+ }
}
}
}
@@ -1471,17 +1504,37 @@ static SaAisErrorT clms_imm_ccb_obj_modi
{
SaAisErrorT rc = SA_AIS_OK;
struct CcbUtilCcbData *ccbUtilCcbData;
+ int i = 0;
+ SaImmAttrModificationT_2 *attrMod;
+ SaNameT *name;
TRACE_ENTER2("CCB ID %llu for object-name:%s ", ccbId, objectName->value);
if ((ccbUtilCcbData = ccbutil_getCcbData(ccbId)) != NULL) {
+ /* saClmNodeEE cannot be longer than 255 */
+ while ((attrMod = (SaImmAttrModificationT_2 *)attrMods[i++]) != NULL) {
+ if (strncmp(attrMod->modAttr.attrName, "saClmNodeEE", 11) != 0)
+ continue;
+
+ if(attrMod->modAttr.attrValuesNumber == 0) {
+ break;
+ }
+
+ name = (SaNameT *)attrMod->modAttr.attrValues[0];
+ if(osaf_extended_name_length(name) >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("saClmNodeEE is longer than 255");
+ rc = SA_AIS_ERR_BAD_OPERATION;
+ break;
+ }
+ }
+
/*memorize the modification request */
if (ccbutil_ccbAddModifyOperation(ccbUtilCcbData, objectName, attrMods) != 0) {
LOG_ER("Failed ccb object modify %s", objectName->value);
rc = SA_AIS_ERR_BAD_OPERATION;
}
} else {
- LOG_ER("Failed to get CCB objectfor %llu", ccbId);
+ LOG_ER("Failed to get CCB object for %llu", ccbId);
rc = SA_AIS_ERR_NO_MEMORY;
}
diff --git a/osaf/services/saf/clmsv/clms/clms_main.c b/osaf/services/saf/clmsv/clms/clms_main.c
--- a/osaf/services/saf/clmsv/clms/clms_main.c
+++ b/osaf/services/saf/clmsv/clms/clms_main.c
@@ -446,6 +446,11 @@ int main(int argc, char *argv[])
daemonize(argc, argv);
+ if(setenv("SA_ENABLE_EXTENDED_NAMES", "1", 1)) {
+ LOG_ER("Failed to set SA_ENABLE_EXTENDED_NAMES");
+ goto done;
+ }
+
if (clms_init() != NCSCC_RC_SUCCESS) {
LOG_ER("clms_init failed");
goto done;
diff --git a/osaf/services/saf/clmsv/clms/clms_util.c b/osaf/services/saf/clmsv/clms/clms_util.c
--- a/osaf/services/saf/clmsv/clms/clms_util.c
+++ b/osaf/services/saf/clmsv/clms/clms_util.c
@@ -17,6 +17,7 @@
#include "clms.h"
#include "osaf_time.h"
+#include "osaf_extended_name.h"
static const SaNameT _clmSvcUsrName = {
.value = "safApp=safClmService",
@@ -292,6 +293,12 @@ uint32_t clms_node_dn_chk(SaNameT *objNa
char *tmpstr;
TRACE_ENTER();
+ if(osaf_extended_name_length(objName) >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("Object name is longer than 255: %s", osaf_extended_name_borrow(objName));
+ TRACE_LEAVE();
+ return NCSCC_RC_FAILURE;
+ }
+
if (!strncmp((char *)objName->value, "safNode=", 8)) {
tmpstr = strchr((char *)objName->value, ',');
if (tmpstr != NULL)
|
|
From: Mathivanan N. P. <mat...@or...> - 2016-08-09 06:25:06
|
Ack,
Mathi.
> -----Original Message-----
> From: Zoran Milinkovic [mailto:zor...@er...]
> Sent: Saturday, July 16, 2016 3:27 AM
> To: Mathivanan Naickan Palanivelu
> Cc: ope...@li...
> Subject: [PATCH 2 of 2] clm: add support for long RDN for clm service [#1906]
>
> osaf/services/saf/clmsv/clms/clms_imm.c | 73
> +++++++++++++++++++++++++++----
> osaf/services/saf/clmsv/clms/clms_main.c | 5 ++
> osaf/services/saf/clmsv/clms/clms_util.c | 7 +++
> 3 files changed, 75 insertions(+), 10 deletions(-)
>
>
> Add support for long RDN to support RDN values longer than 64 bytes
>
> diff --git a/osaf/services/saf/clmsv/clms/clms_imm.c
> b/osaf/services/saf/clmsv/clms/clms_imm.c
> --- a/osaf/services/saf/clmsv/clms/clms_imm.c
> +++ b/osaf/services/saf/clmsv/clms/clms_imm.c
> @@ -18,6 +18,7 @@
> #include <saImmOi.h>
>
> #include "clms.h"
> +#include "osaf_extended_name.h"
>
> extern struct ImmutilWrapperProfile immutilWrapperProfile;
>
> @@ -222,9 +223,17 @@ CLMS_CLUSTER_NODE *clms_node_new(SaNameT
>
> } else if (!strcmp(attr->attrName, "saClmNodeEE")) {
> SaNameT *name = (SaNameT *)value;
> - TRACE("saClmNodeEE attribute name's length %d",
> name->length);
> -
> - if (name->length != 0) {
> + size_t nameLen =
> osaf_extended_name_length(name);
> +
> + TRACE("saClmNodeEE attribute name's length %lu",
> nameLen);
> +
> + if (nameLen != 0) {
> + if (nameLen >= SA_MAX_NAME_LENGTH) {
> + LOG_ER("saClmNodeEE attribute
> name length is longer than 255");
> + free(node);
> + node = NULL;
> + goto done;
> + }
> if (strncmp((const char *)name-
> >value,"safEE=",6)){
> LOG_ER("Please provide the saf
> compliant ee name");
> free(node);
> @@ -1383,8 +1392,19 @@ static SaAisErrorT clms_imm_ccb_obj_crea
> uint32_t rt;
> CcbUtilCcbData_t *ccb_util_ccb_data;
> CcbUtilOperationData_t *operation = NULL;
> -
> - TRACE_ENTER2("CCB ID %llu, class %s, parent %s", ccbId, className,
> parentName->value);
> + size_t parentNameLen = 0;
> +
> + TRACE_ENTER2("CCB ID %llu, class %s, parent %s", ccbId, className,
> + parentName ?
> osaf_extended_name_borrow(parentName) : "(null)");
> +
> + if(parentName) {
> + parentNameLen =
> osaf_extended_name_length(parentName);
> + if(parentNameLen >= SA_MAX_NAME_LENGTH) {
> + LOG_ER("Parent name is longer than 255");
> + rc = SA_AIS_ERR_BAD_OPERATION;
> + goto done;
> + }
> + }
>
> if ((ccb_util_ccb_data = ccbutil_getCcbData(ccbId)) != NULL) {
> int i = 0;
> @@ -1406,17 +1426,30 @@ static SaAisErrorT clms_imm_ccb_obj_crea
> } else if (!strncmp(attrValue->attrName, "safNode",
> 7)) {
> if (attrValue->attrValueType ==
> SA_IMM_ATTR_SASTRINGT) {
> SaStringT rdnVal = *((SaStringT
> *)attrValue->attrValues[0]);
> - if ((parentName != NULL) &&
> (parentName->length > 0)) {
> + if ((parentName != NULL) &&
> (parentNameLen > 0)
> + && (strlen(rdnVal) +
> parentNameLen + 1) < SA_MAX_NAME_LENGTH) {
> operation-
> >objectName.length =
> - (SaUint16T)sprintf((char
> *)operation->objectName.value, "%s,%s",
> - rdnVal,
> parentName->value);
> +
> (SaUint16T)sprintf((char *)operation->objectName.value, "%s,%s",
> +
> rdnVal, parentName->value);
> } else {
> + if(!parentName ||
> parentNameLen == 0) {
> + LOG_ER("Node DN
> name is incorrect. Parent is NULL or empty");
> + } else {
> + LOG_ER("Node DN
> name is incorrect. DN is longer than 255");
> + }
> rc =
> SA_AIS_ERR_BAD_OPERATION;
> + goto done;
> }
> }
>
> TRACE("Operation's object Name %s",
> operation->objectName.value);
> -
> + } else if (!strncmp(attrValue->attrName,
> "saClmNodeEE", 11) && attrValue->attrValuesNumber == 1) {
> + SaNameT *name = (SaNameT *)attrValue-
> >attrValues[0];
> + if(osaf_extended_name_length(name) >=
> SA_MAX_NAME_LENGTH) {
> + LOG_ER("saClmNodeEE is longer than
> 255");
> + rc = SA_AIS_ERR_BAD_OPERATION;
> + goto done;
> + }
> }
> }
> }
> @@ -1471,17 +1504,37 @@ static SaAisErrorT clms_imm_ccb_obj_modi {
> SaAisErrorT rc = SA_AIS_OK;
> struct CcbUtilCcbData *ccbUtilCcbData;
> + int i = 0;
> + SaImmAttrModificationT_2 *attrMod;
> + SaNameT *name;
>
> TRACE_ENTER2("CCB ID %llu for object-name:%s ", ccbId,
> objectName->value);
>
> if ((ccbUtilCcbData = ccbutil_getCcbData(ccbId)) != NULL) {
> + /* saClmNodeEE cannot be longer than 255 */
> + while ((attrMod = (SaImmAttrModificationT_2
> *)attrMods[i++]) != NULL) {
> + if (strncmp(attrMod->modAttr.attrName,
> "saClmNodeEE", 11) != 0)
> + continue;
> +
> + if(attrMod->modAttr.attrValuesNumber == 0) {
> + break;
> + }
> +
> + name = (SaNameT *)attrMod-
> >modAttr.attrValues[0];
> + if(osaf_extended_name_length(name) >=
> SA_MAX_NAME_LENGTH) {
> + LOG_ER("saClmNodeEE is longer than 255");
> + rc = SA_AIS_ERR_BAD_OPERATION;
> + break;
> + }
> + }
> +
> /*memorize the modification request */
> if (ccbutil_ccbAddModifyOperation(ccbUtilCcbData,
> objectName, attrMods) != 0) {
> LOG_ER("Failed ccb object modify %s", objectName-
> >value);
> rc = SA_AIS_ERR_BAD_OPERATION;
> }
> } else {
> - LOG_ER("Failed to get CCB objectfor %llu", ccbId);
> + LOG_ER("Failed to get CCB object for %llu", ccbId);
> rc = SA_AIS_ERR_NO_MEMORY;
> }
>
> diff --git a/osaf/services/saf/clmsv/clms/clms_main.c
> b/osaf/services/saf/clmsv/clms/clms_main.c
> --- a/osaf/services/saf/clmsv/clms/clms_main.c
> +++ b/osaf/services/saf/clmsv/clms/clms_main.c
> @@ -446,6 +446,11 @@ int main(int argc, char *argv[])
>
> daemonize(argc, argv);
>
> + if(setenv("SA_ENABLE_EXTENDED_NAMES", "1", 1)) {
> + LOG_ER("Failed to set SA_ENABLE_EXTENDED_NAMES");
> + goto done;
> + }
> +
> if (clms_init() != NCSCC_RC_SUCCESS) {
> LOG_ER("clms_init failed");
> goto done;
> diff --git a/osaf/services/saf/clmsv/clms/clms_util.c
> b/osaf/services/saf/clmsv/clms/clms_util.c
> --- a/osaf/services/saf/clmsv/clms/clms_util.c
> +++ b/osaf/services/saf/clmsv/clms/clms_util.c
> @@ -17,6 +17,7 @@
>
> #include "clms.h"
> #include "osaf_time.h"
> +#include "osaf_extended_name.h"
>
> static const SaNameT _clmSvcUsrName = {
> .value = "safApp=safClmService",
> @@ -292,6 +293,12 @@ uint32_t clms_node_dn_chk(SaNameT *objNa
> char *tmpstr;
> TRACE_ENTER();
>
> + if(osaf_extended_name_length(objName) >=
> SA_MAX_NAME_LENGTH) {
> + LOG_ER("Object name is longer than 255: %s",
> osaf_extended_name_borrow(objName));
> + TRACE_LEAVE();
> + return NCSCC_RC_FAILURE;
> + }
> +
> if (!strncmp((char *)objName->value, "safNode=", 8)) {
> tmpstr = strchr((char *)objName->value, ',');
> if (tmpstr != NULL)
|
|
From: Mathivanan N. P. <mat...@or...> - 2016-08-15 04:34:31
|
Hi Zoran,
I pushed both the patches and updated the ticket with the following comments:
- testing backward compatibility
- evaluate changes to CLMNA
Mathi.
> -----Original Message-----
> From: Mathivanan Naickan Palanivelu
> Sent: Tuesday, August 09, 2016 11:55 AM
> To: Zoran Milinkovic
> Cc: ope...@li...
> Subject: Re: [devel] [PATCH 2 of 2] clm: add support for long RDN for clm
> service [#1906]
>
> Ack,
> Mathi.
>
>
> > -----Original Message-----
> > From: Zoran Milinkovic [mailto:zor...@er...]
> > Sent: Saturday, July 16, 2016 3:27 AM
> > To: Mathivanan Naickan Palanivelu
> > Cc: ope...@li...
> > Subject: [PATCH 2 of 2] clm: add support for long RDN for clm service
> > [#1906]
> >
> > osaf/services/saf/clmsv/clms/clms_imm.c | 73
> > +++++++++++++++++++++++++++----
> > osaf/services/saf/clmsv/clms/clms_main.c | 5 ++
> > osaf/services/saf/clmsv/clms/clms_util.c | 7 +++
> > 3 files changed, 75 insertions(+), 10 deletions(-)
> >
> >
> > Add support for long RDN to support RDN values longer than 64 bytes
> >
> > diff --git a/osaf/services/saf/clmsv/clms/clms_imm.c
> > b/osaf/services/saf/clmsv/clms/clms_imm.c
> > --- a/osaf/services/saf/clmsv/clms/clms_imm.c
> > +++ b/osaf/services/saf/clmsv/clms/clms_imm.c
> > @@ -18,6 +18,7 @@
> > #include <saImmOi.h>
> >
> > #include "clms.h"
> > +#include "osaf_extended_name.h"
> >
> > extern struct ImmutilWrapperProfile immutilWrapperProfile;
> >
> > @@ -222,9 +223,17 @@ CLMS_CLUSTER_NODE
> *clms_node_new(SaNameT
> >
> > } else if (!strcmp(attr->attrName, "saClmNodeEE")) {
> > SaNameT *name = (SaNameT *)value;
> > - TRACE("saClmNodeEE attribute name's length %d",
> > name->length);
> > -
> > - if (name->length != 0) {
> > + size_t nameLen =
> > osaf_extended_name_length(name);
> > +
> > + TRACE("saClmNodeEE attribute name's length %lu",
> > nameLen);
> > +
> > + if (nameLen != 0) {
> > + if (nameLen >= SA_MAX_NAME_LENGTH) {
> > + LOG_ER("saClmNodeEE attribute
> > name length is longer than 255");
> > + free(node);
> > + node = NULL;
> > + goto done;
> > + }
> > if (strncmp((const char *)name-
> > >value,"safEE=",6)){
> > LOG_ER("Please provide the saf
> > compliant ee name");
> > free(node);
> > @@ -1383,8 +1392,19 @@ static SaAisErrorT clms_imm_ccb_obj_crea
> > uint32_t rt;
> > CcbUtilCcbData_t *ccb_util_ccb_data;
> > CcbUtilOperationData_t *operation = NULL;
> > -
> > - TRACE_ENTER2("CCB ID %llu, class %s, parent %s", ccbId, className,
> > parentName->value);
> > + size_t parentNameLen = 0;
> > +
> > + TRACE_ENTER2("CCB ID %llu, class %s, parent %s", ccbId, className,
> > + parentName ?
> > osaf_extended_name_borrow(parentName) : "(null)");
> > +
> > + if(parentName) {
> > + parentNameLen =
> > osaf_extended_name_length(parentName);
> > + if(parentNameLen >= SA_MAX_NAME_LENGTH) {
> > + LOG_ER("Parent name is longer than 255");
> > + rc = SA_AIS_ERR_BAD_OPERATION;
> > + goto done;
> > + }
> > + }
> >
> > if ((ccb_util_ccb_data = ccbutil_getCcbData(ccbId)) != NULL) {
> > int i = 0;
> > @@ -1406,17 +1426,30 @@ static SaAisErrorT clms_imm_ccb_obj_crea
> > } else if (!strncmp(attrValue->attrName, "safNode",
> > 7)) {
> > if (attrValue->attrValueType ==
> > SA_IMM_ATTR_SASTRINGT) {
> > SaStringT rdnVal = *((SaStringT
> > *)attrValue->attrValues[0]);
> > - if ((parentName != NULL) &&
> > (parentName->length > 0)) {
> > + if ((parentName != NULL) &&
> > (parentNameLen > 0)
> > + && (strlen(rdnVal) +
> > parentNameLen + 1) < SA_MAX_NAME_LENGTH) {
> > operation-
> > >objectName.length =
> > - (SaUint16T)sprintf((char
> > *)operation->objectName.value, "%s,%s",
> > - rdnVal,
> > parentName->value);
> > +
> > (SaUint16T)sprintf((char *)operation->objectName.value, "%s,%s",
> > +
> > rdnVal, parentName->value);
> > } else {
> > + if(!parentName ||
> > parentNameLen == 0) {
> > + LOG_ER("Node DN
> > name is incorrect. Parent is NULL or empty");
> > + } else {
> > + LOG_ER("Node DN
> > name is incorrect. DN is longer than 255");
> > + }
> > rc =
> > SA_AIS_ERR_BAD_OPERATION;
> > + goto done;
> > }
> > }
> >
> > TRACE("Operation's object Name %s",
> > operation->objectName.value);
> > -
> > + } else if (!strncmp(attrValue->attrName,
> > "saClmNodeEE", 11) && attrValue->attrValuesNumber == 1) {
> > + SaNameT *name = (SaNameT *)attrValue-
> > >attrValues[0];
> > + if(osaf_extended_name_length(name) >=
> > SA_MAX_NAME_LENGTH) {
> > + LOG_ER("saClmNodeEE is longer than
> > 255");
> > + rc = SA_AIS_ERR_BAD_OPERATION;
> > + goto done;
> > + }
> > }
> > }
> > }
> > @@ -1471,17 +1504,37 @@ static SaAisErrorT clms_imm_ccb_obj_modi {
> > SaAisErrorT rc = SA_AIS_OK;
> > struct CcbUtilCcbData *ccbUtilCcbData;
> > + int i = 0;
> > + SaImmAttrModificationT_2 *attrMod;
> > + SaNameT *name;
> >
> > TRACE_ENTER2("CCB ID %llu for object-name:%s ", ccbId,
> > objectName->value);
> >
> > if ((ccbUtilCcbData = ccbutil_getCcbData(ccbId)) != NULL) {
> > + /* saClmNodeEE cannot be longer than 255 */
> > + while ((attrMod = (SaImmAttrModificationT_2
> > *)attrMods[i++]) != NULL) {
> > + if (strncmp(attrMod->modAttr.attrName,
> > "saClmNodeEE", 11) != 0)
> > + continue;
> > +
> > + if(attrMod->modAttr.attrValuesNumber == 0) {
> > + break;
> > + }
> > +
> > + name = (SaNameT *)attrMod-
> > >modAttr.attrValues[0];
> > + if(osaf_extended_name_length(name) >=
> > SA_MAX_NAME_LENGTH) {
> > + LOG_ER("saClmNodeEE is longer than 255");
> > + rc = SA_AIS_ERR_BAD_OPERATION;
> > + break;
> > + }
> > + }
> > +
> > /*memorize the modification request */
> > if (ccbutil_ccbAddModifyOperation(ccbUtilCcbData,
> > objectName, attrMods) != 0) {
> > LOG_ER("Failed ccb object modify %s", objectName-
> > >value);
> > rc = SA_AIS_ERR_BAD_OPERATION;
> > }
> > } else {
> > - LOG_ER("Failed to get CCB objectfor %llu", ccbId);
> > + LOG_ER("Failed to get CCB object for %llu", ccbId);
> > rc = SA_AIS_ERR_NO_MEMORY;
> > }
> >
> > diff --git a/osaf/services/saf/clmsv/clms/clms_main.c
> > b/osaf/services/saf/clmsv/clms/clms_main.c
> > --- a/osaf/services/saf/clmsv/clms/clms_main.c
> > +++ b/osaf/services/saf/clmsv/clms/clms_main.c
> > @@ -446,6 +446,11 @@ int main(int argc, char *argv[])
> >
> > daemonize(argc, argv);
> >
> > + if(setenv("SA_ENABLE_EXTENDED_NAMES", "1", 1)) {
> > + LOG_ER("Failed to set SA_ENABLE_EXTENDED_NAMES");
> > + goto done;
> > + }
> > +
> > if (clms_init() != NCSCC_RC_SUCCESS) {
> > LOG_ER("clms_init failed");
> > goto done;
> > diff --git a/osaf/services/saf/clmsv/clms/clms_util.c
> > b/osaf/services/saf/clmsv/clms/clms_util.c
> > --- a/osaf/services/saf/clmsv/clms/clms_util.c
> > +++ b/osaf/services/saf/clmsv/clms/clms_util.c
> > @@ -17,6 +17,7 @@
> >
> > #include "clms.h"
> > #include "osaf_time.h"
> > +#include "osaf_extended_name.h"
> >
> > static const SaNameT _clmSvcUsrName = {
> > .value = "safApp=safClmService",
> > @@ -292,6 +293,12 @@ uint32_t clms_node_dn_chk(SaNameT *objNa
> > char *tmpstr;
> > TRACE_ENTER();
> >
> > + if(osaf_extended_name_length(objName) >=
> > SA_MAX_NAME_LENGTH) {
> > + LOG_ER("Object name is longer than 255: %s",
> > osaf_extended_name_borrow(objName));
> > + TRACE_LEAVE();
> > + return NCSCC_RC_FAILURE;
> > + }
> > +
> > if (!strncmp((char *)objName->value, "safNode=", 8)) {
> > tmpstr = strchr((char *)objName->value, ',');
> > if (tmpstr != NULL)
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and
> traffic patterns at an interface-level. Reveals which users, apps, and
> protocols are consuming the most bandwidth. Provides multi-vendor support
> for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using
> capacity planning reports. http://sdm.link/zohodev2dev
> _______________________________________________
> Opensaf-devel mailing list
> Ope...@li...
> https://lists.sourceforge.net/lists/listinfo/opensaf-devel
|
|
From: Zoran M. <zor...@er...> - 2016-07-15 21:54:24
|
osaf/services/saf/clmsv/clms/clms_imm.c | 73 +++++++++++++++++++++++++++----
osaf/services/saf/clmsv/clms/clms_main.c | 5 ++
osaf/services/saf/clmsv/clms/clms_util.c | 7 +++
3 files changed, 75 insertions(+), 10 deletions(-)
Add support for long RDN to support RDN values longer than 64 bytes
diff --git a/osaf/services/saf/clmsv/clms/clms_imm.c b/osaf/services/saf/clmsv/clms/clms_imm.c
--- a/osaf/services/saf/clmsv/clms/clms_imm.c
+++ b/osaf/services/saf/clmsv/clms/clms_imm.c
@@ -18,6 +18,7 @@
#include <saImmOi.h>
#include "clms.h"
+#include "osaf_extended_name.h"
extern struct ImmutilWrapperProfile immutilWrapperProfile;
@@ -222,9 +223,17 @@ CLMS_CLUSTER_NODE *clms_node_new(SaNameT
} else if (!strcmp(attr->attrName, "saClmNodeEE")) {
SaNameT *name = (SaNameT *)value;
- TRACE("saClmNodeEE attribute name's length %d", name->length);
-
- if (name->length != 0) {
+ size_t nameLen = osaf_extended_name_length(name);
+
+ TRACE("saClmNodeEE attribute name's length %lu", nameLen);
+
+ if (nameLen != 0) {
+ if (nameLen >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("saClmNodeEE attribute name length is longer than 255");
+ free(node);
+ node = NULL;
+ goto done;
+ }
if (strncmp((const char *)name->value,"safEE=",6)){
LOG_ER("Please provide the saf compliant ee name");
free(node);
@@ -1383,8 +1392,19 @@ static SaAisErrorT clms_imm_ccb_obj_crea
uint32_t rt;
CcbUtilCcbData_t *ccb_util_ccb_data;
CcbUtilOperationData_t *operation = NULL;
-
- TRACE_ENTER2("CCB ID %llu, class %s, parent %s", ccbId, className, parentName->value);
+ size_t parentNameLen = 0;
+
+ TRACE_ENTER2("CCB ID %llu, class %s, parent %s", ccbId, className,
+ parentName ? osaf_extended_name_borrow(parentName) : "(null)");
+
+ if(parentName) {
+ parentNameLen = osaf_extended_name_length(parentName);
+ if(parentNameLen >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("Parent name is longer than 255");
+ rc = SA_AIS_ERR_BAD_OPERATION;
+ goto done;
+ }
+ }
if ((ccb_util_ccb_data = ccbutil_getCcbData(ccbId)) != NULL) {
int i = 0;
@@ -1406,17 +1426,30 @@ static SaAisErrorT clms_imm_ccb_obj_crea
} else if (!strncmp(attrValue->attrName, "safNode", 7)) {
if (attrValue->attrValueType == SA_IMM_ATTR_SASTRINGT) {
SaStringT rdnVal = *((SaStringT *)attrValue->attrValues[0]);
- if ((parentName != NULL) && (parentName->length > 0)) {
+ if ((parentName != NULL) && (parentNameLen > 0)
+ && (strlen(rdnVal) + parentNameLen + 1) < SA_MAX_NAME_LENGTH) {
operation->objectName.length =
- (SaUint16T)sprintf((char *)operation->objectName.value, "%s,%s",
- rdnVal, parentName->value);
+ (SaUint16T)sprintf((char *)operation->objectName.value, "%s,%s",
+ rdnVal, parentName->value);
} else {
+ if(!parentName || parentNameLen == 0) {
+ LOG_ER("Node DN name is incorrect. Parent is NULL or empty");
+ } else {
+ LOG_ER("Node DN name is incorrect. DN is longer than 255");
+ }
rc = SA_AIS_ERR_BAD_OPERATION;
+ goto done;
}
}
TRACE("Operation's object Name %s", operation->objectName.value);
-
+ } else if (!strncmp(attrValue->attrName, "saClmNodeEE", 11) && attrValue->attrValuesNumber == 1) {
+ SaNameT *name = (SaNameT *)attrValue->attrValues[0];
+ if(osaf_extended_name_length(name) >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("saClmNodeEE is longer than 255");
+ rc = SA_AIS_ERR_BAD_OPERATION;
+ goto done;
+ }
}
}
}
@@ -1471,17 +1504,37 @@ static SaAisErrorT clms_imm_ccb_obj_modi
{
SaAisErrorT rc = SA_AIS_OK;
struct CcbUtilCcbData *ccbUtilCcbData;
+ int i = 0;
+ SaImmAttrModificationT_2 *attrMod;
+ SaNameT *name;
TRACE_ENTER2("CCB ID %llu for object-name:%s ", ccbId, objectName->value);
if ((ccbUtilCcbData = ccbutil_getCcbData(ccbId)) != NULL) {
+ /* saClmNodeEE cannot be longer than 255 */
+ while ((attrMod = (SaImmAttrModificationT_2 *)attrMods[i++]) != NULL) {
+ if (strncmp(attrMod->modAttr.attrName, "saClmNodeEE", 11) != 0)
+ continue;
+
+ if(attrMod->modAttr.attrValuesNumber == 0) {
+ break;
+ }
+
+ name = (SaNameT *)attrMod->modAttr.attrValues[0];
+ if(osaf_extended_name_length(name) >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("saClmNodeEE is longer than 255");
+ rc = SA_AIS_ERR_BAD_OPERATION;
+ break;
+ }
+ }
+
/*memorize the modification request */
if (ccbutil_ccbAddModifyOperation(ccbUtilCcbData, objectName, attrMods) != 0) {
LOG_ER("Failed ccb object modify %s", objectName->value);
rc = SA_AIS_ERR_BAD_OPERATION;
}
} else {
- LOG_ER("Failed to get CCB objectfor %llu", ccbId);
+ LOG_ER("Failed to get CCB object for %llu", ccbId);
rc = SA_AIS_ERR_NO_MEMORY;
}
diff --git a/osaf/services/saf/clmsv/clms/clms_main.c b/osaf/services/saf/clmsv/clms/clms_main.c
--- a/osaf/services/saf/clmsv/clms/clms_main.c
+++ b/osaf/services/saf/clmsv/clms/clms_main.c
@@ -446,6 +446,11 @@ int main(int argc, char *argv[])
daemonize(argc, argv);
+ if(setenv("SA_ENABLE_EXTENDED_NAMES", "1", 1)) {
+ LOG_ER("Failed to set SA_ENABLE_EXTENDED_NAMES");
+ goto done;
+ }
+
if (clms_init() != NCSCC_RC_SUCCESS) {
LOG_ER("clms_init failed");
goto done;
diff --git a/osaf/services/saf/clmsv/clms/clms_util.c b/osaf/services/saf/clmsv/clms/clms_util.c
--- a/osaf/services/saf/clmsv/clms/clms_util.c
+++ b/osaf/services/saf/clmsv/clms/clms_util.c
@@ -17,6 +17,7 @@
#include "clms.h"
#include "osaf_time.h"
+#include "osaf_extended_name.h"
static const SaNameT _clmSvcUsrName = {
.value = "safApp=safClmService",
@@ -292,6 +293,12 @@ uint32_t clms_node_dn_chk(SaNameT *objNa
char *tmpstr;
TRACE_ENTER();
+ if(osaf_extended_name_length(objName) >= SA_MAX_NAME_LENGTH) {
+ LOG_ER("Object name is longer than 255: %s", osaf_extended_name_borrow(objName));
+ TRACE_LEAVE();
+ return NCSCC_RC_FAILURE;
+ }
+
if (!strncmp((char *)objName->value, "safNode=", 8)) {
tmpstr = strchr((char *)objName->value, ',');
if (tmpstr != NULL)
|