|
From: Michael Chase-S. <mc...@us...> - 2012-04-19 21:45:56
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SFCB - Small Footprint CIM Broker".
The branch, master has been updated
via dad5ce9b2815aa84033cf316398259c2dd295720 (commit)
from 6a6bbcdd5891ff53584c10428d214d097e1a9300 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit dad5ce9b2815aa84033cf316398259c2dd295720
Author: Michael Chase-Salerno <br...@li...>
Date: Thu Apr 19 17:45:21 2012 -0400
[ 3513390 ] Enforce LD and subscription limits
For LDs only
-----------------------------------------------------------------------
Summary of changes:
diff --git a/ChangeLog b/ChangeLog
index 18d3534..921b1ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-04-19 Michael Chase-Salerno <br...@li...>
+
+ * control.c, indCIMXMLHandler.c, interopServerProvider.c,
+ sfcb.cfg.pre.in, test/TestProviders/tests/Makefile.am,
+ test/TestProviders/tests/limitTest.sh:
+ [ 3513390 ] Enforce LD and subscription limits
+ (max for LD only)
+
2012-04-16 Narasimhma Sharoff <nsh...@us...>
* brokerOs.c, brokerUpc.c, native.h:
diff --git a/NEWS b/NEWS
index 9541a3a..1cd82fb 100644
--- a/NEWS
+++ b/NEWS
@@ -94,6 +94,7 @@ Changes in 1.3.15
New Features:
- 3501314 Add dynamic logging and syslog output to sfcb trace
- 3517530 Implement mark, release routines in CMPIBrokerMemFT
+- 3513390 Enforce LD and subscription limits
Bugs Fixed:
- 3514627 unsupported sfcb.cfg param - use exit call
diff --git a/control.c b/control.c
index 3198f99..ab20a3a 100644
--- a/control.c
+++ b/control.c
@@ -128,6 +128,8 @@ Control init[] = {
{"SubscriptionRemovalAction",1,"2"},
{"indicationDeliveryThreadLimit",1,"30"},
{"indicationDeliveryThreadTimeout",1,"0"},
+ {"MaxListenerDestinations",1,"100"},
+ {"MaxActiveSubscriptions",1,"100"},
};
diff --git a/indCIMXMLHandler.c b/indCIMXMLHandler.c
index 33b593b..1db59da 100644
--- a/indCIMXMLHandler.c
+++ b/indCIMXMLHandler.c
@@ -49,6 +49,7 @@ extern ExpSegments exportIndicationReq(CMPIInstance *ci, char *id);
extern void memLinkObjectPath(CMPIObjectPath * op);
static const CMPIBroker *_broker;
+static int LDcount=-1;
static int
interOpNameSpace(const CMPIObjectPath * cop, CMPIStatus *st)
@@ -348,7 +349,14 @@ IndCIMXMLHandlerCreateInstance(CMPIInstanceMI * mi,
if (interOpNameSpace(cop, &st) == 0)
_SFCB_RETURN(st);
- internalProviderGetInstance(cop, &st);
+ CMPIInstance *ciLocal = CMClone(ci, NULL);
+ memLinkInstance(ciLocal);
+ CMPIObjectPath* copLocal = CMClone(cop, NULL);
+ memLinkObjectPath(copLocal);
+
+ setCCN(copLocal,ciLocal,"CIM_ComputerSystem");
+
+ internalProviderGetInstance(copLocal, &st);
if (st.rc == CMPI_RC_ERR_FAILED)
_SFCB_RETURN(st);
if (st.rc == CMPI_RC_OK) {
@@ -356,12 +364,6 @@ IndCIMXMLHandlerCreateInstance(CMPIInstanceMI * mi,
_SFCB_RETURN(st);
}
- CMPIInstance *ciLocal = CMClone(ci, NULL);
- memLinkInstance(ciLocal);
- CMPIObjectPath* copLocal = CMClone(cop, NULL);
- memLinkObjectPath(copLocal);
-
- setCCN(copLocal,ciLocal,"CIM_ComputerSystem");
CMPIString *sysname=ciLocal->ft->getProperty(ciLocal,"SystemName",&st).value.string;
if (sysname == NULL || sysname->hdl == NULL) {
@@ -410,6 +412,16 @@ IndCIMXMLHandlerCreateInstance(CMPIInstanceMI * mi,
CMSetProperty(ciLocal, "persistencetype", &persistenceType, CMPI_uint16);
if (CMClassPathIsA(_broker, copLocal, "cim_listenerdestination", NULL)) {
+
+ // check destination count
+ long cfgmax;
+ getControlNum("MaxListenerDestinations", &cfgmax);
+ if (LDcount+1 > cfgmax) {
+ setStatus(&st,CMPI_RC_ERR_FAILED,"Instance creation would exceed MaxListenerDestinations limit");
+ CMRelease(ciLocal);
+ _SFCB_RETURN(st);
+ }
+
//get the creation timestamp
struct timeval tv;
struct timezone tz;
@@ -440,12 +452,12 @@ IndCIMXMLHandlerCreateInstance(CMPIInstanceMI * mi,
CMSetProperty(ciLocal, "SequenceContext", &scontext, CMPI_string);
CMPIValue zarro = {.sint64 = -1 };
CMSetProperty(ciLocal, "LastSequenceNumber", &zarro, CMPI_sint64);
+ LDcount++;
}
CMPIString *str = CDToString(_broker, copLocal, NULL);
CMPIString *ns = CMGetNameSpace(copLocal, NULL);
- _SFCB_TRACE(1,
- ("--- handler %s %s", (char *) ns->hdl, (char *) str->hdl));
+ _SFCB_TRACE(1,("--- handler %s %s", (char *) ns->hdl, (char *) str->hdl));
in = CMNewArgs(_broker, NULL);
CMAddArg(in, "handler", &ciLocal, CMPI_instance);
@@ -542,6 +554,7 @@ IndCIMXMLHandlerDeleteInstance(CMPIInstanceMI * mi,
if (st.rc == CMPI_RC_OK) {
st = InternalProviderDeleteInstance(NULL, ctx, rslt, cop);
+ LDcount--;
}
_SFCB_RETURN(st);
@@ -975,6 +988,53 @@ int refillRetryQ (const CMPIContext * ctx)
_SFCB_RETURN(0);
}
+
+int countLD (const CMPIContext * ctx) {
+ _SFCB_ENTER(TRACE_INDPROVIDER, "countLD");
+ CMPIEnumeration *enm;
+ CMPIStatus st = { CMPI_RC_OK, NULL };
+ LDcount++; // Mark it initialized
+
+ // Enumerate the destinations
+ CMPIContext * ctxLocal = prepareUpcall((CMPIContext *)ctx);
+ CMPIObjectPath *ref=CMNewObjectPath(_broker,"root/interop","cim_listenerdestination",&st);
+ enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st);
+ while(enm && enm->ft->hasNext(enm, &st)) {
+ LDcount++;
+ enm->ft->getNext(enm, &st);
+ }
+ ref = CMNewObjectPath(_broker,"root/interop","cim_listenerdestinationcimxml",&st);
+ enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st);
+ while(enm && enm->ft->hasNext(enm, &st)) {
+ LDcount++;
+ enm->ft->getNext(enm, &st);
+ }
+ ref = CMNewObjectPath(_broker,"root/interop","cim_indicationhandlercimxml",&st);
+ enm = _broker->bft->enumerateInstanceNames(_broker, ctxLocal, ref, &st);
+ while(enm && enm->ft->hasNext(enm, &st)) {
+ LDcount++;
+ enm->ft->getNext(enm, &st);
+ }
+
+ CMRelease(ref);
+ CMRelease(ctxLocal);
+ _SFCB_TRACE(1,("--- initial count of destinations: %d.",LDcount));
+
+ _SFCB_RETURN(0);
+}
+
+int initIndCIMXML(const CMPIContext * ctx)
+{
+ _SFCB_ENTER(TRACE_INDPROVIDER, "initIndCIMXML");
+ //Refill the queue if there were any from the last run
+ refillRetryQ(ctx);
+ if ( LDcount == -1 ) {
+ //Get the count of ListenerDestinations
+ countLD(ctx);
+ }
+ _SFCB_RETURN(0);
+}
+
CMPIStatus
IndCIMXMLHandlerInvokeMethod(CMPIMethodMI * mi,
const CMPIContext *ctx,
@@ -1106,7 +1166,7 @@ IndCIMXMLHandlerInvokeMethod(CMPIMethodMI * mi,
_SFCB_RETURN(st);
}
-CMInstanceMIStub(IndCIMXMLHandler, IndCIMXMLHandler, _broker, refillRetryQ(ctx) );
+CMInstanceMIStub(IndCIMXMLHandler, IndCIMXMLHandler, _broker, initIndCIMXML(ctx) );
CMMethodMIStub(IndCIMXMLHandler, IndCIMXMLHandler, _broker, CMNoHook);
/* MODELINES */
/* DO NOT EDIT BELOW THIS COMMENT */
diff --git a/interopServerProvider.c b/interopServerProvider.c
index 8e3893b..39b21de 100644
--- a/interopServerProvider.c
+++ b/interopServerProvider.c
@@ -551,6 +551,7 @@ IndServiceCapabilitiesProviderEnumInstances(CMPIInstanceMI * mi,
CMPIStatus st = { CMPI_RC_OK, NULL };
CMPIObjectPath *op;
CMPIInstance *ci = NULL;
+ long ctl=0;
_SFCB_ENTER(TRACE_PROVIDERS,
"IndServiceCapabilitiesProviderEnumInstances");
@@ -566,6 +567,15 @@ IndServiceCapabilitiesProviderEnumInstances(CMPIInstanceMI * mi,
CMAddKey(op, "InstanceID", "CIM:SFCB_ISC", CMPI_chars);
ci = CBGetInstance(_broker, ctxLocal, op, properties, &st);
+ // Get the config options for these max vals and add them to the instance
+ getControlNum("MaxListenerDestinations", &ctl);
+ CMPIValue max = {.uint32 = ctl };
+ CMSetProperty(ci,"MaxListenerDestinations",&max,CMPI_uint32);
+
+ getControlNum("MaxActiveSubscriptions", &ctl);
+ max.uint32 = ctl;
+ CMSetProperty(ci,"MaxActiveSubscriptions",&max,CMPI_uint32);
+
CMReturnInstance(rslt, ci);
CMReturnDone(rslt);
diff --git a/sfcb.cfg.pre.in b/sfcb.cfg.pre.in
index 6d116a9..f7d9cf4 100644
--- a/sfcb.cfg.pre.in
+++ b/sfcb.cfg.pre.in
@@ -321,3 +321,14 @@ sslCiphers: ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH
## 4, ignore (do nothing)
#SubscriptionRemovalAction: 2
+## The maximum number of listener destinations that are allowable.
+## This threshold will prevent creation of new listener destinations,
+## but will not delete them if more are found.
+## Default is 100.
+#MaxListenerDestinations: 100
+
+## The maximum number of ACTIVE subscriptions allowed.
+## This threshold will prevent new activations,
+## but will not deactivate them if more are found.
+## Default is 100.
+#MaxActiveSubscriptions: 100
diff --git a/test/TestProviders/tests/Makefile.am b/test/TestProviders/tests/Makefile.am
index e89ab6d..6510b62 100644
--- a/test/TestProviders/tests/Makefile.am
+++ b/test/TestProviders/tests/Makefile.am
@@ -32,4 +32,4 @@ endif
#Some wbemcat tests
export SRCDIR=$(srcdir)
-TESTS = $(srcdir)/xmltest.sh $(srcdir)/IndRetryTest.sh
+TESTS = $(srcdir)/xmltest.sh $(srcdir)/IndRetryTest.sh $(srcdir)/limitTest.sh
hooks/post-receive
--
SFCB - Small Footprint CIM Broker
|