[PATCH] osmo-pcu[master]: TBF: bail out for unknown timers

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5547

TBF: bail out for unknown timers

Return right after logging error if attempting to start or stop unknown
timer.

Change-Id: Ie6ae564d41a5e03270685c6bafb3504278eb3551
Fixes: CID181512, CID181514
---
M src/tbf.cpp
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/47/5547/1

diff --git a/src/tbf.cpp b/src/tbf.cpp
index 520f6c4..aec67e7 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -543,6 +543,7 @@
if (t >= T_MAX) {
LOGPTBF(this, LOGL_ERROR, "attempting to stop unknown timer %s 
[%s]\n",
get_value_string(tbf_timers_names, t), reason);
+   return;
}
 
if (osmo_timer_pending([t])) {
@@ -600,6 +601,7 @@
if (t >= T_MAX) {
LOGPSRC(DRLCMAC, LOGL_ERROR, file, line, "%s attempting to 
start unknown timer %s [%s]\n",
tbf_name(this), get_value_string(tbf_timers_names, t), 
reason);
+   return;
}
 
if (!force && osmo_timer_pending([t]))

-- 
To view, visit https://gerrit.osmocom.org/5547
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6ae564d41a5e03270685c6bafb3504278eb3551
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 


[ABANDON] libosmocore[master]: Remove unused check

2017-12-21 Thread Harald Welte
Harald Welte has abandoned this change.

Change subject: Remove unused check
..


Abandoned

-- 
To view, visit https://gerrit.osmocom.org/5536
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: abandon
Gerrit-Change-Id: Ib5d9f9278af15f0fee0dc5537489de4469b692d2
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


libosmocore[master]: Remove unused check

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review-1

Wie might do it again some day

-- 
To view, visit https://gerrit.osmocom.org/5536
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib5d9f9278af15f0fee0dc5537489de4469b692d2
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-pcu[master]: Enable sanitize for CI test

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Enable sanitize for CI test
..


Enable sanitize for CI test

Change-Id: Ia33ffb9b25df587706367bc24925cf9cead3b9a0
---
M contrib/jenkins.sh
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index fb529a4..05b9639 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -44,7 +44,8 @@
   cd "$base"
 
 elif [ -z "$with_dsp" -o "$with_dsp" = none ]; then
-  echo "Direct DSP access disabled"
+  echo "Direct DSP access disabled, sanitizer enabled"
+  PCU_CONFIG="$PCU_CONFIG --enable-sanitize"
 else
   echo 'Invalid $with_dsp value:' $with_dsp
   exit 1

-- 
To view, visit https://gerrit.osmocom.org/5546
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia33ffb9b25df587706367bc24925cf9cead3b9a0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] libosmo-sccp[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Enable sanitize for CI tests
..


Enable sanitize for CI tests

Change-Id: Ida8cfcd9a9f86e65273452afa051381bc0c16421
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index adc5db7..0d68f7c 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -36,7 +36,7 @@
 set -x
 
 autoreconf --install --force
-./configure CFLAGS="-Werror" CPPFLAGS="-Werror"
+./configure --enable-sanitize CFLAGS="-Werror" CPPFLAGS="-Werror"
 $MAKE $PARALLEL_MAKE
 $MAKE distcheck \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5538
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ida8cfcd9a9f86e65273452afa051381bc0c16421
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


libosmo-sccp[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5538
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ida8cfcd9a9f86e65273452afa051381bc0c16421
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


libsmpp34[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5539
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ibf070228e439ddb3be9c6570f963ac0db05d1c9c
Gerrit-PatchSet: 1
Gerrit-Project: libsmpp34
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[MERGED] libsmpp34[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Enable sanitize for CI tests
..


Enable sanitize for CI tests

Change-Id: Ibf070228e439ddb3be9c6570f963ac0db05d1c9c
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 6bf176a..4a31aef 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -5,7 +5,7 @@
 osmo-clean-workspace.sh
 
 autoreconf --install --force
-./configure
+./configure --enable-sanitize
 $MAKE CFLAGS="-Werror" CPPFLAGS="-Werror"
 # currently broken $MAKE $PARALLEL_MAKE
 # currently broken $MAKE distcheck

-- 
To view, visit https://gerrit.osmocom.org/5539
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibf070228e439ddb3be9c6570f963ac0db05d1c9c
Gerrit-PatchSet: 1
Gerrit-Project: libsmpp34
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


[MERGED] osmo-ggsn[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Enable sanitize for CI tests
..


Enable sanitize for CI tests

Change-Id: I7559807d54bec5da45ea5c41b10d396d992cb1b7
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 06c24e5..033eed7 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -38,7 +38,7 @@
 
 cd "$base"
 autoreconf --install --force
-./configure CFLAGS="-Werror" CPPFLAGS="-Werror" $GTP
+./configure --enable-sanitize CFLAGS="-Werror" CPPFLAGS="-Werror" $GTP
 $MAKE $PARALLEL_MAKE
 $MAKE distcheck
 

-- 
To view, visit https://gerrit.osmocom.org/5540
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7559807d54bec5da45ea5c41b10d396d992cb1b7
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-bsc[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Enable sanitize for CI tests
..


Enable sanitize for CI tests

Change-Id: I86f8f29dbe13869fa4a0ac1f55ff697a8975525b
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 57954f0..d7a41a8 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -40,7 +40,7 @@
 
 cd "$base"
 autoreconf --install --force
-./configure --enable-vty-tests --enable-external-tests
+./configure --enable-sanitize --enable-vty-tests --enable-external-tests
 $MAKE $PARALLEL_MAKE
 LD_LIBRARY_PATH="$inst/lib" $MAKE check \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5543
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I86f8f29dbe13869fa4a0ac1f55ff697a8975525b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-sgsn[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Enable sanitize for CI tests
..


Enable sanitize for CI tests

While at it, also remove unsupported ./configure options remaining since
before repo split.

Change-Id: I77b3375fd680be269fd2df7db61ece6c5d1754ba
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index fa7c60e..d2db0c9 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -46,7 +46,7 @@
 
 cd "$base"
 autoreconf --install --force
-./configure --enable-osmo-bsc --enable-nat $SMPP $MGCP $IU --enable-vty-tests 
--enable-external-tests
+./configure --enable-sanitize $SMPP $MGCP $IU --enable-vty-tests 
--enable-external-tests
 $MAKE $PARALLEL_MAKE
 LD_LIBRARY_PATH="$inst/lib" $MAKE check \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5541
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I77b3375fd680be269fd2df7db61ece6c5d1754ba
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-ggsn[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5540
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I7559807d54bec5da45ea5c41b10d396d992cb1b7
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-msc[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5542
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I23da6f9b836595d81b509c8a6fb4e46b5d675103
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] libosmo-netif[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Enable sanitize for CI tests
..


Enable sanitize for CI tests

Change-Id: I3a888a415698db5a11d74422f7ccb2d94126f56e
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index ac898f7..c289d2d 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -35,7 +35,7 @@
 set -x
 
 autoreconf --install --force
-./configure CFLAGS="-Werror" CPPFLAGS="-Werror"
+./configure --enable-sanitize CFLAGS="-Werror" CPPFLAGS="-Werror"
 $MAKE $PARALLEL_MAKE
 $MAKE distcheck \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5537
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3a888a415698db5a11d74422f7ccb2d94126f56e
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 


osmo-sgsn[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5541
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I77b3375fd680be269fd2df7db61ece6c5d1754ba
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-msc[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Enable sanitize for CI tests
..


Enable sanitize for CI tests

Change-Id: I23da6f9b836595d81b509c8a6fb4e46b5d675103
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index b0dde06..e4f90e6 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -48,7 +48,7 @@
 
 cd "$base"
 autoreconf --install --force
-./configure --enable-smpp $IU --enable-external-tests
+./configure --enable-sanitize --enable-smpp $IU --enable-external-tests
 $MAKE $PARALLEL_MAKE
 LD_LIBRARY_PATH="$inst/lib" $MAKE check \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5542
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I23da6f9b836595d81b509c8a6fb4e46b5d675103
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-pcu[master]: Enable sanitize for CI test

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5546
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia33ffb9b25df587706367bc24925cf9cead3b9a0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-pcu[master]: Add --enable-sanitize configure option

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5544
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Idb2c1d6057012ed2f032e7504387a0767d02d75b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-bsc[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5543
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I86f8f29dbe13869fa4a0ac1f55ff697a8975525b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


libosmo-netif[master]: Enable sanitize for CI tests

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5537
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I3a888a415698db5a11d74422f7ccb2d94126f56e
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


[MERGED] osmo-bts[master]: Add --enable-sanitize configure option

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Add --enable-sanitize configure option
..


Add --enable-sanitize configure option

Change-Id: I4e31e20ef2361c8f251f3ab04a0ac86e23d2e8a1
---
M configure.ac
1 file changed, 9 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/configure.ac b/configure.ac
index e3ea9ca..89443d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,15 @@
 
 dnl Checks for typedefs, structures and compiler characteristics
 
+AC_ARG_ENABLE(sanitize,
+   [AS_HELP_STRING([--enable-sanitize], [Compile with address 
sanitizer enabled], )],
+   [sanitize=$enableval], [sanitize="no"])
+if test x"$sanitize" = x"yes"
+then
+   CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
+   CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
+fi
+
 dnl checks for libraries
 PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore  >= 0.10.0)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.10.0)

-- 
To view, visit https://gerrit.osmocom.org/5545
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4e31e20ef2361c8f251f3ab04a0ac86e23d2e8a1
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-bts[master]: Add --enable-sanitize configure option

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5545
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I4e31e20ef2361c8f251f3ab04a0ac86e23d2e8a1
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-pcu[master]: Add --enable-sanitize configure option

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Add --enable-sanitize configure option
..


Add --enable-sanitize configure option

Change-Id: Idb2c1d6057012ed2f032e7504387a0767d02d75b
---
M configure.ac
1 file changed, 9 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/configure.ac b/configure.ac
index 3533af9..5867cbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,15 @@
 
 dnl Checks for typedefs, structures and compiler characteristics
 
+AC_ARG_ENABLE(sanitize,
+   [AS_HELP_STRING([--enable-sanitize], [Compile with address 
sanitizer enabled], )],
+   [sanitize=$enableval], [sanitize="no"])
+if test x"$sanitize" = x"yes"
+then
+   CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
+   CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
+fi
+
 dnl checks for libraries
 PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore  >= 0.10.1)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty)

-- 
To view, visit https://gerrit.osmocom.org/5544
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idb2c1d6057012ed2f032e7504387a0767d02d75b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-pcu[master]: Enable sanitize for CI test

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5546

Enable sanitize for CI test

Change-Id: Ia33ffb9b25df587706367bc24925cf9cead3b9a0
---
M contrib/jenkins.sh
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/46/5546/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index fb529a4..05b9639 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -44,7 +44,8 @@
   cd "$base"
 
 elif [ -z "$with_dsp" -o "$with_dsp" = none ]; then
-  echo "Direct DSP access disabled"
+  echo "Direct DSP access disabled, sanitizer enabled"
+  PCU_CONFIG="$PCU_CONFIG --enable-sanitize"
 else
   echo 'Invalid $with_dsp value:' $with_dsp
   exit 1

-- 
To view, visit https://gerrit.osmocom.org/5546
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia33ffb9b25df587706367bc24925cf9cead3b9a0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-bts[master]: Add --enable-sanitize configure option

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5545

Add --enable-sanitize configure option

Change-Id: I4e31e20ef2361c8f251f3ab04a0ac86e23d2e8a1
---
M configure.ac
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/45/5545/1

diff --git a/configure.ac b/configure.ac
index e3ea9ca..89443d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,15 @@
 
 dnl Checks for typedefs, structures and compiler characteristics
 
+AC_ARG_ENABLE(sanitize,
+   [AS_HELP_STRING([--enable-sanitize], [Compile with address 
sanitizer enabled], )],
+   [sanitize=$enableval], [sanitize="no"])
+if test x"$sanitize" = x"yes"
+then
+   CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
+   CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
+fi
+
 dnl checks for libraries
 PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore  >= 0.10.0)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.10.0)

-- 
To view, visit https://gerrit.osmocom.org/5545
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e31e20ef2361c8f251f3ab04a0ac86e23d2e8a1
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-pcu[master]: Add --enable-sanitize configure option

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5544

Add --enable-sanitize configure option

Change-Id: Idb2c1d6057012ed2f032e7504387a0767d02d75b
---
M configure.ac
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/44/5544/1

diff --git a/configure.ac b/configure.ac
index 3533af9..5867cbe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,6 +35,15 @@
 
 dnl Checks for typedefs, structures and compiler characteristics
 
+AC_ARG_ENABLE(sanitize,
+   [AS_HELP_STRING([--enable-sanitize], [Compile with address 
sanitizer enabled], )],
+   [sanitize=$enableval], [sanitize="no"])
+if test x"$sanitize" = x"yes"
+then
+   CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
+   CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
+fi
+
 dnl checks for libraries
 PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore  >= 0.10.1)
 PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty)

-- 
To view, visit https://gerrit.osmocom.org/5544
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb2c1d6057012ed2f032e7504387a0767d02d75b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-msc[master]: Enable sanitize for CI tests

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5542

Enable sanitize for CI tests

Change-Id: I23da6f9b836595d81b509c8a6fb4e46b5d675103
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/42/5542/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index b0dde06..e4f90e6 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -48,7 +48,7 @@
 
 cd "$base"
 autoreconf --install --force
-./configure --enable-smpp $IU --enable-external-tests
+./configure --enable-sanitize --enable-smpp $IU --enable-external-tests
 $MAKE $PARALLEL_MAKE
 LD_LIBRARY_PATH="$inst/lib" $MAKE check \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5542
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23da6f9b836595d81b509c8a6fb4e46b5d675103
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-bsc[master]: Enable sanitize for CI tests

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5543

Enable sanitize for CI tests

Change-Id: I86f8f29dbe13869fa4a0ac1f55ff697a8975525b
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/43/5543/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 57954f0..d7a41a8 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -40,7 +40,7 @@
 
 cd "$base"
 autoreconf --install --force
-./configure --enable-vty-tests --enable-external-tests
+./configure --enable-sanitize --enable-vty-tests --enable-external-tests
 $MAKE $PARALLEL_MAKE
 LD_LIBRARY_PATH="$inst/lib" $MAKE check \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5543
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I86f8f29dbe13869fa4a0ac1f55ff697a8975525b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-sgsn[master]: Enable sanitize for CI tests

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5541

Enable sanitize for CI tests

While at it, also remove unsupported ./configure options remaining since
before repo split.

Change-Id: I77b3375fd680be269fd2df7db61ece6c5d1754ba
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/41/5541/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index fa7c60e..d2db0c9 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -46,7 +46,7 @@
 
 cd "$base"
 autoreconf --install --force
-./configure --enable-osmo-bsc --enable-nat $SMPP $MGCP $IU --enable-vty-tests 
--enable-external-tests
+./configure --enable-sanitize $SMPP $MGCP $IU --enable-vty-tests 
--enable-external-tests
 $MAKE $PARALLEL_MAKE
 LD_LIBRARY_PATH="$inst/lib" $MAKE check \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5541
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I77b3375fd680be269fd2df7db61ece6c5d1754ba
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-ggsn[master]: Enable sanitize for CI tests

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5540

Enable sanitize for CI tests

Change-Id: I7559807d54bec5da45ea5c41b10d396d992cb1b7
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/40/5540/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 06c24e5..033eed7 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -38,7 +38,7 @@
 
 cd "$base"
 autoreconf --install --force
-./configure CFLAGS="-Werror" CPPFLAGS="-Werror" $GTP
+./configure --enable-sanitize CFLAGS="-Werror" CPPFLAGS="-Werror" $GTP
 $MAKE $PARALLEL_MAKE
 $MAKE distcheck
 

-- 
To view, visit https://gerrit.osmocom.org/5540
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7559807d54bec5da45ea5c41b10d396d992cb1b7
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] libsmpp34[master]: Enable sanitize for CI tests

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5539

Enable sanitize for CI tests

Change-Id: Ibf070228e439ddb3be9c6570f963ac0db05d1c9c
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libsmpp34 refs/changes/39/5539/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 6bf176a..4a31aef 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -5,7 +5,7 @@
 osmo-clean-workspace.sh
 
 autoreconf --install --force
-./configure
+./configure --enable-sanitize
 $MAKE CFLAGS="-Werror" CPPFLAGS="-Werror"
 # currently broken $MAKE $PARALLEL_MAKE
 # currently broken $MAKE distcheck

-- 
To view, visit https://gerrit.osmocom.org/5539
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf070228e439ddb3be9c6570f963ac0db05d1c9c
Gerrit-PatchSet: 1
Gerrit-Project: libsmpp34
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] libosmo-sccp[master]: Enable sanitize for CI tests

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5538

Enable sanitize for CI tests

Change-Id: Ida8cfcd9a9f86e65273452afa051381bc0c16421
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/38/5538/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index adc5db7..0d68f7c 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -36,7 +36,7 @@
 set -x
 
 autoreconf --install --force
-./configure CFLAGS="-Werror" CPPFLAGS="-Werror"
+./configure --enable-sanitize CFLAGS="-Werror" CPPFLAGS="-Werror"
 $MAKE $PARALLEL_MAKE
 $MAKE distcheck \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5538
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida8cfcd9a9f86e65273452afa051381bc0c16421
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] libosmo-netif[master]: Enable sanitize for CI tests

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5537

Enable sanitize for CI tests

Change-Id: I3a888a415698db5a11d74422f7ccb2d94126f56e
---
M contrib/jenkins.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/37/5537/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index ac898f7..c289d2d 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -35,7 +35,7 @@
 set -x
 
 autoreconf --install --force
-./configure CFLAGS="-Werror" CPPFLAGS="-Werror"
+./configure --enable-sanitize CFLAGS="-Werror" CPPFLAGS="-Werror"
 $MAKE $PARALLEL_MAKE
 $MAKE distcheck \
   || cat-testlogs.sh

-- 
To view, visit https://gerrit.osmocom.org/5537
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a888a415698db5a11d74422f7ccb2d94126f56e
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] libosmocore[master]: Remove unused check

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5536

Remove unused check

We no longer use FreeBSD in jenkins so there's no point in checking for
it.

Change-Id: Ib5d9f9278af15f0fee0dc5537489de4469b692d2
---
M contrib/jenkins.sh
1 file changed, 0 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/36/5536/1

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index c341d05..df0a512 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -5,10 +5,6 @@
 
 ENABLE_SANITIZE="--enable-sanitize"
 
-if [ "x$label" = "xFreeBSD_amd64" ]; then
-ENABLE_SANITIZE=""
-fi
-
 src_dir="$PWD"
 build() {
 build_dir="$1"

-- 
To view, visit https://gerrit.osmocom.org/5536
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5d9f9278af15f0fee0dc5537489de4469b692d2
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max 


[MERGED] osmo-pcu[master]: Add function to get max supported MS class

2017-12-21 Thread Max
Max has submitted this change and it was merged.

Change subject: Add function to get max supported MS class
..


Add function to get max supported MS class

It's useful for allocation tests.

Change-Id: I31d503af700ec3364042ff7e661710953cacf9f8
Related: OS#2282
---
M src/mslot_class.c
M src/mslot_class.h
2 files changed, 7 insertions(+), 1 deletion(-)

Approvals:
  Neels Hofmeyr: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/mslot_class.c b/src/mslot_class.c
index 6d7c09d..19fea3e 100644
--- a/src/mslot_class.c
+++ b/src/mslot_class.c
@@ -82,6 +82,11 @@
return _ms_multislot_class[index];
 }
 
+uint8_t mslot_class_max()
+{
+   return ARRAY_SIZE(gprs_ms_multislot_class);
+}
+
 uint8_t mslot_class_get_ta(uint8_t ms_cl)
 {
return get_mslot_table(ms_cl)->ta;
diff --git a/src/mslot_class.h b/src/mslot_class.h
index f26bd64..9e9dfba 100644
--- a/src/mslot_class.h
+++ b/src/mslot_class.h
@@ -28,7 +28,7 @@
 
 /* 3GPP TS 05.02 Annex B.1 */
 
-#define MS_NA  255 /* N/A *///
+#define MS_NA  255 /* N/A */
 #define MS_A   254 /* 1 with hopping, 0 without */
 #define MS_B   253 /* 1 with hopping, 0 without (change Rx to Tx)*/
 #define MS_C   252 /* 1 with hopping, 0 without (change Tx to Rx)*/
@@ -44,3 +44,4 @@
 uint8_t mslot_class_get_rx(uint8_t ms_cl);
 uint8_t mslot_class_get_sum(uint8_t ms_cl);
 uint8_t mslot_class_get_type(uint8_t ms_cl);
+uint8_t mslot_class_max();

-- 
To view, visit https://gerrit.osmocom.org/4955
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I31d503af700ec3364042ff7e661710953cacf9f8
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Neels Hofmeyr 


[PATCH] osmo-bsc[master]: Migrate from OpenSSL to osmo_get_rand_id()

2017-12-21 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/3819

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

Migrate from OpenSSL to osmo_get_rand_id()

This avoids potential licensing incompatibility and makes integration of
Debian packaging patches easier.

The libosmocore version requirements are fine already but for jenkins
tests to pass we have to have Ic77866ce65acf524b768882c751a4f9c0635740b
merged into libosmocore master.

Change-Id: Ia57bf1300525cf3c247284fe966b1c415c2d53e2
Related: OS#1694
---
M configure.ac
M contrib/jenkins.sh
M debian/control
M src/osmo-bsc_nat/Makefile.am
M src/osmo-bsc_nat/bsc_nat.c
M tests/channel/Makefile.am
6 files changed, 8 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/19/3819/6

diff --git a/configure.ac b/configure.ac
index 98f96bb..97b2e2f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,6 @@
 PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.3.2)
 PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.1.0)
 PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 0.8.0)
-PKG_CHECK_MODULES(LIBCRYPTO, libcrypto >= 0.9.5)
 PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.0.2)
 PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.2.0)
 PKG_CHECK_MODULES(LIBOSMOLEGACYMGCP, libosmo-legacy-mgcp >= 1.0.0)
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 57954f0..6ae6732 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -18,7 +18,7 @@
 
 mkdir "$deps" || true
 
-osmo-build-dep.sh libosmocore "" ac_cv_path_DOXYGEN=false
+osmo-build-dep.sh libosmocore "" '--disable-doxygen --enable-gnutls'
 
 verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]")
 
diff --git a/debian/control b/debian/control
index 5e9ad60..fae280a 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,6 @@
libtool,
pkg-config,
python-minimal,
-   libssl-dev (>= 0.9.5),
libtalloc-dev,
libosmocore-dev (>= 0.10.0),
libosmo-sccp-dev (>= 0.0.2),
diff --git a/src/osmo-bsc_nat/Makefile.am b/src/osmo-bsc_nat/Makefile.am
index 1bee68e..a941b58 100644
--- a/src/osmo-bsc_nat/Makefile.am
+++ b/src/osmo-bsc_nat/Makefile.am
@@ -12,7 +12,6 @@
$(LIBOSMOCTRL_CFLAGS) \
$(LIBOSMOSCCP_CFLAGS) \
$(LIBOSMOLEGACYMGCP_CFLAGS) \
-   $(LIBCRYPTO_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(NULL)
 
@@ -49,7 +48,6 @@
$(LIBOSMOVTY_LIBS) \
$(LIBOSMOCTRL_LIBS) \
$(LIBOSMOSIGTRAN_LIBS) \
-   $(LIBCRYPTO_LIBS) \
$(LIBRARY_GSM) \
-lrt \
$(NULL)
diff --git a/src/osmo-bsc_nat/bsc_nat.c b/src/osmo-bsc_nat/bsc_nat.c
index 1548ea3..5569d2f 100644
--- a/src/osmo-bsc_nat/bsc_nat.c
+++ b/src/osmo-bsc_nat/bsc_nat.c
@@ -74,8 +74,6 @@
 
 #include 
 
-#include 
-
 #include "../../bscconfig.h"
 
 #define SCCP_CLOSE_TIME 20
@@ -208,7 +206,7 @@
0x01, IPAC_IDTAG_UNITNAME,
0x01, IPAC_IDTAG_SERNR,
};
-
+   int rc;
uint8_t *mrand;
uint8_t id_req[sizeof(s_id_req) + (2+16)];
uint8_t *buf = _req[sizeof(s_id_req)];
@@ -221,19 +219,17 @@
buf = v_put(buf, 0x23);
mrand = bsc->last_rand;
 
-   if (RAND_bytes(mrand, 16) != 1)
-   goto failed_random;
+   rc = osmo_get_rand_id(mrand, 16);
+   if (rc < 0) {
+   /* the timeout will trigger and close this connection */
+   LOGP(DNAT, LOGL_ERROR, "osmo_get_rand_id() failed: %s\n", 
strerror(-rc));
+   return;
+   }
 
memcpy(buf, mrand, 16);
buf += 16;
 
bsc_send_data(bsc, id_req, sizeof(id_req), IPAC_PROTO_IPACCESS);
-   return;
-
-failed_random:
-   /* the timeout will trigger and close this connection */
-   LOGP(DNAT, LOGL_ERROR, "Failed to read from urandom.\n");
-   return;
 }
 
 static struct msgb *nat_create_rlsd(struct nat_sccp_connection *conn)
diff --git a/tests/channel/Makefile.am b/tests/channel/Makefile.am
index 395daf7..12f18f8 100644
--- a/tests/channel/Makefile.am
+++ b/tests/channel/Makefile.am
@@ -29,5 +29,4 @@
$(top_builddir)/src/libcommon/libcommon.a \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
-   $(LIBCRYPTO_LIBS) \
$(NULL)

-- 
To view, visit https://gerrit.osmocom.org/3819
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ia57bf1300525cf3c247284fe966b1c415c2d53e2
Gerrit-PatchSet: 6
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-msc[master]: Migrate from OpenSSL to osmo_get_rand_id()

2017-12-21 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/3820

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

Migrate from OpenSSL to osmo_get_rand_id()

This avoids potential licensing incompatibility and makes integration of
Debian packaging patches easier.

Related: OS#1694
Change-Id: I71cd631704a4dc155c6c752fee2a42cd6e2fa336
---
M configure.ac
M debian/control
M src/libmsc/Makefile.am
M src/libmsc/auth.c
M src/libmsc/db.c
M src/libmsc/gsm_04_08.c
M src/libvlr/Makefile.am
M src/libvlr/vlr.c
M src/osmo-msc/Makefile.am
M tests/db/Makefile.am
M tests/msc_vlr/Makefile.am
M tests/msc_vlr/msc_vlr_tests.c
M tests/sms_queue/Makefile.am
13 files changed, 10 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/20/3820/7

diff --git a/configure.ac b/configure.ac
index 49d06f5..feb3de9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,7 +47,6 @@
 PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.1.0)
 PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 0.8.0)
 PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp)
-PKG_CHECK_MODULES(LIBCRYPTO, libcrypto >= 0.9.5)
 PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.1.0)
 PKG_CHECK_MODULES(LIBSMPP34, libsmpp34 >= 1.12.0)
 
diff --git a/debian/control b/debian/control
index 60d468e..6219ea4 100644
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,6 @@
pkg-config,
libdbi-dev,
libtalloc-dev,
-   libssl-dev (>= 0.9.5),
libsmpp34-dev (>= 1.12),
libasn1c-dev (>= 0.9.28),
libosmocore-dev (>= 0.10.0),
diff --git a/src/libmsc/Makefile.am b/src/libmsc/Makefile.am
index 998df26..7dfb047 100644
--- a/src/libmsc/Makefile.am
+++ b/src/libmsc/Makefile.am
@@ -10,7 +10,6 @@
$(LIBOSMOVTY_CFLAGS) \
$(LIBOSMOABIS_CFLAGS) \
$(COVERAGE_CFLAGS) \
-   $(LIBCRYPTO_CFLAGS) \
$(LIBSMPP34_CFLAGS) \
$(LIBASN1C_CFLAGS) \
$(LIBOSMOSIGTRAN_CFLAGS) \
diff --git a/src/libmsc/auth.c b/src/libmsc/auth.c
index 7b5367b..7c78c6e 100644
--- a/src/libmsc/auth.c
+++ b/src/libmsc/auth.c
@@ -28,8 +28,6 @@
 #include 
 #include 
 
-#include 
-
 #include 
 
 const struct value_string auth_action_names[] = {
diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index 0cb8ff3..28004f7 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -42,8 +42,6 @@
 #include 
 #include 
 
-#include 
-
 static char *db_basename = NULL;
 static char *db_dirname = NULL;
 static dbi_conn conn;
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index 26ac923..88472e0 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -31,7 +31,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "bscconfig.h"
 
diff --git a/src/libvlr/Makefile.am b/src/libvlr/Makefile.am
index 511dfc0..e3d5ced 100644
--- a/src/libvlr/Makefile.am
+++ b/src/libvlr/Makefile.am
@@ -7,7 +7,6 @@
   $(LIBOSMOMGCPCLIENT_CFLAGS) \
   $(LIBOSMOABIS_CFLAGS) \
   $(COVERAGE_CFLAGS) \
-  $(LIBCRYPTO_CFLAGS) \
   $(NULL)
 
 noinst_HEADERS = \
diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index 670ff83..8c6911a 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -31,8 +31,6 @@
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 #include 
@@ -275,12 +273,13 @@
 {
struct vlr_instance *vlr = vsub->vlr;
uint32_t tmsi;
-   int tried;
+   int tried, rc;
 
for (tried = 0; tried < 100; tried++) {
-   if (RAND_bytes((uint8_t *) , sizeof(tmsi)) != 1) {
-   LOGP(DVLR, LOGL_ERROR, "RAND_bytes failed\n");
-   return -1;
+   rc = osmo_get_rand_id((uint8_t *) , sizeof(tmsi));
+   if (rc < 0) {
+   LOGP(DDB, LOGL_ERROR, "osmo_get_rand_id() failed: 
%s\n", strerror(-rc));
+   return rc;
}
/* throw the dice again, if the TSMI doesn't fit */
if (tmsi == GSM_RESERVED_TMSI)
diff --git a/src/osmo-msc/Makefile.am b/src/osmo-msc/Makefile.am
index e296f97..1d8bfbd 100644
--- a/src/osmo-msc/Makefile.am
+++ b/src/osmo-msc/Makefile.am
@@ -13,7 +13,6 @@
$(LIBOSMOCTRL_CFLAGS) \
$(LIBOSMOABIS_CFLAGS) \
$(LIBSMPP34_CFLAGS) \
-   $(LIBCRYPTO_CFLAGS) \
$(LIBOSMORANAP_CFLAGS) \
$(LIBASN1C_CFLAGS) \
$(LIBOSMOSIGTRAN_CFLAGS) \
@@ -43,7 +42,6 @@
$(LIBOSMOCTRL_LIBS) \
$(LIBOSMOABIS_LIBS) \
$(LIBSMPP34_LIBS) \
-   $(LIBCRYPTO_LIBS) \
$(LIBOSMOSIGTRAN_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
-ldbi \
diff --git a/tests/db/Makefile.am b/tests/db/Makefile.am
index bcb66ec..720e005 100644
--- a/tests/db/Makefile.am
+++ b/tests/db/Makefile.am
@@ -42,6 +42,5 @@
$(LIBOSMOGSM_LIBS) \
$(LIBSMPP34_LIBS) \
$(LIBOSMOVTY_LIBS) \
-   $(LIBCRYPTO_LIBS) \
-ldbi \
$(NULL)

[PATCH] python/osmo-python-tests[master]: Add rate counter dumper

2017-12-21 Thread Max
Hello Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/5029

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

Add rate counter dumper

This simple tool dump all the rate counters available via ctrl interface
to cvs file (or stdout).

Change-Id: I12b369434e4ee9b38f92872f297e1f3d4f0698c2
Fixes: OS#2550
---
M README
M contrib/jenkins.sh
A scripts/osmo_rate_ctr2csv.py
M setup.py
4 files changed, 89 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/29/5029/9

diff --git a/README b/README
index e85c1c4..2c04047 100644
--- a/README
+++ b/README
@@ -9,6 +9,7 @@
 There are currently following scripts in this package:
 osmotestconfig.py - test that apps start/write with example configs
 soap.py - implementation of SOAP <-> Ctrl proxy implemented on top of Twisted
+osmo_rate_ctr2csv.py - rate counter dumper on top of osmo_ipa
 osmo_interact_vty.py - pipe stdin/stdout to a VTY session
 osmo_interact_ctrl.py - pipe stdin/stdout to a CTRL port
 osmo_verify_transcript_vty.py - VTY testing by VTY session screen dumps
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 9734549..f1651dc 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -16,7 +16,7 @@
 
 rm -rf ./build
 PY3=python3
-PY3_LIST="osmopy scripts/osmo_ctrl.py scripts/osmo_interact_ctrl.py 
scripts/osmo_interact_vty.py scripts/osmo_verify_transcript_ctrl.py 
scripts/osmo_verify_transcript_vty.py scripts/soap.py scripts/twisted_ipa.py"
+PY3_LIST="osmopy scripts/osmo_ctrl.py scripts/osmo_rate_ctr2csv.py 
scripts/osmo_interact_ctrl.py scripts/osmo_interact_vty.py 
scripts/osmo_verify_transcript_ctrl.py scripts/osmo_verify_transcript_vty.py 
scripts/soap.py scripts/twisted_ipa.py"
 $PY3 ./setup.py install
 $PY3 tests/test_py3.py
 for f in $PY3_LIST
diff --git a/scripts/osmo_rate_ctr2csv.py b/scripts/osmo_rate_ctr2csv.py
new file mode 100644
index 000..1e3fc9f
--- /dev/null
+++ b/scripts/osmo_rate_ctr2csv.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python3
+# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
+"""
+/*
+ * Copyright (C) 2017 sysmocom s.f.m.c. GmbH
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+"""
+
+from osmopy.osmo_ipa import Ctrl
+import socket, argparse, sys, logging, csv
+
+__version__ = "0.0.1" # bump this on every non-trivial change
+
+def connect(host, port):
+sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+sck.setblocking(1)
+sck.connect((host, port))
+return sck
+
+def get_var(sck, var):
+(_, c) = Ctrl().cmd(var, None)
+sck.send(c)
+return Ctrl().parse_kv(sck.recv(4096))
+
+def get_interval(group_name, group_counters, interval):
+log.debug('Getting %s counter values: %s...' % (group_name, interval))
+(_, c) = get_var(sock, 'rate_ctr.%s.%s' % (interval, group_name))
+for ctr in c.split(';'):
+if len(ctr):
+(k, v) = ctr.split()
+group_counters[k] = group_counters.get(k, 
(group_name,)) + (v,)
+return len(group_counters)
+
+
+if __name__ == '__main__':
+p = argparse.ArgumentParser(description='Dump rate counters into csv 
via Osmocom CTRL protocol.')
+p.add_argument('-v', '--version', action='version', version=("%(prog)s 
v" + __version__))
+p.add_argument('-p', '--port', type=int, default=4249, help="Port to 
use for CTRL interface, defaults to 4249")
+p.add_argument('-c', '--ctrl', default='localhost', help="Adress to 
use for CTRL interface, defaults to localhost")
+p.add_argument('-d', '--debug', action='store_true', help="Enable 
debug log")
+p.add_argument('--header', action='store_true', help="Prepend column 
header to output")
+p.add_argument('-o', '--output', nargs='?', 
type=argparse.FileType('w'), default=sys.stdout, help="Output file, defaults to 
stdout")
+args = p.parse_args()
+
+log = logging.getLogger('rate_ctr2csv')
+log.setLevel(logging.DEBUG if args.debug else logging.INFO)
+log.addHandler(logging.StreamHandler(sys.stderr))
+
+log.info('Connecting to %s:%d...' % (args.ctrl, args.port))
+sock = connect(args.ctrl, args.port)
+

[PATCH] python/osmo-python-tests[master]: Update ctrl command parsing for python3

2017-12-21 Thread Max
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/5028

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

Update ctrl command parsing for python3

* make parse() return command id in addition to variable name and value
* introduce parse_kv() wrapper which ignores that id and use it instead
  of old parse()
* make parse() compatible with python3 where we got bytes, not string
  from the socket so we have to decode it properly before using split()
* expand test_py3.py with simply asyn server which verifies that
  osmo_ctrl.py works properly

Change-Id: I599f9f5a18109929f59386ab4416b8bfd75c74d1
---
M contrib/jenkins.sh
M osmopy/osmo_ipa.py
M scripts/osmo_ctrl.py
M scripts/twisted_ipa.py
M tests/test_py3.py
5 files changed, 83 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/28/5028/7

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index d18b19d..9734549 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -24,7 +24,7 @@
 $PY3 $COM_FLAGS $f
 done
 
-cd scripts
-./osmo_ctrl.py --help
+# Run async server which tests scripts/osmo_ctrl.py interaction
+$PY3 tests/test_py3.py
 
 # TODO: add more tests
diff --git a/osmopy/osmo_ipa.py b/osmopy/osmo_ipa.py
index 71cbf45..afabf67 100755
--- a/osmopy/osmo_ipa.py
+++ b/osmopy/osmo_ipa.py
@@ -28,7 +28,7 @@
 """
 Stateless IPA protocol multiplexer: add/remove/parse (extended) header
 """
-version = "0.0.5"
+version = "0.0.6"
 TCP_PORT_OML = 3002
 TCP_PORT_RSL = 3003
 # OpenBSC extensions: OSMO, MGCP_OLD
@@ -231,23 +231,33 @@
 return None
 return d
 
-def parse(self, data, op=None):
+def parse(self, raw_data):
+"""
+Parse Ctrl string returning (id, var, value) tuple
+var could be None in case of ERROR message
+value could be None in case of GET message
+both could be None in case of TRAP with non-zero id
+"""
+data = self.rem_header(raw_data).decode('utf-8')
+(s, i, v) = data.split(' ', 2)
+if s == self.CTRL_ERR:
+return i, None, v
+if s == self.CTRL_GET:
+return i, v, None
+if s == self.CTRL_GET + '_' + self.CTRL_REP:
+return i, v, None
+(s, i, var, val) = data.split(' ', 3)
+if s == self.CTRL_TRAP and i != '0':
+return i, None, None
+return i, var, val
+
+def parse_kv(self, raw_data):
 """
 Parse Ctrl string returning (var, value) pair
 var could be None in case of ERROR message
 value could be None in case of GET message
 """
-(s, i, v) = data.split(' ', 2)
-if s == self.CTRL_ERR:
-return None, v
-if s == self.CTRL_GET:
-return v, None
-(s, i, var, val) = data.split(' ', 3)
-if s == self.CTRL_TRAP and i != '0':
-return None, '%s with non-zero id %s' % (s, i)
-if op is not None and i != op:
-if s == self.CTRL_GET + '_' + self.CTRL_REP or s == self.CTRL_SET 
+ '_' + self.CTRL_REP:
-return None, '%s with unexpected id %s' % (s, i)
+(i, var, val) = self.parse(raw_data)
 return var, val
 
 def trap(self, var, val):
@@ -265,11 +275,19 @@
 return r, self.add_header("%s %s %s %s" % (self.CTRL_SET, r, var, 
val))
 return r, self.add_header("%s %s %s" % (self.CTRL_GET, r, var))
 
+def reply(self, op_id, var, val=None):
+"""
+Make SET/GET command reply: returns assembled message
+"""
+if val is not None:
+return self.add_header("%s_%s %s %s %s" % (self.CTRL_SET, 
self.CTRL_REP, op_id, var, val))
+return self.add_header("%s_%s %s %s" % (self.CTRL_GET, self.CTRL_REP, 
op_id, var))
+
 def verify(self, reply, r, var, val=None):
 """
 Verify reply to SET/GET command: returns (b, v) tuple where v is 
True/False verification result and v is the variable value
 """
-(k, v) = self.parse(reply)
+(k, v) = self.parse_kv(reply)
 if k != var or (val is not None and v != val):
 return False, v
 return True, v
diff --git a/scripts/osmo_ctrl.py b/scripts/osmo_ctrl.py
index 8c0608f..ac20050 100755
--- a/scripts/osmo_ctrl.py
+++ b/scripts/osmo_ctrl.py
@@ -40,8 +40,8 @@
 def do_set_get(sck, var, value = None):
 (r, c) = Ctrl().cmd(var, value)
 sck.send(c)
-answer = Ctrl().rem_header(sck.recv(4096))
-return (answer,) + Ctrl().verify(answer, r, var, value)
+ret = sck.recv(4096)
+return (Ctrl().rem_header(ret),) + Ctrl().verify(ret, r, var, value)
 
 def set_var(sck, var, val):
 (a, _, _) = do_set_get(sck, var, val)
diff --git a/scripts/twisted_ipa.py b/scripts/twisted_ipa.py
index bb8323d..533bfae 100755
--- a/scripts/twisted_ipa.py
+++ b/scripts/twisted_ipa.py
@@ -22,7 +22,7 @@

[PATCH] python/osmo-python-tests[master]: Use python3 for osmo_ctrl.py

2017-12-21 Thread Max
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/5061

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

Use python3 for osmo_ctrl.py

It's a standalone script illustrating the use of ctrl protocol from
python. Since it's not used as a library and nothing depends on it, we
can safely switch to python3.

Change-Id: I2461dd9af67771beed5306116e8a1b0ee2285aa8
---
M contrib/jenkins.sh
M scripts/osmo_ctrl.py
M setup.py
3 files changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/61/5061/5

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index c4ddf7d..d18b19d 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -6,7 +6,7 @@
 
 # FIXME: remove once python 2 support is deprecated
 PY2=python2
-PY2_LIST="osmopy scripts/osmo_ctrl.py scripts/osmodumpdoc.py 
scripts/osmotestvty.py scripts/osmotestconfig.py"
+PY2_LIST="osmopy scripts/osmodumpdoc.py scripts/osmotestvty.py 
scripts/osmotestconfig.py"
 $PY2 ./setup.py install
 $PY2 tests/test_py2.py
 for f in $PY2_LIST
@@ -24,4 +24,7 @@
 $PY3 $COM_FLAGS $f
 done
 
+cd scripts
+./osmo_ctrl.py --help
+
 # TODO: add more tests
diff --git a/scripts/osmo_ctrl.py b/scripts/osmo_ctrl.py
index bec6d1d..8c0608f 100755
--- a/scripts/osmo_ctrl.py
+++ b/scripts/osmo_ctrl.py
@@ -1,8 +1,8 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 # -*- mode: python-mode; py-indent-tabs-mode: nil -*-
 """
 /*
- * Copyright (C) 2016 sysmocom s.f.m.c. GmbH
+ * Copyright (C) 2016-2017 sysmocom s.f.m.c. GmbH
  *
  * All Rights Reserved
  *
@@ -21,7 +21,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 """
-from __future__ import print_function
+
 from optparse import OptionParser
 from osmopy.osmo_ipa import Ctrl
 import socket
diff --git a/setup.py b/setup.py
index 533272e..bab9c38 100755
--- a/setup.py
+++ b/setup.py
@@ -25,6 +25,7 @@
 elif sys.version_info.major == 3:
scripts = ["scripts/osmo_interact_vty.py",
   "scripts/osmo_interact_ctrl.py",
+   "scripts/osmo_ctrl.py",
   "scripts/soap.py",
   "scripts/twisted_ipa.py",
   "scripts/osmo_verify_transcript_vty.py",

-- 
To view, visit https://gerrit.osmocom.org/5061
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2461dd9af67771beed5306116e8a1b0ee2285aa8
Gerrit-PatchSet: 5
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] python/osmo-python-tests[master]: Improve python3 compatibility

2017-12-21 Thread Max
Hello Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/5038

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

Improve python3 compatibility

Use proper print() function to make scripts compatible with both python
2 and 3. This paves the way to deprecating python 2 support altogether.

Change-Id: I80e5850a8978d78cda793e2192ef4bd3fd54a121
---
M contrib/jenkins.sh
M scripts/osmodumpdoc.py
M scripts/osmotestconfig.py
M scripts/osmotestvty.py
M setup.py
5 files changed, 31 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/38/5038/6

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index f1651dc..08908a4 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -16,7 +16,7 @@
 
 rm -rf ./build
 PY3=python3
-PY3_LIST="osmopy scripts/osmo_ctrl.py scripts/osmo_rate_ctr2csv.py 
scripts/osmo_interact_ctrl.py scripts/osmo_interact_vty.py 
scripts/osmo_verify_transcript_ctrl.py scripts/osmo_verify_transcript_vty.py 
scripts/soap.py scripts/twisted_ipa.py"
+PY3_LIST="osmopy scripts/osmo_ctrl.py scripts/osmo_rate_ctr2csv.py 
scripts/osmodumpdoc.py scripts/osmotestvty.py scripts/osmotestconfig.py 
scripts/osmo_interact_ctrl.py scripts/osmo_interact_vty.py 
scripts/osmo_verify_transcript_ctrl.py scripts/osmo_verify_transcript_vty.py 
scripts/soap.py scripts/twisted_ipa.py"
 $PY3 ./setup.py install
 $PY3 tests/test_py3.py
 for f in $PY3_LIST
diff --git a/scripts/osmodumpdoc.py b/scripts/osmodumpdoc.py
index 2464b05..d71edc8 100644
--- a/scripts/osmodumpdoc.py
+++ b/scripts/osmodumpdoc.py
@@ -4,7 +4,7 @@
 # Fixes may need to be applied to both.
 
 """Start the process and dump the documentation to the doc dir."""
-
+from __future__ import print_function
 import subprocess
 import time
 import os
@@ -21,7 +21,7 @@
 out = open(filename, 'w')
 out.write(xml)
 out.close()
-print 'generated %r' % filename
+print('generated %r' % filename)
 
 
 """Dump the config of all the apps.
@@ -40,22 +40,22 @@
 
 for app in apps:
 appname = app[3]
-print "Starting app for %s" % appname
+print("Starting app for %s" % appname)
 proc = None
 cmd = [app[1], "-c", os.path.join(confpath, configs[appname][0])]
-print 'cd', os.path.abspath(os.path.curdir), ';', ' '.join(cmd)
+print('cd', os.path.abspath(os.path.curdir), ';', ' '.join(cmd))
 try:
 proc = subprocess.Popen(cmd, stdin=None, stdout=None)
 except OSError as e:  # Probably a missing binary
-print >> sys.stderr, e
-print >> sys.stderr, "Skipping app %s" % appname
+print(e, file=sys.stderr)
+print("Skipping app %s" % appname, file=sys.stderr)
 failures += 1
 else:
 try:
 dump_doc(app[2], app[0], 'doc/%s_vty_reference.xml' % appname)
 successes += 1
 except IOError:  # Generally a socket issue
-print >> sys.stderr, "%s: couldn't connect, skipping" % appname
+print("%s: couldn't connect, skipping" % appname, 
file=sys.stderr)
 failures += 1
 finally:
 osmoutil.end_proc(proc)
@@ -90,7 +90,7 @@
 num_fails, num_sucs = dump_configs(
 osmoappdesc.apps, osmoappdesc.app_configs, confpath)
 if num_fails > 0:
-print >> sys.stderr, "Warning: Skipped %s apps" % num_fails
+print("Warning: Skipped %s apps" % num_fails, file=sys.stderr)
 if 0 == num_sucs:
-print >> sys.stderr, "Nothing run, wrong working dir? Set with -w"
+print("Nothing run, wrong working dir? Set with -w", 
file=sys.stderr)
 sys.exit(num_fails)
diff --git a/scripts/osmotestconfig.py b/scripts/osmotestconfig.py
index 2132c43..f227504 100644
--- a/scripts/osmotestconfig.py
+++ b/scripts/osmotestconfig.py
@@ -13,7 +13,7 @@
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see .
-
+from __future__ import print_function
 import os
 import os.path
 import time
@@ -52,7 +52,7 @@
 try:
 cmd = app_desc[1].split(' ') + [ "-c", config]
 if verbose:
-print "Verifying %s, test %s" % (' '.join(cmd), run_test.__name__)
+print("Verifying %s, test %s" % (' '.join(cmd), run_test.__name__))
 
 proc = osmoutil.popen_devnull(cmd)
 end = app_desc[2]
@@ -61,10 +61,10 @@
 ret = run_test(vty)
 
 except IOError as se:
-print >> sys.stderr, "Failed to verify %s" % ' '.join(cmd)
-print >> sys.stderr, "Current directory: %s" % os.getcwd()
-print >> sys.stderr, "Error was %s" % se
-print >> sys.stderr, "Config was\n%s" % open(config).read()
+print("Failed to verify %s" % ' '.join(cmd), file=sys.stderr)
+print("Current directory: %s" % os.getcwd(), file=sys.stderr)
+   

[PATCH] python/osmo-python-tests[master]: Add scripts to compilation tests in jenkins

2017-12-21 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5482

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

Add scripts to compilation tests in jenkins

Related: OS#2684
Change-Id: If098c20b1ad17c3868073b9fe07fd3795217c526
---
M contrib/jenkins.sh
1 file changed, 18 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/82/5482/5

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index a60438e..c4ddf7d 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -2,14 +2,26 @@
 
 set -ex
 
+COM_FLAGS='-m compileall'
+
 # FIXME: remove once python 2 support is deprecated
-python2 ./setup.py install
-python2 tests/test_py2.py
-python2 -m compileall osmopy
+PY2=python2
+PY2_LIST="osmopy scripts/osmo_ctrl.py scripts/osmodumpdoc.py 
scripts/osmotestvty.py scripts/osmotestconfig.py"
+$PY2 ./setup.py install
+$PY2 tests/test_py2.py
+for f in $PY2_LIST
+do
+$PY2 $COM_FLAGS $f
+done
 
 rm -rf ./build
-python3 ./setup.py install
-python3 tests/test_py3.py
-python3 -m compileall osmopy
+PY3=python3
+PY3_LIST="osmopy scripts/osmo_ctrl.py scripts/osmo_interact_ctrl.py 
scripts/osmo_interact_vty.py scripts/osmo_verify_transcript_ctrl.py 
scripts/osmo_verify_transcript_vty.py scripts/soap.py scripts/twisted_ipa.py"
+$PY3 ./setup.py install
+$PY3 tests/test_py3.py
+for f in $PY3_LIST
+do
+$PY3 $COM_FLAGS $f
+done
 
 # TODO: add more tests

-- 
To view, visit https://gerrit.osmocom.org/5482
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If098c20b1ad17c3868073b9fe07fd3795217c526
Gerrit-PatchSet: 5
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] python/osmo-python-tests[master]: Add rate counter dumper

2017-12-21 Thread Max
Hello Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/5029

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

Add rate counter dumper

This simple tool dump all the rate counters available via ctrl interface
to cvs file (or stdout).

Change-Id: I12b369434e4ee9b38f92872f297e1f3d4f0698c2
Fixes: OS#2550
---
M README
M contrib/jenkins.sh
A scripts/osmo_rate_ctr2csv.py
M setup.py
4 files changed, 89 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/29/5029/8

diff --git a/README b/README
index e85c1c4..2c04047 100644
--- a/README
+++ b/README
@@ -9,6 +9,7 @@
 There are currently following scripts in this package:
 osmotestconfig.py - test that apps start/write with example configs
 soap.py - implementation of SOAP <-> Ctrl proxy implemented on top of Twisted
+osmo_rate_ctr2csv.py - rate counter dumper on top of osmo_ipa
 osmo_interact_vty.py - pipe stdin/stdout to a VTY session
 osmo_interact_ctrl.py - pipe stdin/stdout to a CTRL port
 osmo_verify_transcript_vty.py - VTY testing by VTY session screen dumps
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 74af1e4..90d9941 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -18,6 +18,7 @@
 $PY3 tests/test_py3.py
 $PY3 $COM_FLAGS osmopy
 $PY3 $COM_FLAGS scripts/osmo_ctrl.py
+$PY3 $COM_FLAGS scripts/osmo_rate_ctr2csv.py
 $PY3 $COM_FLAGS scripts/osmo_interact_common.py
 $PY3 $COM_FLAGS scripts/osmo_interact_ctrl.py
 $PY3 $COM_FLAGS scripts/osmo_interact_vty.py
diff --git a/scripts/osmo_rate_ctr2csv.py b/scripts/osmo_rate_ctr2csv.py
new file mode 100644
index 000..1e3fc9f
--- /dev/null
+++ b/scripts/osmo_rate_ctr2csv.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python3
+# -*- mode: python-mode; py-indent-tabs-mode: nil -*-
+"""
+/*
+ * Copyright (C) 2017 sysmocom s.f.m.c. GmbH
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+"""
+
+from osmopy.osmo_ipa import Ctrl
+import socket, argparse, sys, logging, csv
+
+__version__ = "0.0.1" # bump this on every non-trivial change
+
+def connect(host, port):
+sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+sck.setblocking(1)
+sck.connect((host, port))
+return sck
+
+def get_var(sck, var):
+(_, c) = Ctrl().cmd(var, None)
+sck.send(c)
+return Ctrl().parse_kv(sck.recv(4096))
+
+def get_interval(group_name, group_counters, interval):
+log.debug('Getting %s counter values: %s...' % (group_name, interval))
+(_, c) = get_var(sock, 'rate_ctr.%s.%s' % (interval, group_name))
+for ctr in c.split(';'):
+if len(ctr):
+(k, v) = ctr.split()
+group_counters[k] = group_counters.get(k, 
(group_name,)) + (v,)
+return len(group_counters)
+
+
+if __name__ == '__main__':
+p = argparse.ArgumentParser(description='Dump rate counters into csv 
via Osmocom CTRL protocol.')
+p.add_argument('-v', '--version', action='version', version=("%(prog)s 
v" + __version__))
+p.add_argument('-p', '--port', type=int, default=4249, help="Port to 
use for CTRL interface, defaults to 4249")
+p.add_argument('-c', '--ctrl', default='localhost', help="Adress to 
use for CTRL interface, defaults to localhost")
+p.add_argument('-d', '--debug', action='store_true', help="Enable 
debug log")
+p.add_argument('--header', action='store_true', help="Prepend column 
header to output")
+p.add_argument('-o', '--output', nargs='?', 
type=argparse.FileType('w'), default=sys.stdout, help="Output file, defaults to 
stdout")
+args = p.parse_args()
+
+log = logging.getLogger('rate_ctr2csv')
+log.setLevel(logging.DEBUG if args.debug else logging.INFO)
+log.addHandler(logging.StreamHandler(sys.stderr))
+
+log.info('Connecting to %s:%d...' % (args.ctrl, args.port))
+sock = connect(args.ctrl, args.port)
+
+log.info('Getting rate counter groups info...')
+(_, g) = get_var(sock, 'rate_ctr.*')
+
+w = csv.writer(args.output, dialect='unix')
+total_groups = 0
+total_rows = 0
+
+if args.header:
+w.writerow(['group', 'counter', 

[PATCH] python/osmo-python-tests[master]: Update ctrl command parsing for python3

2017-12-21 Thread Max
Hello Neels Hofmeyr, Jenkins Builder,

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

https://gerrit.osmocom.org/5028

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

Update ctrl command parsing for python3

* make parse() return command id in addition to variable name and value
* introduce parse_kv() wrapper which ignores that id and use it instead
  of old parse()
* make parse() compatible with python3 where we got bytes, not string
  from the socket so we have to decode it properly before using split()
* expand test_py3.py with simply asyn server which verifies that
  osmo_ctrl.py works properly

Change-Id: I599f9f5a18109929f59386ab4416b8bfd75c74d1
---
M contrib/jenkins.sh
M osmopy/osmo_ipa.py
M scripts/osmo_ctrl.py
M scripts/twisted_ipa.py
M tests/test_py3.py
5 files changed, 83 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/28/5028/6

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index cd94868..74af1e4 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -14,7 +14,6 @@
 $PY2 $COM_FLAGS scripts/osmotestconfig.py
 
 rm -rf ./build
-PY3=python3
 $PY3 ./setup.py install
 $PY3 tests/test_py3.py
 $PY3 $COM_FLAGS osmopy
@@ -27,7 +26,7 @@
 $PY3 $COM_FLAGS scripts/soap.py
 $PY3 $COM_FLAGS scripts/twisted_ipa.py
 
-cd scripts
-./osmo_ctrl.py --help
+# Run async server which tests scripts/osmo_ctrl.py interaction
+$PY3 tests/test_py3.py
 
 # TODO: add more tests
diff --git a/osmopy/osmo_ipa.py b/osmopy/osmo_ipa.py
index 71cbf45..afabf67 100755
--- a/osmopy/osmo_ipa.py
+++ b/osmopy/osmo_ipa.py
@@ -28,7 +28,7 @@
 """
 Stateless IPA protocol multiplexer: add/remove/parse (extended) header
 """
-version = "0.0.5"
+version = "0.0.6"
 TCP_PORT_OML = 3002
 TCP_PORT_RSL = 3003
 # OpenBSC extensions: OSMO, MGCP_OLD
@@ -231,23 +231,33 @@
 return None
 return d
 
-def parse(self, data, op=None):
+def parse(self, raw_data):
+"""
+Parse Ctrl string returning (id, var, value) tuple
+var could be None in case of ERROR message
+value could be None in case of GET message
+both could be None in case of TRAP with non-zero id
+"""
+data = self.rem_header(raw_data).decode('utf-8')
+(s, i, v) = data.split(' ', 2)
+if s == self.CTRL_ERR:
+return i, None, v
+if s == self.CTRL_GET:
+return i, v, None
+if s == self.CTRL_GET + '_' + self.CTRL_REP:
+return i, v, None
+(s, i, var, val) = data.split(' ', 3)
+if s == self.CTRL_TRAP and i != '0':
+return i, None, None
+return i, var, val
+
+def parse_kv(self, raw_data):
 """
 Parse Ctrl string returning (var, value) pair
 var could be None in case of ERROR message
 value could be None in case of GET message
 """
-(s, i, v) = data.split(' ', 2)
-if s == self.CTRL_ERR:
-return None, v
-if s == self.CTRL_GET:
-return v, None
-(s, i, var, val) = data.split(' ', 3)
-if s == self.CTRL_TRAP and i != '0':
-return None, '%s with non-zero id %s' % (s, i)
-if op is not None and i != op:
-if s == self.CTRL_GET + '_' + self.CTRL_REP or s == self.CTRL_SET 
+ '_' + self.CTRL_REP:
-return None, '%s with unexpected id %s' % (s, i)
+(i, var, val) = self.parse(raw_data)
 return var, val
 
 def trap(self, var, val):
@@ -265,11 +275,19 @@
 return r, self.add_header("%s %s %s %s" % (self.CTRL_SET, r, var, 
val))
 return r, self.add_header("%s %s %s" % (self.CTRL_GET, r, var))
 
+def reply(self, op_id, var, val=None):
+"""
+Make SET/GET command reply: returns assembled message
+"""
+if val is not None:
+return self.add_header("%s_%s %s %s %s" % (self.CTRL_SET, 
self.CTRL_REP, op_id, var, val))
+return self.add_header("%s_%s %s %s" % (self.CTRL_GET, self.CTRL_REP, 
op_id, var))
+
 def verify(self, reply, r, var, val=None):
 """
 Verify reply to SET/GET command: returns (b, v) tuple where v is 
True/False verification result and v is the variable value
 """
-(k, v) = self.parse(reply)
+(k, v) = self.parse_kv(reply)
 if k != var or (val is not None and v != val):
 return False, v
 return True, v
diff --git a/scripts/osmo_ctrl.py b/scripts/osmo_ctrl.py
index 8c0608f..ac20050 100755
--- a/scripts/osmo_ctrl.py
+++ b/scripts/osmo_ctrl.py
@@ -40,8 +40,8 @@
 def do_set_get(sck, var, value = None):
 (r, c) = Ctrl().cmd(var, value)
 sck.send(c)
-answer = Ctrl().rem_header(sck.recv(4096))
-return (answer,) + Ctrl().verify(answer, r, var, value)
+ret = sck.recv(4096)
+return (Ctrl().rem_header(ret),) + Ctrl().verify(ret, r, var, value)
 
 def set_var(sck, var, val):
  

[PATCH] python/osmo-python-tests[master]: Add scripts to compilation tests in jenkins

2017-12-21 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5482

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

Add scripts to compilation tests in jenkins

Related: OS#2684
Change-Id: If098c20b1ad17c3868073b9fe07fd3795217c526
---
M contrib/jenkins.sh
1 file changed, 22 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/82/5482/4

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index a60438e..1598836 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -2,14 +2,30 @@
 
 set -ex
 
+COM_FLAGS='-m compileall'
+
 # FIXME: remove once python 2 support is deprecated
-python2 ./setup.py install
-python2 tests/test_py2.py
-python2 -m compileall osmopy
+PY2=python2
+$PY2 ./setup.py install
+$PY2 tests/test_py2.py
+$PY2 $COM_FLAGS osmopy
+$PY2 $COM_FLAGS scripts/osmo_ctrl.py
+$PY2 $COM_FLAGS scripts/osmodumpdoc.py
+$PY2 $COM_FLAGS scripts/osmotestvty.py
+$PY2 $COM_FLAGS scripts/osmotestconfig.py
 
 rm -rf ./build
-python3 ./setup.py install
-python3 tests/test_py3.py
-python3 -m compileall osmopy
+PY3=python3
+$PY3 ./setup.py install
+$PY3 tests/test_py3.py
+$PY3 $COM_FLAGS osmopy
+$PY3 $COM_FLAGS scripts/osmo_ctrl.py
+$PY3 $COM_FLAGS scripts/osmo_interact_common.py
+$PY3 $COM_FLAGS scripts/osmo_interact_ctrl.py
+$PY3 $COM_FLAGS scripts/osmo_interact_vty.py
+$PY3 $COM_FLAGS scripts/osmo_verify_transcript_ctrl.py
+$PY3 $COM_FLAGS scripts/osmo_verify_transcript_vty.py
+$PY3 $COM_FLAGS scripts/soap.py
+$PY3 $COM_FLAGS scripts/twisted_ipa.py
 
 # TODO: add more tests

-- 
To view, visit https://gerrit.osmocom.org/5482
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If098c20b1ad17c3868073b9fe07fd3795217c526
Gerrit-PatchSet: 4
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] python/osmo-python-tests[master]: Improve python3 compatibility

2017-12-21 Thread Max
Hello Neels Hofmeyr, Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/5038

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

Improve python3 compatibility

Use proper print() function to make scripts compatible with both python
2 and 3. This paves the way to deprecating python 2 support altogether.

Change-Id: I80e5850a8978d78cda793e2192ef4bd3fd54a121
---
M contrib/jenkins.sh
M scripts/osmodumpdoc.py
M scripts/osmotestconfig.py
M scripts/osmotestvty.py
M setup.py
5 files changed, 33 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/38/5038/5

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 90d9941..b252fc0 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -17,6 +17,9 @@
 $PY3 ./setup.py install
 $PY3 tests/test_py3.py
 $PY3 $COM_FLAGS osmopy
+$PY3 $COM_FLAGS scripts/osmodumpdoc.py
+$PY3 $COM_FLAGS scripts/osmotestvty.py
+$PY3 $COM_FLAGS scripts/osmotestconfig.py
 $PY3 $COM_FLAGS scripts/osmo_ctrl.py
 $PY3 $COM_FLAGS scripts/osmo_rate_ctr2csv.py
 $PY3 $COM_FLAGS scripts/osmo_interact_common.py
diff --git a/scripts/osmodumpdoc.py b/scripts/osmodumpdoc.py
index 2464b05..d71edc8 100644
--- a/scripts/osmodumpdoc.py
+++ b/scripts/osmodumpdoc.py
@@ -4,7 +4,7 @@
 # Fixes may need to be applied to both.
 
 """Start the process and dump the documentation to the doc dir."""
-
+from __future__ import print_function
 import subprocess
 import time
 import os
@@ -21,7 +21,7 @@
 out = open(filename, 'w')
 out.write(xml)
 out.close()
-print 'generated %r' % filename
+print('generated %r' % filename)
 
 
 """Dump the config of all the apps.
@@ -40,22 +40,22 @@
 
 for app in apps:
 appname = app[3]
-print "Starting app for %s" % appname
+print("Starting app for %s" % appname)
 proc = None
 cmd = [app[1], "-c", os.path.join(confpath, configs[appname][0])]
-print 'cd', os.path.abspath(os.path.curdir), ';', ' '.join(cmd)
+print('cd', os.path.abspath(os.path.curdir), ';', ' '.join(cmd))
 try:
 proc = subprocess.Popen(cmd, stdin=None, stdout=None)
 except OSError as e:  # Probably a missing binary
-print >> sys.stderr, e
-print >> sys.stderr, "Skipping app %s" % appname
+print(e, file=sys.stderr)
+print("Skipping app %s" % appname, file=sys.stderr)
 failures += 1
 else:
 try:
 dump_doc(app[2], app[0], 'doc/%s_vty_reference.xml' % appname)
 successes += 1
 except IOError:  # Generally a socket issue
-print >> sys.stderr, "%s: couldn't connect, skipping" % appname
+print("%s: couldn't connect, skipping" % appname, 
file=sys.stderr)
 failures += 1
 finally:
 osmoutil.end_proc(proc)
@@ -90,7 +90,7 @@
 num_fails, num_sucs = dump_configs(
 osmoappdesc.apps, osmoappdesc.app_configs, confpath)
 if num_fails > 0:
-print >> sys.stderr, "Warning: Skipped %s apps" % num_fails
+print("Warning: Skipped %s apps" % num_fails, file=sys.stderr)
 if 0 == num_sucs:
-print >> sys.stderr, "Nothing run, wrong working dir? Set with -w"
+print("Nothing run, wrong working dir? Set with -w", 
file=sys.stderr)
 sys.exit(num_fails)
diff --git a/scripts/osmotestconfig.py b/scripts/osmotestconfig.py
index 2132c43..f227504 100644
--- a/scripts/osmotestconfig.py
+++ b/scripts/osmotestconfig.py
@@ -13,7 +13,7 @@
 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see .
-
+from __future__ import print_function
 import os
 import os.path
 import time
@@ -52,7 +52,7 @@
 try:
 cmd = app_desc[1].split(' ') + [ "-c", config]
 if verbose:
-print "Verifying %s, test %s" % (' '.join(cmd), run_test.__name__)
+print("Verifying %s, test %s" % (' '.join(cmd), run_test.__name__))
 
 proc = osmoutil.popen_devnull(cmd)
 end = app_desc[2]
@@ -61,10 +61,10 @@
 ret = run_test(vty)
 
 except IOError as se:
-print >> sys.stderr, "Failed to verify %s" % ' '.join(cmd)
-print >> sys.stderr, "Current directory: %s" % os.getcwd()
-print >> sys.stderr, "Error was %s" % se
-print >> sys.stderr, "Config was\n%s" % open(config).read()
+print("Failed to verify %s" % ' '.join(cmd), file=sys.stderr)
+print("Current directory: %s" % os.getcwd(), file=sys.stderr)
+print("Error was %s" % se, file=sys.stderr)
+print("Config was\n%s" % open(config).read(), file=sys.stderr)
 raise se
 
 finally:
@@ -125,9 +125,8 @@
 
 all_errs.append(err_lines)
 
-print >> sys.stderr, \
-"Documentation error (missing docs): \n%s\n%s\n" % (
-

[PATCH] python/osmo-python-tests[master]: Use python3 for osmo_ctrl.py

2017-12-21 Thread Max
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/5061

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

Use python3 for osmo_ctrl.py

It's a standalone script illustrating the use of ctrl protocol from
python. Since it's not used as a library and nothing depends on it, we
can safely switch to python3.

Change-Id: I2461dd9af67771beed5306116e8a1b0ee2285aa8
---
M contrib/jenkins.sh
M scripts/osmo_ctrl.py
M setup.py
3 files changed, 7 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/61/5061/4

diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 1598836..cd94868 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -9,7 +9,6 @@
 $PY2 ./setup.py install
 $PY2 tests/test_py2.py
 $PY2 $COM_FLAGS osmopy
-$PY2 $COM_FLAGS scripts/osmo_ctrl.py
 $PY2 $COM_FLAGS scripts/osmodumpdoc.py
 $PY2 $COM_FLAGS scripts/osmotestvty.py
 $PY2 $COM_FLAGS scripts/osmotestconfig.py
@@ -28,4 +27,7 @@
 $PY3 $COM_FLAGS scripts/soap.py
 $PY3 $COM_FLAGS scripts/twisted_ipa.py
 
+cd scripts
+./osmo_ctrl.py --help
+
 # TODO: add more tests
diff --git a/scripts/osmo_ctrl.py b/scripts/osmo_ctrl.py
index bec6d1d..8c0608f 100755
--- a/scripts/osmo_ctrl.py
+++ b/scripts/osmo_ctrl.py
@@ -1,8 +1,8 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
 # -*- mode: python-mode; py-indent-tabs-mode: nil -*-
 """
 /*
- * Copyright (C) 2016 sysmocom s.f.m.c. GmbH
+ * Copyright (C) 2016-2017 sysmocom s.f.m.c. GmbH
  *
  * All Rights Reserved
  *
@@ -21,7 +21,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 """
-from __future__ import print_function
+
 from optparse import OptionParser
 from osmopy.osmo_ipa import Ctrl
 import socket
diff --git a/setup.py b/setup.py
index 533272e..bab9c38 100755
--- a/setup.py
+++ b/setup.py
@@ -25,6 +25,7 @@
 elif sys.version_info.major == 3:
scripts = ["scripts/osmo_interact_vty.py",
   "scripts/osmo_interact_ctrl.py",
+   "scripts/osmo_ctrl.py",
   "scripts/soap.py",
   "scripts/twisted_ipa.py",
   "scripts/osmo_verify_transcript_vty.py",

-- 
To view, visit https://gerrit.osmocom.org/5061
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2461dd9af67771beed5306116e8a1b0ee2285aa8
Gerrit-PatchSet: 4
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 


[PATCH] osmo-pcu[master]: TBF: log source of state transitions

2017-12-21 Thread Max
Hello Harald Welte, Jenkins Builder,

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

https://gerrit.osmocom.org/5209

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

TBF: log source of state transitions

We use the same approach for osmo_fsm: when state transition happens,
it's not very useful to always log the transition function itself, it's
much more useful to see where the actual transition comes from.

Change-Id: I348ba89bdda2b44c7019e9c893c764ee08c80bec
Related: OS#2407
---
M src/bts.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
M tests/tbf/TbfTest.cpp
6 files changed, 24 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/09/5209/2

diff --git a/src/bts.cpp b/src/bts.cpp
index 3655567..4e16f04 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -685,7 +685,7 @@
failure = true;
} else {
tbf->set_ta(ta);
-   tbf->set_state(GPRS_RLCMAC_FLOW);
+   TBF_SET_STATE(tbf, GPRS_RLCMAC_FLOW);
tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH);
tbf->t_start(T3169, m_bts.t3169, 0, "RACH (new 
UL-TBF)", true);
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] START\n");
@@ -1039,7 +1039,7 @@
new_tbf->state_flags &= ~(1 << GPRS_RLCMAC_FLAG_CCCH);
new_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
}
-   new_tbf->set_state(GPRS_RLCMAC_FLOW);
+   TBF_SET_STATE(new_tbf, GPRS_RLCMAC_FLOW);
/* stop pending assignment timer */
new_tbf->stop_timer("control acked (DL-TBF)");
if ((new_tbf->state_flags &
@@ -1067,7 +1067,7 @@
tbf->direction == new_tbf->direction)
tbf_free(tbf);
 
-   new_tbf->set_state(GPRS_RLCMAC_FLOW);
+   TBF_SET_STATE(new_tbf, GPRS_RLCMAC_FLOW);
if ((new_tbf->state_flags &
(1 << GPRS_RLCMAC_FLAG_TO_UL_ASS))) {
new_tbf->state_flags &=
diff --git a/src/tbf.cpp b/src/tbf.cpp
index dc0777f..7fe8071 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -402,7 +402,7 @@
return NULL;
}
tbf->m_contention_resolution_done = 1;
-   tbf->set_state(GPRS_RLCMAC_ASSIGN);
+   TBF_SET_STATE(tbf, GPRS_RLCMAC_ASSIGN);
tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
tbf->t_start(T3169, bts->t3169, 0, "allocation (UL-TBF)", true);
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
@@ -744,7 +744,7 @@
m_n3101++;
if (m_n3101 == bts->bts_data()->n3101) {
LOGP(DRLCMAC, LOGL_NOTICE, " N3101 exceeded MAX (%u)\n", 
bts->bts_data()->n3101);
-   set_state(GPRS_RLCMAC_RELEASING);
+   TBF_SET_STATE(this, GPRS_RLCMAC_RELEASING);
t_start(T3169, bts->bts_data()->t3169, 0, "MAX N3101 reached", 
false);
return;
}
@@ -762,7 +762,7 @@
LOGP(DRLCMAC, LOGL_NOTICE,
 "- N3103 exceeded\n");
bts->pkt_ul_ack_nack_poll_failed();
-   ul_tbf->set_state(GPRS_RLCMAC_RELEASING);
+   TBF_SET_STATE(ul_tbf, GPRS_RLCMAC_RELEASING);
ul_tbf->t_start(T3169, 
ul_tbf->bts->bts_data()->t3169, 0, "MAX N3103 reached", false);
return;
}
@@ -784,7 +784,7 @@
bts->pua_poll_timedout();
if (n3105 == bts_data()->n3105) {
LOGP(DRLCMAC, LOGL_NOTICE, "- N3105 exceeded\n");
-   set_state(GPRS_RLCMAC_RELEASING);
+   TBF_SET_STATE(this, GPRS_RLCMAC_RELEASING);
t_start(T3195, bts_data()->t3195, 0, "MAX N3105 
reached", true);
bts->rlc_ass_failed();
bts->pua_poll_failed();
@@ -806,7 +806,7 @@
bts->pda_poll_timedout();
if (n3105 == bts->bts_data()->n3105) {
LOGP(DRLCMAC, LOGL_NOTICE, "- N3105 exceeded\n");
-   set_state(GPRS_RLCMAC_RELEASING);
+   TBF_SET_STATE(this, GPRS_RLCMAC_RELEASING);
t_start(T3195, bts_data()->t3195, 0, "MAX N3105 
reached", true);
bts->rlc_ass_failed();
bts->pda_poll_failed();
@@ -832,7 +832,7 @@
}
if (dl_tbf->n3105 == dl_tbf->bts->bts_data()->n3105) {
LOGP(DRLCMAC, LOGL_NOTICE, "- N3105 exceeded\n");
-   dl_tbf->set_state(GPRS_RLCMAC_RELEASING);
+   TBF_SET_STATE(dl_tbf, GPRS_RLCMAC_RELEASING);
dl_tbf->t_start(T3195, 

osmocom-bb[master]: bsic decoding of neighbour cells in dedicated mode and parti...

2017-12-21 Thread Max

Patch Set 1:

> What do you think?

I don't have strong opinion either way. It can stay in gerrit or in separate 
branch or both. Whatever is more convenient for the people wiling to work with 
it.

-- 
To view, visit https://gerrit.osmocom.org/5490
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib01460b796d2107c4599d327e184eb42340999d2
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Muhammad Awais Aslam 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-Reviewer: fixeria 
Gerrit-HasComments: No


[PATCH] osmo-pcu[master]: TBF: cleanup state flag handling

2017-12-21 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5367

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

TBF: cleanup state flag handling

 * introduce generic function to check whether particular flag was set
   for'a TBF and clear it if necessary. Use this instead of
   clear_poll_timeout_flag()
 * add function to explicitly set assignment and appropriate state flags

Overall this makes the code easier to read and debug.

Change-Id: Ic4560280c72f91700f2e19c6c7f6658dc29625c2
---
M src/bts.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
5 files changed, 36 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/67/5367/2

diff --git a/src/bts.cpp b/src/bts.cpp
index 867658e..12890f6 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1031,7 +1031,7 @@
tbf->direction == new_tbf->direction)
tbf_free(tbf);
 
-   if ((new_tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))) {
+   if (new_tbf->check_n_clear(GPRS_RLCMAC_FLAG_CCCH)) {
/* We now know that the PACCH really existed */
LOGPTBF(new_tbf, LOGL_INFO,
"The TBF has been confirmed on the PACCH, "
@@ -1042,12 +1042,9 @@
new_tbf->set_state(GPRS_RLCMAC_FLOW);
/* stop pending assignment timer */
new_tbf->stop_timer("control acked (DL-TBF)");
-   if ((new_tbf->state_flags &
-   (1 << GPRS_RLCMAC_FLAG_TO_DL_ASS))) {
-   new_tbf->state_flags &=
-   ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ASS);
+   if (new_tbf->check_n_clear(GPRS_RLCMAC_FLAG_TO_DL_ASS))
LOGPTBF(new_tbf, LOGL_NOTICE, "Recovered downlink 
assignment\n");
-   }
+
tbf_assign_control_ts(new_tbf);
return;
}
@@ -1068,12 +1065,9 @@
tbf_free(tbf);
 
new_tbf->set_state(GPRS_RLCMAC_FLOW);
-   if ((new_tbf->state_flags &
-   (1 << GPRS_RLCMAC_FLAG_TO_UL_ASS))) {
-   new_tbf->state_flags &=
-   ~(1 << GPRS_RLCMAC_FLAG_TO_UL_ASS);
+   if (new_tbf->check_n_clear(GPRS_RLCMAC_FLAG_TO_UL_ASS))
LOGPTBF(new_tbf, LOGL_NOTICE, "Recovered uplink 
assignment for UL\n");
-   }
+
tbf_assign_control_ts(new_tbf);
/* there might be LLC packets waiting in the queue, but the DL
 * TBF might have been released while the UL TBF has been
diff --git a/src/tbf.cpp b/src/tbf.cpp
index dc0777f..8a59478 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -402,8 +402,7 @@
return NULL;
}
tbf->m_contention_resolution_done = 1;
-   tbf->set_state(GPRS_RLCMAC_ASSIGN);
-   tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
+   tbf->set_assigned_on(GPRS_RLCMAC_FLAG_PACCH, false);
tbf->t_start(T3169, bts->t3169, 0, "allocation (UL-TBF)", true);
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
OSMO_ASSERT(tbf->ms());
@@ -1537,8 +1536,7 @@
 
llist_add(_tbf->list(), >bts->ul_tbfs());
ul_tbf->bts->tbf_ul_created();
-   ul_tbf->set_state(GPRS_RLCMAC_ASSIGN);
-   ul_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
+   ul_tbf->set_assigned_on(GPRS_RLCMAC_FLAG_PACCH, false);
 
ul_tbf->set_ms(ms);
ul_tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
diff --git a/src/tbf.h b/src/tbf.h
index 4489695..1d555d4 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -175,6 +175,8 @@
bool state_is(enum gprs_rlcmac_tbf_state rhs) const;
bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const;
void set_state(enum gprs_rlcmac_tbf_state new_state);
+   bool check_n_clear(uint8_t state_flag);
+   void set_assigned_on(uint8_t state_flag, bool check_ccch);
const char *state_name() const;
 
const char *name() const;
@@ -372,12 +374,33 @@
return tbf_state_name[state];
 }
 
+/* Set assignment state and corrsponding flags */
+inline void gprs_rlcmac_tbf::set_assigned_on(uint8_t state_flag, bool 
check_ccch)
+{
+   set_state(GPRS_RLCMAC_ASSIGN);
+   if (check_ccch) {
+   if (!(state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)))
+   state_flags |= (1 << state_flag);
+   } else
+   state_flags |= (1 << state_flag);
+}
+
 inline void gprs_rlcmac_tbf::set_state(enum gprs_rlcmac_tbf_state new_state)
 {
LOGP(DRLCMAC, LOGL_DEBUG, "%s changes state from %s to %s\n",
tbf_name(this),
tbf_state_name[state], tbf_state_name[new_state]);
state = new_state;
+}
+
+inline bool gprs_rlcmac_tbf::check_n_clear(uint8_t state_flag)
+{
+   if ((state_flags & (1 << state_flag))) {
+   

[MERGED] osmo-msc[master]: fix: properly cancel all Paging on IMSI Detach

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: fix: properly cancel all Paging on IMSI Detach
..


fix: properly cancel all Paging on IMSI Detach

It's not clear cut which code is responsible for canceling pending requests,
since the requests list is kept in vlr_subscr, but sending out Paging does
certainly not belong in the VLR. Place the requests cleanup in gsm_04_08.c.

Add to test_ms_timeout_paging() in msc_vlr_test_ms_timeout.c to verify that a
pending paging is canceled on IMSI Detach.

Change-Id: Ib8874a9d92f02b0826525b55518332f6899688fd
---
M include/osmocom/msc/gsm_subscriber.h
M src/libmsc/gsm_04_08.c
M src/libmsc/gsm_subscriber.c
M tests/msc_vlr/msc_vlr_test_ms_timeout.c
M tests/msc_vlr/msc_vlr_test_ms_timeout.err
5 files changed, 43 insertions(+), 5 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/msc/gsm_subscriber.h 
b/include/osmocom/msc/gsm_subscriber.h
index 6b0e3da..4adfd41 100644
--- a/include/osmocom/msc/gsm_subscriber.h
+++ b/include/osmocom/msc/gsm_subscriber.h
@@ -62,6 +62,7 @@
 int subscr_rx_paging_response(struct msgb *msg,
  struct gsm_subscriber_connection *conn);
 
+void subscr_paging_cancel(struct vlr_subscr *vsub, enum gsm_paging_event 
event);
 int subscr_paging_dispatch(unsigned int hooknum, unsigned int event,
   struct msgb *msg, void *data, void *param);
 
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index e370962..26ac923 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -770,6 +770,10 @@
 gsm48_mi_type_name(mi_type), mi_string);
} else {
LOGP(DMM, LOGL_INFO, "IMSI DETACH for %s\n", 
vlr_subscr_name(vsub));
+
+   if (vsub->cs.is_paging)
+   subscr_paging_cancel(vsub, GSM_PAGING_EXPIRED);
+
vlr_subscr_rx_imsi_detach(vsub);
osmo_signal_dispatch(SS_SUBSCR, S_SUBSCR_DETACHED, vsub);
vlr_subscr_put(vsub);
diff --git a/src/libmsc/gsm_subscriber.c b/src/libmsc/gsm_subscriber.c
index b3d38d1..1a7bf59 100644
--- a/src/libmsc/gsm_subscriber.c
+++ b/src/libmsc/gsm_subscriber.c
@@ -52,6 +52,11 @@
 #include 
 #include 
 
+void subscr_paging_cancel(struct vlr_subscr *vsub, enum gsm_paging_event event)
+{
+   subscr_paging_dispatch(GSM_HOOK_RR_PAGING, event, NULL, NULL, vsub);
+}
+
 int subscr_paging_dispatch(unsigned int hooknum, unsigned int event,
   struct msgb *msg, void *data, void *param)
 {
@@ -132,7 +137,7 @@
 static void paging_response_timer_cb(void *data)
 {
struct vlr_subscr *vsub = data;
-   subscr_paging_dispatch(GSM_HOOK_RR_PAGING, GSM_PAGING_EXPIRED, NULL, 
NULL, vsub);
+   subscr_paging_cancel(vsub, GSM_PAGING_EXPIRED);
 }
 
 /*! \brief Start a paging request for vsub, call cbfn(param) when done.
diff --git a/tests/msc_vlr/msc_vlr_test_ms_timeout.c 
b/tests/msc_vlr/msc_vlr_test_ms_timeout.c
index 4e0e27d..4cfd035 100644
--- a/tests/msc_vlr/msc_vlr_test_ms_timeout.c
+++ b/tests/msc_vlr/msc_vlr_test_ms_timeout.c
@@ -258,13 +258,26 @@
OSMO_ASSERT(vsub);
VERBOSE_ASSERT(vsub->cs.is_paging, == false, "%d");
VERBOSE_ASSERT(llist_count(>cs.requests), == 0, "%d");
+
+   BTW("Now that the timeout has expired, another Paging is sent on 
request");
+   paging_expect_imsi(imsi);
+   paging_sent = false;
+
+   send_sms(vsub, vsub,
+"Privacy in residential applications is a desirable"
+" marketing option.");
+
+   VERBOSE_ASSERT(llist_count(>cs.requests), == 1, "%d");
vlr_subscr_put(vsub);
vsub = NULL;
+   VERBOSE_ASSERT(paging_sent, == true, "%d");
+   VERBOSE_ASSERT(paging_stopped, == false, "%d");
 
-   BTW("subscriber detaches");
+   BTW("subscriber detaches, pagings are canceled");
expect_bssap_clear();
ms_sends_msg("05013008991007006402");
VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
+   VERBOSE_ASSERT(paging_stopped, == true, "%d");
 
vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
OSMO_ASSERT(!vsub);
diff --git a/tests/msc_vlr/msc_vlr_test_ms_timeout.err 
b/tests/msc_vlr/msc_vlr_test_ms_timeout.err
index c8b7e96..f0c4116 100644
--- a/tests/msc_vlr/msc_vlr_test_ms_timeout.err
+++ b/tests/msc_vlr/msc_vlr_test_ms_timeout.err
@@ -480,16 +480,30 @@
 DREF VLR subscr MSISDN:46071 usage increases to: 2
   vsub->cs.is_paging == 0
   llist_count(>cs.requests) == 0
-DREF VLR subscr MSISDN:46071 usage decreases to: 1
 ---
-- subscriber detaches
+- Now that the timeout has expired, another Paging is sent on request
+DREF VLR subscr MSISDN:46071 usage increases to: 3
+DMM Subscriber MSISDN:46071 not paged yet, start paging.
+  RAN_GERAN_A sends out paging request to IMSI 90170004620, TMSI 
0x, LAC 

[MERGED] osmo-msc[master]: fix paging: add timeout to discard unsuccessful paging

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: fix paging: add timeout to discard unsuccessful paging
..


fix paging: add timeout to discard unsuccessful paging

Currently, if there is no reply from the BSS / RNC, a subscriber will remain as
"already paged" forever, and is never going to be paged again. Even on IMSI
Detach, the pending request will keep a ref count on the vlr_subscr.

Add a paging timeout, as gsm_network->paging_timeout and in the VTY on the
'msc' node as 'paging timeout (default|<1-65535>'. (There is a 'network' /
'T3113' in OsmoBSC, but to not confuse the two, give this a different name.)

Add test_ms_timeout_paging() test to verify the timeout works.

I hit this while testing Paging across multiple hNodeB, when a UE lost
connection to the hNodeB. I noticed that no matter how long I wait, no Paging
is sent out anymore, and found this embarrassing issue. Good grief...

The choice of 10 seconds is taken from https://osmocom.org/issues/2756

Change-Id: I2db6f1e2ad341cf9c2cc7a21ec2fca0bae5b2db5
---
M include/osmocom/msc/gsm_data.h
M include/osmocom/msc/vlr.h
M src/libcommon-cs/common_cs.c
M src/libmsc/gsm_subscriber.c
M src/libmsc/msc_vty.c
M tests/msc_vlr/msc_vlr_test_ms_timeout.c
M tests/msc_vlr/msc_vlr_test_ms_timeout.err
7 files changed, 298 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/msc/gsm_data.h b/include/osmocom/msc/gsm_data.h
index 6349fe0..1b0bff9 100644
--- a/include/osmocom/msc/gsm_data.h
+++ b/include/osmocom/msc/gsm_data.h
@@ -344,6 +344,7 @@
GSM_AUTH_POLICY_REGEXP, /* accept IMSIs matching given regexp */
 };
 
+#define MSC_PAGING_RESPONSE_TIMER_DEFAULT 10
 
 struct gsm_tz {
int override; /* if 0, use system's time zone instead. */
@@ -408,6 +409,7 @@
unsigned int num_bts;
struct llist_head bts_list;
 
+   unsigned int paging_response_timer;
 
/* timer to expire old location updates */
struct osmo_timer_list subscr_expire_timer;
diff --git a/include/osmocom/msc/vlr.h b/include/osmocom/msc/vlr.h
index b625608..1b365a9 100644
--- a/include/osmocom/msc/vlr.h
+++ b/include/osmocom/msc/vlr.h
@@ -157,6 +157,7 @@
struct {
/* pending requests */
bool is_paging;
+   struct osmo_timer_list paging_response_timer;
/* list of struct subscr_request */
struct llist_head requests;
uint8_t lac;
diff --git a/src/libcommon-cs/common_cs.c b/src/libcommon-cs/common_cs.c
index bad8262..4748865 100644
--- a/src/libcommon-cs/common_cs.c
+++ b/src/libcommon-cs/common_cs.c
@@ -60,6 +60,8 @@
/* Use 30 min periodic update interval as sane default */
net->t3212 = 5;
 
+   net->paging_response_timer = MSC_PAGING_RESPONSE_TIMER_DEFAULT;
+
INIT_LLIST_HEAD(>trans_list);
INIT_LLIST_HEAD(>upqueue);
INIT_LLIST_HEAD(>subscr_conns);
diff --git a/src/libmsc/gsm_subscriber.c b/src/libmsc/gsm_subscriber.c
index a013e0e..b3d38d1 100644
--- a/src/libmsc/gsm_subscriber.c
+++ b/src/libmsc/gsm_subscriber.c
@@ -76,7 +76,10 @@
return -EINVAL;
}
 
-   if (event == GSM_PAGING_SUCCEEDED)
+   osmo_timer_del(>cs.paging_response_timer);
+
+   if (event == GSM_PAGING_SUCCEEDED
+   || event == GSM_PAGING_EXPIRED)
msc_stop_paging(vsub);
 
/* Inform parts of the system we don't know */
@@ -126,6 +129,12 @@
return -EINVAL;
 }
 
+static void paging_response_timer_cb(void *data)
+{
+   struct vlr_subscr *vsub = data;
+   subscr_paging_dispatch(GSM_HOOK_RR_PAGING, GSM_PAGING_EXPIRED, NULL, 
NULL, vsub);
+}
+
 /*! \brief Start a paging request for vsub, call cbfn(param) when done.
  * \param vsub  subscriber to page.
  * \param cbfn  function to call when the conn is established.
@@ -138,6 +147,7 @@
 {
int rc;
struct subscr_request *request;
+   struct gsm_network *net = vsub->vlr->user_ctx;
 
/* Start paging.. we know it is async so we can do it before */
if (!vsub->cs.is_paging) {
@@ -152,6 +162,8 @@
/* reduced on the first paging callback */
vlr_subscr_get(vsub);
vsub->cs.is_paging = true;
+   osmo_timer_setup(>cs.paging_response_timer, 
paging_response_timer_cb, vsub);
+   osmo_timer_schedule(>cs.paging_response_timer, 
net->paging_response_timer, 0);
} else {
LOGP(DMM, LOGL_DEBUG, "Subscriber %s already paged.\n",
vlr_subscr_name(vsub));
diff --git a/src/libmsc/msc_vty.c b/src/libmsc/msc_vty.c
index 14ad19e..c1c9f6b 100644
--- a/src/libmsc/msc_vty.c
+++ b/src/libmsc/msc_vty.c
@@ -109,6 +109,22 @@
return CMD_SUCCESS;
 }
 
+DEFUN(cfg_msc_paging_response_timer, cfg_msc_paging_response_timer_cmd,
+  

osmo-msc[master]: fix paging: add timeout to discard unsuccessful paging

2017-12-21 Thread Harald Welte

Patch Set 4: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5463
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2db6f1e2ad341cf9c2cc7a21ec2fca0bae5b2db5
Gerrit-PatchSet: 4
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


osmo-pcu[master]: cosmetic: clarify coding scheme and puncturing

2017-12-21 Thread Max

Patch Set 1:

I've made it while tracking down possible values for rlc.num_data_blocks which 
is assigned using CS. The benefit is that stricter type immediately gives 
reader a hint at the value range which variable can take. It also increase the 
chance that errors will be spotted by compiler due to type mismatch or by 
coverity during scan. I can drop it from the patch if you think it's better.

-- 
To view, visit https://gerrit.osmocom.org/5535
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If599a6c8a6ef56d847604fcf41bb71decccd8a78
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-HasComments: No


osmo-iuh[master]: hnbap, rua, ranap decode: fix segfault on decode error

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

(1 comment)

https://gerrit.osmocom.org/#/c/5531/1//COMMIT_MSG
Commit Message:

Line 28: +HNBAP_DEBUG("Decoding of message HNBRegisterRequestIEs 
failed\n");
this should probably be more than just DEBUG level, but I'm not sure if this 
part of the code provides you with a related macro?  It's more like a NOTICE 
event to me.


-- 
To view, visit https://gerrit.osmocom.org/5531
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I6cb9cc9a88d22f03befa43f0968a874476fa079d
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: Yes


osmo-iuh[master]: hnbgw: hnb info: record MCC, MNC, show on 'show hnb'

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5530
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Iae094b36fa1cf18e07ed33914b9425368d7cd34b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-iuh[master]: hnbgw: hnb info: record MCC, MNC, show on 'show hnb'

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: hnbgw: hnb info: record MCC, MNC, show on 'show hnb'
..


hnbgw: hnb info: record MCC, MNC, show on 'show hnb'

Before, MCC and MNC were always reported as zero, now the output of 'show hnb 
all' looks like:

  OsmoHNBGW> show hnb all
  HNB "000295-154...@ap.ipaccess.com" MCC 901 MNC 70 LAC 1 RAC 99 SAC 
65535 CID 1048575
 HNBAP ID 0 RUA ID 0

Change-Id: Iae094b36fa1cf18e07ed33914b9425368d7cd34b
---
M src/Makefile.am
M src/hnbgw_hnbap.c
2 files changed, 2 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/Makefile.am b/src/Makefile.am
index ab772a4..85bfad6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -67,7 +67,7 @@
 hnbgw_vty.c \
 context_map.c hnbgw_cn.c
 
-osmo_hnbgw_LDADD = $(OSMOCORE_LIBS) $(OSMOVTY_LIBS) \
+osmo_hnbgw_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOVTY_LIBS) \
   $(ASN1C_LIBS) $(OSMOSIGTRAN_LIBS) \
   $(OSMONETIF_LIBS) \
   hnbap/libosmo-asn1-hnbap.a rua/libosmo-asn1-rua.a \
diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c
index 7c1e239..058a42a 100644
--- a/src/hnbgw_hnbap.c
+++ b/src/hnbgw_hnbap.c
@@ -380,8 +380,7 @@
ctx->id.sac = asn1str_to_u16();
ctx->id.rac = asn1str_to_u8();
ctx->id.cid = asn1bitstr_to_u28();
-   //ctx->id.mcc FIXME
-   //ctx->id.mnc FIXME
+   gsm48_mcc_mnc_from_bcd(ies.plmNidentity.buf, >id.mcc, 
>id.mnc);
 
DEBUGP(DHNBAP, "HNB-REGISTER-REQ from %s\n", ctx->identity_info);
 

-- 
To view, visit https://gerrit.osmocom.org/5530
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iae094b36fa1cf18e07ed33914b9425368d7cd34b
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-iuh[master]: vty: tweak / improve HNB and cnlink introspection

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review-1

(2 comments)

https://gerrit.osmocom.org/#/c/5532/1/src/hnbgw_vty.c
File src/hnbgw_vty.c:

Line 120:   
whitespace


Line 151: vty_out(vty, "%s:%u", inet_ntoa(addr.sin_addr), addr.sin_port);
please don't introduce new IPv4-only-isms without good reason.  Using inet_ntop 
would have not been any more difficult but more future proof.

Also, we do have osmo_sock_get_name() in libosmocore/socket.c, which performs 
both getosckname and getpeername and provides you with a nice string 
representation.  This is what's used in other places already, so I'd appreciate 
if we could use it here, too.

If you really need only the local address, please refactor osmo_sock_get_name() 
in libosmocore and use it from here.


-- 
To view, visit https://gerrit.osmocom.org/5532
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I3c937306a011715e163a40bc8ef8ec7e8d4e5d08
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: Yes


osmo-pcu[master]: TBF: log timer invocation source

2017-12-21 Thread Harald Welte

Patch Set 3: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5208
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If5f883ae52c469e5158bad24da9904fdc455582f
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-iuh[master]: compiler warning: asn1tostruct.py: return 0 at end of *_free...

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5533
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ieba12c09c33a81da964bf88a858714d922ced8c0
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-pcu[master]: TBF: unify timer handling

2017-12-21 Thread Harald Welte

Patch Set 4: Code-Review+1

-- 
To view, visit https://gerrit.osmocom.org/5234
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I63fb7e6f0695383a83472c836a381a055f64690b
Gerrit-PatchSet: 4
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-pcu[master]: Fix warnings

2017-12-21 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Fix warnings
..


Fix warnings

Fix warnings detected by compiler and coverity scan.

Change-Id: If463c7f8769e18d3df74837f0cb0f545cca9b23e
Fixes: CID181479
---
M src/bts.cpp
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/bts.cpp b/src/bts.cpp
index 867658e..3655567 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -219,7 +219,7 @@
}
 
/* The static allocator might have already registered the counter group.
-  If this happens and we still called explicitly (in tests/* for 
example)
+  If this happens and we still called explicitly (in tests/ for 
example)
   than just allocate the group with different index.
   This shall be removed once weget rid of BTS singleton */
if (rate_ctr_get_group_by_name_idx(bts_ctrg_desc.group_name_prefix, 0))
@@ -1439,7 +1439,7 @@
return;
}
LOGPTBFUL(ul_tbf, LOGL_ERROR,
-   "RX: [PCU <- BTS] %s FIXME: Packet resource request\n");
+   "RX: [PCU <- BTS] FIXME: Packet resource request\n");
 
/* Reset N3101 counter: */
ul_tbf->m_n3101 = 0;

-- 
To view, visit https://gerrit.osmocom.org/5534
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If463c7f8769e18d3df74837f0cb0f545cca9b23e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-pcu[master]: Fix warnings

2017-12-21 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/5534
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If463c7f8769e18d3df74837f0cb0f545cca9b23e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


osmo-pcu[master]: cosmetic: clarify coding scheme and puncturing

2017-12-21 Thread Harald Welte

Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/5535/1/src/gprs_coding_scheme.h
File src/gprs_coding_scheme.h:

Line 94:uint8_t sizeUL() const;
I don't understand what we gain by all those conversions?  What's the benefit?  
I can only see the problem of creating more clashes with other patches :/


-- 
To view, visit https://gerrit.osmocom.org/5535
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If599a6c8a6ef56d847604fcf41bb71decccd8a78
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: Yes


[PATCH] osmo-pcu[master]: cosmetic: clarify coding scheme and puncturing

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5535

cosmetic: clarify coding scheme and puncturing

* use appropriate types for coding scheme parameters
* add comment regarding possible number of RLCMAC blocks

The code in create_dl_acked_block() has underlying assumption that
rlc.num_data_blocks can never be more than 2, which is true and is
enforced by appropriate asserts but is not obvious when looking at the
function code alone. It's equally hard for Coverity which leads to false
positives in scan.

Lets' make this assumption explicit by putting it into for(;;) condition
alongside with corresponding comment.

Fixes: CID143070
Change-Id: If599a6c8a6ef56d847604fcf41bb71decccd8a78
---
M src/gprs_coding_scheme.cpp
M src/gprs_coding_scheme.h
M src/rlc.cpp
M src/rlc.h
M src/tbf_dl.cpp
5 files changed, 45 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/35/5535/1

diff --git a/src/gprs_coding_scheme.cpp b/src/gprs_coding_scheme.cpp
index 719cbb2..3094ae6 100644
--- a/src/gprs_coding_scheme.cpp
+++ b/src/gprs_coding_scheme.cpp
@@ -55,12 +55,12 @@
 
 static struct {
struct {
-   unsigned int bytes;
-   unsigned int ext_bits;
-   unsigned int data_header_bits;
+   uint8_t bytes;
+   uint8_t ext_bits;
+   uint8_t data_header_bits;
} uplink, downlink;
-   unsigned int data_bytes;
-   unsigned int optional_padding_bits;
+   uint8_t data_bytes;
+   uint8_t optional_padding_bits;
const char *name;
GprsCodingScheme::HeaderType data_hdr;
GprsCodingScheme::Family family;
@@ -99,10 +99,10 @@
 
 static struct {
struct {
-   int data_header_bits;
+   uint8_t data_header_bits;
} uplink, downlink;
-   unsigned int data_block_header_bits;
-   unsigned int num_blocks;
+   uint8_t data_block_header_bits;
+   uint8_t num_blocks;
const char *name;
 } hdr_type_info[GprsCodingScheme::NUM_HEADER_TYPES] = {
{{0},   {0},   0, 0, "INVALID"},
@@ -134,12 +134,12 @@
return GprsCodingScheme(UNKNOWN);
 }
 
-unsigned int GprsCodingScheme::sizeUL() const
+uint8_t GprsCodingScheme::sizeUL() const
 {
return mcs_info[m_scheme].uplink.bytes + (spareBitsUL() ? 1 : 0);
 }
 
-unsigned int GprsCodingScheme::usedSizeUL() const
+uint8_t GprsCodingScheme::usedSizeUL() const
 {
if (mcs_info[m_scheme].data_hdr == HEADER_GPRS_DATA)
return mcs_info[m_scheme].uplink.bytes;
@@ -147,22 +147,22 @@
return sizeUL();
 }
 
-unsigned int GprsCodingScheme::maxBytesUL() const
+uint8_t GprsCodingScheme::maxBytesUL() const
 {
return mcs_info[m_scheme].uplink.bytes;
 }
 
-unsigned int GprsCodingScheme::spareBitsUL() const
+uint8_t GprsCodingScheme::spareBitsUL() const
 {
return mcs_info[m_scheme].uplink.ext_bits;
 }
 
-unsigned int GprsCodingScheme::sizeDL() const
+uint8_t GprsCodingScheme::sizeDL() const
 {
return mcs_info[m_scheme].downlink.bytes + (spareBitsDL() ? 1 : 0);
 }
 
-unsigned int GprsCodingScheme::usedSizeDL() const
+uint8_t GprsCodingScheme::usedSizeDL() const
 {
if (mcs_info[m_scheme].data_hdr == HEADER_GPRS_DATA)
return mcs_info[m_scheme].downlink.bytes;
@@ -170,42 +170,42 @@
return sizeDL();
 }
 
-unsigned int GprsCodingScheme::maxBytesDL() const
+uint8_t GprsCodingScheme::maxBytesDL() const
 {
return mcs_info[m_scheme].downlink.bytes;
 }
 
-unsigned int GprsCodingScheme::spareBitsDL() const
+uint8_t GprsCodingScheme::spareBitsDL() const
 {
return mcs_info[m_scheme].downlink.ext_bits;
 }
 
-unsigned int GprsCodingScheme::maxDataBlockBytes() const
+uint8_t GprsCodingScheme::maxDataBlockBytes() const
 {
return mcs_info[m_scheme].data_bytes;
 }
 
-unsigned int GprsCodingScheme::optionalPaddingBits() const
+uint8_t GprsCodingScheme::optionalPaddingBits() const
 {
return mcs_info[m_scheme].optional_padding_bits;
 }
 
-unsigned int GprsCodingScheme::numDataBlocks() const
+uint8_t GprsCodingScheme::numDataBlocks() const
 {
return hdr_type_info[headerTypeData()].num_blocks;
 }
 
-unsigned int GprsCodingScheme::numDataHeaderBitsUL() const
+uint8_t GprsCodingScheme::numDataHeaderBitsUL() const
 {
return hdr_type_info[headerTypeData()].uplink.data_header_bits;
 }
 
-unsigned int GprsCodingScheme::numDataHeaderBitsDL() const
+uint8_t GprsCodingScheme::numDataHeaderBitsDL() const
 {
return hdr_type_info[headerTypeData()].downlink.data_header_bits;
 }
 
-unsigned int GprsCodingScheme::numDataBlockHeaderBits() const
+uint8_t GprsCodingScheme::numDataBlockHeaderBits() const
 {
return hdr_type_info[headerTypeData()].data_block_header_bits;
 }
diff --git a/src/gprs_coding_scheme.h b/src/gprs_coding_scheme.h
index dfad240..76cab0f 100644
--- a/src/gprs_coding_scheme.h
+++ b/src/gprs_coding_scheme.h
@@ -70,7 +70,7 @@
 
operator bool() 

[PATCH] osmo-pcu[master]: Fix warnings

2017-12-21 Thread Max

Review at  https://gerrit.osmocom.org/5534

Fix warnings

Fix warnings detected by compiler and coverity scan.

Change-Id: If463c7f8769e18d3df74837f0cb0f545cca9b23e
Fixes: CID181479
---
M src/bts.cpp
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/34/5534/1

diff --git a/src/bts.cpp b/src/bts.cpp
index 867658e..3655567 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -219,7 +219,7 @@
}
 
/* The static allocator might have already registered the counter group.
-  If this happens and we still called explicitly (in tests/* for 
example)
+  If this happens and we still called explicitly (in tests/ for 
example)
   than just allocate the group with different index.
   This shall be removed once weget rid of BTS singleton */
if (rate_ctr_get_group_by_name_idx(bts_ctrg_desc.group_name_prefix, 0))
@@ -1439,7 +1439,7 @@
return;
}
LOGPTBFUL(ul_tbf, LOGL_ERROR,
-   "RX: [PCU <- BTS] %s FIXME: Packet resource request\n");
+   "RX: [PCU <- BTS] FIXME: Packet resource request\n");
 
/* Reset N3101 counter: */
ul_tbf->m_n3101 = 0;

-- 
To view, visit https://gerrit.osmocom.org/5534
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If463c7f8769e18d3df74837f0cb0f545cca9b23e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max 


[PATCH] osmo-pcu[master]: TBF: unify timer handling

2017-12-21 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5234

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

TBF: unify timer handling

Use generic timer handling infrastracture to handle assignment/reject
internal timer. Rename timer array accordingly. Use defines with
explicit second/microsecond values to make it more readable.

Change-Id: I63fb7e6f0695383a83472c836a381a055f64690b
---
M src/bts.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
4 files changed, 32 insertions(+), 68 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/34/5234/4

diff --git a/src/bts.cpp b/src/bts.cpp
index 867658e..8a8ed02 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -554,7 +554,7 @@
LOGP(DRLCMAC, LOGL_DEBUG, "Got IMM.ASS confirm for TLLI=%08x\n", tlli);
 
if (dl_tbf->m_wait_confirm)
-   tbf_timer_start(dl_tbf, 0, Tassign_agch, "assignment (AGCH)");
+   dl_tbf->t_start(T0, 0, T_ASS_AGCH_USEC, "assignment (AGCH)", 
true);
 
return 0;
 }
@@ -1041,7 +1041,7 @@
}
new_tbf->set_state(GPRS_RLCMAC_FLOW);
/* stop pending assignment timer */
-   new_tbf->stop_timer("control acked (DL-TBF)");
+   new_tbf->t_stop(T0, "control acked (DL-TBF)");
if ((new_tbf->state_flags &
(1 << GPRS_RLCMAC_FLAG_TO_DL_ASS))) {
new_tbf->state_flags &=
diff --git a/src/tbf.cpp b/src/tbf.cpp
index dc0777f..ea27597 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -60,6 +60,7 @@
 };
 
 static const struct value_string tbf_timers_names[] = {
+   OSMO_VALUE_STRING(T0),
OSMO_VALUE_STRING(T3169),
OSMO_VALUE_STRING(T3191),
OSMO_VALUE_STRING(T3193),
@@ -170,7 +171,6 @@
poll_fn(0),
poll_ts(0),
n3105(0),
-   T(0),
fT(0),
num_fT_exp(0),
state(GPRS_RLCMAC_NULL),
@@ -191,8 +191,7 @@
/* The classes of these members do not have proper constructors yet.
 * Just set them to 0 like talloc_zero did */
memset(, 0, sizeof(pdch));
-   memset(, 0, sizeof(timer));
-   memset(, 0, sizeof(T31));
+   memset(, 0, sizeof(T));
memset(_rlc, 0, sizeof(m_rlc));
memset(_timer, 0, sizeof(gsm_timer));
 
@@ -472,7 +471,7 @@
"be sure not to free in this state. PLEASE FIX!\n",
 get_value_string(gprs_rlcmac_tbf_dl_ass_state_names,
  tbf->dl_ass_state));
-   tbf->stop_timer("freeing TBF");
+
tbf->stop_timers("freeing TBF");
/* TODO: Could/Should generate  bssgp_tx_llc_discarded */
tbf_unlink_pdch(tbf);
@@ -538,27 +537,6 @@
"RELEASING",
 };
 
-void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T,
-unsigned int seconds, unsigned int microseconds, const 
char *reason)
-{
-   LOGPC(DRLCMAC, (T != tbf->T) ? LOGL_ERROR : LOGL_DEBUG,
- "%s %sstarting timer T%u [%s] with %u sec. %u microsec.",
- tbf_name(tbf), osmo_timer_pending(>timer) ? "re" : "", T, 
reason, seconds, microseconds);
-
-   if (T != tbf->T && osmo_timer_pending(>timer))
-   LOGPC(DRLCMAC, LOGL_ERROR, " while old timer T%u pending", 
tbf->T);
-
-   LOGPC(DRLCMAC, (T != tbf->T) ? LOGL_ERROR : LOGL_DEBUG, "\n");
-
-   tbf->T = T;
-
-   /* Tunning timers can be safely re-scheduled. */
-   tbf->timer.data = tbf;
-   tbf->timer.cb = _timer_cb;
-
-   osmo_timer_schedule(>timer, seconds, microseconds);
-}
-
 void gprs_rlcmac_tbf::t_stop(enum tbf_timers t, const char *reason)
 {
if (t >= T_MAX) {
@@ -579,10 +557,11 @@
uint8_t i;
 
if (t != T_MAX)
-   return osmo_timer_pending([t]);
+   return osmo_timer_pending([t]);
 
+   /* we don't start with T0 because it's internal timer which requires 
special handling */
for (i = T3169; i < T_MAX; i++)
-   if (osmo_timer_pending([i]))
+   if (osmo_timer_pending([i]))
return true;
 
return false;
@@ -591,17 +570,9 @@
 void gprs_rlcmac_tbf::stop_timers(const char *reason)
 {
uint8_t i;
-   for (i = 0; i < T_MAX; i++)
+   /* we start with T0 because timer reset does not require any special 
handling */
+   for (i = T0; i < T_MAX; i++)
t_stop((enum tbf_timers)i, reason);
-}
-
-void gprs_rlcmac_tbf::stop_timer(const char *reason)
-{
-   if (osmo_timer_pending()) {
-   LOGPTBF(this, LOGL_DEBUG, "stopping timer T%u [%s]\n",
-   T, reason);
-   osmo_timer_del();
-   }
 }
 
 static inline void tbf_timeout_free(struct gprs_rlcmac_tbf *tbf, enum 
tbf_timers t, bool run_diag)
@@ -629,33 +600,36 @@
get_value_string(tbf_timers_names, t), reason);
}
 
-   if (!force && osmo_timer_pending([t]))
+   if 

[PATCH] osmo-pcu[master]: TBF: log timer invocation source

2017-12-21 Thread Max
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/5208

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

TBF: log timer invocation source

When troubleshooting TBF timers we're not only interested in timer
duration but also in the code which triggered it. Let's use LOGPSRC to
log it: wrap t_start() in a macro for convenience.

Change-Id: If5f883ae52c469e5158bad24da9904fdc455582f
Related: OS#2407
---
M src/bts.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
5 files changed, 29 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/08/5208/3

diff --git a/src/bts.cpp b/src/bts.cpp
index 8a8ed02..feead9a 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -554,7 +554,7 @@
LOGP(DRLCMAC, LOGL_DEBUG, "Got IMM.ASS confirm for TLLI=%08x\n", tlli);
 
if (dl_tbf->m_wait_confirm)
-   dl_tbf->t_start(T0, 0, T_ASS_AGCH_USEC, "assignment (AGCH)", 
true);
+   T_START(dl_tbf, T0, 0, T_ASS_AGCH_USEC, "assignment (AGCH)", 
true);
 
return 0;
 }
@@ -687,7 +687,7 @@
tbf->set_ta(ta);
tbf->set_state(GPRS_RLCMAC_FLOW);
tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH);
-   tbf->t_start(T3169, m_bts.t3169, 0, "RACH (new 
UL-TBF)", true);
+   T_START(tbf, T3169, m_bts.t3169, 0, "RACH (new 
UL-TBF)", true);
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] START\n");
LOGPTBF(tbf, LOGL_DEBUG, "RX: [PCU <- BTS] RACH "
"qbit-ta=%d ra=0x%02x, Fn=%d "
diff --git a/src/tbf.cpp b/src/tbf.cpp
index ea27597..520f6c4 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 }
 
 #include 
@@ -403,7 +404,7 @@
tbf->m_contention_resolution_done = 1;
tbf->set_state(GPRS_RLCMAC_ASSIGN);
tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
-   tbf->t_start(T3169, bts->t3169, 0, "allocation (UL-TBF)", true);
+   T_START(tbf, T3169, bts->t3169, 0, "allocation (UL-TBF)", true);
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
OSMO_ASSERT(tbf->ms());
 
@@ -544,10 +545,10 @@
get_value_string(tbf_timers_names, t), reason);
}
 
-   if (osmo_timer_pending([t])) {
+   if (osmo_timer_pending([t])) {
LOGPTBF(this, LOGL_DEBUG, "stopping timer %s [%s]\n",
get_value_string(tbf_timers_names, t), reason);
-   osmo_timer_del([t]);
+   osmo_timer_del([t]);
}
 }
 
@@ -593,18 +594,20 @@
 T_CBACK(T3193, false)
 T_CBACK(T3195, true)
 
-void gprs_rlcmac_tbf::t_start(enum tbf_timers t, uint32_t sec, uint32_t 
microsec, const char *reason, bool force)
+void gprs_rlcmac_tbf::t_start(enum tbf_timers t, uint32_t sec, uint32_t 
microsec, const char *reason, bool force,
+ const char *file, unsigned line)
 {
if (t >= T_MAX) {
-   LOGPTBF(this, LOGL_ERROR, "attempting to start unknown timer %s 
[%s]\n",
-   get_value_string(tbf_timers_names, t), reason);
+   LOGPSRC(DRLCMAC, LOGL_ERROR, file, line, "%s attempting to 
start unknown timer %s [%s]\n",
+   tbf_name(this), get_value_string(tbf_timers_names, t), 
reason);
}
 
if (!force && osmo_timer_pending([t]))
return;
 
-   LOGPTBF(this, LOGL_DEBUG, "%sstarting timer %s [%s] with %u sec. %u 
microsec.\n",
-   osmo_timer_pending([t]) ? "re" : "", 
get_value_string(tbf_timers_names, t), reason, sec, microsec);
+   LOGPSRC(DRLCMAC, LOGL_DEBUG, file, line, "%s %sstarting timer %s [%s] 
with %u sec. %u microsec.\n",
+tbf_name(this), osmo_timer_pending([t]) ? "re" : "",
+get_value_string(tbf_timers_names, t), reason, sec, microsec);
 
T[t].data = this;
 
@@ -625,8 +628,8 @@
T[t].cb = cb_T3195;
break;
default:
-   LOGPTBF(this, LOGL_ERROR, "attempting to set callback for 
unknown timer %s [%s]\n",
-   get_value_string(tbf_timers_names, t), reason);
+   LOGPSRC(DRLCMAC, LOGL_ERROR, file, line, "%s attempting to set 
callback for unknown timer %s [%s]\n",
+tbf_name(this), get_value_string(tbf_timers_names, t), 
reason);
}
 
osmo_timer_schedule([t], sec, microsec);
@@ -719,7 +722,7 @@
if (m_n3101 == bts->bts_data()->n3101) {
LOGP(DRLCMAC, LOGL_NOTICE, " N3101 exceeded MAX (%u)\n", 
bts->bts_data()->n3101);
set_state(GPRS_RLCMAC_RELEASING);
-   t_start(T3169, bts->bts_data()->t3169, 0, "MAX N3101 reached", 
false);
+   T_START(this, T3169, bts->bts_data()->t3169, 0, "MAX N3101 
reached", false);
return;
}
 
@@ -737,7 +740,7 @@