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

May 2023

  • 1 participants
  • 2583 discussions
[M] Change in osmo-bts[master]: all models, FR/EFR UL: change SID check to _is_any_sid()
by fixeria 10 May '23

10 May '23
Attention is currently required from: falconia. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/32678 ) Change subject: all models, FR/EFR UL: change SID check to _is_any_sid() ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/32678 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I5c24b379deda8ae551f9924d10770da50e6acbbd Gerrit-Change-Number: 32678 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: falconia <falcon(a)freecalypso.org> Gerrit-Comment-Date: Wed, 10 May 2023 08:55:02 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
[S] Change in osmo-hnbgw[master]: contrib/jenkins.sh: add PFCP variable
by osmith 10 May '23

10 May '23
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/32430 ) Change subject: contrib/jenkins.sh: add PFCP variable ...................................................................... contrib/jenkins.sh: add PFCP variable Related: OS#6013 Change-Id: Iacc6a0267d4896d0149f5e00d77951cdfc281e4e --- M contrib/jenkins.sh 1 file changed, 17 insertions(+), 2 deletions(-) Approvals: laforge: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh index 98291b4..dfbbbfe 100755 --- a/contrib/jenkins.sh +++ b/contrib/jenkins.sh @@ -2,9 +2,11 @@ # jenkins build helper script for osmo-hnbgw. This is how we build on jenkins.osmocom.org # # environment variables: +# * PFCP: configure PFCP support if set to "1" (default) # * WITH_MANUALS: build manual PDFs if set to "1" # * PUBLISH: upload manuals after building if set to "1" (ignored without WITH_MANUALS = "1") # +PFCP=${PFCP:-1} if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then echo "Error: We need to have scripts/osmo-deps.sh from http://git.osmocom.org/osmo-ci/ in PATH !" @@ -33,15 +35,18 @@ osmo-build-dep.sh libosmo-abis osmo-build-dep.sh libosmo-netif osmo-build-dep.sh libosmo-sccp -osmo-build-dep.sh libosmo-pfcp osmo-build-dep.sh libasn1c osmo-build-dep.sh osmo-iuh osmo-build-dep.sh osmo-mgw # Additional configure options and depends CONFIG="" +if [ "$PFCP" = "1" ]; then + osmo-build-dep.sh libosmo-pfcp + CONFIG="$CONFIG --enable-pfcp" +fi if [ "$WITH_MANUALS" = "1" ]; then - CONFIG="--enable-manuals" + CONFIG="$CONFIG --enable-manuals" fi set +x -- To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/32430 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hnbgw Gerrit-Branch: master Gerrit-Change-Id: Iacc6a0267d4896d0149f5e00d77951cdfc281e4e Gerrit-Change-Number: 32430 Gerrit-PatchSet: 4 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[L] Change in docker-playground[master]: new bsc-nat: msc tests
by Hoernchen 10 May '23

10 May '23
Attention is currently required from: Hoernchen. Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/docker-playground/+/27625 to look at the new patch set (#3). Change subject: new bsc-nat: msc tests ...................................................................... new bsc-nat: msc tests Copies of the MSC tests with added bscnat that should work just like the msc tests without the bscnat. Change-Id: Ifdb9956a8bdde8aa3f9f62bfcfc035baab01c934 --- A osmo-bsc-nat-latest/Dockerfile A osmo-bsc-nat-latest/Makefile A osmo-bsc-nat-latest/osmo-bsc-nat.cfg A osmo-bsc-nat-master/Dockerfile A osmo-bsc-nat-master/Makefile A osmo-bsc-nat-master/osmo-bsc-nat.cfg A ttcn3-bsc-nat-msc-test/Dockerfile A ttcn3-bsc-nat-msc-test/MSC_Tests.cfg A ttcn3-bsc-nat-msc-test/Makefile A ttcn3-bsc-nat-msc-test/jenkins.sh A ttcn3-bsc-nat-msc-test/osmo-bsc-nat.cfg A ttcn3-bsc-nat-msc-test/osmo-mgw.cfg A ttcn3-bsc-nat-msc-test/osmo-msc.cfg A ttcn3-bsc-nat-msc-test/osmo-stp-nat.cfg A ttcn3-bsc-nat-msc-test/osmo-stp.cfg 15 files changed, 687 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/25/27625/3 -- To view, visit https://gerrit.osmocom.org/c/docker-playground/+/27625 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: docker-playground Gerrit-Branch: master Gerrit-Change-Id: Ifdb9956a8bdde8aa3f9f62bfcfc035baab01c934 Gerrit-Change-Number: 27625 Gerrit-PatchSet: 3 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge <laforge(a)osmocom.org> Gerrit-CC: msuraev <msuraev(a)sysmocom.de> Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de> Gerrit-MessageType: newpatchset
1 0
0 0
[S] Change in libosmo-abis[master]: e1d: get rid of strange file descriptor registered check
by dexter 10 May '23

10 May '23
dexter has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/32569 ) Change subject: e1d: get rid of strange file descriptor registered check ...................................................................... e1d: get rid of strange file descriptor registered check When the line update happens the list.next member of the file descriptor is checked for NULL and != LLIST_POISON1. This directly tampers with the llist API and might be problematic. Also we can tell by the file descriptor number if the file descriptor is registered or not. An open file descriptor is always registered. Change-Id: I92c426271dc5455427471030fcf0749566e4c2ee Related: OS#5983 --- M src/input/e1d.c 1 file changed, 18 insertions(+), 2 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/src/input/e1d.c b/src/input/e1d.c index e1a1526..cf50e27 100644 --- a/src/input/e1d.c +++ b/src/input/e1d.c @@ -410,8 +410,8 @@ struct e1inp_ts *e1i_ts = &line->ts[idx]; struct osmo_fd *bfd = &e1i_ts->driver.e1d.fd; - /* unregister FD if it was already registered */ - if (bfd->list.next && bfd->list.next != LLIST_POISON1) + /* unregister FD if it was already registered/in use */ + if (osmo_fd_is_registered(bfd)) osmo_fd_unregister(bfd); if (e1i_ts->type != E1INP_TS_TYPE_NONE && ts >= num_ts_info) { -- To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/32569 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-abis Gerrit-Branch: master Gerrit-Change-Id: I92c426271dc5455427471030fcf0749566e4c2ee Gerrit-Change-Number: 32569 Gerrit-PatchSet: 4 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: tnt <tnt(a)246tNt.com> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmo-hlr[master]: hlr: use talloc for memory allocation in osmo_gsup_create_insert_subs...
by lynxis lazus 10 May '23

10 May '23
lynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/32511 ) Change subject: hlr: use talloc for memory allocation in osmo_gsup_create_insert_subscriber_data_msg ...................................................................... hlr: use talloc for memory allocation in osmo_gsup_create_insert_subscriber_data_msg Don't use static buffers for APN and MSISDN. When encoding multiple APNs the static buffer might be too small. In prepration to support multiple APNs in subscriber data Change-Id: I00b5c2dfadcf6e0740e93b4c3292d2654d22e80c --- M include/osmocom/hlr/gsup_server.h M src/gsup_server.c M src/hlr.c M src/lu_fsm.c 4 files changed, 26 insertions(+), 28 deletions(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/hlr/gsup_server.h b/include/osmocom/hlr/gsup_server.h index 9c562e2..86ae4ec 100644 --- a/include/osmocom/hlr/gsup_server.h +++ b/include/osmocom/hlr/gsup_server.h @@ -69,8 +69,6 @@ int osmo_gsup_configure_wildcard_apn(struct osmo_gsup_message *gsup, uint8_t *apn_buf, size_t apn_buf_size); int osmo_gsup_create_insert_subscriber_data_msg(struct osmo_gsup_message *gsup, const char *imsi, const char *msisdn, - uint8_t *msisdn_enc, size_t msisdn_enc_size, - uint8_t *apn_buf, size_t apn_buf_size, - enum osmo_gsup_cn_domain cn_domain); + enum osmo_gsup_cn_domain cn_domain, void *talloc_ctx); int osmo_gsup_forward_to_local_peer(struct osmo_gsup_server *server, const struct osmo_cni_peer_id *to_peer, struct osmo_gsup_req *req, struct osmo_gsup_message *modified_gsup); diff --git a/src/gsup_server.c b/src/gsup_server.c index f0d8101..097a854 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -446,19 +446,16 @@ * \param[out] gsup The gsup message to populate. * \param[in] imsi The subscriber's IMSI. * \param[in] msisdn The subscriber's MSISDN. - * \param[out] msisdn_enc A buffer large enough to store the MSISDN in encoded form. - * \param[in] msisdn_enc_size Size of the buffer (must be >= OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN). - * \param[out] apn_buf A buffer large enough to store an APN (required if cn_domain is OSMO_GSUP_CN_DOMAIN_PS). - * \param[in] apn_buf_size Size of APN buffer (must be >= APN_MAXLEN). * \param[in] cn_domain The CN Domain of the subscriber connection. + * \param[in] talloc_ctx To allocation memory for dynamic fields (msisdn, apn) in the gsup field * \returns 0 on success, and negative on error. */ int osmo_gsup_create_insert_subscriber_data_msg(struct osmo_gsup_message *gsup, const char *imsi, const char *msisdn, - uint8_t *msisdn_enc, size_t msisdn_enc_size, - uint8_t *apn_buf, size_t apn_buf_size, - enum osmo_gsup_cn_domain cn_domain) + enum osmo_gsup_cn_domain cn_domain, + void *talloc_ctx) { int len; + uint8_t *msisdn_buf = talloc_size(talloc_ctx, OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN); OSMO_ASSERT(gsup); *gsup = (struct osmo_gsup_message){ @@ -467,27 +464,22 @@ osmo_strlcpy(gsup->imsi, imsi, sizeof(gsup->imsi)); - if (msisdn_enc_size < OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN) - return -ENOSPC; - - OSMO_ASSERT(msisdn_enc); - len = gsm48_encode_bcd_number(msisdn_enc, msisdn_enc_size, 0, msisdn); + len = gsm48_encode_bcd_number(msisdn_buf, OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN, 0, msisdn); if (len < 1) { LOGP(DLGSUP, LOGL_ERROR, "%s: Error: cannot encode MSISDN '%s'\n", imsi, msisdn); return -ENOSPC; } - gsup->msisdn_enc = msisdn_enc; + gsup->msisdn_enc = msisdn_buf; gsup->msisdn_enc_len = len; #pragma message "FIXME: deal with encoding the following data: gsup.hlr_enc" gsup->cn_domain = cn_domain; if (gsup->cn_domain == OSMO_GSUP_CN_DOMAIN_PS) { - OSMO_ASSERT(apn_buf_size >= APN_MAXLEN); - OSMO_ASSERT(apn_buf); + uint8_t *apn_buf = talloc_size(talloc_ctx, APN_MAXLEN); /* FIXME: PDP infos - use more fine-grained access control instead of wildcard APN */ - osmo_gsup_configure_wildcard_apn(gsup, apn_buf, apn_buf_size); + osmo_gsup_configure_wildcard_apn(gsup, apn_buf, APN_MAXLEN); } return 0; diff --git a/src/hlr.c b/src/hlr.c index 8183d9b..e3b54ac 100644 --- a/src/hlr.c +++ b/src/hlr.c @@ -85,8 +85,6 @@ llist_for_each_entry(co, &g_hlr->gs->clients, list) { struct osmo_gsup_message gsup = { }; - uint8_t msisdn_enc[OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN]; - uint8_t apn[APN_MAXLEN]; struct msgb *msg_out; uint8_t *peer; int peer_len; @@ -131,8 +129,7 @@ subscr->imsi, cn_domain == OSMO_GSUP_CN_DOMAIN_PS ? "PS" : "CS", osmo_quote_str(peer_compare, -1)); - if (osmo_gsup_create_insert_subscriber_data_msg(&gsup, subscr->imsi, subscr->msisdn, msisdn_enc, - sizeof(msisdn_enc), apn, sizeof(apn), cn_domain) != 0) { + if (osmo_gsup_create_insert_subscriber_data_msg(&gsup, subscr->imsi, subscr->msisdn, cn_domain, OTC_SELECT) != 0) { LOGP(DLGSUP, LOGL_ERROR, "IMSI='%s': Cannot notify GSUP client; could not create gsup message " "for %s:%u\n", subscr->imsi, diff --git a/src/lu_fsm.c b/src/lu_fsm.c index deb180b..e6ed31a 100644 --- a/src/lu_fsm.c +++ b/src/lu_fsm.c @@ -241,13 +241,11 @@ struct lu *lu = fi->priv; struct hlr_subscriber *subscr = &lu->subscr; struct osmo_gsup_message gsup; - uint8_t msisdn_enc[OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN]; - uint8_t apn[APN_MAXLEN]; if (osmo_gsup_create_insert_subscriber_data_msg(&gsup, subscr->imsi, - subscr->msisdn, msisdn_enc, sizeof(msisdn_enc), - apn, sizeof(apn), - lu->is_ps? OSMO_GSUP_CN_DOMAIN_PS : OSMO_GSUP_CN_DOMAIN_CS)) { + subscr->msisdn, + lu->is_ps ? OSMO_GSUP_CN_DOMAIN_PS : OSMO_GSUP_CN_DOMAIN_CS, + OTC_SELECT)) { lu_failure(lu, GMM_CAUSE_NET_FAIL, "cannot encode Insert Subscriber Data message"); return; } -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/32511 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I00b5c2dfadcf6e0740e93b4c3292d2654d22e80c Gerrit-Change-Number: 32511 Gerrit-PatchSet: 5 Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: msuraev <msuraev(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmo-hlr[master]: hlr: use talloc for memory allocation in osmo_gsup_create_insert_subs...
by lynxis lazus 10 May '23

10 May '23
Attention is currently required from: pespin, fixeria, msuraev. lynxis lazus has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/32511 ) Change subject: hlr: use talloc for memory allocation in osmo_gsup_create_insert_subscriber_data_msg ...................................................................... Patch Set 4: (1 comment) File src/gsup_server.c: https://gerrit.osmocom.org/c/osmo-hlr/+/32511/comment/0471a0c9_08087036 PS3, Line 455: void *talloc_ctx) > Agreeing with @lynxis here. Done -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/32511 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I00b5c2dfadcf6e0740e93b4c3292d2654d22e80c Gerrit-Change-Number: 32511 Gerrit-PatchSet: 4 Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu> 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-CC: msuraev <msuraev(a)sysmocom.de> Gerrit-Attention: pespin <pespin(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: msuraev <msuraev(a)sysmocom.de> Gerrit-Comment-Date: Wed, 10 May 2023 07:58:55 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de> Comment-In-Reply-To: pespin <pespin(a)sysmocom.de> Comment-In-Reply-To: lynxis lazus <lynxis(a)fe80.eu> Gerrit-MessageType: comment
1 0
0 0
[L] Change in osmo-hlr[master]: Add support for multiple APN profiles for subscriber data
by lynxis lazus 10 May '23

10 May '23
Attention is currently required from: laforge. lynxis lazus has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/32512 ) Change subject: Add support for multiple APN profiles for subscriber data ...................................................................... Patch Set 5: (1 comment) File src/hlr_vty.c: https://gerrit.osmocom.org/c/osmo-hlr/+/32512/comment/867e78dd_cf23be1f PS5, Line 133: Define a PDP profile set.\n" : "Unique identifier for this PDP profile set.\n") > I think the description strings don't fit the default profile enabled flag, but they were copied fro […] I wasn't sure what a complex scenario could be. In some future we want to have subscriber specific profiles. On the other end most of the subscriber will use a common pdp-profile. The idea here is to allow multiple common pdp-profiles (called pdp profile sets) in the future. Do you have an idea how to improve the help? -- To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/32512 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-hlr Gerrit-Branch: master Gerrit-Change-Id: I540132ee5dcfd09f4816e02e702927e1074ca50f Gerrit-Change-Number: 32512 Gerrit-PatchSet: 5 Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-CC: laforge <laforge(a)osmocom.org> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Wed, 10 May 2023 07:58:31 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org> Gerrit-MessageType: comment
1 0
0 0
[M] Change in libosmocore[master]: tests: Add initial osmo_io tests
by daniel 10 May '23

10 May '23
daniel has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32181 ) Change subject: tests: Add initial osmo_io tests ...................................................................... tests: Add initial osmo_io tests Change-Id: Ia67629e53f4d2e5784177250d58e268fdfcaa0c2 --- M tests/Makefile.am A tests/osmo_io/osmo_io_test.c A tests/osmo_io/osmo_io_test.err A tests/osmo_io/osmo_io_test.ok M tests/testsuite.at 5 files changed, 212 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/tests/Makefile.am b/tests/Makefile.am index 6876df3..c6027a9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -53,6 +53,7 @@ v110/test_frame \ v110/test_ra1 \ gsm44021/test_frame_csd \ + osmo_io/osmo_io_test \ $(NULL) if ENABLE_MSGFILE @@ -367,6 +368,8 @@ $(top_builddir)/src/gsm/libosmogsm.la \ $(LDADD) +osmo_io_osmo_io_test_SOURCES = osmo_io/osmo_io_test.c + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac @@ -469,6 +472,7 @@ v110/test_frame.ok \ v110/test_ra1.ok \ gsm44021/test_frame_csd.ok \ + osmo_io/osmo_io_test.ok osmo_io/osmo_io_test.err \ $(NULL) if ENABLE_LIBSCTP @@ -678,6 +682,10 @@ >$(srcdir)/v110/test_ra1.ok gsm44021/test_frame_csd \ >$(srcdir)/gsm44021/test_frame_csd.ok + osmo_io/osmo_io_test \ + >$(srcdir)/osmo_io/osmo_io_test.ok \ + 2>$(srcdir)/osmo_io/osmo_io_test.err + check-local: atconfig $(TESTSUITE) [ -e /proc/cpuinfo ] && cat /proc/cpuinfo diff --git a/tests/osmo_io/osmo_io_test.c b/tests/osmo_io/osmo_io_test.c new file mode 100644 index 0000000..1991926 --- /dev/null +++ b/tests/osmo_io/osmo_io_test.c @@ -0,0 +1,179 @@ +/* + * (C) 2023 by sysmocom s.f.m.c + * Author: Daniel Willmann <daniel(a)sysmocom.de> + * + * All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ + * + * 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 <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/socket.h> +#include <errno.h> + +#include <osmocom/core/application.h> +#include <osmocom/core/bits.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/osmo_io.h> +#include <osmocom/core/select.h> +#include <osmocom/core/utils.h> + +#include "config.h" + +#define TEST_START() printf("Running %s\n", __func__) + +static void *ctx = NULL; + +static void read_cb(struct osmo_io_fd *iofd, int rc, struct msgb *msg) +{ + printf("%s: read() msg with len=%d\n", osmo_iofd_get_name(iofd), rc); + if (msg) + printf("%s\n", osmo_hexdump(msgb_data(msg), msgb_length(msg))); + + talloc_free(msg); +} + +static void write_cb(struct osmo_io_fd *iofd, int rc, const struct msgb *msg) +{ + printf("%s: write() returned rc=%d\n", osmo_iofd_get_name(iofd), rc); +} + +struct osmo_io_ops ioops_conn_read_write = { + .read_cb = read_cb, + .write_cb = write_cb, +}; + +uint8_t TESTDATA[] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 +}; + +static void test_connected(void) +{ + int fds[2] = {0, 0}, rc; + struct osmo_io_fd *iofd1, *iofd2; + struct msgb *msg; + uint8_t *buf; + + TEST_START(); + + rc = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); + OSMO_ASSERT(rc == 0); + + iofd1 = osmo_iofd_setup(ctx, fds[0], "ep1", OSMO_IO_FD_MODE_READ_WRITE, &ioops_conn_read_write, NULL); + osmo_iofd_register(iofd1, fds[0]); + iofd2 = osmo_iofd_setup(ctx, fds[1], "ep2", OSMO_IO_FD_MODE_READ_WRITE, &ioops_conn_read_write, NULL); + osmo_iofd_register(iofd2, fds[1]); + + msg = msgb_alloc(1024, "Test data"); + buf = msgb_put(msg, sizeof(TESTDATA)); + memcpy(buf, TESTDATA, sizeof(TESTDATA)); + + osmo_iofd_write_msgb(iofd1, msg); + osmo_iofd_write_enable(iofd1); + osmo_iofd_write_enable(iofd2); + osmo_iofd_read_enable(iofd1); + osmo_iofd_read_enable(iofd2); + + + /* Allow enough cycles to handle the messages */ + for (int i = 0; i < 128; i++) + osmo_select_main(1); + + osmo_iofd_free(iofd1); + osmo_iofd_free(iofd2); +} + +static void recvfrom_cb(struct osmo_io_fd *iofd, int rc, struct msgb *msg, + const struct osmo_sockaddr *saddr) +{ + printf("%s: recvfrom() msg with len=%d\n", osmo_iofd_get_name(iofd), rc); + if (msg) + printf("%s\n", osmo_hexdump(msgb_data(msg), msgb_length(msg))); + + talloc_free(msg); +} + +static void sendto_cb(struct osmo_io_fd *iofd, int rc, const struct msgb *msg, + const struct osmo_sockaddr *daddr) +{ + printf("%s: sendto() returned rc=%d\n", osmo_iofd_get_name(iofd), rc); +} + +struct osmo_io_ops ioops_conn_recvfrom_sendto = { + .sendto_cb = sendto_cb, + .recvfrom_cb = recvfrom_cb, +}; + +static void test_unconnected(void) +{ + int fds[2] = {0, 0}, rc; + struct osmo_io_fd *iofd1, *iofd2; + struct msgb *msg; + uint8_t *buf; + + TEST_START(); + + rc = socketpair(AF_UNIX, SOCK_DGRAM, 0, fds); + OSMO_ASSERT(rc == 0); + + iofd1 = osmo_iofd_setup(ctx, fds[0], "ep1", OSMO_IO_FD_MODE_RECVFROM_SENDTO, &ioops_conn_recvfrom_sendto, NULL); + osmo_iofd_register(iofd1, fds[0]); + iofd2 = osmo_iofd_setup(ctx, fds[1], "ep2", OSMO_IO_FD_MODE_RECVFROM_SENDTO, &ioops_conn_recvfrom_sendto, NULL); + osmo_iofd_register(iofd2, fds[1]); + + msg = msgb_alloc(1024, "Test data"); + buf = msgb_put(msg, sizeof(TESTDATA)); + memcpy(buf, TESTDATA, sizeof(TESTDATA)); + + osmo_iofd_sendto_msgb(iofd1, msg, 0, NULL); + osmo_iofd_write_enable(iofd1); + osmo_iofd_write_enable(iofd2); + osmo_iofd_read_enable(iofd1); + osmo_iofd_read_enable(iofd2); + + + /* Allow enough cycles to handle the messages */ + for (int i = 0; i < 128; i++) + osmo_select_main(1); + + osmo_iofd_free(iofd1); + osmo_iofd_free(iofd2); +} +static const struct log_info_cat default_categories[] = { +}; + +static struct log_info info = { + .cat = default_categories, + .num_cat = ARRAY_SIZE(default_categories), +}; + +int main(int argc, char *argv[]) +{ + ctx = talloc_named_const(NULL, 0, "osmo_io_test"); + osmo_init_logging2(ctx, &info); + log_set_use_color(osmo_stderr_target, 0); + log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE); + log_set_print_category(osmo_stderr_target, 0); + log_set_print_category_hex(osmo_stderr_target, 0); + + test_connected(); + test_unconnected(); + + return EXIT_SUCCESS; +} diff --git a/tests/osmo_io/osmo_io_test.err b/tests/osmo_io/osmo_io_test.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/osmo_io/osmo_io_test.err diff --git a/tests/osmo_io/osmo_io_test.ok b/tests/osmo_io/osmo_io_test.ok new file mode 100644 index 0000000..745e36a --- /dev/null +++ b/tests/osmo_io/osmo_io_test.ok @@ -0,0 +1,8 @@ +Running test_connected +ep1: write() returned rc=16 +ep2: read() msg with len=16 +01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 +Running test_unconnected +ep1: sendto() returned rc=16 +ep2: recvfrom() msg with len=16 +01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 diff --git a/tests/testsuite.at b/tests/testsuite.at index 60aa74d..a2c8845 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -508,3 +508,11 @@ cat $abs_srcdir/gsm44021/test_frame_csd.ok > expout AT_CHECK([$abs_top_builddir/tests/gsm44021/test_frame_csd], [], [expout],[]) AT_CLEANUP + +AT_SETUP([osmo_io]) +AT_KEYWORDS([osmo_io]) +cat $abs_srcdir/osmo_io/osmo_io_test.ok > expout +cat $abs_srcdir/osmo_io/osmo_io_test.err > experr +touch experr +AT_CHECK([$abs_top_builddir/tests/osmo_io/osmo_io_test], [0], [expout], [experr]) +AT_CLEANUP -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32181 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ia67629e53f4d2e5784177250d58e268fdfcaa0c2 Gerrit-Change-Number: 32181 Gerrit-PatchSet: 14 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[XL] Change in libosmocore[master]: Add osmo_io with initial poll backend
by daniel 10 May '23

10 May '23
daniel has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/30934 ) Change subject: Add osmo_io with initial poll backend ...................................................................... Add osmo_io with initial poll backend * make backend configurable for later * segmentation callback for chunked streams * logging target for osmo_io * support partial writes Change-Id: I50d73cf550d6ce8154bf827bf47408131cf5b0a0 Related: SYS#5094, OS#5751 --- M TODO-RELEASE M include/osmocom/core/Makefile.am M include/osmocom/core/logging.h A include/osmocom/core/osmo_io.h M src/core/Makefile.am M src/core/libosmocore.map M src/core/logging.c A src/core/osmo_io.c A src/core/osmo_io_internal.h A src/core/osmo_io_poll.c M tests/logging/logging_vty_test.vty 11 files changed, 1,064 insertions(+), 3 deletions(-) Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve dexter: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/TODO-RELEASE b/TODO-RELEASE index bade6f5..7270257 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -10,3 +10,4 @@ libosmogsm new header osmocom/gsm/protocol/gsm_44_060.h libosmocore ADD new defines in osmocom/gsm/protocol/gsm_04_08.h (old ones marked deprecated) libosmovty drop API drop struct vty_parent_node from public API, it should never have been public +libosmocore ADD new API osmo_io_*() diff --git a/include/osmocom/core/Makefile.am b/include/osmocom/core/Makefile.am index e1cd92a..1d394cd 100644 --- a/include/osmocom/core/Makefile.am +++ b/include/osmocom/core/Makefile.am @@ -37,6 +37,7 @@ msgb.h \ netdev.h \ netns.h \ + osmo_io.h \ panic.h \ prbs.h \ prim.h \ diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index 755564d..e8433a1 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -154,7 +154,8 @@ #define DLCSN1 -26 /*!< CSN.1 (Concrete Syntax Notation 1) codec */ #define DLM2PA -27 /*!< Osmocom M2PA (libosmo-sigtran) */ #define DLM2UA -28 /*!< Reserved for future Osmocom M2UA (libosmo-sigtran) */ -#define OSMO_NUM_DLIB 28 /*!< Number of logging sub-systems in libraries */ +#define DLIO -29 /*!< Osmocom IO sub-system */ +#define OSMO_NUM_DLIB 29 /*!< Number of logging sub-systems in libraries */ /* Colors that can be used in log_info_cat.color */ #define OSMO_LOGCOLOR_NORMAL NULL diff --git a/include/osmocom/core/osmo_io.h b/include/osmocom/core/osmo_io.h new file mode 100644 index 0000000..ffc8cfa --- /dev/null +++ b/include/osmocom/core/osmo_io.h @@ -0,0 +1,90 @@ +/*! \file osmo_io.h + * io(_uring) abstraction osmo fd compatibility + */ + +#pragma once + +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/socket.h> +#include <osmocom/core/utils.h> + + +#define LOGPIO(iofd, level, fmt, args...) \ + LOGP(DLIO, level, "iofd(%s)" fmt, iofd->name, ## args) + +struct osmo_io_fd; + +enum osmo_io_fd_mode { + /*! use read() / write() calls */ + OSMO_IO_FD_MODE_READ_WRITE, + /*! use recvfrom() / sendto() calls */ + OSMO_IO_FD_MODE_RECVFROM_SENDTO, + /*! emulate sctp_recvmsg() and sctp_sendmsg() */ + OSMO_IO_FD_MODE_SCTP_RECVMSG_SENDMSG, +}; + +enum osmo_io_backend { + OSMO_IO_BACKEND_POLL, +}; + +extern const struct value_string osmo_io_backend_names[]; +static inline const char *osmo_io_backend_name(enum osmo_io_backend val) +{ return get_value_string(osmo_io_backend_names, val); } + +struct osmo_io_ops { + union { + /* mode OSMO_IO_FD_MODE_READ_WRITE: */ + struct { + /*! call-back function when something was read from fd */ + void (*read_cb)(struct osmo_io_fd *iofd, int res, struct msgb *msg); + /*! call-back function when write has completed on fd */ + void (*write_cb)(struct osmo_io_fd *iofd, int res, + const struct msgb *msg); + /*! call-back function to segment the data returned by read_cb */ + int (*segmentation_cb)(struct msgb *msg, int data_len); + }; + + /* mode OSMO_IO_FD_MODE_RECVFROM_SENDTO: */ + struct { + /*! call-back function emulating sendto */ + void (*sendto_cb)(struct osmo_io_fd *iofd, int res, + const struct msgb *msg, + const struct osmo_sockaddr *daddr); + /*! call-back function emulating recvfrom */ + void (*recvfrom_cb)(struct osmo_io_fd *iofd, int res, + struct msgb *msg, + const struct osmo_sockaddr *saddr); + }; + }; +}; + +void osmo_io_init(void); + +struct osmo_io_fd *osmo_iofd_setup(const void *ctx, int fd, const char *name, + enum osmo_io_fd_mode mode, const struct osmo_io_ops *ioops, void *data); +int osmo_iofd_register(struct osmo_io_fd *iofd, int fd); +int osmo_iofd_unregister(struct osmo_io_fd *iofd); +unsigned int osmo_iofd_txqueue_len(struct osmo_io_fd *iofd); +void osmo_iofd_txqueue_clear(struct osmo_io_fd *iofd); +int osmo_iofd_close(struct osmo_io_fd *iofd); +void osmo_iofd_free(struct osmo_io_fd *iofd); +void osmo_iofd_read_enable(struct osmo_io_fd *iofd); +void osmo_iofd_read_disable(struct osmo_io_fd *iofd); +void osmo_iofd_write_enable(struct osmo_io_fd *iofd); +void osmo_iofd_write_disable(struct osmo_io_fd *iofd); + +int osmo_iofd_write_msgb(struct osmo_io_fd *iofd, struct msgb *msg); +int osmo_iofd_sendto_msgb(struct osmo_io_fd *iofd, struct msgb *msg, int sendto_flags, + const struct osmo_sockaddr *dest); + +void osmo_iofd_set_alloc_info(struct osmo_io_fd *iofd, unsigned int size, unsigned int headroom); +void *osmo_iofd_get_data(const struct osmo_io_fd *iofd); +void osmo_iofd_set_data(struct osmo_io_fd *iofd, void *data); + +unsigned int osmo_iofd_get_priv_nr(const struct osmo_io_fd *iofd); +void osmo_iofd_set_priv_nr(struct osmo_io_fd *iofd, unsigned int priv_nr); + +int osmo_iofd_get_fd(const struct osmo_io_fd *iofd); +const char *osmo_iofd_get_name(const struct osmo_io_fd *iofd); diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 50c39d1..80ee458 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -50,6 +50,8 @@ msgb.c \ netdev.c \ netns.c \ + osmo_io.c \ + osmo_io_poll.c \ panic.c \ prbs.c \ prim.c \ @@ -107,6 +109,7 @@ conv_acc_sse_impl.h \ conv_acc_neon_impl.h \ crcXXgen.c.tpl \ + osmo_io_internal.h \ stat_item_internal.h \ libosmocore.map \ $(NULL) diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map index 095a4c0..7bca331 100644 --- a/src/core/libosmocore.map +++ b/src/core/libosmocore.map @@ -252,6 +252,30 @@ osmo_init_logging2; osmo_int_to_float_str_buf; osmo_int_to_float_str_c; +osmo_io_backend_names; +osmo_iofd_close; +osmo_iofd_free; +osmo_iofd_get_data; +osmo_iofd_get_fd; +osmo_iofd_get_name; +osmo_iofd_get_priv_nr; +osmo_iofd_init; +osmo_iofd_ops; +osmo_iofd_read_disable; +osmo_iofd_read_enable; +osmo_iofd_register; +osmo_iofd_sendto_msgb; +osmo_iofd_set_alloc_info; +osmo_iofd_set_data; +osmo_iofd_set_priv_nr; +osmo_iofd_setup; +osmo_iofd_txqueue_clear; +osmo_iofd_txqueue_len; +osmo_iofd_unregister; +osmo_iofd_uring_init; +osmo_iofd_write_disable; +osmo_iofd_write_enable; +osmo_iofd_write_msgb; osmo_ip_str_type; osmo_isdnhdlc_decode; osmo_isdnhdlc_encode; diff --git a/src/core/logging.c b/src/core/logging.c index 3095f0d..c6774f5 100644 --- a/src/core/logging.c +++ b/src/core/logging.c @@ -313,6 +313,12 @@ .enabled = 1, .loglevel = LOGL_NOTICE, .color = "\033[38;5;11m", }, + [INT2IDX(DLIO)] = { + .name = "DLIO", + .description = "libosmocore IO Subsystem", + .enabled = 1, .loglevel = LOGL_NOTICE, + .color = "\033[38;5;67m", + }, }; void assert_loginfo(const char *src) diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c new file mode 100644 index 0000000..cfb6d68 --- /dev/null +++ b/src/core/osmo_io.c @@ -0,0 +1,602 @@ +/*! \file osmo_io.c + * New osmocom async I/O API. + * + * (C) 2022 by Harald Welte <laforge(a)osmocom.org> + * (C) 2022-2023 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Daniel Willmann <dwillmann(a)sysmocom.de> + * + * All Rights Reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + * + * 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 "../config.h" +#if defined(__linux__) + +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <talloc.h> +#include <unistd.h> +#include <string.h> +#include <stdbool.h> +#include <errno.h> + +#include <osmocom/core/osmo_io.h> +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/socket.h> +#include <osmocom/core/talloc.h> +#include <osmocom/core/utils.h> + +#include "osmo_io_internal.h" + +/*! This environment variable can be set to manually set the backend used in osmo_io */ +#define OSMO_IO_BACKEND_ENV "LIBOSMO_IO_BACKEND" + +const struct value_string osmo_io_backend_names[] = { + { OSMO_IO_BACKEND_POLL, "poll" }, + { 0, NULL } +}; + +static enum osmo_io_backend g_io_backend; + +/* Used by some tests, can't be static */ +struct iofd_backend_ops osmo_iofd_ops; + +/*! initialize osmo_io for the current thread */ +void osmo_iofd_init(void) +{ + switch (g_io_backend) { + case OSMO_IO_BACKEND_POLL: + break; + default: + OSMO_ASSERT(0); + break; + } +} + +/* ensure main thread always has pre-initialized osmo_io + * priority 103: run after on_dso_load_select */ +static __attribute__((constructor(103))) void on_dso_load_osmo_io(void) +{ + char *backend = getenv(OSMO_IO_BACKEND_ENV); + if (backend == NULL) + backend = OSMO_IO_BACKEND_DEFAULT; + + if (!strcmp("POLL", backend)) { + g_io_backend = OSMO_IO_BACKEND_POLL; + osmo_iofd_ops = iofd_poll_ops; + } else { + fprintf(stderr, "Invalid osmo_io backend requested: \"%s\"\nCheck the environment variable %s\n", backend, OSMO_IO_BACKEND_ENV); + exit(1); + } + + osmo_iofd_init(); +} + +/*! Allocate the msghdr + * \param[in] iofd the osmo_io file structure + * \param[in] action the action this msg(hdr) is for (read, write, ..) + * \param[in] msg the msg buffer to use. Will allocate a new one if NULL + * \returns the newly allocated msghdr or NULL in case of error */ +struct iofd_msghdr *iofd_msghdr_alloc(struct osmo_io_fd *iofd, enum iofd_msg_action action, struct msgb *msg) +{ + struct iofd_msghdr *hdr = talloc_zero(iofd, struct iofd_msghdr); + if (!hdr) + return NULL; + if (!msg) { + msg = iofd_msgb_alloc(iofd); + if (!msg) { + talloc_free(hdr); + return NULL; + } + } + + hdr->action = action; + hdr->iofd = iofd; + hdr->msg = msg; + + return hdr; +} + +/*! Free the msghdr + * \param[in] msghdr the msghdr to free + */ +void iofd_msghdr_free(struct iofd_msghdr *msghdr) +{ + /* msghdr->msg is never owned by msghdr, it will either be freed in the send path or + * or passed on to the read callback which takes ownership. */ + talloc_free(msghdr); +} + +/*! convenience wrapper to call msgb_alloc with parameters from osmo_io_fd */ +struct msgb *iofd_msgb_alloc(struct osmo_io_fd *iofd) +{ + uint16_t headroom = iofd->msgb_alloc.headroom; + + OSMO_ASSERT(iofd->msgb_alloc.size < 0xffff - headroom); + return msgb_alloc_headroom_c(iofd->msgb_alloc.ctx, + iofd->msgb_alloc.size + headroom, headroom, iofd->name); +} + +/*! return the pending msgb in iofd or NULL if there is none*/ +struct msgb *iofd_msgb_pending(struct osmo_io_fd *iofd) +{ + struct msgb *msg = NULL; + + msg = iofd->pending; + iofd->pending = NULL; + + return msg; +} + +/*! Return the pending msgb or allocate and return a new one */ +struct msgb *iofd_msgb_pending_or_alloc(struct osmo_io_fd *iofd) +{ + struct msgb *msg = NULL; + + msg = iofd_msgb_pending(iofd); + if (!msg) + msg = iofd_msgb_alloc(iofd); + + return msg; +} + +/*! Enqueue a message to be sent + * + * Enqueues the message at the back of the queue provided there is enough space. + * \param[in] iofd the file descriptor + * \param[in] msghdr the message to enqueue + * \returns 0 if the message was enqueued succcessfully, + * -ENOSPC if the queue already contains the maximum number of messages + */ +int iofd_txqueue_enqueue(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr) +{ + if (iofd->tx_queue.current_length >= iofd->tx_queue.max_length) + return -ENOSPC; + + llist_add_tail(&msghdr->list, &iofd->tx_queue.msg_queue); + iofd->tx_queue.current_length++; + + if (iofd->write_enabled && iofd->tx_queue.current_length == 1) + osmo_iofd_ops.write_enable(iofd); + + return 0; +} + +/*! Enqueue a message at the front + * + * Used to enqueue a msgb from a partial send again. This function will always + * enqueue the message, even if the maximum number of messages is reached. + * \param[in] iofd the file descriptor + * \param[in] msghdr the message to enqueue + */ +void iofd_txqueue_enqueue_front(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr) +{ + llist_add(&msghdr->list, &iofd->tx_queue.msg_queue); + iofd->tx_queue.current_length++; +} + +/*! Dequeue a message from the front + * + * \param[in] iofd the file descriptor + * \returns the msghdr from the front of the queue or NULL if the queue is empty + */ +struct iofd_msghdr *iofd_txqueue_dequeue(struct osmo_io_fd *iofd) +{ + struct llist_head *lh; + + if (iofd->tx_queue.current_length == 0) + return NULL; + + lh = iofd->tx_queue.msg_queue.next; + + OSMO_ASSERT(lh); + iofd->tx_queue.current_length--; + llist_del(lh); + + if (iofd->tx_queue.current_length == 0) + osmo_iofd_ops.write_disable(iofd); + + return llist_entry(lh, struct iofd_msghdr, list); +} + +/*! Handle segmentation of the msg. If this function returns *_HANDLE_ONE or MORE then the data in msg will contain + * one complete message. + * If there are bytes left over, *pending_out will point to a msgb with the remaining data. +*/ +static enum iofd_seg_act iofd_handle_segmentation(struct osmo_io_fd *iofd, struct msgb *msg, struct msgb **pending_out) +{ + int pending_len, msg_len; + struct msgb *msg_pending; + + msg_len = msgb_length(msg); + + if (!iofd->io_ops.segmentation_cb) { + *pending_out = NULL; + return IOFD_SEG_ACT_HANDLE_ONE; + } + + int len = iofd->io_ops.segmentation_cb(msg, msg_len); + + pending_len = msg_len - len; + /* No segmentation needed, return */ + if (pending_len == 0) { + *pending_out = NULL; + return IOFD_SEG_ACT_HANDLE_ONE; + } else if (pending_len < 0) { + *pending_out = msg; + return IOFD_SEG_ACT_DEFER; + } + + /* Copy the pending data over */ + msg_pending = iofd_msgb_alloc(iofd); + memcpy(msgb_data(msg_pending), msgb_data(msg) + len, pending_len); + msgb_put(msg_pending, pending_len); + *pending_out = msg_pending; + + /* Trim the original msgb to size */ + msgb_trim(msg, len); + return IOFD_SEG_ACT_HANDLE_MORE; +} + +/*! Restore message boundaries on read() and pass individual messages to the read callback + */ +void iofd_handle_segmented_read(struct osmo_io_fd *iofd, struct msgb *msg, int rc) +{ + int res; + struct msgb *pending = NULL; + + if (rc <= 0) { + iofd->io_ops.read_cb(iofd, rc, msg); + return; + } + + do { + res = iofd_handle_segmentation(iofd, msg, &pending); + if (res != IOFD_SEG_ACT_DEFER || rc < 0) + iofd->io_ops.read_cb(iofd, rc, msg); + if (res == IOFD_SEG_ACT_HANDLE_MORE) + msg = pending; + } while (res == IOFD_SEG_ACT_HANDLE_MORE); + + OSMO_ASSERT(iofd->pending == NULL); + iofd->pending = pending; +} + +/* Public functions */ + +/*! Send a message through a connected socket + * + * Appends the message to the internal transmit queue. + * If the function returns success (0) it will take ownership of the msgb and + * internally call msgb_free() after the write request completes. + * In case of an error the msgb needs to be freed by the caller. + * \param[in] iofd file descriptor to write to + * \param[in] msg message buffer to write + * \returns 0 in case of success; a negative value in case of error + */ +int osmo_iofd_write_msgb(struct osmo_io_fd *iofd, struct msgb *msg) +{ + int rc; + struct iofd_msghdr *msghdr = iofd_msghdr_alloc(iofd, IOFD_ACT_WRITE, msg); + if (!msghdr) + return -ENOMEM; + + msghdr->flags = 0; + msghdr->iov[0].iov_base = msgb_data(msghdr->msg); + msghdr->iov[0].iov_len = msgb_length(msghdr->msg); + msghdr->hdr.msg_iov = &msghdr->iov[0]; + msghdr->hdr.msg_iovlen = 1; + + rc = iofd_txqueue_enqueue(iofd, msghdr); + if (rc < 0) { + iofd_msghdr_free(msghdr); + LOGPIO(iofd, LOGL_ERROR, "enqueueing message failed (%d). Rejecting msgb\n", rc); + return rc; + } + + return 0; +} + +/*! Send a message through an unconnected socket + * + * Appends the message to the internal transmit queue. + * If the function returns success (0), it will take ownership of the msgb and + * internally call msgb_free() after the write request completes. + * In case of an error the msgb needs to be freed by the caller. + * \param[in] iofd file descriptor to write to + * \param[in] msg message buffer to send + * \param[in] sendto_flags Flags to pass to the send call + * \param[in] dest destination address to send the message to + * \returns 0 in case of success; a negative value in case of error + */ +int osmo_iofd_sendto_msgb(struct osmo_io_fd *iofd, struct msgb *msg, int sendto_flags, const struct osmo_sockaddr *dest) +{ + int rc; + + OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_RECVFROM_SENDTO); + + struct iofd_msghdr *msghdr = iofd_msghdr_alloc(iofd, IOFD_ACT_SENDTO, msg); + if (!msghdr) + return -ENOMEM; + + if (dest) { + msghdr->osa = *dest; + msghdr->hdr.msg_name = &msghdr->osa.u.sa; + msghdr->hdr.msg_namelen = osmo_sockaddr_size(&msghdr->osa); + } + msghdr->flags = sendto_flags; + msghdr->iov[0].iov_base = msgb_data(msghdr->msg); + msghdr->iov[0].iov_len = msgb_length(msghdr->msg); + msghdr->hdr.msg_iov = &msghdr->iov[0]; + msghdr->hdr.msg_iovlen = 1; + + rc = iofd_txqueue_enqueue(iofd, msghdr); + if (rc < 0) { + iofd_msghdr_free(msghdr); + LOGPIO(iofd, LOGL_ERROR, "enqueueing message failed (%d). Rejecting msgb\n", rc); + return rc; + } + + return 0; +} + +/*! Enable reading from this iofd + * + * \param[in] iofd the file descriptor + */ +void osmo_iofd_read_enable(struct osmo_io_fd *iofd) +{ + iofd->read_enabled = true; + osmo_iofd_ops.read_enable(iofd); +} + +/*! Disable reading from this iofd + * + * \param[in] iofd the file descriptor + */ +void osmo_iofd_read_disable(struct osmo_io_fd *iofd) +{ + iofd->read_enabled = false; + osmo_iofd_ops.read_disable(iofd); +} + +/*! Enable writing to this iofd + * + * \param[in] iofd the file descriptor + */ +void osmo_iofd_write_enable(struct osmo_io_fd *iofd) +{ + iofd->write_enabled = true; + if (iofd->tx_queue.current_length > 0) + osmo_iofd_ops.write_enable(iofd); +} + +/*! Disable writing to this iofd + * + * \param[in] iofd the file descriptor + */ +void osmo_iofd_write_disable(struct osmo_io_fd *iofd) +{ + iofd->write_enabled = false; + osmo_iofd_ops.write_disable(iofd); +} + +/*! Allocate and setup a new iofd + * \param[in] ctx the parent context from which to allocate + * \param[in] fd the underlying system file descriptor + * \param[in] name the name of the iofd + * \param[in] mode the mode of the iofd, whether it should use read()/write(), sendto()/recvfrom() + * \param[in] ioops structure with read/write/send/recv callbacks + * \param[in] data user data pointer accessible by the ioops callbacks + * \returns The newly allocated osmo_io_fd struct or NULL on failure + */ +struct osmo_io_fd *osmo_iofd_setup(const void *ctx, int fd, const char *name, enum osmo_io_fd_mode mode, + const struct osmo_io_ops *ioops, void *data) +{ + struct osmo_io_fd *iofd = talloc_zero(ctx, struct osmo_io_fd); + if (!iofd) + return NULL; + + iofd->fd = fd; + iofd->mode = mode; + + iofd->name = talloc_strdup(iofd, name); + + if (ioops) + iofd->io_ops = *ioops; + + iofd->pending = NULL; + + iofd->data = data; + + iofd->msgb_alloc.ctx = ctx; + iofd->msgb_alloc.size = OSMO_IO_DEFAULT_MSGB_SIZE; + iofd->msgb_alloc.headroom = OSMO_IO_DEFAULT_MSGB_HEADROOM; + + iofd->tx_queue.max_length = 32; + INIT_LLIST_HEAD(&iofd->tx_queue.msg_queue); + + return iofd; +} + +/*! Register the fd with the underlying backend + * + * \param[in] iofd the iofd file descriptor + * \param[in] fd the system fd number that will be registeres. If negative will use the one already set. + * \returns zero on success, a negative value on error +*/ +int osmo_iofd_register(struct osmo_io_fd *iofd, int fd) +{ + if (fd >= 0) + iofd->fd = fd; + iofd->closed = false; + + if (osmo_iofd_ops.register_fd) + return osmo_iofd_ops.register_fd(iofd); + + return 0; +} + +/*! Unregister the fd from the underlying backend + * + * \param[in] iofd the file descriptor + * \returns zero on success, a negative value on error + */ +int osmo_iofd_unregister(struct osmo_io_fd *iofd) +{ + if (osmo_iofd_ops.unregister_fd) + return osmo_iofd_ops.unregister_fd(iofd); + + return 0; +} + +/*! Get the number of messages in the tx queue + * + * \param[in] iofd the file descriptor + */ +unsigned int osmo_iofd_txqueue_len(struct osmo_io_fd *iofd) +{ + return iofd->tx_queue.current_length; +} + +/*! Clear the transmit queue of the the iofd + * + * This function frees all messages currently pending in the transmit queue + * \param[in] iofd the file descriptor + */ +void osmo_iofd_txqueue_clear(struct osmo_io_fd *iofd) +{ + struct iofd_msghdr *hdr; + while ((hdr = iofd_txqueue_dequeue(iofd))) { + msgb_free(hdr->msg); + iofd_msghdr_free(hdr); + } +} + +/*! Free the iofd + * + * This function is safe to use in the read/write callbacks and will defer freeing it until safe to do so. + * The iofd will be closed before. + * \param[in] iofd the file descriptor + */ +void osmo_iofd_free(struct osmo_io_fd *iofd) +{ + if (!iofd) + return; + + osmo_iofd_close(iofd); + + if (!iofd->in_callback) { + talloc_free(iofd); + } else { + /* Prevent our parent context from freeing us prematurely */ + talloc_steal(NULL, iofd); + iofd->to_free = true; + } +} + +/*! Close the iofd + * + * This function closes the underlying fd and clears any messages in the tx queue + * The iofd is not freed and can be assigned a new file descriptor with osmo_iofd_register() + * \param[in] iofd the file descriptor + * \ returns 0 on success, a negative value otherwise + */ +int osmo_iofd_close(struct osmo_io_fd *iofd) +{ + int rc = 0; + + if (iofd->closed) + return rc; + + iofd->closed = true; + + /* Free pending msgs in tx queue */ + osmo_iofd_txqueue_clear(iofd); + msgb_free(iofd->pending); + + iofd->pending = NULL; + + if (osmo_iofd_ops.close) + rc = osmo_iofd_ops.close(iofd); + iofd->fd = -1; + return rc; +} + +/*! Set the size and headroom of the msgb allocated when receiving messages + * \param[in] size the size of the msgb when receiving data + * \param[in] headroom the headroom of the msgb when receiving data + */ +void osmo_iofd_set_alloc_info(struct osmo_io_fd *iofd, unsigned int size, unsigned int headroom) +{ + iofd->msgb_alloc.headroom = headroom; + iofd->msgb_alloc.size = size; +} + +/*! Get the associated user-data from an iofd + * \param[in] iofd the file descriptor + * \returns the data that was previously set with \ref osmo_iofd_setup() + */ +void *osmo_iofd_get_data(const struct osmo_io_fd *iofd) +{ + return iofd->data; +} + +/*! Set the associated user-data from an iofd + * \param[in] iofd the file descriptor + * \param[in] data the data to set + */ +void osmo_iofd_set_data(struct osmo_io_fd *iofd, void *data) +{ + iofd->data = data; +} + +/*! Get the private number from an iofd + * \param[in] iofd the file descriptor + * \returns the private number that was previously set with \ref osmo_iofd_set_priv_nr() + */ +unsigned int osmo_iofd_get_priv_nr(const struct osmo_io_fd *iofd) +{ + return iofd->priv_nr; +} + +/*! Set the private number from an iofd + * \param[in] iofd the file descriptor + * \param[in] priv_nr the private number to set + */ +void osmo_iofd_set_priv_nr(struct osmo_io_fd *iofd, unsigned int priv_nr) +{ + iofd->priv_nr = priv_nr; +} + +/*! Get the underlying file descriptor from an iofd + * \param[in] iofd the file descriptor + * \returns the underlying file descriptor number */ +int osmo_iofd_get_fd(const struct osmo_io_fd *iofd) +{ + return iofd->fd; +} + +/*! Get the name of the file descriptor + * \param[in] iofd the file descriptor + * \returns the name of the iofd as given in \ref osmo_iofd_setup() */ +const char *osmo_iofd_get_name(const struct osmo_io_fd *iofd) +{ + return iofd->name; +} + +#endif /* defined(__linux__) */ diff --git a/src/core/osmo_io_internal.h b/src/core/osmo_io_internal.h new file mode 100644 index 0000000..7fc4b6b --- /dev/null +++ b/src/core/osmo_io_internal.h @@ -0,0 +1,132 @@ +/*! \file osmo_io_internal.h */ + +#pragma once + +#include <unistd.h> +#include <stdbool.h> + +#include <osmocom/core/osmo_io.h> +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/select.h> +#include <osmocom/core/socket.h> + +#include "../config.h" + +#define OSMO_IO_DEFAULT_MSGB_SIZE 1024 +#define OSMO_IO_DEFAULT_MSGB_HEADROOM 128 + +extern const struct iofd_backend_ops iofd_poll_ops; +#define OSMO_IO_BACKEND_DEFAULT "POLL" + +struct iofd_backend_ops { + int (*register_fd)(struct osmo_io_fd *iofd); + int (*unregister_fd)(struct osmo_io_fd *iofd); + int (*close)(struct osmo_io_fd *iofd); + void (*write_enable)(struct osmo_io_fd *iofd); + void (*write_disable)(struct osmo_io_fd *iofd); + void (*read_enable)(struct osmo_io_fd *iofd); + void (*read_disable)(struct osmo_io_fd *iofd); +}; + +struct osmo_io_fd { + /*! linked list for internal management */ + struct llist_head list; + /*! actual operating-system level file decriptor */ + int fd; + /*! type of read/write mode to use */ + enum osmo_io_fd_mode mode; + + /*! flags to guard closing/freeing of iofd */ + bool closed; + bool in_callback; + bool to_free; + + bool write_enabled; + bool read_enabled; + + /*! human-readable name to associte with fd */ + const char *name; + + /*! send/recv (msg) callback functions */ + struct osmo_io_ops io_ops; + /*! Pending msgb to keep partial data during segmentation */ + struct msgb *pending; + + /*! data pointer passed through to call-back function */ + void *data; + /*! private number, extending \a data */ + unsigned int priv_nr; + + struct { + /*! talloc context from which to allocate msgb when reading */ + const void *ctx; + /*! size of msgb to allocate (excluding headroom) */ + unsigned int size; + /*! headroom to allocate when allocating msgb's */ + unsigned int headroom; + } msgb_alloc; + + struct { + /*! maximum length of write queue */ + unsigned int max_length; + /*! current length of write queue */ + unsigned int current_length; + /*! actual linked list implementing the transmit queue */ + struct llist_head msg_queue; + } tx_queue; + + union { + struct { + struct osmo_fd ofd; + } poll; + struct { + bool read_enabled; + bool read_pending; + bool write_pending; + bool write_enabled; + /* TODO: index into array of registered fd's? */ + } uring; + } u; +}; + +enum iofd_msg_action { + IOFD_ACT_READ, + IOFD_ACT_WRITE, + IOFD_ACT_RECVFROM, + IOFD_ACT_SENDTO, + // TODO: SCTP_* +}; + + +/* serialized version of 'struct msghdr' employed by sendmsg/recvmsg */ +struct iofd_msghdr { + struct llist_head list; + enum iofd_msg_action action; + struct msghdr hdr; + struct osmo_sockaddr osa; + struct iovec iov[1]; + int flags; + + struct msgb *msg; + struct osmo_io_fd *iofd; +}; + +enum iofd_seg_act { + IOFD_SEG_ACT_HANDLE_ONE, + IOFD_SEG_ACT_HANDLE_MORE, + IOFD_SEG_ACT_DEFER, +}; + +struct iofd_msghdr *iofd_msghdr_alloc(struct osmo_io_fd *iofd, enum iofd_msg_action action, struct msgb *msg); +void iofd_msghdr_free(struct iofd_msghdr *msghdr); + +struct msgb *iofd_msgb_alloc(struct osmo_io_fd *iofd); +struct msgb *iofd_msgb_pending(struct osmo_io_fd *iofd); +struct msgb *iofd_msgb_pending_or_alloc(struct osmo_io_fd *iofd); + +void iofd_handle_segmented_read(struct osmo_io_fd *iofd, struct msgb *msg, int rc); + +int iofd_txqueue_enqueue(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr); +void iofd_txqueue_enqueue_front(struct osmo_io_fd *iofd, struct iofd_msghdr *msghdr); +struct iofd_msghdr *iofd_txqueue_dequeue(struct osmo_io_fd *iofd); diff --git a/src/core/osmo_io_poll.c b/src/core/osmo_io_poll.c new file mode 100644 index 0000000..95aa84a --- /dev/null +++ b/src/core/osmo_io_poll.c @@ -0,0 +1,185 @@ +/*! \file osmo_io_poll.c + * New osmocom async I/O API. + * + * (C) 2022 by Harald Welte <laforge(a)osmocom.org> + * (C) 2022-2023 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de> + * Author: Daniel Willmann <dwillmann(a)sysmocom.de> + * + * All Rights Reserved. + * + * SPDX-License-Identifier: GPL-2.0+ + * + * 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 "../config.h" +#if defined(__linux__) + +#include <errno.h> +#include <stdio.h> +#include <talloc.h> +#include <unistd.h> +#include <stdbool.h> +#include <sys/socket.h> + +#include <osmocom/core/osmo_io.h> +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/msgb.h> +#include <osmocom/core/select.h> +#include <osmocom/core/socket.h> +#include <osmocom/core/talloc.h> +#include <osmocom/core/utils.h> + +#include "osmo_io_internal.h" + +static void iofd_poll_ofd_cb_recvmsg_sendmsg(struct osmo_fd *ofd, unsigned int what) +{ + struct osmo_io_fd *iofd = ofd->data; + struct msgb *msg; + int rc, flags = 0; + + if (what & OSMO_FD_READ) { + struct iofd_msghdr hdr; + msg = iofd_msgb_pending_or_alloc(iofd); + if (!msg) { + LOGP(DLIO, LOGL_ERROR, "iofd(%s): Could not get msgb for reading\n", iofd->name); + OSMO_ASSERT(0); + } + + hdr.msg = msg; + hdr.iov[0].iov_base = msgb_data(msg); + hdr.iov[0].iov_len = msgb_tailroom(msg); + hdr.hdr.msg_iov = &hdr.iov[0]; + hdr.hdr.msg_iovlen = 1; + hdr.hdr.msg_name = &hdr.osa.u.sa; + hdr.hdr.msg_namelen = osmo_sockaddr_size(&hdr.osa); + + rc = recvmsg(ofd->fd, &hdr.hdr, flags); + if (rc > 0) + msgb_put(msg, rc); + + switch (iofd->mode) { + case OSMO_IO_FD_MODE_READ_WRITE: + iofd_handle_segmented_read(iofd, msg, rc); + break; + case OSMO_IO_FD_MODE_RECVFROM_SENDTO: + iofd->io_ops.recvfrom_cb(iofd, rc, msg, &hdr.osa); + break; + case OSMO_IO_FD_MODE_SCTP_RECVMSG_SENDMSG: + /* TODO Implement */ + OSMO_ASSERT(false); + break; + } + } + + if (iofd->closed) + return; + + if (what & OSMO_FD_WRITE) { + struct iofd_msghdr *msghdr = iofd_txqueue_dequeue(iofd); + if (msghdr) { + msg = msghdr->msg; + + rc = sendmsg(ofd->fd, &msghdr->hdr, msghdr->flags); + if (rc > 0 && rc < msgb_length(msg)) { + msgb_pull(msg, rc); + iofd_txqueue_enqueue_front(iofd, msghdr); + return; + } + + switch (iofd->mode) { + case OSMO_IO_FD_MODE_READ_WRITE: + iofd->io_ops.write_cb(iofd, rc, msg); + break; + case OSMO_IO_FD_MODE_RECVFROM_SENDTO: + iofd->io_ops.sendto_cb(iofd, rc, msg, &msghdr->osa); + break; + case OSMO_IO_FD_MODE_SCTP_RECVMSG_SENDMSG: + OSMO_ASSERT(false); + break; + } + + talloc_free(msghdr); + msgb_free(msg); + } + } +} + +static int iofd_poll_ofd_cb_dispatch(struct osmo_fd *ofd, unsigned int what) +{ + struct osmo_io_fd *iofd = ofd->data; + + iofd->in_callback = true; + iofd_poll_ofd_cb_recvmsg_sendmsg(ofd, what); + iofd->in_callback = false; + + if (iofd->to_free) { + talloc_free(iofd); + return 0; + } + + return 0; +} + +int iofd_poll_register(struct osmo_io_fd *iofd) +{ + struct osmo_fd *ofd = &iofd->u.poll.ofd; + osmo_fd_setup(ofd, iofd->fd, 0, &iofd_poll_ofd_cb_dispatch, iofd, 0); + return osmo_fd_register(ofd); +} + +int iofd_poll_unregister(struct osmo_io_fd *iofd) +{ + struct osmo_fd *ofd = &iofd->u.poll.ofd; + osmo_fd_unregister(ofd); + + return 0; +} + +int iofd_poll_close(struct osmo_io_fd *iofd) +{ + osmo_fd_close(&iofd->u.poll.ofd); + + return 0; +} + +void iofd_poll_read_enable(struct osmo_io_fd *iofd) +{ + osmo_fd_read_enable(&iofd->u.poll.ofd); +} + +void iofd_poll_read_disable(struct osmo_io_fd *iofd) +{ + osmo_fd_read_disable(&iofd->u.poll.ofd); +} + +void iofd_poll_write_enable(struct osmo_io_fd *iofd) +{ + osmo_fd_write_enable(&iofd->u.poll.ofd); +} + +void iofd_poll_write_disable(struct osmo_io_fd *iofd) +{ + osmo_fd_write_disable(&iofd->u.poll.ofd); +} + +const struct iofd_backend_ops iofd_poll_ops = { + .register_fd = iofd_poll_register, + .unregister_fd = iofd_poll_unregister, + .close = iofd_poll_close, + .write_enable = iofd_poll_write_enable, + .write_disable = iofd_poll_write_disable, + .read_enable = iofd_poll_read_enable, + .read_disable = iofd_poll_read_disable, +}; + +#endif /* defined(__linux__) */ diff --git a/tests/logging/logging_vty_test.vty b/tests/logging/logging_vty_test.vty index f9b4e01..da09be7 100644 --- a/tests/logging/logging_vty_test.vty +++ b/tests/logging/logging_vty_test.vty @@ -54,7 +54,7 @@ logging print level (0|1) logging print file (0|1|basename) [last] logging set-log-mask MASK - logging level (aa|bb|ccc|dddd|eee|lglobal|llapd|linp|lmux|lmi|lmib|lsms|lctrl|lgtp|lstats|lgsup|loap|lss7|lsccp|lsua|lm3ua|lmgcp|ljibuf|lrspro|lns|lbssgp|lnsdata|lnssignal|liuup|lpfcp|lcsn1) (debug|info|notice|error|fatal) + logging level (aa|bb|ccc|dddd|eee|lglobal|llapd|linp|lmux|lmi|lmib|lsms|lctrl|lgtp|lstats|lgsup|loap|lss7|lsccp|lsua|lm3ua|lmgcp|ljibuf|lrspro|lns|lbssgp|lnsdata|lnssignal|liuup|lpfcp|lcsn1|lio) (debug|info|notice|error|fatal) logging level set-all (debug|info|notice|error|fatal) logging level force-all (debug|info|notice|error|fatal) no logging level force-all @@ -568,7 +568,7 @@ logging_vty_test# list ... - logp (aa|bb|ccc|dddd|eee|lglobal|llapd|linp|lmux|lmi|lmib|lsms|lctrl|lgtp|lstats|lgsup|loap|lss7|lsccp|lsua|lm3ua|lmgcp|ljibuf|lrspro|lns|lbssgp|lnsdata|lnssignal|liuup|lpfcp|lcsn1) (debug|info|notice|error|fatal) .LOGMESSAGE + logp (aa|bb|ccc|dddd|eee|lglobal|llapd|linp|lmux|lmi|lmib|lsms|lctrl|lgtp|lstats|lgsup|loap|lss7|lsccp|lsua|lm3ua|lmgcp|ljibuf|lrspro|lns|lbssgp|lnsdata|lnssignal|liuup|lpfcp|lcsn1|lio) (debug|info|notice|error|fatal) .LOGMESSAGE ... logging_vty_test# logp? @@ -606,6 +606,7 @@ liuup Iu UP layer lpfcp libosmo-pfcp Packet Forwarding Control Protocol lcsn1 libosmo-csn1 Concrete Syntax Notation 1 codec + lio libosmocore IO Subsystem logging_vty_test# logp lglobal ? debug Log debug messages and higher levels -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30934 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I50d73cf550d6ce8154bf827bf47408131cf5b0a0 Gerrit-Change-Number: 30934 Gerrit-PatchSet: 18 Gerrit-Owner: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
[M] Change in osmo-bts[master]: all models, FR/EFR UL: change SID check to _is_any_sid()
by falconia 10 May '23

10 May '23
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/32678 ) Change subject: all models, FR/EFR UL: change SID check to _is_any_sid() ...................................................................... all models, FR/EFR UL: change SID check to _is_any_sid() In all OsmoBTS models in FR and EFR speech modes, as the UL traffic frame stream is passed from the PHY to l1sap and ultimately to RTP output, all passed frames are checked for SID. The Boolean result of this SID check is used in two ways: * RFC 3551 instructs that the Marker bit in the RTP header SHOULD be set in the first packet of a talkspurt after a period of silence suppression. OsmoBTS implements this recommendation by setting the Marker bit in the first RTP-transmitted non-SID UL packet that was preceded by SID. * In osmo-bts-trx only, this same SID check serves a second purpose: handling of BFI conditions depends on whether or not the last received good traffic frame was a SID. If a BFI condition is received after a non-SID traffic frame, the ECU is invoked, and if this ECU fails or when libosmocodec does not provide an ECU for the codec in use, a special FR (EFR) BFI frame of 260 (244) zero bits is emitted. Both the ECU call and the peculiar form of BFI are skipped when the last received good traffic frame was a SID. For both of the above purposes, in all BTS models, change the SID check from osmo_{fr,efr}_check_sid() to osmo_{fr,efr}_is_any_sid(). The effect of this change is that "what counts as a SID" for the just-listed purposes changes from recognizing only perfectly uncorrupted SID frames without any bit errors to recognizing all frames which the rules of GSM 06.31 (FR) or 06.81 (EFR) classify as either valid or invalid SID. Change-Id: I5c24b379deda8ae551f9924d10770da50e6acbbd --- M src/osmo-bts-lc15/tch.c M src/osmo-bts-oc2g/tch.c M src/osmo-bts-sysmo/tch.c M src/osmo-bts-trx/sched_lchan_tchf.c 4 files changed, 44 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/78/32678/1 diff --git a/src/osmo-bts-lc15/tch.c b/src/osmo-bts-lc15/tch.c index fdbf995..56c56ca 100644 --- a/src/osmo-bts-lc15/tch.c +++ b/src/osmo-bts-lc15/tch.c @@ -68,7 +68,7 @@ cur = msgb_put(msg, GSM_FR_BYTES); memcpy(cur, l1_payload, GSM_FR_BYTES); - lchan_set_marker(osmo_fr_check_sid(l1_payload, payload_len), lchan); + lchan_set_marker(osmo_fr_is_any_sid(l1_payload), lchan); return msg; } @@ -102,7 +102,7 @@ cur = msgb_put(msg, GSM_EFR_BYTES); memcpy(cur, l1_payload, GSM_EFR_BYTES); - lchan_set_marker(osmo_efr_check_sid(l1_payload, payload_len), lchan); + lchan_set_marker(osmo_efr_is_any_sid(l1_payload), lchan); return msg; } diff --git a/src/osmo-bts-oc2g/tch.c b/src/osmo-bts-oc2g/tch.c index fce100f..491e736 100644 --- a/src/osmo-bts-oc2g/tch.c +++ b/src/osmo-bts-oc2g/tch.c @@ -68,7 +68,7 @@ cur = msgb_put(msg, GSM_FR_BYTES); memcpy(cur, l1_payload, GSM_FR_BYTES); - lchan_set_marker(osmo_fr_check_sid(l1_payload, payload_len), lchan); + lchan_set_marker(osmo_fr_is_any_sid(l1_payload), lchan); return msg; } @@ -102,7 +102,7 @@ cur = msgb_put(msg, GSM_EFR_BYTES); memcpy(cur, l1_payload, GSM_EFR_BYTES); - lchan_set_marker(osmo_efr_check_sid(l1_payload, payload_len), lchan); + lchan_set_marker(osmo_efr_is_any_sid(l1_payload), lchan); return msg; } diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c index 5039cc4..0109771 100644 --- a/src/osmo-bts-sysmo/tch.c +++ b/src/osmo-bts-sysmo/tch.c @@ -77,7 +77,7 @@ cur[0] |= 0xD0; #endif /* USE_L1_RTP_MODE */ - lchan_set_marker(osmo_fr_check_sid(l1_payload, payload_len), lchan); + lchan_set_marker(osmo_fr_is_any_sid(l1_payload), lchan); return msg; } @@ -132,7 +132,7 @@ cur[0] |= 0xC0; #endif /* USE_L1_RTP_MODE */ - lchan_set_marker(osmo_efr_check_sid(l1_payload, payload_len), lchan); + lchan_set_marker(osmo_efr_is_any_sid(l1_payload), lchan); return msg; } diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c index da4a475..6d6fb0b 100644 --- a/src/osmo-bts-trx/sched_lchan_tchf.c +++ b/src/osmo-bts-trx/sched_lchan_tchf.c @@ -146,12 +146,12 @@ case GSM48_CMODE_SPEECH_V1: /* FR */ rc = gsm0503_tch_fr_decode(tch_data, *bursts_p, 1, 0, &n_errors, &n_bits_total); if (rc == GSM_FR_BYTES) /* only for valid *speech* frames */ - lchan_set_marker(osmo_fr_check_sid(tch_data, rc), lchan); /* DTXu */ + lchan_set_marker(osmo_fr_is_any_sid(tch_data), lchan); /* DTXu */ break; case GSM48_CMODE_SPEECH_EFR: /* EFR */ rc = gsm0503_tch_fr_decode(tch_data, *bursts_p, 1, 1, &n_errors, &n_bits_total); if (rc == GSM_EFR_BYTES) /* only for valid *speech* frames */ - lchan_set_marker(osmo_efr_check_sid(tch_data, rc), lchan); /* DTXu */ + lchan_set_marker(osmo_efr_is_any_sid(tch_data), lchan); /* DTXu */ break; case GSM48_CMODE_SPEECH_AMR: /* AMR */ /* the first FN 0,8,17 defines that CMI is included in frame, -- To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/32678 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Change-Id: I5c24b379deda8ae551f9924d10770da50e6acbbd Gerrit-Change-Number: 32678 Gerrit-PatchSet: 1 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-MessageType: newchange
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • ...
  • 259
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.