lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

November 2022

  • 2 participants
  • 2503 discussions
Change in libosmo-sccp[master]: contrib/jenkins.sh: add missing 'make check'
by fixeria 14 Nov '22

14 Nov '22
Attention is currently required from: osmith, laforge. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/30079 ) Change subject: contrib/jenkins.sh: add missing 'make check' ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/30079 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Change-Id: I09b7e2223d19c9e055ecddf3b2690cdea26b9be7 Gerrit-Change-Number: 30079 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Mon, 14 Nov 2022 08:23:56 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in libosmo-sccp[master]: tests: fix old-style function definition
by osmith 14 Nov '22

14 Nov '22
osmith has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/30078 ) Change subject: tests: fix old-style function definition ...................................................................... tests: fix old-style function definition Fix for: xua_test.c:575:6: error: old-style function definition [-Werror=old-style-definition] Change-Id: Iccc942f9f25fb091045d906eb8be658b54c58529 --- M tests/vty/ss7_asp_vty_test.c M tests/xua/xua_test.c 2 files changed, 2 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/tests/vty/ss7_asp_vty_test.c b/tests/vty/ss7_asp_vty_test.c index 4ee0f7f..80ce3ec 100644 --- a/tests/vty/ss7_asp_vty_test.c +++ b/tests/vty/ss7_asp_vty_test.c @@ -41,7 +41,7 @@ const struct log_info log_info = { }; -static void print_help() +static void print_help(void) { printf( "options:\n" " -h --help this text\n" diff --git a/tests/xua/xua_test.c b/tests/xua/xua_test.c index abf2fae..6b4eef5 100644 --- a/tests/xua/xua_test.c +++ b/tests/xua/xua_test.c @@ -572,7 +572,7 @@ talloc_free(xua); } -void test_sccp_addr_cmp() +static void test_sccp_addr_cmp(void) { int ai; int bi; -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/30078 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Change-Id: Iccc942f9f25fb091045d906eb8be658b54c58529 Gerrit-Change-Number: 30078 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in osmo-remsim[master]: ignore libtool artifacts from cross-compile environments
by jtavares 14 Nov '22

14 Nov '22
jtavares has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30141 ) Change subject: ignore libtool artifacts from cross-compile environments ...................................................................... ignore libtool artifacts from cross-compile environments Change-Id: I549ee65e72fed2d1599b3e2dfc7a37f02a8f80e6 --- M .gitignore 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/41/30141/1 diff --git a/.gitignore b/.gitignore index 1ceb8d7..5a5118b 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ install-sh libosmo-rspro.pc libtool +*-libtool ltmain.sh missing Makefile.in -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30141 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I549ee65e72fed2d1599b3e2dfc7a37f02a8f80e6 Gerrit-Change-Number: 30141 Gerrit-PatchSet: 1 Gerrit-Owner: jtavares <jtavares(a)kvh.com> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-remsim[master]: bankd: edge detect RESET and VCC indications
by jtavares 14 Nov '22

14 Nov '22
jtavares has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30140 ) Change subject: bankd: edge detect RESET and VCC indications ...................................................................... bankd: edge detect RESET and VCC indications - perform edge detection on RESET and VCC client indications to filter out duplicate resets - prior to this change, unrelated changes in the client slot status indication (such as CLK change) could trigger duplicate resets - these resets could happen in rapid succession and lead to reader libusb communication errors that lock-up the PC/SC daemon - a drop in VCC will always induce a cold reset, even if a warm reset is already in progress. - overall, this change better matches what the hardware would do Change-Id: I36d30d176c0a03d97554112ca712d658d986c752 --- M src/bankd/bankd.h M src/bankd/bankd_main.c 2 files changed, 28 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/40/30140/1 diff --git a/src/bankd/bankd.h b/src/bankd/bankd.h index 0f94818..e340b5a 100644 --- a/src/bankd/bankd.h +++ b/src/bankd/bankd.h @@ -96,6 +96,12 @@ uint8_t atr[MAX_ATR_SIZE]; unsigned int atr_len; } card; + + /* last known state of the SIM card VCC indication */ + bool last_vccPresent; + + /* last known state of the SIM card reset indication */ + bool last_resetActive; }; /* bankd card reader driver operations */ diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c index b3b8dff..10334ff 100644 --- a/src/bankd/bankd_main.c +++ b/src/bankd/bankd_main.c @@ -115,6 +115,8 @@ worker->bankd = bankd; worker->num = i; worker->ops = &pcsc_driver_ops; + worker->last_vccPresent = true; /* allow cold reset should first indication be false */ + worker->last_resetActive = false; /* allow warm reset should first indication be true */ /* in the initial state, the worker has no client.fd, bank_slot or pcsc handle yet */ @@ -774,10 +776,26 @@ sps->clkActive ? *sps->clkActive ? "ACTIVE" : "INACTIVE" : "NULL"); /* perform cold or warm reset */ - if (sps->vccPresent && *sps->vccPresent == 0) - rc = worker->ops->reset_card(worker, true); - else if (sps->resetActive) - rc = worker->ops->reset_card(worker, false); + if (sps->vccPresent && *sps->vccPresent == 0) { + /* VCC is not present */ + + if (worker->last_vccPresent) { + /* falling edge detected on VCC; perform cold reset */ + rc = worker->ops->reset_card(worker, true); + } + } else if (sps->resetActive) { + if (!worker->last_resetActive) { + /* VCC is present (or not reported) and rising edge detected on reset; perform warm reset */ + rc = worker->ops->reset_card(worker, false); + } + } + + /* update last known states */ + if (sps->vccPresent) { + worker->last_vccPresent = *sps->vccPresent != 0; + } + + worker->last_resetActive = sps->resetActive != 0; return rc; } -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30140 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I36d30d176c0a03d97554112ca712d658d986c752 Gerrit-Change-Number: 30140 Gerrit-PatchSet: 1 Gerrit-Owner: jtavares <jtavares(a)kvh.com> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-remsim[master]: bankd: Add GSMTAP functionality for SIM traffic
by Jenkins Builder 14 Nov '22

14 Nov '22
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30139 ) Change subject: bankd: Add GSMTAP functionality for SIM traffic ...................................................................... Patch Set 1: (2 comments) File src/bankd/bankd.h: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-963): https://gerrit.osmocom.org/c/osmo-remsim/+/30139/comment/54695fd7_eea74fbc PS1, Line 136: char* gsmtap_host; "foo* bar" should be "foo *bar" File src/bankd/gsmtap.h: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-963): https://gerrit.osmocom.org/c/osmo-remsim/+/30139/comment/ed07d93c_5fb7ca55 PS1, Line 7: const uint8_t *sim_tpdu, unsigned int sim_tpdu_len); adding a line without newline at end of file -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30139 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I05b599858d8758633aa56c3f12f258c27cf42d08 Gerrit-Change-Number: 30139 Gerrit-PatchSet: 1 Gerrit-Owner: jtavares <jtavares(a)kvh.com> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Mon, 14 Nov 2022 05:15:16 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
Change in osmo-remsim[master]: bankd: Add GSMTAP functionality for SIM traffic
by jtavares 14 Nov '22

14 Nov '22
jtavares has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30139 ) Change subject: bankd: Add GSMTAP functionality for SIM traffic ...................................................................... bankd: Add GSMTAP functionality for SIM traffic If a --gsmtap-host (-g) address is specified on the command line, trace SIM ATRs and APDUs to the given IP. If --gsmtap-slot (-G) is provided, limit tracing to the specified bank slot number. This feature may be useful when diagnosing issues with the remote SIM framework. Also, cleaned up alignment in bankd --help output. Change-Id: I05b599858d8758633aa56c3f12f258c27cf42d08 --- M src/bankd/Makefile.am M src/bankd/bankd.h M src/bankd/bankd_main.c A src/bankd/gsmtap.c A src/bankd/gsmtap.h 5 files changed, 151 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/39/30139/1 diff --git a/src/bankd/Makefile.am b/src/bankd/Makefile.am index 42c9bd3..4899aef 100644 --- a/src/bankd/Makefile.am +++ b/src/bankd/Makefile.am @@ -3,7 +3,7 @@ $(OSMOCORE_CFLAGS) $(OSMOGSM_CFLAGS) $(OSMOABIS_CFLAGS) \ $(PCSC_CFLAGS) -noinst_HEADERS = bankd.h internal.h +noinst_HEADERS = bankd.h internal.h gsmtap.h bin_PROGRAMS = osmo-remsim-bankd noinst_PROGRAMS = pcsc_test @@ -13,7 +13,7 @@ $(PCSC_LIBS) $(top_builddir)/src/libosmo-rspro.la osmo_remsim_bankd_SOURCES = ../slotmap.c ../rspro_client_fsm.c ../debug.c \ - bankd_main.c bankd_pcsc.c + bankd_main.c bankd_pcsc.c gsmtap.c osmo_remsim_bankd_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \ $(PCSC_LIBS) $(CSV_LIBS) $(top_builddir)/src/libosmo-rspro.la diff --git a/src/bankd/bankd.h b/src/bankd/bankd.h index 0f94818..ce23135 100644 --- a/src/bankd/bankd.h +++ b/src/bankd/bankd.h @@ -133,6 +133,8 @@ struct { bool permit_shared_pcsc; + char* gsmtap_host; + int gsmtap_slot; } cfg; }; diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c index b3b8dff..8e3ed91 100644 --- a/src/bankd/bankd_main.c +++ b/src/bankd/bankd_main.c @@ -47,6 +47,7 @@ #include "rspro_client_fsm.h" #include "debug.h" #include "rspro_util.h" +#include "gsmtap.h" /* signal indicates to worker thread that its map has been deleted */ #define SIGMAPDEL SIGRTMIN+1 @@ -100,6 +101,8 @@ INIT_LLIST_HEAD(&bankd->pcsc_slot_names); bankd->cfg.permit_shared_pcsc = false; + bankd->cfg.gsmtap_host = NULL; + bankd->cfg.gsmtap_slot = -1; } /* create + start a new bankd_worker thread */ @@ -282,18 +285,20 @@ static void printf_help() { printf( -" -h --help Print this help message\n" -" -V --version Print the version of the program\n" -" -d --debug option Enable debug logging (e.g. DMAIN:DST2)\n" -" -i --server-host A.B.C.D remsim-server IP address (default: 127.0.0.1)\n" -" -p --server-port <1-65535> remsim-server TCP port (default: 9998)\n" -" -b --bank-id <1-1023> Bank Identifier of this SIM bank (default: 1)\n" -" -n --num-slots <1-1023> Number of Slots in this SIM bank (default: 8)\n" -" -I --bind-ip A.B.C.D Local IP address to bind for incoming client\n" -" connections (default: INADDR_ANY)\n" -" -P --bind-port <1-65535> Local TCP port to bind for incoming client\n" -" connectionss (default: 9999)\n" -" -s --permit-shared-pcsc Permit SHARED access to PC/SC readers (default: exclusive)\n" +" -h --help Print this help message\n" +" -V --version Print the version of the program\n" +" -d --debug option Enable debug logging (e.g. DMAIN:DST2)\n" +" -i --server-host A.B.C.D remsim-server IP address (default: 127.0.0.1)\n" +" -p --server-port <1-65535> remsim-server TCP port (default: 9998)\n" +" -b --bank-id <1-1023> Bank Identifier of this SIM bank (default: 1)\n" +" -n --num-slots <1-1023> Number of Slots in this SIM bank (default: 8)\n" +" -I --bind-ip A.B.C.D Local IP address to bind for incoming client\n" +" connections (default: INADDR_ANY)\n" +" -P --bind-port <1-65535> Local TCP port to bind for incoming client\n" +" connections (default: 9999)\n" +" -s --permit-shared-pcsc Permit SHARED access to PC/SC readers (default: exclusive)\n" +" -g --gsmtap-ip A.B.C.D Enable GSMTAP and send APDU traces to given IP\n" +" -G --gsmtap-slot <0-1023> Limit tracing to given bank slot, only (default: all slots)\n" ); } @@ -316,10 +321,12 @@ { "bind-ip", 1, 0, 'I' }, { "bind-port", 1, 0, 'P' }, { "permit-shared-pcsc", 0, 0, 's' }, + { "gsmtap-ip", 1, 0, 'g' }, + { "gsmtap-slot", 1, 0, 'G' }, { 0, 0, 0, 0 } }; - c = getopt_long(argc, argv, "hVd:i:o:b:n:N:I:P:s", long_options, &option_index); + c = getopt_long(argc, argv, "hVd:i:o:b:n:N:I:P:sg:G:", long_options, &option_index); if (c == -1) break; @@ -359,6 +366,12 @@ case 's': g_bankd->cfg.permit_shared_pcsc = true; break; + case 'g': + g_bankd->cfg.gsmtap_host = optarg; + break; + case 'G': + g_bankd->cfg.gsmtap_slot = atoi(optarg); + break; } } } @@ -416,6 +429,15 @@ } g_bankd->accept_fd = rc; + /* initialize gsmtap, if required */ + if (g_bankd->cfg.gsmtap_host) { + rc = osmo_bankd_gsmtap_init(g_bankd->cfg.gsmtap_host); + if (rc < 0) { + fprintf(stderr, "Unable to open GSMTAP"); + exit(1); + } + } + /* create worker threads: One per reader/slot! */ for (i = 0; i < g_bankd->srvc.bankd.num_slots; i++) { struct bankd_worker *w; @@ -659,6 +681,14 @@ set_atr = rspro_gen_SetAtrReq(worker->client.clslot.client_id, worker->client.clslot.slot_nr, worker->card.atr, worker->card.atr_len); + + /* trace ATR to GSMTAP, if configured */ + if (g_bankd->cfg.gsmtap_host && (g_bankd->cfg.gsmtap_slot == -1 || + g_bankd->cfg.gsmtap_slot == worker->slot.slot_nr)) { + osmo_bankd_gsmtap_send_apdu(GSMTAP_SIM_ATR, worker->card.atr, worker->card.atr_len, + NULL, 0); + } + if (!set_atr) return -1; return worker_send_rspro(worker, set_atr); @@ -759,6 +789,12 @@ rx_buf, rx_buf_len); worker_send_rspro(worker, pdu_resp); + /* trace APDU to GSMTAP, if configured */ + if (g_bankd->cfg.gsmtap_host && (g_bankd->cfg.gsmtap_slot == -1 || + g_bankd->cfg.gsmtap_slot == worker->slot.slot_nr)) { + osmo_bankd_gsmtap_send_apdu(GSMTAP_SIM_APDU, mdm2sim->data.buf, mdm2sim->data.size, rx_buf, + rx_buf_len); + } return 0; } @@ -808,7 +844,7 @@ break; } - return rc; + return rc; } static int wait_for_fd_or_timeout(int fd, unsigned int timeout_secs) diff --git a/src/bankd/gsmtap.c b/src/bankd/gsmtap.c new file mode 100644 index 0000000..1bbb9dc --- /dev/null +++ b/src/bankd/gsmtap.c @@ -0,0 +1,90 @@ +/* gsmtap - How to encapsulate SIM protocol traces in GSMTAP + * + * (C) 2016-2019 by Harald Welte <hwelte(a)hmw-consulting.de> + * + * 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 2 + * 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. + */ + +#include <osmocom/core/gsmtap.h> +#include <osmocom/core/gsmtap_util.h> + +#include <errno.h> +#include <string.h> +#include <unistd.h> +#include <stdio.h> + +/*! global GSMTAP instance */ +static struct gsmtap_inst *g_gti; + +/*! initialize the global GSMTAP instance for SIM traces */ +int osmo_bankd_gsmtap_init(const char *gsmtap_host) +{ + if (g_gti) + return -EEXIST; + + g_gti = gsmtap_source_init(gsmtap_host, GSMTAP_UDP_PORT, 0); + if (!g_gti) { + perror("unable to open GSMTAP"); + return -EIO; + } + gsmtap_source_add_sink(g_gti); + + return 0; +} + +/*! Log one APDU via the global GSMTAP instance by concatenating mdm_tpdu and sim_tpdu. + * + * \param[in] sub_type GSMTAP sub-type (GSMTAP_SIM_* constant) + * \param[in] mdm_tpdu User-provided buffer with ModemToCard TPDU to log. May be NULL. + * \param[in] mdm_tpdu_len Length of ModemToCard TPDU, in bytes. + * \param[in] sim_tpdu User-provided buffer with CardToModem TPDU to log. May be NULL. + * \param[in] sim_tpdu_len Length of CardToModem TPDU, in bytes. + */ +int osmo_bankd_gsmtap_send_apdu(uint8_t sub_type, const uint8_t *mdm_tpdu, unsigned int mdm_tpdu_len, + const uint8_t *sim_tpdu, unsigned int sim_tpdu_len) +{ + struct gsmtap_hdr *gh; + const unsigned int gross_len = sizeof(*gh) + mdm_tpdu_len + sim_tpdu_len; + uint8_t *buf = malloc(gross_len); + size_t offset = 0; + int rc; + + if (!buf) + return -ENOMEM; + + memset(buf + offset, 0, sizeof(*gh)); + gh = (struct gsmtap_hdr *) buf; + gh->version = GSMTAP_VERSION; + gh->hdr_len = sizeof(*gh)/4; + gh->type = GSMTAP_TYPE_SIM; + gh->sub_type = sub_type; + offset += sizeof(*gh); + + if (mdm_tpdu && mdm_tpdu_len) { + memcpy(buf + offset, mdm_tpdu, mdm_tpdu_len); + offset += mdm_tpdu_len; + } + + if (sim_tpdu && sim_tpdu_len) { + memcpy(buf + offset, sim_tpdu, sim_tpdu_len); + offset += sim_tpdu_len; + } + + rc = write(gsmtap_inst_fd(g_gti), buf, offset); + if (rc < 0) { + perror("write gsmtap"); + free(buf); + return rc; + } + + free(buf); + return 0; +} diff --git a/src/bankd/gsmtap.h b/src/bankd/gsmtap.h new file mode 100644 index 0000000..f6b136a --- /dev/null +++ b/src/bankd/gsmtap.h @@ -0,0 +1,7 @@ +#pragma once +#include <stdint.h> +#include <osmocom/core/gsmtap.h> + +int osmo_bankd_gsmtap_init(const char *gsmtap_host); +int osmo_bankd_gsmtap_send_apdu(uint8_t sub_type, const uint8_t *mdm_tpdu, unsigned int mdm_tpdu_len, + const uint8_t *sim_tpdu, unsigned int sim_tpdu_len); \ No newline at end of file -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30139 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I05b599858d8758633aa56c3f12f258c27cf42d08 Gerrit-Change-Number: 30139 Gerrit-PatchSet: 1 Gerrit-Owner: jtavares <jtavares(a)kvh.com> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-remsim[master]: rspro_client: implement re-establish delay
by Jenkins Builder 14 Nov '22

14 Nov '22
Jenkins Builder has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30138 ) Change subject: rspro_client: implement re-establish delay ...................................................................... Patch Set 1: (5 comments) File src/rspro_client_fsm.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962): https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/2fb56f24_41996682 PS1, Line 61: #define REESTABLISH_DELAY_COUNT sizeof(k_reestablish_delay_s)/sizeof(k_reestablish_delay_s[0]) Prefer ARRAY_SIZE(k_reestablish_delay_s) Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962): https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/4ee1174b_e3104353 PS1, Line 216: static int64_t get_monotonic_ms() Bad function definition - int64_t get_monotonic_ms() should probably be int64_t get_monotonic_ms(void) Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962): https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/2cac44b3_fe241958 PS1, Line 218: struct timespec t; please, no spaces at the start of a line Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962): https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/ec1d3112_50da4864 PS1, Line 219: clock_gettime(CLOCK_BOOTTIME, &t); please, no spaces at the start of a line Robot Comment from checkpatch (run ID jenkins-gerrit-lint-962): https://gerrit.osmocom.org/c/osmo-remsim/+/30138/comment/04062233_daaf4329 PS1, Line 220: return ((1000LL * t.tv_sec) + (t.tv_nsec / 1000000)); please, no spaces at the start of a line -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30138 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I86cdc3ba37482e6577b429194d273a2399f32208 Gerrit-Change-Number: 30138 Gerrit-PatchSet: 1 Gerrit-Owner: jtavares <jtavares(a)kvh.com> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Mon, 14 Nov 2022 04:44:31 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
1 0
0 0
Change in osmo-remsim[master]: rspro_client: implement re-establish delay
by jtavares 14 Nov '22

14 Nov '22
jtavares has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30138 ) Change subject: rspro_client: implement re-establish delay ...................................................................... rspro_client: implement re-establish delay - add new SRVC_ST_REESTABLISH_DELAY state with delay stipulated by table k_reestablish_delay_s[], that implements a simple exponential-like back-off with an upper bound. - new function srvc_do_reestablish() is used to initiate a reestablish, and apply the appropriate delay, if any. - takes external delays (such as TCP connect() delay) into account, and does not double-penalize. - delay is reset to shortest possible if there has been no reestablish initiated in a long time (2x greater than our longest delay). Allows for fast reconnects even if a delay was used to connect. - addresses issues https://osmocom.org/issues/5348 and https://osmocom.org/issues/5610 Change-Id: I86cdc3ba37482e6577b429194d273a2399f32208 --- M src/rspro_client_fsm.c M src/rspro_client_fsm.h 2 files changed, 118 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/38/30138/1 diff --git a/src/rspro_client_fsm.c b/src/rspro_client_fsm.c index bd267ca..da39a09 100644 --- a/src/rspro_client_fsm.c +++ b/src/rspro_client_fsm.c @@ -20,6 +20,7 @@ #include <stdint.h> #include <string.h> #include <errno.h> +#include <unistd.h> #include <talloc.h> @@ -40,6 +41,25 @@ #define T1_WAIT_CLIENT_CONN_RES 10 #define T2_RECONNECT 10 +static const int k_reestablish_delay_s[] = { + 0, 0, 0, // 3 immediate retries + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 Hz for 30 seconds + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 1/2 hz for 1 minute + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 1/4 Hz for 2 minutes + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, // 1/8 Hz for 4 minutes + 16, // 1/16 Hz thereafter +}; + +#define REESTABLISH_DELAY_COUNT sizeof(k_reestablish_delay_s)/sizeof(k_reestablish_delay_s[0]) + /*********************************************************************** * client-side FSM for a RSPRO connection to remsim-server * @@ -101,7 +121,9 @@ SRVC_ST_ESTABLISHED, /* server connection established, ClientConnect succeeded */ SRVC_ST_CONNECTED, - /* connection lost, we're waiting for a re-establish */ + /* connection lost, 1st step: delaying until we re-establish */ + SRVC_ST_REESTABLISH_DELAY, + /* connection lost, 2nd step: wait for a re-establish */ SRVC_ST_REESTABLISH, }; @@ -191,6 +213,46 @@ .wait_for_resp = 10, }; +static int64_t get_monotonic_ms() +{ + struct timespec t; + clock_gettime(CLOCK_BOOTTIME, &t); + return ((1000LL * t.tv_sec) + (t.tv_nsec / 1000000)); +} + +static void srvc_do_reestablish(struct osmo_fsm_inst *fi) +{ + struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv; + + const int64_t since_last_ms = get_monotonic_ms() - srvc->reestablish_last_ms; + + /* reset delay loop if it has been > 2x the longest timeout since our last attempt; + * this lets us revert to rapid reconnect behavior for a good connection */ + const int64_t reset_ms = 2*1000*(OSMO_MAX(OSMO_MAX(T1_WAIT_CLIENT_CONN_RES, T2_RECONNECT), + k_reestablish_delay_s[REESTABLISH_DELAY_COUNT-1])); + + if (since_last_ms > reset_ms) { + srvc->reestablish_delay_idx = 0; + LOGPFSML(fi, LOGL_NOTICE, "->REESTABLISH_DELAY reset; %" PRId64 "ms since last attempt\n", + since_last_ms); + } + + /* determine if we need to delay reestablishment */ + const int64_t need_ms = k_reestablish_delay_s[srvc->reestablish_delay_idx] * 1000; + int64_t delay_ms = need_ms - since_last_ms; + + if (delay_ms > 0) { + LOGPFSML(fi, LOGL_NOTICE, "->REESTABLISH_DELAY delay %" PRId64 "ms; %" PRId64 "ms since last attempt [step %zu/%zu@%ds]\n", + delay_ms, since_last_ms, srvc->reestablish_delay_idx, (REESTABLISH_DELAY_COUNT-1), + k_reestablish_delay_s[srvc->reestablish_delay_idx]); + } else { + /* cheat and always use a minimum delay of 1ms to ensure a fsm timeout is triggered */ + delay_ms = 1; + } + + osmo_fsm_inst_state_chg_ms(fi, SRVC_ST_REESTABLISH_DELAY, delay_ms, 3); +} + static void srvc_st_init(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { @@ -224,7 +286,7 @@ switch (event) { case SRVC_E_TCP_DOWN: case SRVC_E_KA_TIMEOUT: - osmo_fsm_inst_state_chg(fi, SRVC_ST_REESTABLISH, T2_RECONNECT, 2); + srvc_do_reestablish(fi); break; case SRVC_E_CLIENT_CONN_RES: pdu = data; @@ -260,7 +322,7 @@ switch (event) { case SRVC_E_TCP_DOWN: case SRVC_E_KA_TIMEOUT: - osmo_fsm_inst_state_chg(fi, SRVC_ST_REESTABLISH, T2_RECONNECT, 2); + srvc_do_reestablish(fi); break; case SRVC_E_RSPRO_TX: pdu = data; @@ -286,10 +348,9 @@ return 0; /* we will explicitly terminate it */ } -static void srvc_st_reestablish_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +static void srvc_st_reestablish_delay_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) { struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv; - int rc; if (srvc->keepalive_fi) { ipa_keepalive_fsm_stop(srvc->keepalive_fi); @@ -303,6 +364,27 @@ ipa_client_conn_destroy(srvc->conn); srvc->conn = NULL; } + + /* saturate timeout at last (longest) entry */ + if (srvc->reestablish_delay_idx < REESTABLISH_DELAY_COUNT-1) { + srvc->reestablish_delay_idx++; + } +} + +static void srvc_st_reestablish_delay(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + default: + OSMO_ASSERT(0); + } +} +static void srvc_st_reestablish_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state) +{ + struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv; + int rc; + + srvc->reestablish_last_ms = get_monotonic_ms(); + LOGPFSML(fi, LOGL_INFO, "Creating TCP connection to server at %s:%u\n", srvc->server_host, srvc->server_port); srvc->conn = ipa_client_conn_create2(fi, NULL, 0, NULL, 0, srvc->server_host, srvc->server_port, @@ -351,7 +433,10 @@ switch (event) { case SRVC_E_ESTABLISH: - osmo_fsm_inst_state_chg(fi, SRVC_ST_REESTABLISH, T2_RECONNECT, 2); + /* reset delay connect immediately on our first connection */ + srvc->reestablish_delay_idx = 0; + srvc->reestablish_last_ms = 0; + srvc_do_reestablish(fi); break; case SRVC_E_DISCONNECT: if (srvc->keepalive_fi) { @@ -377,10 +462,14 @@ struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv; switch (fi->T) { - case 2: - /* TCP reconnect failed: retry */ + case 3: + /* delay has expired; let's re-establish */ osmo_fsm_inst_state_chg(fi, SRVC_ST_REESTABLISH, T2_RECONNECT, 2); break; + case 2: + /* TCP reconnect failed: retry after wait */ + srvc_do_reestablish(fi); + break; case 1: /* no ClientConnectRes received: disconnect + reconnect */ ipa_client_conn_close(srvc->conn); @@ -397,28 +486,35 @@ [SRVC_ST_INIT] = { .name = "INIT", .in_event_mask = 0, /* S(SRVC_E_ESTABLISH) via allstate */ - .out_state_mask = S(SRVC_ST_INIT) | S(SRVC_ST_REESTABLISH), + .out_state_mask = S(SRVC_ST_INIT) | S(SRVC_ST_REESTABLISH_DELAY), .action = srvc_st_init, }, [SRVC_ST_ESTABLISHED] = { .name = "ESTABLISHED", .in_event_mask = S(SRVC_E_TCP_DOWN) | S(SRVC_E_KA_TIMEOUT) | S(SRVC_E_CLIENT_CONN_RES), - .out_state_mask = S(SRVC_ST_CONNECTED) | S(SRVC_ST_REESTABLISH) | S(SRVC_ST_INIT), + .out_state_mask = S(SRVC_ST_CONNECTED) | S(SRVC_ST_REESTABLISH_DELAY) | S(SRVC_ST_INIT), .action = srvc_st_established, .onenter = srvc_st_established_onenter, }, [SRVC_ST_CONNECTED] = { .name = "CONNECTED", .in_event_mask = S(SRVC_E_TCP_DOWN) | S(SRVC_E_KA_TIMEOUT) | S(SRVC_E_RSPRO_TX), - .out_state_mask = S(SRVC_ST_REESTABLISH) | S(SRVC_ST_INIT), + .out_state_mask = S(SRVC_ST_REESTABLISH_DELAY) | S(SRVC_ST_INIT), .action = srvc_st_connected, .onenter = srvc_st_connected_onenter, .onleave = srvc_st_connected_onleave, }, + [SRVC_ST_REESTABLISH_DELAY] = { + .name = "REESTABLISH_DELAY", + .in_event_mask = 0, + .out_state_mask = S(SRVC_ST_REESTABLISH) | S(SRVC_ST_INIT), + .action = srvc_st_reestablish_delay, + .onenter = srvc_st_reestablish_delay_onenter, + }, [SRVC_ST_REESTABLISH] = { .name = "REESTABLISH", .in_event_mask = S(SRVC_E_TCP_UP) | S(SRVC_E_TCP_DOWN), - .out_state_mask = S(SRVC_ST_ESTABLISHED) | S(SRVC_ST_REESTABLISH) | S(SRVC_ST_INIT), + .out_state_mask = S(SRVC_ST_ESTABLISHED) | S(SRVC_ST_REESTABLISH_DELAY) | S(SRVC_ST_INIT), .action = srvc_st_reestablish, .onenter = srvc_st_reestablish_onenter, }, @@ -444,6 +540,9 @@ return -1; srvc->fi = fi; + srvc->reestablish_delay_idx = 0; + srvc->reestablish_last_ms = 0; + return 0; } diff --git a/src/rspro_client_fsm.h b/src/rspro_client_fsm.h index 029fcd9..55fe4a4 100644 --- a/src/rspro_client_fsm.h +++ b/src/rspro_client_fsm.h @@ -26,6 +26,13 @@ struct osmo_fsm_inst *fi; struct osmo_fsm_inst *keepalive_fi; int (*handle_rx)(struct rspro_server_conn *conn, const RsproPDU_t *pdu); + + /* index into k_reestablish_delay[] for this connection */ + size_t reestablish_delay_idx; + + /* timestamp of last re-establish attempt, in milliseconds */ + int64_t reestablish_last_ms; + /* IPA protocol identity */ struct ipaccess_unit ipa_dev; -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30138 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I86cdc3ba37482e6577b429194d273a2399f32208 Gerrit-Change-Number: 30138 Gerrit-PatchSet: 1 Gerrit-Owner: jtavares <jtavares(a)kvh.com> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-remsim[master]: client: set the local/remote mode before inserting card
by jtavares 14 Nov '22

14 Nov '22
jtavares has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30137 ) Change subject: client: set the local/remote mode before inserting card ...................................................................... client: set the local/remote mode before inserting card - avoids a race with the modem Change-Id: I7b0640b929e174e8dfdcc86947fa409e4acf338f --- M src/client/main_fsm.c 1 file changed, 4 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/37/30137/1 diff --git a/src/client/main_fsm.c b/src/client/main_fsm.c index 1da0106..18798d3 100644 --- a/src/client/main_fsm.c +++ b/src/client/main_fsm.c @@ -188,10 +188,6 @@ { struct bankd_client *bc = (struct bankd_client *) fi->priv; - /* Simulate card-insert to modem */ - frontend_request_card_insert(bc); - call_script(bc, "request-card-insert"); - /* Select remote (forwarded) SIM */ frontend_request_sim_remote(bc); call_script(bc, "request-sim-remote"); @@ -199,6 +195,10 @@ /* Set the ATR */ frontend_handle_set_atr(bc, bc->cfg->atr.data, bc->cfg->atr.len); + /* Simulate card insertion to modem */ + frontend_request_card_insert(bc); + call_script(bc, "request-card-insert"); + /* Reset the modem */ frontend_request_modem_reset(bc); call_script(bc, "request-modem-reset"); -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30137 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I7b0640b929e174e8dfdcc86947fa409e4acf338f Gerrit-Change-Number: 30137 Gerrit-PatchSet: 1 Gerrit-Owner: jtavares <jtavares(a)kvh.com> Gerrit-MessageType: newchange
1 0
0 0
Change in osmo-remsim[master]: bankd: add missing -p short form option
by jtavares 14 Nov '22

14 Nov '22
jtavares has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-remsim/+/30136 ) Change subject: bankd: add missing -p short form option ...................................................................... bankd: add missing -p short form option Change-Id: I44969c70612a25184fc51b695c7dbf97865fb116 --- M src/bankd/bankd_main.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/36/30136/1 diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c index b3b8dff..e184aba 100644 --- a/src/bankd/bankd_main.c +++ b/src/bankd/bankd_main.c @@ -319,7 +319,7 @@ { 0, 0, 0, 0 } }; - c = getopt_long(argc, argv, "hVd:i:o:b:n:N:I:P:s", long_options, &option_index); + c = getopt_long(argc, argv, "hVd:i:p:o:b:n:N:I:P:s", long_options, &option_index); if (c == -1) break; @@ -808,7 +808,7 @@ break; } - return rc; + return rc; } static int wait_for_fd_or_timeout(int fd, unsigned int timeout_secs) -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/30136 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I44969c70612a25184fc51b695c7dbf97865fb116 Gerrit-Change-Number: 30136 Gerrit-PatchSet: 1 Gerrit-Owner: jtavares <jtavares(a)kvh.com> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • ...
  • 251
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.