Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37883?usp=email
to look at the new patch set (#2).
Change subject: hnbgw: tweak errmsg for counter mismatch
......................................................................
hnbgw: tweak errmsg for counter mismatch
- instead of "-1", print "not present", so humans know what is
happening.
- the comma separated args in setverdict() create a lot of weird quotes.
Use string concatenation to have only one set of quotes around the
entire error message.
Related: OS#6545
Change-Id: I672fcef819a6542a5b3bcfa0a6d9c84d34b468f3
---
M library/Osmocom_CTRL_Functions.ttcn
1 file changed, 12 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/83/37883/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37883?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I672fcef819a6542a5b3bcfa0a6d9c84d34b468f3
Gerrit-Change-Number: 37883
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Attention is currently required from: neels.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/37881?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: CTRL: get rate_ctr_group by the id from rate_ctr_group_set_name()
......................................................................
CTRL: get rate_ctr_group by the id from rate_ctr_group_set_name()
Some objects always have fixed indexes, because they come from the
config file (think "bts.0" or "msc.0").
However, some object IDs are created dynamically, which makes it
"impossible" to verify them in tests. In osmo-hnbgw, the same hNodeB may
show up as hnb.0, hnb.1, etc.
We do already have the rate_ctr_group_set_name() API which allows
tagging an identifier on a rate counter group. For above example,
osmo-hnbgw sets rate_ctr_group_set_name(cell_id_str).
In CTRL, when a counter group index token is not a clean number, look up
that token as the group instance's name instead. This allows for
example:
GET 123 rate_ctr.abs.hnb.001-01-L2342-R0-S55-C1.iuh:established
in addition to currently:
GET 123 rate_ctr.abs.hnb.0.iuh:established
When merging this patch, magically all rate_ctr_groups in all osmo
programs will become accessible by their given rate_ctr_group_set_name()
IDs.
Related: OS#6545
Change-Id: I841a12f76e6fcb2bd7aecb5f4b1707d9ec927137
---
M include/osmocom/core/rate_ctr.h
M src/core/libosmocore.map
M src/core/rate_ctr.c
M src/ctrl/control_if.c
4 files changed, 52 insertions(+), 15 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/81/37881/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37881?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I841a12f76e6fcb2bd7aecb5f4b1707d9ec927137
Gerrit-Change-Number: 37881
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
neels has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37882?usp=email )
Change subject: ctrl, hnbgw: access rate counter groups by given ID instead of index
......................................................................
ctrl, hnbgw: access rate counter groups by given ID instead of index
Teach Osmocom_CTRL_Functions to retrieve rate counters by the ID that
the program has set with rate_ctr_group_set_name() (e.g. a hNodeB's cell
id).
In our tests, the logic is firmly built on indexed arrays. For example,
for CN pooling, the tests conveniently have an array of msc.0, msc.1
etc.. This clashes with objects where the indexes on the CTRL interface
may vary dynamically. This patch allows the same indexed handling of
rate counters even when using the ID names instead of the indexes: still
keep the objects in an indexed array, and also provide a mapping from
index to ID name.
Specific motivation:
Since osmo-hnbgw commit 61e278a452bf4fd240e45f1fe8c094a4b3795317
"hnb_persistent: Use incrementing counter for rate_ctr + stat_item index"
the hnb rate counter index increments after a hnbp has expired.
Instead, use the hNodeB's cell ID (which osmo-hnbgw sets on the counter
group with rate_ctr_group_set_name()) to retrieve counters from the CTRL
interface.
Depends: libosmocore I841a12f76e6fcb2bd7aecb5f4b1707d9ec927137
Related: OS#6545
Change-Id: I70e74e7554482df67aa1d90bc04314124dea444f
---
M hnbgw/HNBGW_Tests.ttcn
M library/Osmocom_CTRL_Functions.ttcn
2 files changed, 55 insertions(+), 22 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/82/37882/2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37882?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I70e74e7554482df67aa1d90bc04314124dea444f
Gerrit-Change-Number: 37882
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37882?usp=email )
Change subject: ctrl, hnbgw: access rate counter groups by given ID instead of index
......................................................................
ctrl, hnbgw: access rate counter groups by given ID instead of index
Teach Osmocom_CTRL_Functions to retrieve rate counters by the ID that
the program has set with rate_ctr_group_set_name() (e.g. a hNodeB's cell
id).
In our tests, the logic is firmly built on indexed arrays. For example,
for CN pooling, the tests conveniently have an array of msc.0, msc.1
etc.. This clashes with objects where the indexes on the CTRL interface
may vary dynamically. This patch allows the same indexed handling of
rate counters even when using the ID names instead of the indexes: still
keep the objects in an indexed array, and also provide a mapping from
index to ID name.
Specific motivation:
Since osmo-hnbgw commit 61e278a452bf4fd240e45f1fe8c094a4b3795317
"hnb_persistent: Use incrementing counter for rate_ctr + stat_item index"
the hnb rate counter index increments after a hnbp has expired.
Instead, use the hNodeB's cell ID (which osmo-hnbgw sets on the counter
group with rate_ctr_group_set_name()) to retrieve counters from the CTRL
interface.
Related: OS#6545
Change-Id: I70e74e7554482df67aa1d90bc04314124dea444f
---
M hnbgw/HNBGW_Tests.ttcn
M library/Osmocom_CTRL_Functions.ttcn
2 files changed, 55 insertions(+), 22 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/82/37882/1
diff --git a/hnbgw/HNBGW_Tests.ttcn b/hnbgw/HNBGW_Tests.ttcn
index 3765411..a06e28f 100644
--- a/hnbgw/HNBGW_Tests.ttcn
+++ b/hnbgw/HNBGW_Tests.ttcn
@@ -358,6 +358,7 @@
/* Counter state */
var CounterNameValsList g_ctr_cn;
var CounterNameValsList g_ctr_hnb;
+ var charstring_list g_hnb_instance_id_map;
}
/* global altstep for global guard timer; */
@@ -1032,8 +1033,10 @@
};
private function f_ctrs_hnb_init(integer hnb_start := 0, integer hnb_count := 1,
- CounterNameVals counternames := counternames_hnb) runs on test_CT {
+ CounterNameVals counternames := counternames_hnb,
+ charstring_list instance_id_map := {}) runs on test_CT {
g_ctr_hnb := f_counter_name_vals_get_n(IPA_CTRL, "hnb", hnb_count, counternames, start_idx := hnb_start);
+ g_hnb_instance_id_map := instance_id_map;
log("initial hnb rate counters: ", g_ctr_hnb);
}
@@ -1047,7 +1050,7 @@
*/
private function f_ctrs_hnb_verify() runs on test_CT {
log("verifying hnb rate counters: ", g_ctr_hnb);
- f_counter_name_vals_expect_n(IPA_CTRL, "hnb", g_ctr_hnb);
+ f_counter_name_vals_expect_n(IPA_CTRL, "hnb", g_ctr_hnb, instance_id_map := g_hnb_instance_id_map);
}
/* convenience: f_ctrs_hnb_add() and f_ctrs_hnb_verify() in one call.
@@ -1089,7 +1092,7 @@
f_vty_run_hnbgw(HNBGWVTY, "timer hnbgw X35 5");
/* Init the counters when the hnb already exists. There should be a nonzero iuh:established count now. */
- f_ctrs_hnb_init();
+ f_ctrs_hnb_init(instance_id_map := { "001-01-L2342-R0-S55-C1" });
/* Drop the Iuh link */
f_drop_hnodeb(0);
diff --git a/library/Osmocom_CTRL_Functions.ttcn b/library/Osmocom_CTRL_Functions.ttcn
index f8788b9..97863c8 100644
--- a/library/Osmocom_CTRL_Functions.ttcn
+++ b/library/Osmocom_CTRL_Functions.ttcn
@@ -153,19 +153,39 @@
}
}
- template charstring ts_ctrl_ratectr(CtrlVariable grp, integer instance, CtrlVariable name,
- CtrlVariable kind := "abs") :=
- "rate_ctr." & kind & "." & grp & "." & int2str(instance) & "." & name;
+ /* Some objects in osmocom programs have volatile instance indexes that are created by external events rather
+ * than a fixed config. To access these, allow passing a mapping of an index number as the test expects them to
+ * instance names given dynamically.
+ *
+ * For example, in osmo-hnbgw, hnb.0 could be hnb.123 depending on how many HNB connected beforehand. To use the
+ * cell ID instad, pass in a mapping of index to cell id, to use the name given by rate_ctr_group_set_name()
+ * instead; so this would ask the CTRL for 'hnb.my-cell-id-foo' as instance_id_map[0] == 'my-cell-id-foo':
+ * f_ctrl_ctr_resolve_instance_id(0, { "my-cell-id-foo", "my-cell-id-bar" });
+ */
+ private function f_ctrl_ctr_resolve_instance_id(integer instance_idx, charstring_list instance_id_map) return charstring
+ {
+ if (lengthof(instance_id_map) > instance_idx) {
+ return instance_id_map[instance_idx];
+ }
+ return int2str(instance_idx);
+ }
+
+ private template charstring ts_ctrl_ratectr(CtrlVariable grp, integer instance, CtrlVariable name,
+ CtrlVariable kind := "abs", charstring_list instance_id_map) :=
+ "rate_ctr." & kind & "." & grp & "." & f_ctrl_ctr_resolve_instance_id(instance, instance_id_map) & "." & name;
function f_ctrl_get_ratectr_abs(IPA_CTRL_PT pt, CtrlVariable grp, integer instance,
- CtrlVariable name) return integer {
- return str2int(f_ctrl_get(pt, valueof(ts_ctrl_ratectr(grp, instance, name)), on_err := "-1"));
+ CtrlVariable name, charstring_list instance_id_map := {}) return integer {
+ return str2int(f_ctrl_get(pt,
+ valueof(ts_ctrl_ratectr(grp, instance, name, instance_id_map := instance_id_map)),
+ on_err := "-1"));
}
function f_ctrl_get_exp_ratectr_abs(IPA_CTRL_PT pt, CtrlVariable grp, integer instance,
- CtrlVariable name, template integer exp) {
+ CtrlVariable name, template integer exp,
+ charstring_list instance_id_map := {}) {
var charstring ctrl_resp;
- var CtrlVariable variable := valueof(ts_ctrl_ratectr(grp, instance, name));
+ var CtrlVariable variable := valueof(ts_ctrl_ratectr(grp, instance, name, instance_id_map := instance_id_map));
ctrl_resp := f_ctrl_get(pt, variable);
if (not match(str2int(ctrl_resp), exp)) {
setverdict(fail, variable & " value " & ctrl_resp & " didn't match ", exp);
@@ -223,13 +243,15 @@
/* Retrieve one instance's rate counter values of the given names. */
function f_counter_name_vals_get(IPA_CTRL_PT pt, charstring instance_name, integer instance_nr,
- CounterNameVals counternames)
+ CounterNameVals counternames,
+ charstring_list instance_id_map := {})
return CounterNameVals {
var CounterNameVals vals;
for (var integer i := 0; i < lengthof(counternames); i := i + 1) {
vals[i] := {
name := counternames[i].name,
- val := f_ctrl_get_ratectr_abs(pt, instance_name, instance_nr, counternames[i].name)
+ val := f_ctrl_get_ratectr_abs(pt, instance_name, instance_nr, counternames[i].name,
+ instance_id_map := instance_id_map)
};
}
return vals;
@@ -298,14 +320,16 @@
/* For a specific instance, call f_counter_name_vals_get() and compare with expected counter values.
* Set the test verdict accordingly. */
function f_counter_name_vals_expect(IPA_CTRL_PT pt, charstring instance_name, integer instance_nr,
- CounterNameVals vals) {
- var CounterNameVals last := f_counter_name_vals_get(pt, instance_name, instance_nr, vals);
+ CounterNameVals vals, charstring_list instance_id_map := {}) {
+ var CounterNameVals last := f_counter_name_vals_get(pt, instance_name, instance_nr, vals,
+ instance_id_map := instance_id_map);
for (var integer i := 0; i < lengthof(vals); i := i + 1) {
if (last[i].name != vals[i].name) {
setverdict(fail, "Internal error");
}
if (last[i].val != vals[i].val) {
- setverdict(fail, "Rate counter mismatch: ", instance_name, " ", instance_nr,
+ setverdict(fail, "Rate counter mismatch: ", instance_name, " ",
+ f_ctrl_ctr_resolve_instance_id(instance_nr, instance_id_map),
" ", vals[i].name, " is at ", last[i].val, " but expected ", vals[i].val);
}
}
@@ -314,19 +338,22 @@
/* For N instances, call f_counter_name_vals_get() and compare with expected counter values.
* Set the test verdict accordingly. The number of instances is given by lengthof(valslist). */
- function f_counter_name_vals_expect_n(IPA_CTRL_PT pt, charstring instance_name, CounterNameValsList valslist) {
+ function f_counter_name_vals_expect_n(IPA_CTRL_PT pt, charstring instance_name, CounterNameValsList valslist,
+ charstring_list instance_id_map := {}) {
for (var integer instance_nr := 0; instance_nr < lengthof(valslist); instance_nr := instance_nr + 1) {
- f_counter_name_vals_expect(pt, instance_name, instance_nr, valslist[instance_nr]);
+ f_counter_name_vals_expect(pt, instance_name, instance_nr, valslist[instance_nr],
+ instance_id_map := instance_id_map);
}
}
/* For a specific instance, call f_counter_name_vals_get() and indentify counters that have changed with respect
* to 'vals'. Return list of the changed counter names in the order they appear in 'vals'. */
- function f_counter_name_vals_get_changed(IPA_CTRL_PT pt, charstring instance_name, integer instance_nr,
- CounterNameVals vals)
+ private function f_counter_name_vals_get_changed(IPA_CTRL_PT pt, charstring instance_name, integer instance_nr,
+ CounterNameVals vals,
+ charstring_list instance_id_map := {})
return charstring_list {
var charstring_list changed := {};
- var CounterNameVals last := f_counter_name_vals_get(pt, instance_name, instance_nr, vals);
+ var CounterNameVals last := f_counter_name_vals_get(pt, instance_name, instance_nr, vals, instance_id_map);
for (var integer i := 0; i < lengthof(vals); i := i + 1) {
if (last[i].name != vals[i].name) {
setverdict(fail, "Internal error");
@@ -340,11 +367,14 @@
/* For N instances, call f_counter_name_vals_get() and indentify counters that have changed with respect
* to 'vals'. Return list of the changed counter names in the order they appear in 'vals'. */
- function f_counter_name_vals_get_changed_n(IPA_CTRL_PT pt, charstring instance_name, CounterNameValsList valslist)
+ function f_counter_name_vals_get_changed_n(IPA_CTRL_PT pt, charstring instance_name, CounterNameValsList valslist,
+ charstring_list instance_id_map := {})
return charstring_list {
var charstring_list changed := {};
for (var integer instance_nr := 0; instance_nr < lengthof(valslist); instance_nr := instance_nr + 1) {
- changed := changed & f_counter_name_vals_get_changed(pt, instance_name, instance_nr, valslist[instance_nr]);
+ changed := changed & f_counter_name_vals_get_changed(pt, instance_name, instance_nr,
+ valslist[instance_nr],
+ instance_id_map := instance_id_map);
}
return changed;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37882?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I70e74e7554482df67aa1d90bc04314124dea444f
Gerrit-Change-Number: 37882
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Jenkins Builder has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/libosmocore/+/37881?usp=email )
Change subject: CTRL: get rate_ctr_group by the id from rate_ctr_group_set_name()
......................................................................
Patch Set 1:
(1 comment)
File src/core/rate_ctr.c:
Robot Comment from checkpatch (run ID jenkins-gerrit-lint-17923):
https://gerrit.osmocom.org/c/libosmocore/+/37881/comment/0cca077c_c46f2350?… :
PS1, Line 425: llist_for_each_entry(ctrg, &rate_ctr_groups, list) {
space required before the open parenthesis '('
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37881?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I841a12f76e6fcb2bd7aecb5f4b1707d9ec927137
Gerrit-Change-Number: 37881
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Tue, 20 Aug 2024 21:46:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/37881?usp=email )
Change subject: CTRL: get rate_ctr_group by the id from rate_ctr_group_set_name()
......................................................................
CTRL: get rate_ctr_group by the id from rate_ctr_group_set_name()
Some objects always have fixed indexes, because they come from the
config file (think "bts.0" or "msc.0").
However, some object IDs are created dynamically, which makes it
"impossible" to verify them in tests. In osmo-hnbgw, the same hNodeB may
show up as hnb.0, hnb.1, etc.
We do already have the rate_ctr_group_set_name() API which allows
tagging an identifier on a rate counter group. For above example,
osmo-hnbgw sets rate_ctr_group_set_name(cell_id_str).
In CTRL, when a counter group index token is not a clean number, look up
that token as the group instance's name instead. This allows for
example:
GET 123 rate_ctr.abs.hnb.001-01-L2342-R0-S55-C1.iuh:established
in addition to currently:
GET 123 rate_ctr.abs.hnb.0.iuh:established
When merging this patch, magically all rate_ctr_groups in all osmo
programs will become accessible by their given rate_ctr_group_set_name()
IDs.
Related: OS#6545
Change-Id: I841a12f76e6fcb2bd7aecb5f4b1707d9ec927137
---
M include/osmocom/core/rate_ctr.h
M src/core/libosmocore.map
M src/core/rate_ctr.c
M src/ctrl/control_if.c
4 files changed, 52 insertions(+), 15 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/81/37881/1
diff --git a/include/osmocom/core/rate_ctr.h b/include/osmocom/core/rate_ctr.h
index 0a3eb2c..6e336db 100644
--- a/include/osmocom/core/rate_ctr.h
+++ b/include/osmocom/core/rate_ctr.h
@@ -117,6 +117,7 @@
int rate_ctr_init(void *tall_ctx);
struct rate_ctr_group *rate_ctr_get_group_by_name_idx(const char *name, const unsigned int idx);
+struct rate_ctr_group *rate_ctr_get_group_by_name_name(const char *group_name, const char *instance_name);
const struct rate_ctr *rate_ctr_get_by_name(const struct rate_ctr_group *ctrg, const char *name);
typedef int (*rate_ctr_handler_t)(
diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map
index c5ab6e3..f0a7cb8 100644
--- a/src/core/libosmocore.map
+++ b/src/core/libosmocore.map
@@ -607,6 +607,7 @@
rate_ctr_for_each_group;
rate_ctr_get_by_name;
rate_ctr_get_group_by_name_idx;
+rate_ctr_get_group_by_name_name;
rate_ctr_group_alloc;
rate_ctr_group_free;
rate_ctr_group_get_ctr;
diff --git a/src/core/rate_ctr.c b/src/core/rate_ctr.c
index 44e2658..6e2c4a4 100644
--- a/src/core/rate_ctr.c
+++ b/src/core/rate_ctr.c
@@ -279,6 +279,9 @@
*/
void rate_ctr_group_set_name(struct rate_ctr_group *grp, const char *name)
{
+ if (!osmo_identifier_valid(name))
+ LOGP(DLGLOBAL, LOGL_ERROR, "The application is setting an invalid rate counter group name: %s\n",
+ osmo_quote_str(name, -1));
osmo_talloc_replace_string(grp, &grp->name, name);
}
@@ -390,10 +393,10 @@
return 0;
}
-/*! Search for counter group based on group name and index
- * \param[in] name Name of the counter group you're looking for
- * \param[in] idx Index inside the counter group
- * \returns \ref rate_ctr_group or NULL in case of error */
+/*! Search for counter group based on group name and index.
+ * \param[in] group_name Name of the counter group family (like a "bsc", "hnb", ...).
+ * \param[in] idx Instance index inside the counter group (like 23 in "bsc.23").
+ * \returns \ref rate_ctr_group or NULL in case of error. */
struct rate_ctr_group *rate_ctr_get_group_by_name_idx(const char *name, const unsigned int idx)
{
struct rate_ctr_group *ctrg;
@@ -410,6 +413,29 @@
return NULL;
}
+/*! Search for counter group based on group name and instance name.
+ * \param[in] group_name Name of the counter group family (like a "bsc", "hnb", ...).
+ * \param[in] instance_name Name given to the specific instance of the counter group (something like a cell ID string,
+ * it is up to the calling application to set rate_ctr_group_set_name() on each created instance).
+ * \returns \ref rate_ctr_group or NULL in case of error */
+struct rate_ctr_group *rate_ctr_get_group_by_name_name(const char *group_name, const char *instance_name)
+{
+ struct rate_ctr_group *ctrg;
+
+ llist_for_each_entry(ctrg, &rate_ctr_groups, list) {
+ if (!ctrg->desc)
+ continue;
+
+ if (strcmp(ctrg->desc->group_name_prefix, group_name))
+ continue;
+
+ if (strcmp(ctrg->name, instance_name))
+ continue;
+ return ctrg;
+ }
+ return NULL;
+}
+
/*! Search for counter based on group + name
* \param[in] ctrg pointer to \ref rate_ctr_group
* \param[in] name name of counter inside group
diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index c265c3a..8445c54 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -633,8 +633,8 @@
static int get_rate_ctr(struct ctrl_cmd *cmd, void *data)
{
int intv;
- unsigned int idx;
- char *ctr_group, *ctr_idx, *tmp, *dup, *saveptr, *interval;
+ int idx;
+ char *ctr_group, *ctr_idx_or_name, *tmp, *dup, *saveptr, *interval;
struct rate_ctr_group *ctrg;
const struct rate_ctr *ctr;
@@ -680,21 +680,30 @@
}
ctr_group = strtok_r(NULL, ".", &saveptr);
- ctr_idx = strtok_r(NULL, ".", &saveptr);
- if (!ctr_group || !ctr_idx) {
+ ctr_idx_or_name = strtok_r(NULL, ".", &saveptr);
+ if (!ctr_group || !ctr_idx_or_name) {
talloc_free(dup);
cmd->reply = "Counter group must be of name.index form e. g. "
"e1inp.0";
goto err;
}
- idx = atoi(ctr_idx);
-
- ctrg = rate_ctr_get_group_by_name_idx(ctr_group, idx);
- if (!ctrg) {
- talloc_free(dup);
- cmd->reply = "Counter group with given name and index not found";
- goto err;
+ /* If the token is a valid integer, osmo_str_to_int() returns success, and we interpret it as an index. If not,
+ * try to look up a counter group instance name instead. */
+ if (osmo_str_to_int(&idx, ctr_idx_or_name, 10, 0, INT_MAX) == 0) {
+ ctrg = rate_ctr_get_group_by_name_idx(ctr_group, idx);
+ if (!ctrg) {
+ talloc_free(dup);
+ cmd->reply = "Counter group with given name and index not found";
+ goto err;
+ }
+ } else {
+ ctrg = rate_ctr_get_group_by_name_name(ctr_group, ctr_idx_or_name);
+ if (!ctrg) {
+ talloc_free(dup);
+ cmd->reply = "Counter group with given name and instance ID not found";
+ goto err;
+ }
}
if (!strlen(saveptr)) {
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37881?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I841a12f76e6fcb2bd7aecb5f4b1707d9ec927137
Gerrit-Change-Number: 37881
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Attention is currently required from: daniel, lynxis lazus.
pespin has posted comments on this change by lynxis lazus. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/37869?usp=email )
Change subject: GMM: split parsing of a RA Update Request in a separate file
......................................................................
Patch Set 5:
(4 comments)
File src/sgsn/gprs_gmm.c:
https://gerrit.osmocom.org/c/osmo-sgsn/+/37869/comment/018b4518_74f268f2?us… :
PS5, Line 1624: LOGMMCTXP(LOGL_NOTICE, mmctx, "Update type %i unsupported in Mode III, is your SI13 corrupt?\n", req.update_type);
> Use %d instead of %i
Please fix.
File src/sgsn/gprs_gmm_util.c:
https://gerrit.osmocom.org/c/osmo-sgsn/+/37869/comment/625581be_3ecbe9d0?us… :
PS5, Line 98: if (msgb_l3len(msg) < (len + (cur - msgb_gmmh(msg))))
> that open brace { should be on the previous line
Please fix.
https://gerrit.osmocom.org/c/osmo-sgsn/+/37869/comment/5228b622_b4120833?us… :
PS5, Line 108: if (msgb_l3len(msg) == mandatory_fields_len) {
> braces {} are not necessary for single statement blocks
Please fix.
https://gerrit.osmocom.org/c/osmo-sgsn/+/37869/comment/98ae620e_c3b7d523?us… :
PS5, Line 115: if (ret < 0) {
> braces {} are not necessary for single statement blocks
Please fix.
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/37869?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I413da1b6b4b7c0c4781393acd8564661bc74ce2d
Gerrit-Change-Number: 37869
Gerrit-PatchSet: 5
Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Comment-Date: Tue, 20 Aug 2024 19:21:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: daniel, lynxis lazus.
pespin has posted comments on this change by lynxis lazus. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/37868?usp=email )
Change subject: move gsm48_gmm_att_tlvdef into gprs_gmm_util
......................................................................
Patch Set 5: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/37868?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I67dcdb986fd01dc093501d324b5c376246a5d30d
Gerrit-Change-Number: 37868
Gerrit-PatchSet: 5
Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Comment-Date: Tue, 20 Aug 2024 19:20:14 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes