[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-04-02 Thread Jenkins Builder
Attention is currently required from: neels.

Jenkins Builder has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email )

Change subject: use json to decode counters from nftables
..


Patch Set 5:

(2 comments)

File src/osmo-hnbgw/nft_kpi.c:

Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15524):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/1cbefed0_686fda1e
PS5, Line 266:  json_array_foreach (nftables, i, item) {
space prohibited between function name and open parenthesis '('


Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15524):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/c433aa74_85485d32
PS5, Line 294:  json_array_foreach (expr, j, expr_item) {
space prohibited between function name and open parenthesis '('



--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
Gerrit-Change-Number: 36485
Gerrit-PatchSet: 5
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-CC: osmith 
Gerrit-Attention: neels 
Gerrit-Comment-Date: Wed, 03 Apr 2024 00:53:57 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-03-29 Thread laforge
Attention is currently required from: neels.

laforge has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email )

Change subject: use json to decode counters from nftables
..


Patch Set 4:

(1 comment)

Patchset:

PS4:
from the build errors and looking at the patch it seems like it's missing using 
the LIBJANSSON_LIBS / LIBJANSSON_CFLAGS in the Makefile.am ?



--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
Gerrit-Change-Number: 36485
Gerrit-PatchSet: 4
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: laforge 
Gerrit-CC: osmith 
Gerrit-Attention: neels 
Gerrit-Comment-Date: Fri, 29 Mar 2024 10:04:35 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-03-28 Thread Jenkins Builder
Attention is currently required from: neels.

Jenkins Builder has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email )

Change subject: use json to decode counters from nftables
..


Patch Set 4:

(2 comments)

File src/osmo-hnbgw/nft_kpi.c:

Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15489):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/440cb2eb_4da76159
PS4, Line 266:  json_array_foreach (nftables, i, item) {
space prohibited between function name and open parenthesis '('


Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15489):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/46adcedb_e8c91e24
PS4, Line 294:  json_array_foreach (expr, j, expr_item) {
space prohibited between function name and open parenthesis '('



--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
Gerrit-Change-Number: 36485
Gerrit-PatchSet: 4
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: osmith 
Gerrit-Attention: neels 
Gerrit-Comment-Date: Thu, 28 Mar 2024 15:21:25 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-03-28 Thread neels
Attention is currently required from: neels.

Hello Jenkins Builder,

I'd like you to reexamine a change. Please visit

https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email

to look at the new patch set (#4).

The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder


Change subject: use json to decode counters from nftables
..

use json to decode counters from nftables

Switch nft output to json. Add libjansson dependency, and use it to
parse the result. Navigate the json tree to retrieve the counter values.

Parsing with json takes longer than the direct string parsing of nft
language, but it is the more correct and more stable approach: in case
nftables changes its API, json is likely to still be compatible.

Related: SYS#6773
Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
---
M configure.ac
M src/osmo-hnbgw/nft_kpi.c
2 files changed, 115 insertions(+), 72 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/85/36485/4
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
Gerrit-Change-Number: 36485
Gerrit-PatchSet: 4
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: osmith 
Gerrit-Attention: neels 
Gerrit-MessageType: newpatchset


[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-03-28 Thread Jenkins Builder
Attention is currently required from: neels.

Jenkins Builder has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email )

Change subject: use json to decode counters from nftables
..


Patch Set 3:

(2 comments)

File src/osmo-hnbgw/nft_kpi.c:

Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15486):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/9b8a4186_13126240
PS3, Line 266:  json_array_foreach (nftables, i, item) {
space prohibited between function name and open parenthesis '('


Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15486):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/ce27fe6c_95a4e951
PS3, Line 294:  json_array_foreach (expr, j, expr_item) {
space prohibited between function name and open parenthesis '('



--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
Gerrit-Change-Number: 36485
Gerrit-PatchSet: 3
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: osmith 
Gerrit-Attention: neels 
Gerrit-Comment-Date: Thu, 28 Mar 2024 15:00:50 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-03-28 Thread osmith
Attention is currently required from: neels.

osmith has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email )

Change subject: use json to decode counters from nftables
..


Patch Set 2:

(1 comment)

File src/osmo-hnbgw/nft_kpi.c:

https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/8cc89a5e_740b8d79
PS2, Line 266:  json_array_foreach (nftables, i, item) {
> space prohibited between function name and open parenthesis '('

fix for the linter: https://gerrit.osmocom.org/c/osmo-ci/+/36487



--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
Gerrit-Change-Number: 36485
Gerrit-PatchSet: 2
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: osmith 
Gerrit-Attention: neels 
Gerrit-Comment-Date: Thu, 28 Mar 2024 08:03:09 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-03-27 Thread Jenkins Builder
Attention is currently required from: neels.

Jenkins Builder has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email )

Change subject: use json to decode counters from nftables
..


Patch Set 2:

(2 comments)

File src/osmo-hnbgw/nft_kpi.c:

Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15477):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/c6d17c27_557d122d
PS2, Line 266:  json_array_foreach (nftables, i, item) {
space prohibited between function name and open parenthesis '('


Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15477):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/ef649c34_b6c04499
PS2, Line 294:  json_array_foreach (expr, j, expr_item) {
space prohibited between function name and open parenthesis '('



--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
Gerrit-Change-Number: 36485
Gerrit-PatchSet: 2
Gerrit-Owner: neels 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: neels 
Gerrit-Comment-Date: Thu, 28 Mar 2024 02:47:41 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-03-27 Thread Jenkins Builder
Jenkins Builder has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email )

Change subject: use json to decode counters from nftables
..


Patch Set 1:

(2 comments)

File src/osmo-hnbgw/nft_kpi.c:

Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15475):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/a499530c_d95520ab
PS1, Line 266:  json_array_foreach (nftables, i, item) {
space prohibited between function name and open parenthesis '('


Robot Comment from checkpatch (run ID jenkins-gerrit-lint-15475):
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485/comment/9f3d3d71_2c6def1a
PS1, Line 294:  json_array_foreach (expr, j, expr_item) {
space prohibited between function name and open parenthesis '('



--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
Gerrit-Change-Number: 36485
Gerrit-PatchSet: 1
Gerrit-Owner: neels 
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Wed, 27 Mar 2024 21:57:25 +
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment


[M] Change in osmo-hnbgw[master]: use json to decode counters from nftables

2024-03-27 Thread neels
neels has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-hnbgw/+/36485?usp=email )


Change subject: use json to decode counters from nftables
..

use json to decode counters from nftables

Switch nft output to json. Add libjansson dependency, and use it to
parse the result. Navigate the json tree to retrieve the counter values.

Parsing with json takes longer than the direct string parsing of nft
language, but it is the more correct and more stable approach: in case
nftables changes its API, json is likely to still be compatible.

Related: SYS#6773
Change-Id: Id4e7fa017c31945388a010d8581715d71482116b
---
M configure.ac
M src/osmo-hnbgw/nft_kpi.c
2 files changed, 115 insertions(+), 72 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/85/36485/1

diff --git a/configure.ac b/configure.ac
index bea9a76..657ad0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,6 +60,7 @@
 PKG_CHECK_MODULES(LIBOSMOHNBAP, libosmo-hnbap >= 1.5.0)
 PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.12.0)
 PKG_CHECK_MODULES(LIBNFTABLES, libnftables >= 1.0.2)
+PKG_CHECK_MODULES(LIBJANSSON, jansson >= 2.14)

 # Enable PFCP support for GTP tunnel mapping via UPF
 AC_ARG_ENABLE([pfcp], [AS_HELP_STRING([--enable-pfcp], [Build with PFCP 
support, for GTP tunnel mapping via UPF])],
diff --git a/src/osmo-hnbgw/nft_kpi.c b/src/osmo-hnbgw/nft_kpi.c
index 0dd702f..0b5ac91 100644
--- a/src/osmo-hnbgw/nft_kpi.c
+++ b/src/osmo-hnbgw/nft_kpi.c
@@ -19,6 +19,7 @@
 #include 
 #include 

+#include 
 #include 

 #include 
@@ -51,7 +52,7 @@
OSMO_ASSERT(false);
}

-   nft_ctx_output_set_flags(s->nft.nft_ctx, NFT_CTX_OUTPUT_HANDLE);
+   nft_ctx_output_set_flags(s->nft.nft_ctx, NFT_CTX_OUTPUT_JSON);

return s->nft.nft_ctx;
 }
@@ -219,99 +220,123 @@
   >bytes, bytes);
 }

-/* In the string section *pos .. end, find the first occurence of after_str 
and return the following token, which ends
- * by a space or at end. If end is NULL, search until the '\0' termination of 
*pos.
- * Return true if after_str was found, copy the following token into buf, and 
in *pos, return the position just after
- * that token. */
-static bool get_token_after(char *buf, size_t buflen, const char **pos, const 
char *end, const char *after_str)
+static int hnb_update_counters_by_id(const char *id_str, bool ul, int64_t 
packets, int64_t bytes, int64_t handle,
+struct hnb_persistent **last_hnbp)
 {
-   const char *found = strstr(*pos, after_str);
-   const char *token_end;
-   size_t token_len;
-   if (!found)
-   return false;
-   if (end && found >= end) {
-   *pos = end;
-   return false;
+   struct hnb_persistent *hnbp;
+   LOGP(DNFT, LOGL_DEBUG, "%s(%s, %s, %"PRId64", %"PRId64", %"PRId64")\n", 
__func__,
+id_str, ul ? "ul" : "dl", packets, bytes, handle);
+
+   /* Half the time, we already have a pointer to the correct hnb */
+   if (last_hnbp && *last_hnbp && !strcmp((*last_hnbp)->id_str, id_str))
+   hnbp = *last_hnbp;
+   else
+   hnbp = hnb_persistent_find_by_id_str(id_str);
+   if (!hnbp) {
+   LOGP(DNFT, LOGL_DEBUG, "%s(): cannot update counters, hNodeB 
not found: %s\n", __func__, id_str);
+   return -ENOENT;
}
-   found += strlen(after_str);
-   while (*found && *found == ' ' && (!end || found < end))
-   found++;
-   token_end = found;
-   while (*token_end != ' ' && (!end || token_end < end))
-   token_end++;
-   if (token_end <= found) {
-   *pos = found;
-   return false;
-   }
-   if (*found == '"' && token_end > found + 1 && *(token_end - 1) == '"') {
-   found++;
-   token_end--;
-   }
-   token_len = token_end - found;
-   token_len = OSMO_MIN(token_len, buflen - 1);
-   memcpy(buf, found, token_len);
-   buf[token_len] = '\0';
-   *pos = token_end;
-   return true;
+   if (last_hnbp)
+   *last_hnbp = hnbp;
+   hnb_update_counters(hnbp, ul, packets, bytes, handle);
+   return 0;
 }

 static void decode_nft_response(const char *response)
 {
struct nft_kpi_state *s = _nft_kpi_state;
-   const char *pos;
-   char buf[128];
+   struct hnb_persistent *hnbp = NULL;
+   json_t *json;
+   json_error_t json_err;
+
+   json_t *nftables;
+   json_t *item;
+   int i;
int count = 0;

-   /* find and parse all occurences of strings like:
-*[...] counter packets 3 bytes 129 comment "ul:001-01-L2-R3-S4-C1" 
# handle 10
-*/
-   pos = response;
-   while (*pos) {
-   const char *line_end;
-   int64_t packets;
-   int64_t bytes;
-