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
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/+/37867?usp=email )
Change subject: Refactor diffing same GMM messages
......................................................................
Patch Set 5: Code-Review+1
(1 comment)
File src/sgsn/gprs_gmm.c:
https://gerrit.osmocom.org/c/osmo-sgsn/+/37867/comment/ff96c0a5_93e3afa3?us… :
PS5, Line 1445: return -1;
is this an error? shouldn't it be 1? (see description above).
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/37867?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: Ie698d3a6894a5796663c22c8bfd12b47acda57e6
Gerrit-Change-Number: 37867
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:19:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
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/+/37866?usp=email )
Change subject: Implement correct Routing Area based paging
......................................................................
Patch Set 5: Code-Review-1
(3 comments)
File src/sgsn/gprs_routing_area.c:
https://gerrit.osmocom.org/c/osmo-sgsn/+/37866/comment/24c9af63_321001ef?us… :
PS5, Line 315: llist_for_each_entry(cell, &ra->cells, list) {
> space required before the open parenthesis '('
Please fix.
https://gerrit.osmocom.org/c/osmo-sgsn/+/37866/comment/5fcae8c4_80640db3?us… :
PS5, Line 319: }
/* TODO for UTRAN */ here I guess?
File src/sgsn/sgsn_vty.c:
https://gerrit.osmocom.org/c/osmo-sgsn/+/37866/comment/d4e0b7af_f8b59673?us… :
PS5, Line 1338: rate_ctr_inc(rate_ctr_group_get_ctr(mm->ctrg, GMM_CTR_PAGING_PS));
I don't really like the fact that now we have this counter incremented in several places. I'd put this into the function doing the paging.
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/37866?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: I181da9f656e394ccfcb8999021a5b7e13ca0419f
Gerrit-Change-Number: 37866
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:18:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
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/+/37865?usp=email )
Change subject: Routing Area: Remove cells when NSEI becomes unavailable
......................................................................
Patch Set 5: Code-Review-1
(2 comments)
File src/sgsn/gprs_routing_area.c:
https://gerrit.osmocom.org/c/osmo-sgsn/+/37865/comment/aac5edc4_e6c13be7?us… :
PS5, Line 289: llist_for_each_entry_safe(ra, ra2, &sgsn_ra_ctx->ras, list) {
> space required before the open parenthesis '('
This one needs to be fixed. This is a for, not a function, we use a space.
https://gerrit.osmocom.org/c/osmo-sgsn/+/37865/comment/dcb5aee8_96ef0504?us… :
PS5, Line 290: llist_for_each_entry_safe(cell, cell2, &ra->cells, list) {
> space required before the open parenthesis '('
Please fix.
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/37865?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: I9f0386d9eb7f0cabaf0fde45f8e78b4ea28c67c5
Gerrit-Change-Number: 37865
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 18:50:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes