Change in osmo-ttcn3-hacks[master]: pcu: Verify IPv4 address communicated in PCU-originated SNS-CONFIG PDU

2019-03-16 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13295 )

Change subject: pcu: Verify IPv4 address communicated in PCU-originated 
SNS-CONFIG PDU
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13295
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia57100c7833bebc8d77118968c19ab12a3834036
Gerrit-Change-Number: 13295
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Sat, 16 Mar 2019 17:53:59 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ttcn3-hacks[master]: pcu: Verify IPv4 address communicated in PCU-originated SNS-CONFIG PDU

2019-03-16 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13295 )

Change subject: pcu: Verify IPv4 address communicated in PCU-originated 
SNS-CONFIG PDU
..

pcu: Verify IPv4 address communicated in PCU-originated SNS-CONFIG PDU

Prior to this patch, the test accepted anything as list of IPv4
endpoints in the PCU-originated SNS-CONFIG PDU.  Using this patch,
the corect IPv4 address and UDP port number is verified.

Change-Id: Ia57100c7833bebc8d77118968c19ab12a3834036
Related: OS#3845
---
M pcu/PCU_Tests_RAW_SNS.ttcn
1 file changed, 3 insertions(+), 1 deletion(-)

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



diff --git a/pcu/PCU_Tests_RAW_SNS.ttcn b/pcu/PCU_Tests_RAW_SNS.ttcn
index a216dbe..7f71744 100644
--- a/pcu/PCU_Tests_RAW_SNS.ttcn
+++ b/pcu/PCU_Tests_RAW_SNS.ttcn
@@ -39,7 +39,9 @@
 runs on RAW_NS_CT {
log("f_incoming_sns_config(idx=", idx, ")");
var PDU_NS rx;
-   rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v4 
:= ?), idx);
+   var template IP4_Elements v4_elem := { 
tr_SNS_IPv4(mp_nsconfig.remote_ip,
+  
mp_nsconfig.remote_udp_port) };
+   rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v4 
:= v4_elem), idx);
NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], 
ts_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause)));
 }


--
To view, visit https://gerrit.osmocom.org/13295
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia57100c7833bebc8d77118968c19ab12a3834036
Gerrit-Change-Number: 13295
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in libosmocore[master]: gprs_ns: Don't use initial IP/port for anything but SNS

2019-03-16 Thread Harald Welte
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/13291

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

Change subject: gprs_ns: Don't use initial IP/port for anything but SNS
..

gprs_ns: Don't use initial IP/port for anything but SNS

Section 6.2.1 of 3GPP TS 48.016 states:
> A pre-configured endpoint shall not be used for NSE data or signalling
> traffic (with the exception of Size and Configuration procedures) unless
> it is configured by the SGSN using the auto-configuration procedures.

However, in the current SNS implementation, the initial IP/Port over
which we perform the SNS-SIZE + SNS-CONFIG are treated as one of the
normal NS-VCs. Specifically, we also perform the NS-ALIVE procedure on
it, which is clearly wrong.

Let's explicitly create the "initial" NS-VC with data and signalling
weight of 0, and ensure we never start the alive timer or send any
non-SNS PDUs on this connection as long as SNS was not used to change
either of the two weights to non-zero.

While at it, also safeguard against processing any incoming non-SNS
messages on such a all-zero-weight connection.

Change-Id: I16a91a07e5914d123b2ea2f8413b94e7cd518628
Closes: OS#3844
---
M src/gb/gprs_ns.c
1 file changed, 55 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/91/13291/2
--
To view, visit https://gerrit.osmocom.org/13291
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I16a91a07e5914d123b2ea2f8413b94e7cd518628
Gerrit-Change-Number: 13291
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Alexander Chemeris 


Change in libosmocore[master]: gprs_ns_sns: Use "correct" remote IP address for local IP endpoint

2019-03-16 Thread Harald Welte
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/13293

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

Change subject: gprs_ns_sns: Use "correct" remote IP address for local IP 
endpoint
..

gprs_ns_sns: Use "correct" remote IP address for local IP endpoint

we cannot use "nsi->nsip.remote_ip", as this address is not set
when SNS is in use.  We can only have a valid nsi->nsip.remote_ip
if there's only a single NS-VC inside the NS Instance, as this would
connect() the UDP socket to the remote IP/port, breaking any possibility
to have multiple NS-VCs to different SGNS-side IP addresses.

Closes: OS#3845
Change-Id: Ic094621eb01d7458063f531289d5eeadf52bf330
---
M src/gb/gprs_ns_sns.c
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/13293/2
--
To view, visit https://gerrit.osmocom.org/13293
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ic094621eb01d7458063f531289d5eeadf52bf330
Gerrit-Change-Number: 13293
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)


Change in libosmocore[master]: gprs_ns.c: Update comment: IP SNS has recently been implemented

2019-03-16 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13290 )

Change subject: gprs_ns.c: Update comment: IP SNS has recently been implemented
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13290
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8b98621a582a23d0483a5340b4aca7e0bc096e6d
Gerrit-Change-Number: 13290
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Sat, 16 Mar 2019 17:34:14 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in libosmocore[master]: gprs_ns.c: Update comment: IP SNS has recently been implemented

2019-03-16 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13290 )

Change subject: gprs_ns.c: Update comment: IP SNS has recently been implemented
..

gprs_ns.c: Update comment: IP SNS has recently been implemented

Change-Id: I8b98621a582a23d0483a5340b4aca7e0bc096e6d
---
M src/gb/gprs_ns.c
1 file changed, 0 insertions(+), 1 deletion(-)

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



diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 33de2c1..93c219c 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -58,7 +58,6 @@
  * - Only one NS-VC for each NSE: No load-sharing function
  * - NSVCI 65535 and 65534 are reserved for internal use
  * - Only UDP is supported as of now, no frame relay support
- * - The IP Sub-Network-Service (SNS) as specified in 48.016 is not implemented
  * - There are no BLOCK and UNBLOCK timers (yet?)
  *
  * \file gprs_ns.c */

--
To view, visit https://gerrit.osmocom.org/13290
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8b98621a582a23d0483a5340b4aca7e0bc096e6d
Gerrit-Change-Number: 13290
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in osmo-sysmon[master]: openvn: Fix missing break in last commit

2019-03-16 Thread Pau Espin Pedrol
Pau Espin Pedrol has posted comments on this change. ( 
https://gerrit.osmocom.org/13294 )

Change subject: openvn: Fix missing break in last commit
..


Patch Set 2: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13294
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sysmon
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I6d5aeea965cc9d2f417be24dbeca0278d2f83567
Gerrit-Change-Number: 13294
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Sat, 16 Mar 2019 17:32:39 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-sysmon[master]: openvn: Fix missing break in last commit

2019-03-16 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13294 )

Change subject: openvn: Fix missing break in last commit
..

openvn: Fix missing break in last commit

Fixes: a3a92ecc5c6208e495a45b0061ae7ef1b0477622
Change-Id: I6d5aeea965cc9d2f417be24dbeca0278d2f83567
---
M src/osysmon_openvpn.c
1 file changed, 1 insertion(+), 0 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osysmon_openvpn.c b/src/osysmon_openvpn.c
index 5d9af8a..8d88def 100644
--- a/src/osysmon_openvpn.c
+++ b/src/osysmon_openvpn.c
@@ -107,6 +107,7 @@
case 2:
snprintf(buf, sizeof(buf), "%s (%s)", 
vpn->rem_cfg->name, tok);
update_name(vpn->rem_cfg, buf);
+   break;
case 3:
osmo_talloc_replace_string(vpn->rem_cfg, >tun_ip, 
tok);
break;

--
To view, visit https://gerrit.osmocom.org/13294
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sysmon
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6d5aeea965cc9d2f417be24dbeca0278d2f83567
Gerrit-Change-Number: 13294
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in libosmocore[master]: gprs_ns.c: Update comment: IP SNS has recently been implemented

2019-03-16 Thread Pau Espin Pedrol
Pau Espin Pedrol has posted comments on this change. ( 
https://gerrit.osmocom.org/13290 )

Change subject: gprs_ns.c: Update comment: IP SNS has recently been implemented
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13290
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I8b98621a582a23d0483a5340b4aca7e0bc096e6d
Gerrit-Change-Number: 13290
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Comment-Date: Sat, 16 Mar 2019 17:29:05 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-sysmon[master]: openvn: Fix missing break in last commit

2019-03-16 Thread Pau Espin Pedrol
Hello Jenkins Builder,

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

https://gerrit.osmocom.org/13294

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

Change subject: openvn: Fix missing break in last commit
..

openvn: Fix missing break in last commit

Fixes: a3a92ecc5c6208e495a45b0061ae7ef1b0477622
Change-Id: I6d5aeea965cc9d2f417be24dbeca0278d2f83567
---
M src/osysmon_openvpn.c
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sysmon refs/changes/94/13294/2
--
To view, visit https://gerrit.osmocom.org/13294
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sysmon
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I6d5aeea965cc9d2f417be24dbeca0278d2f83567
Gerrit-Change-Number: 13294
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder (102)


Change in osmo-sysmon[master]: openvn: Fix missing break in last commit

2019-03-16 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13294


Change subject: openvn: Fix missing break in last commit
..

openvn: Fix missing break in last commit

Fixes: 778ac848d30b3c814f40dde2e30ea374b12bcc7a
Change-Id: I6d5aeea965cc9d2f417be24dbeca0278d2f83567
---
M src/osysmon_openvpn.c
1 file changed, 1 insertion(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sysmon refs/changes/94/13294/1

diff --git a/src/osysmon_openvpn.c b/src/osysmon_openvpn.c
index 5d9af8a..8d88def 100644
--- a/src/osysmon_openvpn.c
+++ b/src/osysmon_openvpn.c
@@ -107,6 +107,7 @@
case 2:
snprintf(buf, sizeof(buf), "%s (%s)", 
vpn->rem_cfg->name, tok);
update_name(vpn->rem_cfg, buf);
+   break;
case 3:
osmo_talloc_replace_string(vpn->rem_cfg, >tun_ip, 
tok);
break;

--
To view, visit https://gerrit.osmocom.org/13294
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sysmon
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d5aeea965cc9d2f417be24dbeca0278d2f83567
Gerrit-Change-Number: 13294
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 


Change in libosmocore[master]: gprs_ns_sns: Use "correct" remote IP address for local IP endpoint

2019-03-16 Thread Harald Welte
Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/13293


Change subject: gprs_ns_sns: Use "correct" remote IP address for local IP 
endpoint
..

gprs_ns_sns: Use "correct" remote IP address for local IP endpoint

we cannot use "nsi->nsip.remote_ip", as this address is not set
when SNS is in use.  We can only have a valid nsi->nsip.remote_ip
if there's only a single NS-VC inside the NS Instance, as this would
connect() the UDP socket to the remote IP/port, breaking any possibility
to have multiple NS-VCs to different SGNS-side IP addresses.

Change-Id: Ic094621eb01d7458063f531289d5eeadf52bf330
---
M src/gb/gprs_ns_sns.c
1 file changed, 2 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/13293/1

diff --git a/src/gb/gprs_ns_sns.c b/src/gb/gprs_ns_sns.c
index b0ee5d7..cbaa468 100644
--- a/src/gb/gprs_ns_sns.c
+++ b/src/gb/gprs_ns_sns.c
@@ -657,8 +657,8 @@
/* unspecified local address. Figure out which address the 
kernel would use if we
 * wanted to send a packet to the remote_ip */
char local_ip[32];
-   struct in_addr in = { .s_addr = htonl(nsi->nsip.remote_ip) };
-   osmo_sock_local_ip(local_ip, inet_ntoa(in));
+   struct sockaddr_in *daddr = >ip.bts_addr;
+   osmo_sock_local_ip(local_ip, inet_ntoa(daddr->sin_addr));
ip4->ip_addr = inet_addr(local_ip);
}
ip4->udp_port = htons(gss->nsi->nsip.local_port);

--
To view, visit https://gerrit.osmocom.org/13293
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic094621eb01d7458063f531289d5eeadf52bf330
Gerrit-Change-Number: 13293
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 


Change in libosmocore[master]: gprs_ns: Don't use initial IP/port for anything but SNS

2019-03-16 Thread Alexander Chemeris
Alexander Chemeris has posted comments on this change. ( 
https://gerrit.osmocom.org/13291 )

Change subject: gprs_ns: Don't use initial IP/port for anything but SNS
..


Patch Set 1:

(1 comment)

https://gerrit.osmocom.org/#/c/13291/1/src/gb/gprs_ns.c
File src/gb/gprs_ns.c:

https://gerrit.osmocom.org/#/c/13291/1/src/gb/gprs_ns.c@483
PS1, Line 483: i
Typo



--
To view, visit https://gerrit.osmocom.org/13291
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I16a91a07e5914d123b2ea2f8413b94e7cd518628
Gerrit-Change-Number: 13291
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Alexander Chemeris 
Gerrit-Comment-Date: Sat, 16 Mar 2019 14:00:34 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in osmo-ttcn3-hacks[master]: pcu: Test SNS where initial IP/port is not part of configured NS-VCs

2019-03-16 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13292 )

Change subject: pcu: Test SNS where initial IP/port is not part of configured 
NS-VCs
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13292
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie2a017250ca1d5386e2cf42d1945e61d170ac92d
Gerrit-Change-Number: 13292
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Comment-Date: Sat, 16 Mar 2019 13:51:14 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-ttcn3-hacks[master]: pcu: Test SNS where initial IP/port is not part of configured NS-VCs

2019-03-16 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13292 )

Change subject: pcu: Test SNS where initial IP/port is not part of configured 
NS-VCs
..

pcu: Test SNS where initial IP/port is not part of configured NS-VCs

As per section 6.2.1 of 3GPP TS 48.016, the initial IP/port where the
SNS SIZE/CONFIG procedures are being performed is not automatically part
of the later NS-VCs.  This means we shall not perform the NS-ALIVE
procedure or any other procedure beyond SNS with that specific endpoint.

This adds a new TC_sns_1c1u_separate() to test for this behavior.

Change-Id: Ie2a017250ca1d5386e2cf42d1945e61d170ac92d
Related: OS#3844
---
M pcu/PCU_Tests_RAW.ttcn
M pcu/PCU_Tests_RAW_SNS.ttcn
2 files changed, 91 insertions(+), 0 deletions(-)

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



diff --git a/pcu/PCU_Tests_RAW.ttcn b/pcu/PCU_Tests_RAW.ttcn
index 923b086..a30829e 100644
--- a/pcu/PCU_Tests_RAW.ttcn
+++ b/pcu/PCU_Tests_RAW.ttcn
@@ -124,6 +124,37 @@
}
 }

+/* perform outbound NS-ALIVE procedure */
+function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs 
on RAW_NS_CT {
+   timer T := tout;
+   NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
+   T.start;
+   alt {
+   [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) {
+   setverdict(fail, "Received unexpected NS-ALIVE ACK");
+   }
+   [] NSCP[idx].receive { repeat; }
+   [] T.timeout {
+   setverdict(pass);
+   }
+   }
+}
+
+/* ensure no matching message is received within 'tout' */
+function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout 
:= 3.0)
+runs on RAW_Test_CT {
+   timer T := tout;
+   T.start;
+   alt {
+   [] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
+   setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) 
endpoint");
+   }
+   [] T.timeout {
+   setverdict(pass);
+   }
+   }
+}
+
 /* perform outbound NS-BLOCK procedure */
 function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on 
RAW_NS_CT {
NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_BLOCK(cause, 
g_nsconfig[idx].nsvci)));
diff --git a/pcu/PCU_Tests_RAW_SNS.ttcn b/pcu/PCU_Tests_RAW_SNS.ttcn
index cc3cb5b..a216dbe 100644
--- a/pcu/PCU_Tests_RAW_SNS.ttcn
+++ b/pcu/PCU_Tests_RAW_SNS.ttcn
@@ -67,6 +67,19 @@
rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
 }

+/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 
for user */
+function f_outgoing_sns_config_1c1u_separate(template (omit) NsCause cause := 
omit, integer idx := 0)
+runs on RAW_NS_CT {
+   log("f_outgoing_sns_config_1c1u_separate(idx=", idx, ")");
+   var PDU_NS rx;
+   var template (omit) IP4_Elements v4 := { 
ts_SNS_IPv4(g_nsconfig[1].local_ip,
+
g_nsconfig[1].local_udp_port, 1, 0),
+
ts_SNS_IPv4(g_nsconfig[2].local_ip,
+
g_nsconfig[2].local_udp_port, 0, 1) };
+   NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], 
ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
+   rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
+}
+
 function f_outgoing_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t 
w_user := 1, integer idx := 0)
 runs on RAW_NS_CT {
log("f_outgoing_sns_add(idx_add=", idx_add, ")");
@@ -211,6 +224,52 @@
setverdict(pass);
 }

+private function f_sns_bringup_1c1u_separate() runs on RAW_Test_CT {
+   /* Activate two NS codec ports */
+   f_init_ns_codec();
+   f_init_ns_codec(1);
+   f_init_ns_codec(2);
+   f_init_pcuif();
+   /* Perform Size + BSS-originated config */
+   f_incoming_sns_size();
+   f_incoming_sns_config();
+   /* perform SGSN-originated config using idx==0 for signalling and 
idx==1 for user traffic */
+   f_outgoing_sns_config_1c1u_separate();
+
+   /* wait for one ALIVE cycle, then ACK any further ALIVE in the 
background
+* for both NS-VCs */
+   as_rx_alive_tx_ack(oneshot := true, idx := 1);
+   activate(as_rx_alive_tx_ack(idx := 1));
+   as_rx_alive_tx_ack(oneshot := true, idx := 2);
+   activate(as_rx_alive_tx_ack(idx := 2));
+   /* ensure there's no NS-ALIVE received on idx==0 */
+   f_ensure_no_ns(t_NS_ALIVE, idx := 0);
+
+   /* perform outgoing ALIVE procedure for both NS-VCs */
+   f_outgoing_ns_alive(1);
+   f_outgoing_ns_alive(2);
+   /* ensure there's no response to NS-ALIVE sent on idx==0 */
+   f_outgoing_ns_alive_no_ack(idx := 0);
+
+   /* Expect BVC-RESET for signaling BVCI=0 and ptp BVCI */
+   as_rx_bvc_reset_tx_ack(0, oneshot := 

Change in osmo-ttcn3-hacks[master]: pcu: Test SNS where initial IP/port is not part of configured NS-VCs

2019-03-16 Thread Harald Welte
Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/13292


Change subject: pcu: Test SNS where initial IP/port is not part of configured 
NS-VCs
..

pcu: Test SNS where initial IP/port is not part of configured NS-VCs

As per section 6.2.1 of 3GPP TS 48.016, the initial IP/port where the
SNS SIZE/CONFIG procedures are being performed is not automatically part
of the later NS-VCs.  This means we shall not perform the NS-ALIVE
procedure or any other procedure beyond SNS with that specific endpoint.

This adds a new TC_sns_1c1u_separate() to test for this behavior.

Change-Id: Ie2a017250ca1d5386e2cf42d1945e61d170ac92d
Related: OS#3844
---
M pcu/PCU_Tests_RAW.ttcn
M pcu/PCU_Tests_RAW_SNS.ttcn
2 files changed, 91 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/92/13292/1

diff --git a/pcu/PCU_Tests_RAW.ttcn b/pcu/PCU_Tests_RAW.ttcn
index 923b086..a30829e 100644
--- a/pcu/PCU_Tests_RAW.ttcn
+++ b/pcu/PCU_Tests_RAW.ttcn
@@ -124,6 +124,37 @@
}
 }

+/* perform outbound NS-ALIVE procedure */
+function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs 
on RAW_NS_CT {
+   timer T := tout;
+   NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
+   T.start;
+   alt {
+   [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) {
+   setverdict(fail, "Received unexpected NS-ALIVE ACK");
+   }
+   [] NSCP[idx].receive { repeat; }
+   [] T.timeout {
+   setverdict(pass);
+   }
+   }
+}
+
+/* ensure no matching message is received within 'tout' */
+function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout 
:= 3.0)
+runs on RAW_Test_CT {
+   timer T := tout;
+   T.start;
+   alt {
+   [] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
+   setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) 
endpoint");
+   }
+   [] T.timeout {
+   setverdict(pass);
+   }
+   }
+}
+
 /* perform outbound NS-BLOCK procedure */
 function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on 
RAW_NS_CT {
NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_BLOCK(cause, 
g_nsconfig[idx].nsvci)));
diff --git a/pcu/PCU_Tests_RAW_SNS.ttcn b/pcu/PCU_Tests_RAW_SNS.ttcn
index cc3cb5b..a216dbe 100644
--- a/pcu/PCU_Tests_RAW_SNS.ttcn
+++ b/pcu/PCU_Tests_RAW_SNS.ttcn
@@ -67,6 +67,19 @@
rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
 }

+/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 
for user */
+function f_outgoing_sns_config_1c1u_separate(template (omit) NsCause cause := 
omit, integer idx := 0)
+runs on RAW_NS_CT {
+   log("f_outgoing_sns_config_1c1u_separate(idx=", idx, ")");
+   var PDU_NS rx;
+   var template (omit) IP4_Elements v4 := { 
ts_SNS_IPv4(g_nsconfig[1].local_ip,
+
g_nsconfig[1].local_udp_port, 1, 0),
+
ts_SNS_IPv4(g_nsconfig[2].local_ip,
+
g_nsconfig[2].local_udp_port, 0, 1) };
+   NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], 
ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
+   rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
+}
+
 function f_outgoing_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t 
w_user := 1, integer idx := 0)
 runs on RAW_NS_CT {
log("f_outgoing_sns_add(idx_add=", idx_add, ")");
@@ -211,6 +224,52 @@
setverdict(pass);
 }

+private function f_sns_bringup_1c1u_separate() runs on RAW_Test_CT {
+   /* Activate two NS codec ports */
+   f_init_ns_codec();
+   f_init_ns_codec(1);
+   f_init_ns_codec(2);
+   f_init_pcuif();
+   /* Perform Size + BSS-originated config */
+   f_incoming_sns_size();
+   f_incoming_sns_config();
+   /* perform SGSN-originated config using idx==0 for signalling and 
idx==1 for user traffic */
+   f_outgoing_sns_config_1c1u_separate();
+
+   /* wait for one ALIVE cycle, then ACK any further ALIVE in the 
background
+* for both NS-VCs */
+   as_rx_alive_tx_ack(oneshot := true, idx := 1);
+   activate(as_rx_alive_tx_ack(idx := 1));
+   as_rx_alive_tx_ack(oneshot := true, idx := 2);
+   activate(as_rx_alive_tx_ack(idx := 2));
+   /* ensure there's no NS-ALIVE received on idx==0 */
+   f_ensure_no_ns(t_NS_ALIVE, idx := 0);
+
+   /* perform outgoing ALIVE procedure for both NS-VCs */
+   f_outgoing_ns_alive(1);
+   f_outgoing_ns_alive(2);
+   /* ensure there's no response to NS-ALIVE sent on idx==0 */
+   f_outgoing_ns_alive_no_ack(idx := 0);
+
+   /* Expect BVC-RESET for signaling BVCI=0 and ptp BVCI */
+   as_rx_bvc_reset_tx_ack(0, oneshot := true, 

Change in libosmocore[master]: gprs_ns.c: Update comment: IP SNS has recently been implemented

2019-03-16 Thread Harald Welte
Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/13290


Change subject: gprs_ns.c: Update comment: IP SNS has recently been implemented
..

gprs_ns.c: Update comment: IP SNS has recently been implemented

Change-Id: I8b98621a582a23d0483a5340b4aca7e0bc096e6d
---
M src/gb/gprs_ns.c
1 file changed, 0 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/90/13290/1

diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 33de2c1..93c219c 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -58,7 +58,6 @@
  * - Only one NS-VC for each NSE: No load-sharing function
  * - NSVCI 65535 and 65534 are reserved for internal use
  * - Only UDP is supported as of now, no frame relay support
- * - The IP Sub-Network-Service (SNS) as specified in 48.016 is not implemented
  * - There are no BLOCK and UNBLOCK timers (yet?)
  *
  * \file gprs_ns.c */

--
To view, visit https://gerrit.osmocom.org/13290
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8b98621a582a23d0483a5340b4aca7e0bc096e6d
Gerrit-Change-Number: 13290
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 


Change in libosmocore[master]: gprs_ns: Don't use initial IP/port for anything but SNS

2019-03-16 Thread Harald Welte
Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/13291


Change subject: gprs_ns: Don't use initial IP/port for anything but SNS
..

gprs_ns: Don't use initial IP/port for anything but SNS

Section 6.2.1 of 3GPP TS 48.016 states:
> A pre-configured endpoint shall not be used for NSE data or signalling
> traffic (with the exception of Size and Configuration procedures) unless
> it is configured by the SGSN using the auto-configuration procedures.

However, in the current SNS implementation, the initial IP/Port over
which we perform the SNS-SIZE + SNS-CONFIG are treated as one of the
normal NS-VCs. Specifically, we also perform the NS-ALIVE procedure on
it, which is clearly wrong.

Let's explicitly create the "initial" NS-VC with data and signalling
weight of 0, and ensure we never start the alive timer or send any
non-SNS PDUs on this connection as long as SNS was not used to change
either of the two weights to non-zero.

While at it, also safeguard against processing any incoming non-SNS
messages on such a all-zero-weight connection.

Change-Id: I16a91a07e5914d123b2ea2f8413b94e7cd518628
Closes: OS#3844
---
M src/gb/gprs_ns.c
1 file changed, 55 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/91/13291/1

diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 93c219c..6508aa7 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -195,6 +195,14 @@
LOGP(DNS, LOGL_ERROR, "TX failed (%d) to peer %s\n",
\
rc, gprs_ns_ll_str(nsvc));

+static bool nsvc_is_not_used(const struct gprs_nsvc *nsvc)
+{
+   if (nsvc->data_weight == 0 && nsvc->sig_weight == 0)
+   return true;
+   else
+   return false;
+}
+
 struct msgb *gprs_ns_msgb_alloc(void)
 {
struct msgb *msg = msgb_alloc_headroom(NS_ALLOC_SIZE, NS_ALLOC_HEADROOM,
@@ -444,12 +452,40 @@
 static int nsip_sendmsg(struct gprs_nsvc *nsvc, struct msgb *msg);
 extern int grps_ns_frgre_sendmsg(struct gprs_nsvc *nsvc, struct msgb *msg);

+static bool ns_is_sns(uint8_t pdu_type)
+{
+   switch (pdu_type) {
+   case SNS_PDUT_CONFIG:
+   case SNS_PDUT_ACK:
+   case SNS_PDUT_ADD:
+   case SNS_PDUT_CHANGE_WEIGHT:
+   case SNS_PDUT_DELETE:
+   case SNS_PDUT_CONFIG_ACK:
+   case SNS_PDUT_SIZE:
+   case SNS_PDUT_SIZE_ACK:
+   return true;
+   default:
+   return false;
+   }
+}
+
 static int gprs_ns_tx(struct gprs_nsvc *nsvc, struct msgb *msg)
 {
+   struct gprs_ns_hdr *nsh = (struct gprs_ns_hdr *) msg->l2h;
int ret;

log_set_context(LOG_CTX_GB_NSVC, nsvc);

+   /* A pre-configured endpoint shall not be used for NSE data or 
signalling
+* traffic (with the exception of Size and Configuration procedures) 
unless it
+* is configured by the SGSN using the auto-configuration procedures. */
+   if (nsvc_is_not_used(nsvc) && !ns_is_sns(nsh->pdu_type) && 
nsh->pdu_type != NS_PDUT_STATUS) {
+   LOGP(DNS, LOGL_NOTICE, "Not transmitting %s on 
unused/pre-configured eindpoint\n",
+   get_value_string(gprs_ns_pdu_strings, nsh->pdu_type));
+   msgb_free(msg);
+   return -EINVAL;
+   }
+
/* Increment number of Uplink bytes */
rate_ctr_inc(>ctrg->ctr[NS_CTR_PKTS_OUT]);
rate_ctr_add(>ctrg->ctr[NS_CTR_BYTES_OUT], msgb_l2len(msg));
@@ -1690,6 +1726,13 @@
rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_PKTS_IN]);
rate_ctr_add(&(*nsvc)->ctrg->ctr[NS_CTR_BYTES_IN], msgb_l2len(msg));

+   if (nsvc_is_not_used(*nsvc) && !ns_is_sns(nsh->pdu_type) && 
nsh->pdu_type != NS_PDUT_STATUS) {
+   LOGP(DNS, LOGL_NOTICE, "NSEI=%u Rx %s on unused/pre-configured 
endpoint, discarding\n",
+   (*nsvc)->nsei, get_value_string(gprs_ns_pdu_strings, 
nsh->pdu_type));
+   gprs_ns_tx_status(*nsvc, NS_CAUSE_PROTO_ERR_UNSPEC, 0, msg);
+   return 0;
+   }
+
switch (nsh->pdu_type) {
case NS_PDUT_ALIVE:
/* If we're dead and blocked and suddenly receive a
@@ -2116,8 +2159,14 @@
 * require some massive code and API changes compared to existing 
libosmogb,
 * so let's keep the old logic. */
nsvc = gprs_nsvc_by_rem_addr(nsi, dest);
-   if (!nsvc)
-   nsvc = gprs_nsvc_create(nsi, nsvci);
+   if (!nsvc) {
+   /* create NSVC with 0 data + signalling weight. This is illegal 
in SNS
+* and can hence only be created locally and serves as 
indication that
+* this NS-VC shall not be used for anything except SNS 
_unless_ it is
+* modified via SNS-{CONFIG,CHANGEWEIGHT,ADD} to become part of 
the
+* active NS-VCs */
+   nsvc = gprs_nsvc_create2(nsi, nsvci, 0, 0);
+   }
 

Change in osmo-msc[master]: vlr_subscr: use osmo_use_count

2019-03-16 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13136 )

Change subject: vlr_subscr: use osmo_use_count
..


Patch Set 2:

(3 comments)

https://gerrit.osmocom.org/#/c/13136/2/src/libmsc/gsm_04_08.c
File src/libmsc/gsm_04_08.c:

https://gerrit.osmocom.org/#/c/13136/2/src/libmsc/gsm_04_08.c@1804
PS2, Line 1804: "conn"
no #define here?  See my comment about in-line literal strings vs. #defines and 
the risk of undiscovered typos in the use_count libosmocore patchset.


https://gerrit.osmocom.org/#/c/13136/2/src/libmsc/ran_conn.c
File src/libmsc/ran_conn.c:

https://gerrit.osmocom.org/#/c/13136/2/src/libmsc/ran_conn.c@555
PS2, Line 555:  vlr_subscr_put(conn->vsub, "conn");
no #define here?  See my comment about in-line literal strings vs. #defines and 
the risk of undiscovered typos in the use_count libosmocore patchset.


https://gerrit.osmocom.org/#/c/13136/2/src/libmsc/sgs_iface.c
File src/libmsc/sgs_iface.c:

https://gerrit.osmocom.org/#/c/13136/2/src/libmsc/sgs_iface.c@101
PS2, Line 101:  vlr_subscr_get(vsub, "conn");
no #define here?  See my comment about in-line literal strings vs. #defines and 
the risk of undiscovered typos in the use_count libosmocore patchset.



--
To view, visit https://gerrit.osmocom.org/13136
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib06d030e8464abe415ff597d462ed40eeddef475
Gerrit-Change-Number: 13136
Gerrit-PatchSet: 2
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Harald Welte 
Gerrit-CC: Max 
Gerrit-Comment-Date: Sat, 16 Mar 2019 08:06:55 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No


Change in libosmocore[master]: add osmo_use_count API

2019-03-16 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13121 )

Change subject: add osmo_use_count API
..


Patch Set 5:

(1 comment)

https://gerrit.osmocom.org/#/c/13121/5/include/osmocom/core/use_count.h
File include/osmocom/core/use_count.h:

https://gerrit.osmocom.org/#/c/13121/5/include/osmocom/core/use_count.h@154
PS5, Line 154: * foo_get(foo, "bar");   // one 
osmo_use_count_entry was allocated
 :  * foo_get(foo, "baz");   // a second 
osmo_use_count_entry was allocated
 :  * foo_get(foo, "baz");   // still two entries
 :  *
 :  * printf("use: %s\n", 
osmo_use_count_name_buf(namebuf, sizeof(namebuf), >use_count));
 :  * // "use: 3 (bar,2*baz)"
 :  *
 :  * foo_put(foo, "bar");   // still two entries, 
one entry is idle ("bar"=0)
 :  * foo_put(foo, "baz");
I know this is just an example, but at least in any code that eveer uses this I 
strongly suggest to not use literal strings here, but have #defines for it.  
The rationale is quite simple: If you have a typo in the enum, then it will 
give a compile-time failure.  If you have a typo in a literal string that you 
write dozens of time in your code, it is hard to spot by the human eye and the 
compiler will not warn/fail.  You will only see the error at runtime, which is 
the worst outcome.



-- 
To view, visit https://gerrit.osmocom.org/13121
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ife31e6798b4e728a23913179e346552a7dd338c0
Gerrit-Change-Number: 13121
Gerrit-PatchSet: 5
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-CC: Max 
Gerrit-Comment-Date: Sat, 16 Mar 2019 08:01:48 +
Gerrit-HasComments: Yes
Gerrit-HasLabels: No