Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-iuh/+/43593?usp=email )
Change subject: hnb-test: count N(SD) over uplink MM messages
......................................................................
hnb-test: count N(SD) over uplink MM messages
Setting N(SD) on the Authentication Response earlier in this series
fixed that one message. The TMSI Reallocation Complete that follows the
Location Updating Accept still went out with N(SD) = 0, so osmo-msc
dropped it as a duplicate as well and released the Location Update with
a reject when the TMSI reallocation timer expired.
Keep the send sequence number per signalling connection instead of
setting it per message. The Location Updating Request in the
InitialUE-Message is number 0, and every later uplink MM message, the
Identity Response, the Authentication Response and the TMSI
Reallocation Complete, takes the next value, two bits wide as on UTRAN
(3GPP TS 24.007 section 11.2.3.2.3).
This replaces the constant introduced earlier with a counter, so the
hard-coded value in gen_nas_auth_resp() goes away.
Change-Id: Ieceaee806be43a41e7662e8fa8d119e4e663a3d9
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M tests/hnb-test.c
M tests/hnb-test.h
2 files changed, 27 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/93/43593/1
diff --git a/tests/hnb-test.c b/tests/hnb-test.c
index be9f170..86ee5a9 100644
--- a/tests/hnb-test.c
+++ b/tests/hnb-test.c
@@ -191,11 +191,24 @@
return 0;
}
-static struct msgb *gen_nas_id_resp()
+/* Message type octet of an uplink MM message with the send sequence number
+ * N(SD) in bits 7 and 6 (3GPP TS 24.007 section 11.2.3.2.3). The network
+ * drops a message whose N(SD) is not the one it expects as a duplicate,
+ * so every uplink MM message on a connection has to count: the Location
+ * Updating Request in the InitialUE-Message is number 0. */
+static uint8_t mm_msg_type_nsd(struct hnb_test *hnb, uint8_t msg_type)
+{
+ struct hnbtest_chan *chan = hnb->cur_chan ? hnb->cur_chan : hnb->cs.chan;
+ uint8_t n_sd = chan ? chan->n_sd++ : 0;
+
+ return (msg_type & 0x3f) | ((n_sd & 0x03) << 6);
+}
+
+static struct msgb *gen_nas_id_resp(struct hnb_test *hnb)
{
uint8_t id_resp[] = {
GSM48_PDISC_MM,
- GSM48_MT_MM_ID_RESP,
+ mm_msg_type_nsd(hnb, GSM48_MT_MM_ID_RESP),
/* IMEISV */
0x09, /* len */
0x03, /* first digit (0000) + even (0) + id IMEISV (011) */
@@ -206,11 +219,11 @@
return ranap_new_msg_dt(0, id_resp, sizeof(id_resp));
}
-static struct msgb *gen_nas_tmsi_realloc_compl()
+static struct msgb *gen_nas_tmsi_realloc_compl(struct hnb_test *hnb)
{
uint8_t id_resp[] = {
GSM48_PDISC_MM,
- GSM48_MT_MM_TMSI_REALL_COMPL,
+ mm_msg_type_nsd(hnb, GSM48_MT_MM_TMSI_REALL_COMPL),
};
return ranap_new_msg_dt(0, id_resp, sizeof(id_resp));
@@ -219,10 +232,8 @@
/* MM Authentication Response, 3GPP TS 24.008 section 9.2.3. For GSM AKA
* only the four octet SRES is present. For UMTS AKA the first four octets
* of RES go into that field and the rest into the Authentication Response
- * Parameter (extension) IE, as a UE does. The message type octet carries
- * N(SD) = 1: it is the second uplink MM message on the connection, after
- * the Location Updating Request (TS 24.007 section 11.2.3.2.3). */
-static struct msgb *gen_nas_auth_resp(const uint8_t *res, unsigned int res_len)
+ * Parameter (extension) IE, as a UE does. */
+static struct msgb *gen_nas_auth_resp(struct hnb_test *hnb, const uint8_t *res, unsigned int res_len)
{
uint8_t buf[2 + 4 + 2 + 12];
unsigned int len = 0;
@@ -230,7 +241,7 @@
OSMO_ASSERT(res_len >= 4 && res_len <= 16);
buf[len++] = GSM48_PDISC_MM;
- buf[len++] = 0x40 | GSM48_MT_MM_AUTH_RESP;
+ buf[len++] = mm_msg_type_nsd(hnb, GSM48_MT_MM_AUTH_RESP);
memcpy(buf + len, res, 4);
len += 4;
if (res_len > 4) {
@@ -439,7 +450,7 @@
if (res_len < 0)
return res_len;
- return hnb_test_tx_dt(hnb, gen_nas_auth_resp(res, res_len));
+ return hnb_test_tx_dt(hnb, gen_nas_auth_resp(hnb, res, res_len));
}
void hnb_test_tx_iu_release_req(struct hnb_test *hnb)
@@ -473,13 +484,13 @@
switch (msg_type) {
case GSM48_MT_MM_ID_REQ:
- return hnb_test_tx_dt(hnb, gen_nas_id_resp());
+ return hnb_test_tx_dt(hnb, gen_nas_id_resp(hnb));
case GSM48_MT_MM_LOC_UPD_ACCEPT:
if (hnb_test_nas_rx_lu_accept(gh, len, &sent_tmsi))
return -1;
if (sent_tmsi)
- return hnb_test_tx_dt(hnb, gen_nas_tmsi_realloc_compl());
+ return hnb_test_tx_dt(hnb, gen_nas_tmsi_realloc_compl(hnb));
else
return 0;
@@ -965,6 +976,7 @@
chan->imsi = talloc_strdup(chan, argv[1]);
chan->conn_id = conn_id;
conn_id++;
+ chan->n_sd = 1; /* the Location Updating Request below is number 0 */
msg = gen_initue_lu(chan->is_ps, chan->conn_id, chan->imsi);
rua = rua_new_conn(chan->is_ps, chan->conn_id, msg);
diff --git a/tests/hnb-test.h b/tests/hnb-test.h
index 44fba35..b3a0c11 100644
--- a/tests/hnb-test.h
+++ b/tests/hnb-test.h
@@ -43,6 +43,9 @@
int is_ps;
uint32_t conn_id;
char *imsi;
+ /*! N(SD) of the next uplink MM message on this connection,
+ * 3GPP TS 24.007 section 11.2.3.2.3 */
+ uint8_t n_sd;
};
struct hnb_test {
--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/43593?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: Ieceaee806be43a41e7662e8fa8d119e4e663a3d9
Gerrit-Change-Number: 43593
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-iuh/+/43594?usp=email )
Change subject: hnb-test: decode CO messages as the RAN side
......................................................................
hnb-test: decode CO messages as the RAN side
hnb-test plays the RNC, but decoded the RANAP carried in a RUA
DirectTransfer with ranap_cn_rx_co(), the decoder for messages a CN
receives. That table has DirectTransfer, SecurityModeControl and Iu
Release, but no RAB Assignment, so the request an SGSN sends after a
successful Create PDP Context ended in
Received RANAP Procedure RAB Assignment (CO, IM) from RNC. Decode not
implemented
and no RAB Assignment Response was ever sent.
Decode connection oriented messages with ranap_ran_rx_co() instead.
Its table in ranap_common_ran.c has the RAB Assignment procedure code
along with Common ID, Security Mode Control, Iu Release and Direct
Transfer, which is what a CN sends to a RAN.
libosmo-ranap has no RAN-side connectionless decoder, so Paging and
Reset Acknowledge keep using ranap_cn_rx_cl().
Change-Id: Ibdf7fa518d15ebdb247fa349ee4df7b3888ca455
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M tests/hnb-test-rua.c
1 file changed, 9 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/94/43594/1
diff --git a/tests/hnb-test-rua.c b/tests/hnb-test-rua.c
index b84087c..6030555 100644
--- a/tests/hnb-test-rua.c
+++ b/tests/hnb-test-rua.c
@@ -2,6 +2,7 @@
#include <asn1c/ANY.h>
#include <osmocom/core/talloc.h>
#include <osmocom/ranap/ranap_common_cn.h>
+#include <osmocom/ranap/ranap_common_ran.h>
#include <osmocom/rua/rua_ies_defs.h>
#include "hnb-test.h"
@@ -25,7 +26,14 @@
else
hnb->cur_chan = hnb->cs.chan;
- rc = ranap_cn_rx_co(hnb_test_rua_dt_handle_ranap, hnb, ies.ranaP_Message.buf, ies.ranaP_Message.size);
+ /* hnb-test is the RAN side of Iu: decode the connection oriented
+ * messages the CN sends to an RNC (RAB Assignment, Security Mode
+ * Command, Common ID, Iu Release Command, Direct Transfer). The
+ * CN-side decoder used before knows only what a CN receives and
+ * dropped RAB Assignment as "Decode not implemented". There is no
+ * RAN-side connectionless decoder in libosmo-ranap, so the
+ * connectionless path keeps the CN-side one. */
+ rc = ranap_ran_rx_co(hnb_test_rua_dt_handle_ranap, hnb, ies.ranaP_Message.buf, ies.ranaP_Message.size);
hnb->cur_chan = NULL;
--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/43594?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: Ibdf7fa518d15ebdb247fa349ee4df7b3888ca455
Gerrit-Change-Number: 43594
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-iuh/+/43589?usp=email )
Change subject: hnbap, rua, sabp: link against libosmo-ranap
......................................................................
hnbap, rua, sabp: link against libosmo-ranap
libosmo-hnbap, libosmo-rua and libosmo-sabp call asn1_xer_print() and
talloc_asn1_ctx, both defined in iu_helpers.c and shipped in
libosmo-ranap, but none of the three declares that dependency.
GNU ld leaves such references unresolved in a shared object and lets
the executable supply them later, even with -no-undefined, so nothing
shows on GNU/Linux. Darwin's ld64 refuses:
Undefined symbols for architecture arm64: _asn1_xer_print,
_talloc_asn1_ctx
while linking libosmo-rua.la, libosmo-hnbap.la and libosmo-sabp.la.
Add libosmo-ranap.la to the LIBADD of each library and "Requires:
libosmo-ranap" to the three .pc.in files, so both the library itself
and a consumer that links only one of them record the dependency.
There is no cycle: nm on the built libosmo-ranap shows it defines both
symbols and references nothing from hnbap, rua or sabp. On GNU/Linux
the only change is an explicit DT_NEEDED entry.
Change-Id: Ic936829788536bc1b1973a5ed3082a82cbf90d04
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M libosmo-hnbap.pc.in
M libosmo-rua.pc.in
M libosmo-sabp.pc.in
M src/Makefile.am
4 files changed, 10 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/89/43589/1
diff --git a/libosmo-hnbap.pc.in b/libosmo-hnbap.pc.in
index db05756..49eae7c 100644
--- a/libosmo-hnbap.pc.in
+++ b/libosmo-hnbap.pc.in
@@ -6,5 +6,6 @@
Name: Osmocom HNBAP protocol library
Description: C Utility Library
Version: @VERSION@
+Requires: libosmo-ranap
Libs: -L${libdir} -losmo-hnbap
Cflags: -I${includedir}/
diff --git a/libosmo-rua.pc.in b/libosmo-rua.pc.in
index b9bd1d4..893e4b5 100644
--- a/libosmo-rua.pc.in
+++ b/libosmo-rua.pc.in
@@ -6,5 +6,6 @@
Name: Osmocom RUA protocol library
Description: C Utility Library
Version: @VERSION@
+Requires: libosmo-ranap
Libs: -L${libdir} -losmo-rua
Cflags: -I${includedir}/
diff --git a/libosmo-sabp.pc.in b/libosmo-sabp.pc.in
index fd0c2d4..7cd6a6d 100644
--- a/libosmo-sabp.pc.in
+++ b/libosmo-sabp.pc.in
@@ -6,5 +6,6 @@
Name: Osmocom SABP protocol library
Description: C Utility Library
Version: @VERSION@
+Requires: libosmo-ranap
Libs: -L${libdir} -losmo-sabp
Cflags: -I${includedir}/
diff --git a/src/Makefile.am b/src/Makefile.am
index 343fa53..e8962fa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,10 +65,14 @@
RANAP_LIBVERSION=12:0:5
RUA_LIBVERSION=2:0:2
SABP_LIBVERSION=3:0:2
+# libosmo-hnbap, libosmo-rua and libosmo-sabp use asn1_xer_print and
+# talloc_asn1_ctx, both defined in iu_helpers.c of libosmo-ranap, so they
+# depend on it. Link it explicitly: GNU ld lets a shared object keep such a
+# reference unresolved despite -no-undefined, ld64 on Darwin does not.
lib_LTLIBRARIES = libosmo-hnbap.la libosmo-ranap.la libosmo-rua.la libosmo-sabp.la
libosmo_hnbap_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(HNBAP_LIBVERSION) -no-undefined
libosmo_hnbap_la_LIBADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOVTY_LIBS) $(OSMOSIGTRAN_LIBS) \
- $(ASN1C_LIBS) hnbap/libosmo-asn1-hnbap.la
+ $(ASN1C_LIBS) hnbap/libosmo-asn1-hnbap.la libosmo-ranap.la
libosmo_hnbap_la_SOURCES = hnbap_common.c hnbap_encoder.c hnbap_decoder.c
libosmo_ranap_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(RANAP_LIBVERSION) -no-undefined
@@ -79,12 +83,12 @@
libosmo_rua_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(RUA_LIBVERSION) -no-undefined
libosmo_rua_la_LIBADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOVTY_LIBS) $(OSMOSIGTRAN_LIBS) \
- $(ASN1C_LIBS) rua/libosmo-asn1-rua.la
+ $(ASN1C_LIBS) rua/libosmo-asn1-rua.la libosmo-ranap.la
libosmo_rua_la_SOURCES = rua_common.c rua_encoder.c rua_decoder.c rua_msg_factory.c
libosmo_sabp_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(SABP_LIBVERSION) -no-undefined
libosmo_sabp_la_LIBADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOVTY_LIBS) $(OSMOSIGTRAN_LIBS) \
- $(ASN1C_LIBS) sabp/libosmo-asn1-sabp.la
+ $(ASN1C_LIBS) sabp/libosmo-asn1-sabp.la libosmo-ranap.la
libosmo_sabp_la_SOURCES = sabp_common.c sabp_encoder.c sabp_decoder.c
--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/43589?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: Ic936829788536bc1b1973a5ed3082a82cbf90d04
Gerrit-Change-Number: 43589
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-iuh/+/43588?usp=email )
Change subject: build: rewrite generated includes without sed -i
......................................................................
build: rewrite generated includes without sed -i
The gen_*.stamp rules in src/Makefile.am post-process the output of
asn1tostruct.py with "sed -i 'script' file...". The -i option is not
portable. GNU sed takes an optional suffix attached to the option; BSD
sed, on macOS and the other BSDs, takes the next argument as the backup
suffix, so it reads the script as a suffix and the first file name as
the script. The build stops in src/ before a single object is compiled:
sed: 1: "hnbap_encoder.c": unterminated substitute pattern
All eight rules are affected, for hnbap, rua, ranap and sabp.
Loop over the files instead and write each substitution through a
temporary file that then replaces the original. That uses only the
portable form of sed and gives the same result with either dialect.
Change-Id: I6f803fcfb5dd81f0a0b2998b00622f6a19afc5da
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M src/Makefile.am
1 file changed, 27 insertions(+), 8 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/88/43588/1
diff --git a/src/Makefile.am b/src/Makefile.am
index 343fa53..f668c7b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,9 @@
SUBDIRS = hnbap rua ranap sabp
# Build {hnbap,rua,ranap}_{encoder,decoder}.c using asn1tostruct
+# The generated files get their include lines rewritten below. BSD sed on
+# macOS takes the argument after -i as a backup suffix, so "sed -i 'script'
+# file" is not portable; write through a temporary file instead.
ASN1_ROOT = $(top_srcdir)/asn1
ASN1TOSTRUCT = $(ASN1_ROOT)/utils/asn1tostruct.py
BUILT_SOURCES = hnbap_decoder.c hnbap_encoder.c rua_decoder.c rua_encoder.c sabp_encoder.c sabp_decoder.c \
@@ -9,8 +12,12 @@
gen_hnbap.stamp: $(ASN1_ROOT)/hnbap/HNBAP-PDU-Contents.asn $(ASN1TOSTRUCT)
$(ASN1TOSTRUCT) -p HNBAP_ -f $<
# We also need to replace the include in the newly generated .c files:
- sed -i 's,^#include "hnbap_ies_defs.h",#include <osmocom/hnbap/hnbap_ies_defs.h>,' hnbap_encoder.c hnbap_decoder.c
- sed -i 's,^#include "hnbap_common.h",#include <osmocom/hnbap/hnbap_common.h>,' hnbap_encoder.c hnbap_decoder.c hnbap_ies_defs.h
+ for f in hnbap_encoder.c hnbap_decoder.c; do \
+ sed 's,^#include "hnbap_ies_defs.h",#include <osmocom/hnbap/hnbap_ies_defs.h>,' $$f > $$f.tmp && mv $$f.tmp $$f || exit 1; \
+ done
+ for f in hnbap_encoder.c hnbap_decoder.c hnbap_ies_defs.h; do \
+ sed 's,^#include "hnbap_common.h",#include <osmocom/hnbap/hnbap_common.h>,' $$f > $$f.tmp && mv $$f.tmp $$f || exit 1; \
+ done
mv hnbap_ies_defs.h $(top_builddir)/include/osmocom/hnbap/
# this is ugly ^. hnbap_ies_defs.h is generated from asn1tostruct.py here, but
# it should live in include/osmocom/hnbap/.
@@ -21,8 +28,12 @@
gen_rua.stamp: $(ASN1_ROOT)/rua/RUA-PDU-Contents.asn $(ASN1TOSTRUCT)
$(ASN1TOSTRUCT) -p RUA_ -f $<
# We also need to replace the include in the newly generated .c files:
- sed -i 's,^#include "rua_ies_defs.h",#include <osmocom/rua/rua_ies_defs.h>,' rua_encoder.c rua_decoder.c
- sed -i 's,^#include "rua_common.h",#include <osmocom/rua/rua_common.h>,' rua_encoder.c rua_decoder.c rua_ies_defs.h
+ for f in rua_encoder.c rua_decoder.c; do \
+ sed 's,^#include "rua_ies_defs.h",#include <osmocom/rua/rua_ies_defs.h>,' $$f > $$f.tmp && mv $$f.tmp $$f || exit 1; \
+ done
+ for f in rua_encoder.c rua_decoder.c rua_ies_defs.h; do \
+ sed 's,^#include "rua_common.h",#include <osmocom/rua/rua_common.h>,' $$f > $$f.tmp && mv $$f.tmp $$f || exit 1; \
+ done
mv rua_ies_defs.h $(top_builddir)/include/osmocom/rua/
# this is ugly ^. rua_ies_defs.h is generated from asn1tostruct.py here, but
# it should live in include/osmocom/rua/.
@@ -33,8 +44,12 @@
gen_ranap.stamp: $(ASN1_ROOT)/ranap/RANAP-PDU-Contents.asn $(ASN1TOSTRUCT)
$(ASN1TOSTRUCT) -p RANAP_ -f $<
# We also need to replace the include in the newly generated .c files:
- sed -i 's,^#include "ranap_ies_defs.h",#include <osmocom/ranap/ranap_ies_defs.h>,' ranap_encoder.c ranap_decoder.c
- sed -i 's,^#include "ranap_common.h",#include <osmocom/ranap/ranap_common.h>,' ranap_encoder.c ranap_decoder.c ranap_ies_defs.h
+ for f in ranap_encoder.c ranap_decoder.c; do \
+ sed 's,^#include "ranap_ies_defs.h",#include <osmocom/ranap/ranap_ies_defs.h>,' $$f > $$f.tmp && mv $$f.tmp $$f || exit 1; \
+ done
+ for f in ranap_encoder.c ranap_decoder.c ranap_ies_defs.h; do \
+ sed 's,^#include "ranap_common.h",#include <osmocom/ranap/ranap_common.h>,' $$f > $$f.tmp && mv $$f.tmp $$f || exit 1; \
+ done
mv ranap_ies_defs.h $(top_builddir)/include/osmocom/ranap/
# this is ugly ^. ranap_ies_defs.h is generated from asn1tostruct.py here, but
# it should live in include/osmocom/ranap/.
@@ -45,8 +60,12 @@
gen_sabp.stamp: $(ASN1_ROOT)/sabp/SABP-PDU-Contents.asn $(ASN1TOSTRUCT)
$(ASN1TOSTRUCT) -p SABP_ -f $<
# We also need to replace the include in the newly generated .c files:
- sed -i 's,^#include "sabp_ies_defs.h",#include <osmocom/sabp/sabp_ies_defs.h>,' sabp_encoder.c sabp_decoder.c
- sed -i 's,^#include "sabp_common.h",#include <osmocom/sabp/sabp_common.h>,' sabp_encoder.c sabp_decoder.c sabp_ies_defs.h
+ for f in sabp_encoder.c sabp_decoder.c; do \
+ sed 's,^#include "sabp_ies_defs.h",#include <osmocom/sabp/sabp_ies_defs.h>,' $$f > $$f.tmp && mv $$f.tmp $$f || exit 1; \
+ done
+ for f in sabp_encoder.c sabp_decoder.c sabp_ies_defs.h; do \
+ sed 's,^#include "sabp_common.h",#include <osmocom/sabp/sabp_common.h>,' $$f > $$f.tmp && mv $$f.tmp $$f || exit 1; \
+ done
mv sabp_ies_defs.h $(top_builddir)/include/osmocom/sabp/
# this is ugly ^. sabp_ies_defs.h is generated from asn1tostruct.py here, but
# it should live in include/osmocom/sabp/.
--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/43588?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: I6f803fcfb5dd81f0a0b2998b00622f6a19afc5da
Gerrit-Change-Number: 43588
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/43587?usp=email )
Change subject: sgsn: vty: guard NULL iu.ue_ctx when dumping
......................................................................
sgsn: vty: guard NULL iu.ue_ctx when dumping
vty_dump_mmctx() reads mm->iu.ue_ctx->conn_id without checking the
pointer whenever mm->ran_type is MM_CTX_T_UTRAN_Iu.
iu.ue_ctx is NULL for an attached subscriber whose Iu connection has
been released. Both paths that do it leave the MM context in place and
only clear the pointer: sgsn_mm_ctx_iu_ranap_release_free() and
sgsn_mm_ctx_iu_ranap_free() in mmctx.c both end with
"mmctx->iu.ue_ctx = NULL". Both also open with "if (!mmctx->iu.ue_ctx)
return", so the rest of the file already treats a live MM context with
no ue_ctx as an ordinary state. Releasing the Iu connection on
inactivity while the subscriber stays attached is standard behaviour,
so this is reachable in normal operation, not only after an error.
Any "show mm-context" command then dereferences NULL and takes osmo-sgsn
down with it. This was hit during Iu integration testing, after a
completed GMM Attach followed by an Iu release.
Guard the read. The connection id stays 0 when there is no connection,
which is what the Gb branch already does for an unset TLLI. The MM
state printed just below comes from iu.mm_state_fsm, which is untouched
by the release, so the line still reports PMM-IDLE and no information
is lost.
Change-Id: I19d380401edcdce18586ed9de26cfe85c925c1f2
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M src/sgsn/sgsn_vty.c
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/87/43587/1
diff --git a/src/sgsn/sgsn_vty.c b/src/sgsn/sgsn_vty.c
index ff14589..3d8a3bd 100644
--- a/src/sgsn/sgsn_vty.c
+++ b/src/sgsn/sgsn_vty.c
@@ -666,7 +666,11 @@
switch(mm->ran_type) {
case MM_CTX_T_UTRAN_Iu:
#if BUILD_IU
- id = mm->iu.ue_ctx->conn_id;
+ /* The Iu connection can be released while the MM context stays
+ * attached, which leaves iu.ue_ctx NULL; there is no connection
+ * id to show then. The MM state below still reports PMM-IDLE. */
+ if (mm->iu.ue_ctx)
+ id = mm->iu.ue_ctx->conn_id;
mm_state_name = osmo_fsm_inst_state_name(mm->iu.mm_state_fsm);
#endif
break;
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/43587?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I19d380401edcdce18586ed9de26cfe85c925c1f2
Gerrit-Change-Number: 43587
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/43586?usp=email )
Change subject: gtphub: add LIBCARES_CFLAGS to AM_CFLAGS
......................................................................
gtphub: add LIBCARES_CFLAGS to AM_CFLAGS
gtphub_ares.c and gtphub_vty.c reach <ares.h> through
osmocom/sgsn/sgsn.h, and src/gtphub/Makefile.am already has
$(LIBCARES_LIBS) on the link line, but AM_CFLAGS never got
$(LIBCARES_CFLAGS). The compile therefore only works where c-ares
headers sit in a default include directory.
With c-ares from Homebrew on macOS ARM64 the header is in
/opt/homebrew/include and the build stops:
fatal error: 'ares.h' file not found
Every other directory in the tree that uses c-ares already passes the
flag: src/gprs, src/sgsn, and the tests under tests/sgsn,
tests/gprs_routing_area, tests/slhc, tests/sndcp_xid, tests/v42bis and
tests/xid. src/gtphub is the only one missing it.
No change where the header was already found.
Change-Id: Ibe4ddc357fb3ccf285e9a9f91217fc130bc3973c
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M src/gtphub/Makefile.am
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/86/43586/1
diff --git a/src/gtphub/Makefile.am b/src/gtphub/Makefile.am
index a242a05..6ea5ab2 100644
--- a/src/gtphub/Makefile.am
+++ b/src/gtphub/Makefile.am
@@ -12,6 +12,7 @@
$(LIBOSMOVTY_CFLAGS) \
$(LIBOSMOGSUPCLIENT_CFLAGS) \
$(COVERAGE_CFLAGS) \
+ $(LIBCARES_CFLAGS) \
$(LIBGTP_CFLAGS) \
$(NULL)
if BUILD_IU
--
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/43586?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: Ibe4ddc357fb3ccf285e9a9f91217fc130bc3973c
Gerrit-Change-Number: 43586
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/43585?usp=email )
Change subject: ggsn: use the runtime tun interface name
......................................................................
ggsn: use the runtime tun interface name
The IP pool of an APN excludes the addresses of its own tun interface.
alloc_ippool_blacklist() finds them with netdev_ip_local_get(), which
walks getifaddrs() and matches on the interface name, and it passes
apn->tun.cfg.dev_name, the name from the configuration file.
tun_ip_local_get() does the same with tun->devname when it looks up the
IPv6 link-local address.
The configured name is not always the name the interface ends up with.
libosmocore already knows this: osmo_tundev keeps dev_name current, and
tundev_dev_name_chg_cb() rewrites it on rename, logging "netdev changed
name". Once that happens, or wherever the kernel picks the name itself,
the lookup is done under a name getifaddrs() does not report, no
addresses are found, and the blacklist is empty.
An empty blacklist is not a harmless miss. The pool then hands out its
first address, which is the tun's own, so the first PDP context gets
the address of the GGSN side of the link and collides with it.
Observed on Darwin, where the kernel always names a utun itself and a
requested "tun4" comes back as "utun6": the first attached UE was given
10.45.0.1, the tun address. With the fix it gets 10.45.0.2.
Take the name from the open osmo_tundev with
osmo_tundev_get_dev_name(), which returns what the interface is called
now, in both places. Fall back to the configured name when there is no
tundev, which is the gtp kernel mode path. No change where the two
names agree, which is the normal case on Linux.
Change-Id: Ibd754ea3a5be4d5227488d0de571723b69e9d39d
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M ggsn/ggsn.c
M lib/tun.c
2 files changed, 18 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/85/43585/1
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 3177713..79efae3 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -174,23 +174,31 @@
static int alloc_ippool_blacklist(struct apn_ctx *apn, struct in46_prefix **blacklist, bool ipv6)
{
-
+ const char *dev_name = apn->tun.cfg.dev_name;
int flags, len, len2, i;
*blacklist = NULL;
+ /* The kernel may give the interface another name than the one that
+ * was configured (a Darwin utun: "tun4" requested, "utun6" assigned).
+ * getifaddrs() lists the addresses under the real name, so ask the
+ * open tun device for it; otherwise the blacklist stays empty and the
+ * pool hands the tun's own address to the first PDP context. */
+ if (apn->tun.tun && apn->tun.tun->tundev.tundev)
+ dev_name = osmo_tundev_get_dev_name(apn->tun.tun->tundev.tundev);
+
if (ipv6)
flags = IP_TYPE_IPv6_NONLINK;
else
flags = IP_TYPE_IPv4;
while (1) {
- len = netdev_ip_local_get(apn->tun.cfg.dev_name, NULL, 0, flags);
+ len = netdev_ip_local_get(dev_name, NULL, 0, flags);
if (len < 1)
return len;
*blacklist = talloc_zero_size(apn, len * sizeof(struct in46_prefix));
- len2 = netdev_ip_local_get(apn->tun.cfg.dev_name, *blacklist, len, flags);
+ len2 = netdev_ip_local_get(dev_name, *blacklist, len, flags);
if (len2 < 1) {
talloc_free(*blacklist);
*blacklist = NULL;
diff --git a/lib/tun.c b/lib/tun.c
index 60d9b5e..13a8b9d 100644
--- a/lib/tun.c
+++ b/lib/tun.c
@@ -279,5 +279,11 @@
*/
int tun_ip_local_get(const struct tun_t *tun, struct in46_prefix *prefix_list, size_t prefix_size, int flags)
{
- return netdev_ip_local_get(tun->devname, prefix_list, prefix_size, flags);
+ /* Ask the tun device for the name the kernel gave the interface; it can
+ * differ from the configured one (Darwin utun) and getifaddrs() only
+ * knows the real one. */
+ const char *devname = tun->devname;
+ if (tun->tundev.tundev)
+ devname = osmo_tundev_get_dev_name(tun->tundev.tundev);
+ return netdev_ip_local_get(devname, prefix_list, prefix_size, flags);
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/43585?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: Ibd754ea3a5be4d5227488d0de571723b69e9d39d
Gerrit-Change-Number: 43585
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/43584?usp=email )
Change subject: configure: search libresolv for res_9_init
......................................................................
configure: search libresolv for res_9_init
sgsnemu points the resolver at the DNS server received in the PCO by
writing to the resolver state from <resolv.h>. glibc keeps that state
in libc, so nothing extra is needed on GNU/Linux.
Darwin keeps it in libresolv and renames the interface to the BIND 9
symbols: /usr/include/resolv.h has "#define res_init res_9_init" and
"#define __res_state __res_9_state". The link of sgsnemu then fails
with
Undefined symbols for architecture arm64: "___res_9_state"
Add AC_SEARCH_LIBS([res_9_init], [resolv]) so -lresolv is picked up
where the symbol lives there. res_9_init is deliberately the name
searched for, rather than res_init: it exists only on the platforms
that carry this renaming, so on glibc the search finds nothing, LIBS
stays as it was and the link line does not change.
Change-Id: I97787b051c712c5cfdb241cb7931a214d5a87630
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M configure.ac
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/84/43584/1
diff --git a/configure.ac b/configure.ac
index cbb6b66..3283aae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,6 +152,10 @@
# check for getopt in standard library
adl_FUNC_GETOPT_LONG
+# sgsnemu sets the resolver state (_res) from <resolv.h>. glibc keeps it in
+# libc; Darwin exports it from libresolv under BIND 9 names (res_9_*).
+AC_SEARCH_LIBS([res_9_init], [resolv])
+
AM_INIT_AUTOMAKE([foreign])
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.14.2)
--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/43584?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I97787b051c712c5cfdb241cb7931a214d5a87630
Gerrit-Change-Number: 43584
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/43583?usp=email )
Change subject: lib/getopt1: declare _getopt_internal()
......................................................................
lib/getopt1: declare _getopt_internal()
lib/getopt1.c and lib/getopt.c include "getopt.h", but the bundled
header is named lib/gnugetopt.h and no lib/getopt.h exists. The include
therefore falls through to the system getopt.h. That header declares
getopt(), getopt_long() and getopt_long_only(), but not
_getopt_internal(), which is private to the GNU implementation, so the
two calls in getopt1.c have no declaration in scope.
clang 16 and later reject an implicit declaration instead of warning:
lib/getopt1.c:72:9: error: call to undeclared function
'_getopt_internal'; ISO C99 and later do not support implicit
function declarations
GNU/Linux never gets there. On glibc, getopt1.c defines ELIDE_CODE and
compiles to nothing, because the C library already provides the whole
interface. The bundled copy is only really built where the C library is
not glibc, which is where the declaration is missing.
Declare _getopt_internal() in getopt1.c, matching the K&R definition in
getopt.c. Fixing the include to name gnugetopt.h would be the other
way, but that header is installed under a different name on purpose and
the declaration is the smaller change.
Reproduced with clang 17 (Xcode 16) on macOS ARM64; the file compiles
clean with the declaration in place.
Change-Id: Ia8bfe94dfd1ea1f4b270f1661305d6247dfc361b
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M lib/getopt1.c
1 file changed, 5 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/83/43583/1
diff --git a/lib/getopt1.c b/lib/getopt1.c
index c4e4190..9215a27 100644
--- a/lib/getopt1.c
+++ b/lib/getopt1.c
@@ -52,6 +52,11 @@
#ifndef ELIDE_CODE
+/* getopt.c defines this in K&R style; clang 16 and later refuse the
+ * implicit declaration that the non-glibc branch of gnugetopt.h leaves. */
+extern int _getopt_internal(int argc, char *const *argv, const char *shortopts,
+ const struct option *longopts, int *longind, int long_only);
+
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/43583?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: Ia8bfe94dfd1ea1f4b270f1661305d6247dfc361b
Gerrit-Change-Number: 43583
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>
Andrei G has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ggsn/+/43582?usp=email )
Change subject: gtp: define htobe64 and be64toh on Darwin
......................................................................
gtp: define htobe64 and be64toh on Darwin
gtp/gtp.c converts the GTPv0 TID with htobe64() and be64toh(). glibc
declares both in <endian.h>, FreeBSD in <sys/endian.h>, and the file
already has a branch for the FreeBSD spelling. Darwin has neither
header, so the build of libgtp stops with "call to undeclared function
'be64toh'".
Add an __APPLE__ branch next to the existing FreeBSD one, mapping both
names to the OSSwap macros from <libkern/OSByteOrder.h>, which is where
Darwin keeps the fixed-width byte swaps. Nothing outside the new branch
changes.
Change-Id: I8a687ab94315878f1eaa8a4e68628084fd385c75
Signed-off-by: Andrei Gosman <andrei.gosman(a)gmail.com>
---
M gtp/gtp.c
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/82/43582/1
diff --git a/gtp/gtp.c b/gtp/gtp.c
index f378c17..f5adccd 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -30,6 +30,12 @@
#if defined(__FreeBSD__)
#include <sys/endian.h>
+#elif defined(__APPLE__)
+/* Darwin has neither <endian.h> nor <sys/endian.h>; the 64 bit swaps
+ * used for the GTPv0 TID come from libkern. */
+#include <libkern/OSByteOrder.h>
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
#endif
#include "../config.h"
--
To view, visit https://gerrit.osmocom.org/c/osmo-ggsn/+/43582?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Change-Id: I8a687ab94315878f1eaa8a4e68628084fd385c75
Gerrit-Change-Number: 43582
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <andrei.gosman(a)gmail.com>