summaryrefslogtreecommitdiffstats
path: root/src/ctrl
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-11-24 13:51:57 +0100
committerMax <msuraev@sysmocom.de>2017-11-24 13:51:57 +0100
commitb214af5360439ebd36f5ae3439acacdaf3055433 (patch)
treec258637f62fca25e471741c4dc5ec544b4e56947 /src/ctrl
parent52a38ddfde38afcbfa0fd57d1286aaf238dfffcd (diff)
ctrl: log incorrect interval values
This should never happen with the current code, but if it ever does, we should log the error instead of silently returning 0. Change-Id: I544001d3072e5f12a96a67e4178f9b945c5f6b6c Related: OS#2550
Diffstat (limited to 'src/ctrl')
-rw-r--r--src/ctrl/control_if.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index 665239a2..590f74d0 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -483,10 +483,13 @@ static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
return ret;
}
-static uint64_t get_rate_ctr_value(const struct rate_ctr *ctr, int intv)
+static uint64_t get_rate_ctr_value(const struct rate_ctr *ctr, int intv, const char *grp)
{
- if (intv >= RATE_CTR_INTV_NUM)
+ if (intv >= RATE_CTR_INTV_NUM) {
+ LOGP(DLCTRL, LOGL_ERROR, "Unexpected interval value %d while trying to get rate counter value in %s\n",
+ intv, grp);
return 0;
+ }
/* Absolute value */
if (intv == -1) {
@@ -507,7 +510,7 @@ static char *get_all_rate_ctr_in_group(void *ctx, const struct rate_ctr_group *c
counters = talloc_asprintf_append(counters, "\n%s.%u.%s %"PRIu64,
ctrg->desc->group_name_prefix, ctrg->idx,
ctrg->desc->ctr_desc[i].name,
- get_rate_ctr_value(&ctrg->ctr[i], intv));
+ get_rate_ctr_value(&ctrg->ctr[i], intv, ctrg->desc->group_name_prefix));
if (!counters)
return NULL;
}
@@ -630,7 +633,7 @@ static int get_rate_ctr(struct ctrl_cmd *cmd, void *data)
talloc_free(dup);
- cmd->reply = talloc_asprintf(cmd, "%"PRIu64, get_rate_ctr_value(ctr, intv));
+ cmd->reply = talloc_asprintf(cmd, "%"PRIu64, get_rate_ctr_value(ctr, intv, ctrg->desc->group_name_prefix));
if (!cmd->reply)
goto oom;