pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40816?usp=email )
Change subject: {S1AP,NGAP}_Emulation: Fix using the value of an optional field containing omit
......................................................................
{S1AP,NGAP}_Emulation: Fix using the value of an optional field containing omit
This was triggered in NGAP_Emulation during run of C5G_Tests complete
testusite, when running TC_ng_register_ping4_256.
Titan apparently doesn't like using a field set as omit in a field of a
record during match().
Same fix is applied for S1AP_Emulation since they basically use the same
logic.
Change-Id: I4812c2e9eeeadc26ad057cd8019f7570e4a16155
---
M library/NGAP_Emulation.ttcn
M library/S1AP_Emulation.ttcn
2 files changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/16/40816/1
diff --git a/library/NGAP_Emulation.ttcn b/library/NGAP_Emulation.ttcn
index cd71395..7b7d93d 100644
--- a/library/NGAP_Emulation.ttcn
+++ b/library/NGAP_Emulation.ttcn
@@ -264,6 +264,9 @@
runs on NGAP_Emulation_CT return integer {
var integer i;
for (i := 0; i < sizeof(NGapAssociationTable); i := i+1) {
+ if (not isvalue(NGapAssociationTable[i].ran_ue_ngap_id)) {
+ continue;
+ }
if (istemplatekind(ran_id, "omit") or
match(NGapAssociationTable[i].ran_ue_ngap_id, ran_id)) {
if (istemplatekind(amf_id, "omit")) {
diff --git a/library/S1AP_Emulation.ttcn b/library/S1AP_Emulation.ttcn
index d1ac243..55a3380 100644
--- a/library/S1AP_Emulation.ttcn
+++ b/library/S1AP_Emulation.ttcn
@@ -209,6 +209,9 @@
runs on S1AP_Emulation_CT return integer {
var integer i;
for (i := 0; i < sizeof(S1apAssociationTable); i := i+1) {
+ if (not isvalue(S1apAssociationTable[i].enb_ue_s1ap_id)) {
+ continue;
+ }
if (istemplatekind(enb_id, "omit") or
match(S1apAssociationTable[i].enb_ue_s1ap_id, enb_id)) {
if (istemplatekind(mme_id, "omit")) {
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40816?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I4812c2e9eeeadc26ad057cd8019f7570e4a16155
Gerrit-Change-Number: 40816
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-uecups/+/40798?usp=email )
Change subject: cosmetic: Improve comments on cancellable thread safety
......................................................................
cosmetic: Improve comments on cancellable thread safety
* Move the comment explaining safety measures to the top of the thread
function
* Document that special care must be taken in mutual exclusion zones
within the thread code.
Change-Id: Ic1ffe68c1637cb06787d4193347cb4200c819154
---
M daemon/gtp_endpoint.c
M daemon/tun_device.c
2 files changed, 21 insertions(+), 10 deletions(-)
Approvals:
osmith: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/daemon/gtp_endpoint.c b/daemon/gtp_endpoint.c
index 7892d4e..87d333c 100644
--- a/daemon/gtp_endpoint.c
+++ b/daemon/gtp_endpoint.c
@@ -124,11 +124,16 @@
}
}
-/* one thread for reading from each GTP/UDP socket (GTP decapsulation -> tun)
- * IMPORTANT!: All logging functions in this function block must be called with
- * PTHREAD_CANCEL_DISABLE set, otherwise the thread could be cancelled while
- * holding the logging mutex, hence causing deadlock with main (or other)
- * thread. */
+/* One thread for reading from each GTP/UDP socket (GTP decapsulation -> tun)
+ * IMPORTANT!: Since this thread is cancellable (deferred type):
+ * - All osmo logging functions in this thread must be called with PTHREAD_CANCEL_DISABLE set,
+ * otherwise the thread could be cancelled while holding the libosmocore logging mutex, hence causing
+ * deadlock with main (or other) thread.
+ * - Within pthread_rwlock_*(&d->rwlock) mutual exclusion zone, if we ever do any call considered
+ * a cancellation point (see "man pthreads"), then make sure to do the call protected with
+ * PTHREAD_CANCEL_DISABLE set, otherwise we may leave the d->rwlock held forever and cause a deadlock
+ * with main (or other) thread.
+ */
static void *gtp_endpoint_thread(void *arg)
{
struct gtp_endpoint *ep = (struct gtp_endpoint *)arg;
diff --git a/daemon/tun_device.c b/daemon/tun_device.c
index ee4fbcc..40b6ec3 100644
--- a/daemon/tun_device.c
+++ b/daemon/tun_device.c
@@ -212,7 +212,16 @@
return rc;
}
-/* one thread for reading from each TUN device (TUN -> GTP encapsulation) */
+/* One thread for reading from each TUN device (TUN -> GTP encapsulation)
+ * IMPORTANT!: Since this thread is cancellable (deferred type):
+ * - All osmo logging functions in this thread must be called with PTHREAD_CANCEL_DISABLE set,
+ * otherwise the thread could be cancelled while holding the libosmocore logging mutex, hence causing
+ * deadlock with main (or other) thread.
+ * - Within pthread_rwlock_*(&d->rwlock) mutual exclusion zone, if we ever do any call considered
+ * a cancellation point (see "man pthreads"), then make sure to do the call protected with
+ * PTHREAD_CANCEL_DISABLE set, otherwise we may leave the d->rwlock held forever and cause a deadlock
+ * with main (or other) thread.
+ */
static void *tun_device_thread(void *arg)
{
struct tun_device *tun = (struct tun_device *)arg;
@@ -223,10 +232,6 @@
uint8_t base_buffer[payload_off_4byte_aligned + MAX_UDP_PACKET];
pthread_cleanup_push(tun_device_pthread_cleanup_routine, tun);
- /* IMPORTANT!: All logging functions in this function block must be called with
- * PTHREAD_CANCEL_DISABLE set, otherwise the thread could be cancelled while
- * holding the logging mutex, hence causing deadlock with main (or other)
- * thread. */
snprintf(thread_name, sizeof(thread_name), "Rx%s", tun->devname);
pthread_setname_np(pthread_self(), thread_name);
@@ -269,6 +274,7 @@
continue;
}
rc = tx_gtp1u_pkt(t, base_buffer, buffer, nread);
+ /* pthread_rwlock_unlock() was called inside tx_gtp1u_pkt(). */
if (rc < 0) {
LOGTUN_NC(tun, LOGL_FATAL, "Error Writing to UDP socket: %s\n", strerror(errno));
exit(1);
--
To view, visit https://gerrit.osmocom.org/c/osmo-uecups/+/40798?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-uecups
Gerrit-Branch: master
Gerrit-Change-Id: Ic1ffe68c1637cb06787d4193347cb4200c819154
Gerrit-Change-Number: 40798
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>