Skip to content

Commit

Permalink
Merge pull request rsyslog#4952 from taavi-valjaots/ksi-network-send-…
Browse files Browse the repository at this point in the history
…timeout-fix

ksi bugfix: request cache size and send timeout issue fixed.
  • Loading branch information
rgerhards authored Aug 9, 2022
2 parents d14de2e + 24a3f2d commit 4d63968
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
12 changes: 10 additions & 2 deletions runtime/lib_ksils12.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ static void handle_ksi_config(rsksictx ctx, KSI_AsyncService *as, KSI_Config *co
if(res != KSI_OK)
reportKSIAPIErr(ctx, NULL, "KSI_AsyncService_setOption(max_request)", res);

optValue = 5 * ctx->max_requests;
optValue = 3 * ctx->max_requests * ctx->blockSigTimeout;
KSI_AsyncService_setOption(as, KSI_ASYNC_OPT_REQUEST_CACHE_SIZE,
(void*)optValue);
}
Expand Down Expand Up @@ -892,6 +892,7 @@ rsksiCtxNew(void) {
ctx->bKeepTreeHashes = false;
ctx->bKeepRecordHashes = true;
ctx->max_requests = (1 << 8);
ctx->blockSigTimeout = 10;
ctx->confInterval = 3600;
ctx->tConfRequested = 0;
ctx->threadSleepms = 1000;
Expand Down Expand Up @@ -1979,6 +1980,7 @@ void *signer_thread(void *arg) {
rsksictx ctx = (rsksictx) arg;
KSI_CTX *ksi_ctx = NULL;
KSI_AsyncService *as = NULL;
size_t size_t_value = 0;
size_t ksiFileCount = 0;
int endpoints = 0;
bool bSleep = true;
Expand Down Expand Up @@ -2028,8 +2030,14 @@ void *signer_thread(void *arg) {
goto cleanup;
}

/* Lets use buffer value, as libksi requires size_t. */
size_t_value = ctx->max_requests;
KSI_AsyncService_setOption(as, KSI_ASYNC_OPT_REQUEST_CACHE_SIZE,
(void*) (ctx->max_requests));
(void*)size_t_value);
size_t_value = ctx->blockSigTimeout;
KSI_AsyncService_setOption(as, KSI_ASYNC_OPT_SND_TIMEOUT,
(void*)size_t_value);


ctx->signer_state = SIGNER_STARTED;
while (true) {
Expand Down
2 changes: 2 additions & 0 deletions runtime/lib_ksils12.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ struct rsksictx_s {
time_t tConfRequested;
uint64_t blockLevelLimit;
uint32_t blockTimeLimit;
uint32_t blockSigTimeout;
uint32_t effectiveBlockLevelLimit; /* level limit adjusted by gateway settings */
uint32_t threadSleepms;
uint8_t syncMode;
Expand Down Expand Up @@ -204,6 +205,7 @@ struct rsksistatefile {
#define getIVLenKSI(bh) (hashOutputLengthOctetsKSI((bh)->hashID))
#define rsksiSetBlockLevelLimit(ctx, limit) ((ctx)->blockLevelLimit = (ctx)->effectiveBlockLevelLimit = limit)
#define rsksiSetBlockTimeLimit(ctx, limit) ((ctx)->blockTimeLimit = limit)
#define rsksiSetBlockSigTimeout(ctx, val) ((ctx)->blockSigTimeout = val)
#define rsksiSetConfInterval(ctx, val) ((ctx)->confInterval = val)
#define rsksiSetKeepRecordHashes(ctx, val) ((ctx)->bKeepRecordHashes = val)
#define rsksiSetKeepTreeHashes(ctx, val) ((ctx)->bKeepTreeHashes = val)
Expand Down
9 changes: 9 additions & 0 deletions runtime/lmsig_ksi-ls12.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static struct cnfparamdescr cnfpdescr[] = {
{ "sig.aggregator.hmacAlg", eCmdHdlrGetWord, 0 },
{ "sig.block.levelLimit", eCmdHdlrSize, CNFPARAM_REQUIRED},
{ "sig.block.timeLimit", eCmdHdlrInt, 0},
{ "sig.block.signtimeout", eCmdHdlrInt, 0},
{ "sig.confinterval", eCmdHdlrInt, 0},
{ "sig.keeprecordhashes", eCmdHdlrBinary, 0 },
{ "sig.keeptreehashes", eCmdHdlrBinary, 0},
Expand Down Expand Up @@ -179,6 +180,14 @@ SetCnfParam(void *pT, struct nvlst *lst)
}
} else if (!strcmp(pblk.descr[i].name, "sig.keeprecordhashes")) {
rsksiSetKeepRecordHashes(pThis->ctx, pvals[i].val.d.n);
} else if (!strcmp(pblk.descr[i].name, "sig.block.signtimeout")) {
if (pvals[i].val.d.n < 0) {
LogError(0, RS_RET_ERR, "sig.block.signtimeout "
"%llu invalid - signing disabled", pvals[i].val.d.n);
pThis->ctx->disabled = true;
} else {
rsksiSetBlockSigTimeout(pThis->ctx, pvals[i].val.d.n);
}
} else if(!strcmp(pblk.descr[i].name, "sig.keeptreehashes")) {
rsksiSetKeepTreeHashes(pThis->ctx, pvals[i].val.d.n);
} else if (!strcmp(pblk.descr[i].name, "sig.syncmode")) {
Expand Down

0 comments on commit 4d63968

Please sign in to comment.