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 2026

  • 1 participants
  • 714 discussions
[S] Change in libosmocore[master]: gb: ns2: clamp embedded NS PDU to msgb tailroom
by pespin 19 Nov '26

19 Nov '26
Attention is currently required from: daniel, fixeria, lynxis, ws1004. pespin has posted comments on this change by ws1004. ( https://gerrit.osmocom.org/c/libosmocore/+/44138?usp=email ) Change subject: gb: ns2: clamp embedded NS PDU to msgb tailroom ...................................................................... Patch Set 2: (2 comments) File src/gb/gprs_ns2.c: https://gerrit.osmocom.org/c/libosmocore/+/44138/comment/86597d43_0ca5b124?… : PS2, Line 755: /* The original PDU can be larger than what is left in our own This all looks a bit too much convoluted imho. What about the following which doesn't need so much unsigned vs signed checks? const unsigned int avail = (int)msgb_tailroom(msg); unsigned int embed_len = msgb_l2len(orig_msg); if (avail < 3) embed_len = 0; else if (avail < 3 + embed_len) embed_len = avail - 3; if (embed_len > 0) msgb_tvlv_put(msg, NS_IE_PDU, embed_len, orig_msg->l2h); File src/gb/gprs_ns2_message.c: https://gerrit.osmocom.org/c/libosmocore/+/44138/comment/00f93736_78c4bc05?… : PS2, Line 469: else if (nsvc->bind->mtu - msgb_length(msg) < max_orig_len) Again, this looks imho too convoluted. I propose this: /* Trim available space to MTU: */ unsigned int avail = msgb_tailroom(msg); if (msgb_length(msg) > nsvc->bind->mtu) avail = 0; else if (nsvc->bind->mtu - msgb_length(msg) > avail) avail = nsvc->bind->mtu - msgb_length(msg); /* Figure out how many origin PDU bytes we can fit given available space: */ if (avail < 3) orig_len = 0; else orig_len = avail - 3; if (orig_len > 0) msgb_tvlv_put(msg, NS_IE_PDU, orig_len, orig_msg->l2h); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/44138?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Iac1c5c15875f30f34d0f7e9fc74264530a02b6ae Gerrit-Change-Number: 44138 Gerrit-PatchSet: 2 Gerrit-Owner: ws1004 <ws1004(a)kakao.com> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <daniel(a)totalueberwachung.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: lynxis <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: lynxis <lynxis(a)fe80.eu> Gerrit-Attention: daniel <daniel(a)totalueberwachung.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: ws1004 <ws1004(a)kakao.com> Gerrit-Comment-Date: Thu, 19 Nov 2026 10:17:29 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No
1 0
0 0
[M] Change in libosmocore[master]: gsm: fix one-byte overflow in BCD number encoders
by pespin 19 Nov '26

19 Nov '26
Attention is currently required from: bucketking657, fixeria. pespin has posted comments on this change by bucketking657. ( https://gerrit.osmocom.org/c/libosmocore/+/44142?usp=email ) Change subject: gsm: fix one-byte overflow in BCD number encoders ...................................................................... Patch Set 1: Code-Review-1 (1 comment) File src/gsm/gsm48_ie.c: https://gerrit.osmocom.org/c/libosmocore/+/44142/comment/645048c6_0c526713?… : PS1, Line 140: * \param[in] max_len Maximum value of the L octet; \a bcd_lv must have MY understanding is that you are basically changing the meaning of this parameter here, and hence changing the API. I think it makes more sense to keep the old meaning (max_len is the allocated size in bcd_lv buffer) and tweak the implementation to do the checks accordingly. What do you think? -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/44142?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I99521d30896f3d58ecfb28de290bce7e31388fca Gerrit-Change-Number: 44142 Gerrit-PatchSet: 1 Gerrit-Owner: bucketking657 <joshuashilts(a)gmail.com> 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: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: bucketking657 <joshuashilts(a)gmail.com> Gerrit-Comment-Date: Thu, 19 Nov 2026 09:44:44 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes
1 0
0 0
[S] Change in pysim[master]: pySim-shell: enable apdu_strict by default
by dexter 19 Nov '26

19 Nov '26
Attention is currently required from: Hoernchen. dexter has posted comments on this change by Hoernchen. ( https://gerrit.osmocom.org/c/pysim/+/43726?usp=email ) Change subject: pySim-shell: enable apdu_strict by default ...................................................................... Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/43726?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ic413e12e2792e8cd9d455b1b0d6791bdf757c80e Gerrit-Change-Number: 43726 Gerrit-PatchSet: 2 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de> Gerrit-Comment-Date: Thu, 19 Nov 2026 09:20:19 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: RemSIM/server: Expand maintenance mapping test with timeout
by laforge 19 Nov '26

19 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43839?usp=email ) ( 3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: RemSIM/server: Expand maintenance mapping test with timeout ...................................................................... RemSIM/server: Expand maintenance mapping test with timeout Expand the previous test by adding a timeout. Instead of removing the maintenance mapping via REST API, wait until timeout and expect the mapping to be removed automatically. Related: SYS#8159 Change-Id: Iab27eb51ef51fafc2cdef8aee7dc96892fb613fd --- M remsim/RemsimServer_Tests.ttcn 1 file changed, 26 insertions(+), 5 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/remsim/RemsimServer_Tests.ttcn b/remsim/RemsimServer_Tests.ttcn index 22a8c31..8e1ea55 100644 --- a/remsim/RemsimServer_Tests.ttcn +++ b/remsim/RemsimServer_Tests.ttcn @@ -37,7 +37,8 @@ } /* run a HTTP PUT to add a new slotmap to the remsim-server */ -function f_rsres_post_slotmap(JsSlotmap slotmap, template integer exp_sts := 201, integer priority := 0) +function f_rsres_post_slotmap(JsSlotmap slotmap, template integer exp_sts := 201, integer priority := 0, + integer tiout := 0) runs on http_CT return HTTPResponse { var charstring body := oct2char(f_enc_JsSlotmap(slotmap)); var HTTPMessage http_resp; @@ -45,6 +46,14 @@ if (priority != 0) { url := url & "?priority=" & int2str(priority); } + if (tiout > 0) { + if (priority != 0) { + url := url & "&"; + } else { + url := url & "?"; + } + url := url & "timeout=" & int2str(tiout); + } http_resp := f_http_transact(url := url, method := "POST", body := body, exp := tr_HTTP_Resp(exp_sts)) return http_resp.response; } @@ -672,7 +681,7 @@ /* Create a regular mapping between client and bank, then override it via priority mapping. */ -function f_TC_slotmap_switch_priority_mapping() runs on test_CT { +function f_TC_slotmap_switch_priority_mapping(integer tiout := 0) runs on test_CT { var ComponentIdentity rspro_id := valueof(ts_CompId(remsimBankd, testcasename())); var BankSlot bslot := valueof(ts_BankSlot(1, 2)); var ClientSlot cslot1 := valueof(ts_ClientSlot(3, 4)); @@ -719,7 +728,7 @@ /* 2. Create higher priority mapping, while having a regular mapping. */ /* Create a new slotmap via HTTP. It uses the same bankd/slot */ - f_rsres_post_slotmap(sm2, priority := 1); + f_rsres_post_slotmap(sm2, priority := 1, tiout := tiout); /* Expect the slotmap to be removed from bank. */ as_rspro_remove_mapping(0, sm1.client, sm1.bank); @@ -744,8 +753,13 @@ /* 3. Delete higher priority mapping while still having regular mapping. */ - /* Delete the maintenance slotmap via REST. */ - f_rsres_delete_slotmap(sm2.bank, priority := 1); + if (tiout == 0) { + /* Delete the higher piority slotmap via REST. */ + f_rsres_delete_slotmap(sm2.bank, priority := 1); + } else { + log("Waiting for mapping to time out..."); + f_sleep(int2float(tiout + 1)); + } /* Expect the higher piority slotmap to be removed from bank. */ as_rspro_remove_mapping(0, sm2.client, sm2.bank); @@ -788,6 +802,12 @@ f_TC_slotmap_switch_priority_mapping(); } +/* Same as above, but use timeout rather than delete command via rest API to remove higher piority mapping. */ +testcase TC_slotmap_switch_priority_mapping_timeout() runs on test_CT { + f_TC_slotmap_switch_priority_mapping(tiout := 2); +} + + /* TODO @@ -817,6 +837,7 @@ execute( TC_slotmap_del_active_client() ); execute( TC_slotmap_add_active_bank() ); execute( TC_slotmap_switch_priority_mapping() ); + execute( TC_slotmap_switch_priority_mapping_timeout() ); } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43839?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Iab27eb51ef51fafc2cdef8aee7dc96892fb613fd Gerrit-Change-Number: 43839 Gerrit-PatchSet: 5 Gerrit-Owner: jolly <andreas(a)eversberg.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>
1 0
0 0
[M] Change in osmo-ttcn3-hacks[master]: RemSIM/server: Add test to verify maintenance mapping
by laforge 19 Nov '26

19 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43838?usp=email ) ( 3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: RemSIM/server: Add test to verify maintenance mapping ...................................................................... RemSIM/server: Add test to verify maintenance mapping While have a regular mapping, add a maintenance mapping to a different client but to the same bank/slot. Expect the regular mapping to be suspended while the maintenance mapping exist. After maintenance mapping is deleted, expect the regular mapping to be resumed. Related: SYS#8159 Change-Id: I091dfe999b5b3473c67d6874ca31d238ee75b70e --- M remsim/RSRES.ttcn M remsim/RemsimServer_Tests.ttcn 2 files changed, 142 insertions(+), 13 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/remsim/RSRES.ttcn b/remsim/RSRES.ttcn index a988b66..7ccd817 100644 --- a/remsim/RSRES.ttcn +++ b/remsim/RSRES.ttcn @@ -61,7 +61,8 @@ UNACKNOWLEDGED, ACTIVE, DELETE_REQ, - DELETING + DELETING, + INACTIVE }; type record JsSlotmap { diff --git a/remsim/RemsimServer_Tests.ttcn b/remsim/RemsimServer_Tests.ttcn index 4dce01f..22a8c31 100644 --- a/remsim/RemsimServer_Tests.ttcn +++ b/remsim/RemsimServer_Tests.ttcn @@ -37,12 +37,15 @@ } /* run a HTTP PUT to add a new slotmap to the remsim-server */ -function f_rsres_post_slotmap(JsSlotmap slotmap, template integer exp_sts := 201) +function f_rsres_post_slotmap(JsSlotmap slotmap, template integer exp_sts := 201, integer priority := 0) runs on http_CT return HTTPResponse { var charstring body := oct2char(f_enc_JsSlotmap(slotmap)); var HTTPMessage http_resp; - http_resp := f_http_transact(url := "/api/backend/v1/slotmaps", method := "POST", - body := body, exp := tr_HTTP_Resp(exp_sts)) + var charstring url := "/api/backend/v1/slotmaps"; + if (priority != 0) { + url := url & "?priority=" & int2str(priority); + } + http_resp := f_http_transact(url := url, method := "POST", body := body, exp := tr_HTTP_Resp(exp_sts)) return http_resp.response; } @@ -57,12 +60,15 @@ /* run a HTTP DELETE to remove a slotmap from te remsim-server */ -function f_rsres_delete_slotmap(BankSlot bs, template integer exp_sts := 200) +function f_rsres_delete_slotmap(BankSlot bs, template integer exp_sts := 200, integer priority := 0) runs on http_CT return HTTPResponse { var HTTPMessage http_resp; var integer slotmap_id := bs.bankId * 65536 + bs.slotNr; - http_resp := f_http_transact(url := "/api/backend/v1/slotmaps/" & int2str(slotmap_id), - method := "DELETE", exp := tr_HTTP_Resp(exp_sts)); + var charstring url := "/api/backend/v1/slotmaps/" & int2str(slotmap_id); + if (priority != 0) { + url := url & "?priority=" & int2str(priority); + } + http_resp := f_http_transact(url := url, method := "DELETE", exp := tr_HTTP_Resp(exp_sts)); return http_resp.response; } @@ -301,12 +307,16 @@ } -function f_ensure_slotmaps(template JsSlotmaps maps) +function f_ensure_slotmaps(template JsSlotmaps maps, integer priority := 0) runs on http_CT { var JsRoot js; + var charstring url := "/api/backend/v1/slotmaps"; /* check that it is actually added */ - js := f_rsres_get("/api/backend/v1/slotmaps"); + if (priority != 0) { + url := url & "?priority=" & int2str(priority); + } + js := f_rsres_get(url); if (match(js.slotmaps, maps)) { setverdict(pass); } else { @@ -316,16 +326,16 @@ /* verify that exactly only one slotmap exists (the specified one) */ function f_ensure_slotmap_exists_only(template ClientSlot cslot, template BankSlot bslot, - template SlotmapState state := ?) + template SlotmapState state := ?, integer priority := 0) runs on http_CT { - f_ensure_slotmaps({ tr_JsSlotmap(bslot, cslot, state) } ); + f_ensure_slotmaps({ tr_JsSlotmap(bslot, cslot, state) }, priority); } /* verify that exactly only one slotmap exists (possibly among others) */ function f_ensure_slotmap_exists(template ClientSlot cslot, template BankSlot bslot, - template SlotmapState state := ?) + template SlotmapState state := ?, integer priority := 0) runs on http_CT { - f_ensure_slotmaps({ *, tr_JsSlotmap(bslot, cslot, state), * } ); + f_ensure_slotmaps({ *, tr_JsSlotmap(bslot, cslot, state), * }, priority); } @@ -661,6 +671,123 @@ } +/* Create a regular mapping between client and bank, then override it via priority mapping. */ +function f_TC_slotmap_switch_priority_mapping() runs on test_CT { + var ComponentIdentity rspro_id := valueof(ts_CompId(remsimBankd, testcasename())); + var BankSlot bslot := valueof(ts_BankSlot(1, 2)); + var ClientSlot cslot1 := valueof(ts_ClientSlot(3, 4)); + var ClientSlot cslot2 := valueof(ts_ClientSlot(5, 6)); + var JsSlotmap sm1 := valueof(ts_JsSlotmap(bslot, cslot1)); + var JsSlotmap sm2 := valueof(ts_JsSlotmap(bslot, cslot2)); + + f_init(); + f_rsres_init(); + + /* Create a band and two clients. */ + f_rspro_init(rspro[0], mp_server_ip, mp_server_port, rspro_id, 0); + rspro[0].rspro_bank_id := bslot.bankId; + rspro[0].rspro_bank_nslots := 8; + f_rspro_connect_client(0); + + rspro_id := valueof(ts_CompId(remsimClient, "client1")); + f_rspro_init(rspro[1], mp_server_ip, mp_server_port, rspro_id, 1); + rspro[1].rspro_client_slot := cslot1; + f_rspro_connect_client(1); + + rspro_id := valueof(ts_CompId(remsimClient, "client2")); + f_rspro_init(rspro[2], mp_server_ip, mp_server_port, rspro_id, 2); + rspro[2].rspro_client_slot := cslot2; + f_rspro_connect_client(2); + + /* 1. Create regular mapping. */ + + /* Create a new slotmap via HTTP. */ + f_rsres_post_slotmap(sm1); + + /* Expect the slotmap to be pushed to bank and ACK it. */ + as_rspro_create_mapping(0, sm1.client, sm1.bank); + + /* An immediate slotmaps check doesn't work. */ + f_sleep(1.0); + + /* Verify that the slotmap exists and is ACTIVE. */ + f_ensure_slotmap_exists_only(sm1.client, sm1.bank, ACTIVE); + + /* Expect the client to be configured to connect to bank. */ + as_rspro_cfg_client_bank(1, sm1.bank, ?); + + /* 2. Create higher priority mapping, while having a regular mapping. */ + + /* Create a new slotmap via HTTP. It uses the same bankd/slot */ + f_rsres_post_slotmap(sm2, priority := 1); + + /* Expect the slotmap to be removed from bank. */ + as_rspro_remove_mapping(0, sm1.client, sm1.bank); + + /* Verify the slotmap is removed from client by setting IP/port to '0'. */ + as_rspro_cfg_client_bank(1, ?, tr_IpPort(ts_IPv4("0.0.0.0"), 0)); + + /* Expect the higher piority slotmap to be pushed to bank and ACK it. */ + as_rspro_create_mapping(0, sm2.client, sm2.bank); + + /* Expect the second client to be configured to connect to bank. */ + as_rspro_cfg_client_bank(2, sm2.bank, ?); + + /* An immediate slotmaps check doesn't work. */ + f_sleep(1.0); + + /* Verify that the regular slotmap is INACTIVE. */ + f_ensure_slotmap_exists_only(sm1.client, sm1.bank, INACTIVE); + + /* Verify that the higher piority slotmap exists and is ACTIVE. */ + f_ensure_slotmap_exists_only(sm2.client, sm2.bank, ACTIVE, 1); + + /* 3. Delete higher priority mapping while still having regular mapping. */ + + /* Delete the maintenance slotmap via REST. */ + f_rsres_delete_slotmap(sm2.bank, priority := 1); + + /* Expect the higher piority slotmap to be removed from bank. */ + as_rspro_remove_mapping(0, sm2.client, sm2.bank); + + /* Verify the higher piority slotmap is removed from client by setting IP/port to '0'. */ + as_rspro_cfg_client_bank(2, ?, tr_IpPort(ts_IPv4("0.0.0.0"), 0)); + + /* Expect the regular INACTIVE slotmap to be pushed to bank and ACK it. */ + as_rspro_create_mapping(0, sm1.client, sm1.bank); + + /* Expect the client to be configured to connect to bank. */ + as_rspro_cfg_client_bank(1, sm1.bank, ?); + + /* An immediate slotmaps check doesn't work. */ + f_sleep(1.0); + + /* Verify that the slotmap exists and is ACTIVE. */ + f_ensure_slotmap_exists_only(sm1.client, sm1.bank, ACTIVE); + + /* 3. Delete regular mapping. */ + + /* delete the slotmap via REST */ + f_rsres_delete_slotmap(sm1.bank); + + /* an immediate slotmaps check doesn't work */ + f_sleep(1.0); + + /* verify the slotmap is gone from REST interface immediately */ + f_ensure_slotmaps({}); + + /* verify the slotmap is removed from bankd */ + as_rspro_remove_mapping(0, sm1.client, sm1.bank); + + /* verify the slotmap is removed from client by setting IP/port to '0' */ + as_rspro_cfg_client_bank(1, ?, tr_IpPort(ts_IPv4("0.0.0.0"), 0)); +} + +/* Create a regular mapping between client and bank, then override it via higher piority mapping. */ +testcase TC_slotmap_switch_priority_mapping() runs on test_CT { + f_TC_slotmap_switch_priority_mapping(); +} + /* TODO @@ -689,6 +816,7 @@ execute( TC_slotmap_del_active() ); execute( TC_slotmap_del_active_client() ); execute( TC_slotmap_add_active_bank() ); + execute( TC_slotmap_switch_priority_mapping() ); } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43838?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I091dfe999b5b3473c67d6874ca31d238ee75b70e Gerrit-Change-Number: 43838 Gerrit-PatchSet: 5 Gerrit-Owner: jolly <andreas(a)eversberg.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>
1 0
0 0
[M] Change in osmo-remsim[master]: Update osmo-remsim-apitool to support maintenance flag
by laforge 19 Nov '26

19 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/43747?usp=email ) Change subject: Update osmo-remsim-apitool to support maintenance flag ...................................................................... Update osmo-remsim-apitool to support maintenance flag In order to create, delete or show mappings with different priorities, a command line option '--priority <prio>' is introduced. Without this attribute, all operations relate to mappings with default priority of 0. Optionally a timeout can be set via '--timeout <seconds>' option. This option sets the maximum time before a mapping ist automatically deleted. The argument of option '--show-slotmaps' is removed, because the rest API does not allow an argument, except the priority value. Related: SYS#8159 Change-Id: Iaac6423b3a2f7209d0c26e9624d90b21b7c39f89 --- M contrib/osmo-remsim-apitool 1 file changed, 38 insertions(+), 21 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/contrib/osmo-remsim-apitool b/contrib/osmo-remsim-apitool index 50f0e72..44b574c 100755 --- a/contrib/osmo-remsim-apitool +++ b/contrib/osmo-remsim-apitool @@ -11,11 +11,11 @@ BASE_PATH = "/api/backend/v1" return ("http://" + server_host + ":" + server_port + BASE_PATH + suffix) -def rest_get(suffix): +def rest_get(suffix, params = None): if verbose: print("GET "+ build_url(suffix)) try: - resp = requests.get(build_url(suffix)) + resp = requests.get(build_url(suffix), params=params) except: print("REST GET failed") return @@ -28,31 +28,48 @@ else: return None -def rest_post(suffix, js = None): +def rest_post(suffix, params = None, js = None): if verbose: print("POST "+ build_url(suffix)+ str(js)) - resp = requests.post(build_url(suffix), json=js) + resp = requests.post(build_url(suffix), json=js, params=params) if not resp.ok: print("post failed") -def rest_delete(suffix): +def rest_delete(suffix, params = None): if verbose: print("DELETE "+ build_url(suffix)) - resp = requests.delete(build_url(suffix)) + resp = requests.delete(build_url(suffix), params=params) if not resp.ok: print("delete failed") #rest calls -def slotmap_create(bank_id, bank_slot, client_id, client_slot): +def slotmap_create(bank_id, bank_slot, client_id, client_slot, priority, timeout): js = { 'bank': {'bankId': int(bank_id), 'slotNr': int(bank_slot)}, 'client': {'clientId': int(client_id), 'slotNr': int(client_slot)}, } - return rest_post('/slotmaps', js) + url = "/slotmaps" + params = {} + if priority: + params['priority'] = str(priority) + if timeout > 0: + params['timeout'] = str(timeout) + return rest_post(url, params, js) -def slotmap_delete(bank_id, bank_slot): +def slotmap_delete(bank_id, bank_slot, priority): slotmap_id = bank_id * 65536 + bank_slot - return rest_delete("/slotmaps/%u"%slotmap_id) + url = "/slotmaps/%u" % slotmap_id + params = {} + if priority: + params['priority'] = str(priority) + return rest_delete(url, params) + +def slotmap_show(priority): + url = "/slotmaps/" + params = {} + if priority: + params['priority'] = str(priority) + return rest_get(url, params) def reset_global(): return rest_post('/global-reset') @@ -61,14 +78,16 @@ global server_port, server_host, verbose parser = argparse.ArgumentParser() - parser.add_argument("-H", "--host", help="host to connect to", default="127.0.0.1") - parser.add_argument("-p", "--port", help="port to connect to", default="9997") - parser.add_argument("-v", "--verbose", help="increase output verbosity", action="count", default=0) + parser.add_argument("-H", "--host", help="host to connect to", default="127.0.0.1") + parser.add_argument("-p", "--port", help="port to connect to", default="9997") + parser.add_argument("-v", "--verbose", help="increase output verbosity", action="count", default=0) + parser.add_argument("--priority", help="create/delete/show slotmaps of given priority", default=None) + parser.add_argument("--timeout", help="timeout (in seconds) for automatic removal of mapping", default=0) group = parser.add_mutually_exclusive_group() group.add_argument("-r", "--reset", help="remove all mappings (POST /global-reset)", action="store_true") group.add_argument("-c", "--show-clients", help="show clients (GET /clients)",nargs='?',const="all",default=None) group.add_argument("-b", "--show-banks", help="show banks (GET /banks)",nargs='?',const="all",default=None) - group.add_argument("-s", "--show-slotmaps", help="show slotmaps (GET /slotmaps)",nargs='?',const="all",default=None) + group.add_argument("-s", "--show-slotmaps", help="show slotmaps (GET /slotmaps)", action="store_true") group.add_argument("-m", "--create-slotmap", help="create new slotmap (POST /slotmaps)", type=int, nargs=4,metavar=('bank_id', 'bank_slot','client_id','client_slot')) group.add_argument("-d", "--delete-slotmap", help="delete slotmapping (DELETE /slotmaps/<id>)", type=int, nargs=2, metavar=('bank_id','bank_slot')) group.add_argument("-a", "--show-all", help="show all (default if no argument given)", action="store_true") @@ -97,20 +116,18 @@ rest_get("/banks/" + str(args.show_banks)) return if args.show_slotmaps: - if args.show_slotmaps == "all": - rest_get("/slotmaps") - else: - rest_get("/slotmaps/" + str(args.show_slotmaps)) + slotmap_show(args.priority) return if args.create_slotmap: - slotmap_create(args.create_slotmap[0],args.create_slotmap[1],args.create_slotmap[2],args.create_slotmap[3]) + slotmap_create(args.create_slotmap[0],args.create_slotmap[1],args.create_slotmap[2],args.create_slotmap[3], + args.priority, int(args.timeout)) return if args.delete_slotmap: - slotmap_delete(args.delete_slotmap[0],args.delete_slotmap[1]) + slotmap_delete(args.delete_slotmap[0],args.delete_slotmap[1],args.priority) return rest_get("/clients") rest_get("/banks") - rest_get("/slotmaps") + slotmap_show(args.priority) if __name__ == "__main__": main(sys.argv) -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/43747?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: Iaac6423b3a2f7209d0c26e9624d90b21b7c39f89 Gerrit-Change-Number: 43747 Gerrit-PatchSet: 12 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-remsim[master]: Add optional timeout to mapping
by laforge 19 Nov '26

19 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/43746?usp=email ) Change subject: Add optional timeout to mapping ...................................................................... Add optional timeout to mapping To prevent a broken or crashed application from blocking a mapping for an undefined time, a timeout can be specified. The application that controls the mapping, chooses a timeout that is long enough to complete the operation before the timeout occurs. This patch applies to any mapping, but it was created to support timeout for maintenance mapping (with higher priority). Related: SYS#8159 Change-Id: I2f7ee24e6c926b65876af2b14da3534555398769 --- M src/server/rest_api.c M src/server/rspro_server.c M src/slotmap.c M src/slotmap.h 4 files changed, 45 insertions(+), 0 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/server/rest_api.c b/src/server/rest_api.c index f26096a..766b367 100644 --- a/src/server/rest_api.c +++ b/src/server/rest_api.c @@ -316,6 +316,7 @@ static int api_cb_slotmaps_post(const struct _u_request *req, struct _u_response *resp, void *user_data) { const char *priority_str = u_map_get(req->map_url, "priority"); + const char *timeout_str = u_map_get(req->map_url, "timeout"); struct rspro_server *srv = g_rps; struct slot_mapping slotmap, *map, *other_map; struct rspro_client_conn *conn; @@ -323,9 +324,11 @@ json_t *json_req = NULL; bool suspending_map = false; int priority; + int timeout; int rc; priority = (priority_str) ? atoi(priority_str) : 0; + timeout = (timeout_str) ? atoi(timeout_str) : 0; json_req = ulfius_get_json_body_request(req, &json_err); if (!json_req) { @@ -362,6 +365,7 @@ LOGP(DREST, LOGL_NOTICE, "REST: Cannot add slotmap\n"); goto err; } + map->timeout = timeout; slotmap_state_change(map, SLMAP_S_NEW, NULL); /* If there is already a mapping with higher priority. */ diff --git a/src/server/rspro_server.c b/src/server/rspro_server.c index a6172b8..e6b56f6 100644 --- a/src/server/rspro_server.c +++ b/src/server/rspro_server.c @@ -410,6 +410,25 @@ } } +/* Handle timeout for mapping. */ +static void mapping_timeout(void *data) +{ + struct slot_mapping *map = data; + struct rspro_client_conn *conn; + + conn = bankd_conn_by_id(g_rps, map->bank.bank_id); + if (!conn) + return; + + /* The timer fires in ACTIVE state, so we trigger deletion now. */ + if (map->state == SLMAP_S_ACTIVE) { + LOGPFSML(conn->fi, LOGL_INFO, "Temporary mapping timed out, delete from B%u:%u.\n", + map->bank.bank_id, map->bank.slot_nr); + slotmap_state_change(map, SLMAP_S_DELETE_REQ, &conn->bank.maps_delreq); + osmo_fsm_inst_dispatch(conn->fi, CLNTC_E_PUSH, NULL); + } +} + static void clnt_st_connected_bankd(struct osmo_fsm_inst *fi, uint32_t event, void *data) { struct rspro_client_conn *conn = fi->priv; @@ -440,7 +459,11 @@ RsproPDU_t *pdu = slotmap2RemoveMappingReq(map); client_conn_send(conn, pdu); slotmap_state_change(map, SLMAP_S_DELETING, &conn->bank.maps_deleting); + break; } + /* If mapping has been created, start mapping timeout timer. */ + if (map->timeout > 0) + slotmap_start_timer(map, mapping_timeout); break; case CLNTC_E_REMOVE_MAP_RES: /* Bankd acknowledges mapping was removed */ rx = data; diff --git a/src/slotmap.c b/src/slotmap.c index 9f53ff7..5323fbb 100644 --- a/src/slotmap.c +++ b/src/slotmap.c @@ -181,6 +181,15 @@ return map; } +#ifdef REMSIM_SERVER +void slotmap_start_timer(struct slot_mapping *map, void(*timeout_cb)(void *data)) +{ + osmo_timer_setup(&map->timer, timeout_cb, map); + osmo_timer_schedule(&map->timer, map->timeout, 0); +} + +#endif + /* thread-safe removal of a bank<->client map */ void _slotmap_del(struct slotmaps *maps, struct slot_mapping *map) { @@ -190,6 +199,7 @@ llist_del(&map->list); #ifdef REMSIM_SERVER + osmo_timer_del(&map->timer); llist_del(&map->bank_list); #endif diff --git a/src/slotmap.h b/src/slotmap.h index 756c29f..60af877 100644 --- a/src/slotmap.h +++ b/src/slotmap.h @@ -3,6 +3,7 @@ #include <stdbool.h> #include <pthread.h> #include <osmocom/core/linuxlist.h> +#include <osmocom/core/timer.h> #define REMSIM_SERVER 1 @@ -60,6 +61,9 @@ #ifdef REMSIM_SERVER struct llist_head bank_list; enum slot_mapping_state state; + /* optional timer to limit mapping duration */ + struct osmo_timer_list timer; + int timeout; /* priority of mapping: any signed integer (negative, 0, or positive); * higher value means higher priority; default is 0 */ int priority; @@ -97,6 +101,10 @@ struct slot_mapping *slotmap_add(struct slotmaps *maps, const struct bank_slot *bank, const struct client_slot *client, int priority); +#ifdef REMSIM_SERVER +void slotmap_start_timer(struct slot_mapping *map, void(*timeout_cb)(void *data)); +#endif + /* thread-safe removal of a bank<->client map */ void slotmap_del(struct slotmaps *maps, struct slot_mapping *map); void _slotmap_del(struct slotmaps *maps, struct slot_mapping *map); -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/43746?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I2f7ee24e6c926b65876af2b14da3534555398769 Gerrit-Change-Number: 43746 Gerrit-PatchSet: 12 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-remsim[master]: Add priority to slot_mapping structure
by laforge 19 Nov '26

19 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/43743?usp=email ) Change subject: Add priority to slot_mapping structure ...................................................................... Add priority to slot_mapping structure In order to store two or more mappings to the same bank/slot, a priority attribute is introduced. Multiple mappings to the same bank/slot is only allowed if the priority values differ. This will be used in later patches to allow mappings to maintenance clients (higher priority), while having inactive mappings to regular clients (lower/default priority). Related: SYS#8159 Change-Id: Ibc9f771cda5d3ba94934cb04e00e60acd466e8bf --- M src/bankd/bankd_main.c M src/server/rest_api.c M src/slotmap.c M src/slotmap.h 4 files changed, 60 insertions(+), 7 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve diff --git a/src/bankd/bankd_main.c b/src/bankd/bankd_main.c index f924cfb..c85f678 100644 --- a/src/bankd/bankd_main.c +++ b/src/bankd/bankd_main.c @@ -229,7 +229,7 @@ } /* Add a new mapping */ - map = slotmap_add(g_bankd->slotmaps, &bs, &cs); + map = slotmap_add(g_bankd->slotmaps, &bs, &cs, 0); if (!map) { LOGPFSML(srvc->fi, LOGL_ERROR, "could not create slotmap\n"); resp = rspro_gen_CreateMappingRes(ResultCode_illegalSlotId); diff --git a/src/server/rest_api.c b/src/server/rest_api.c index 6e025ad..2dc54a2 100644 --- a/src/server/rest_api.c +++ b/src/server/rest_api.c @@ -325,7 +325,7 @@ rc = json2slotmap(&slotmap, json_req); if (rc < 0) goto err; - map = slotmap_add(g_rps->slotmaps, &slotmap.bank, &slotmap.client); + map = slotmap_add(g_rps->slotmaps, &slotmap.bank, &slotmap.client, 0); if (!map) { LOGP(DREST, LOGL_NOTICE, "REST: Cannot add slotmap\n"); goto err; diff --git a/src/slotmap.c b/src/slotmap.c index 1883cf5..57cb5b4 100644 --- a/src/slotmap.c +++ b/src/slotmap.c @@ -92,9 +92,45 @@ return NULL; } +#ifdef REMSIM_SERVER +/* thread-safe lookup of map by bank:slot with specific priority */ +struct slot_mapping *slotmap_by_bank_and_prio(struct slotmaps *maps, const struct bank_slot *bank, int priority) +{ + struct slot_mapping *map; + + slotmaps_rdlock(maps); + llist_for_each_entry(map, &maps->mappings, list) { + if (map->priority != priority) + continue; + if (bank_slot_equals(&map->bank, bank)) { + slotmaps_unlock(maps); + return map; + } + } + slotmaps_unlock(maps); + return NULL; +} + +/* thread-safe lookup of map by bank:slot with highest priority */ +struct slot_mapping *slotmap_by_bank_and_highest_prio(struct slotmaps *maps, const struct bank_slot *bank) +{ + struct slot_mapping *map_found = NULL, *map; + + slotmaps_rdlock(maps); + llist_for_each_entry(map, &maps->mappings, list) { + if (bank_slot_equals(&map->bank, bank)) { + if (!map_found || map->priority > map_found->priority) + map_found = map; + } + } + slotmaps_unlock(maps); + return map_found; +} +#endif + /* thread-safe creating of a new bank<->client map */ -struct slot_mapping *slotmap_add(struct slotmaps *maps, const struct bank_slot *bank, - const struct client_slot *client) +struct slot_mapping *slotmap_add(struct slotmaps *maps, const struct bank_slot *bank, const struct client_slot *client, + int priority) { struct slot_mapping *map; char mapname[64]; @@ -103,10 +139,14 @@ * and hence we don't have any races by first grabbing + releasing the read * lock twice before grabbing the writelock below */ +#ifdef REMSIM_SERVER + map = slotmap_by_bank_and_prio(maps, bank, priority); +#else map = slotmap_by_bank(maps, bank); +#endif if (map) { - LOGP(DSLOTMAP, LOGL_ERROR, "BANKD %u:%u already in use, cannot add new map\n", - bank->bank_id, bank->slot_nr); + LOGP(DSLOTMAP, LOGL_ERROR, "BANKD %u:%u (priority %d) already in use, cannot add new map\n", + bank->bank_id, bank->slot_nr, priority); return NULL; } @@ -131,6 +171,7 @@ #ifdef REMSIM_SERVER map->state = SLMAP_S_NEW; INIT_LLIST_HEAD(&map->bank_list); /* to ensure llist_del() always succeeds */ + map->priority = priority; #endif slotmaps_unlock(maps); diff --git a/src/slotmap.h b/src/slotmap.h index a14e1cf..9128e70 100644 --- a/src/slotmap.h +++ b/src/slotmap.h @@ -59,6 +59,9 @@ #ifdef REMSIM_SERVER struct llist_head bank_list; enum slot_mapping_state state; + /* priority of mapping: any signed integer (negative, 0, or positive); + * higher value means higher priority; default is 0 */ + int priority; #endif }; @@ -79,8 +82,17 @@ /* thread-safe lookup of map by bank:slot */ struct slot_mapping *slotmap_by_bank(struct slotmaps *maps, const struct bank_slot *bank); +#ifdef REMSIM_SERVER +/* thread-safe lookup of map by bank:slot with specific priority */ +struct slot_mapping *slotmap_by_bank_and_prio(struct slotmaps *maps, const struct bank_slot *bank, int priority); + +/* thread-safe lookup of map by bank:slot with highest priority */ +struct slot_mapping *slotmap_by_bank_and_highest_prio(struct slotmaps *maps, const struct bank_slot *bank); +#endif + /* thread-safe creating of a new bank<->client map */ -struct slot_mapping *slotmap_add(struct slotmaps *maps, const struct bank_slot *bank, const struct client_slot *client); +struct slot_mapping *slotmap_add(struct slotmaps *maps, const struct bank_slot *bank, const struct client_slot *client, + int priority); /* thread-safe removal of a bank<->client map */ void slotmap_del(struct slotmaps *maps, struct slot_mapping *map); -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/43743?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: Ibc9f771cda5d3ba94934cb04e00e60acd466e8bf Gerrit-Change-Number: 43743 Gerrit-PatchSet: 9 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-remsim[master]: Add priority mapping support to osmo-remsim-server
by laforge 19 Nov '26

19 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/43745?usp=email ) Change subject: Add priority mapping support to osmo-remsim-server ...................................................................... Add priority mapping support to osmo-remsim-server A normal mapping and a mapping with higher priority may share the same bank/slot. In this case the normal mapping will be inactive until the mapping with higher priority has been removed. This allows temporary mapping for maintenance purposes without removing the existing mapping to a bank/slot. If a mappings with different priority share the same bank/slot, the mapping with higher priority is activated and the mapping with the lower priority is suspended. The following steps are performed, if a mapping to the same bank/slot is added with higher priority: * The higher priority mapping is created and put into INACTIVE state. * The lower priority mapping is suspended and put into INACTIVE state. * The higher priority mapping is activated and becomes ACTIVE. Once the higher priority mapping is removed, the lower priority mapping is resumed. The following steps are performed: * The higher priority mapping is deactivated and then removed. * The lower priority mapping in INACTIVE state is activated again and becomes ACTIVE. If a lower priority mapping is added while a higher priority mapping to the same bank/slot exists, the added mapping will stay in INACTIVE state until it is removed or the higher priority mapping is removed. To control the priority attribute, the rest API is expanded. An optional 'priority' tag is added to the URL. If not specified, the default priority of 0 is used. The rest API allows to show only mappings with given or default priority, not all at once. This prevents prioritized mappings from interfering with user's applications. Related: SYS#8159 Change-Id: I885b3b529276f46fbbe6d86be2170b0bffbb8434 --- M src/server/rest_api.c M src/server/rspro_server.c M src/slotmap.h 3 files changed, 103 insertions(+), 10 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/server/rest_api.c b/src/server/rest_api.c index 99c3238..f26096a 100644 --- a/src/server/rest_api.c +++ b/src/server/rest_api.c @@ -278,12 +278,18 @@ static int api_cb_slotmaps_get(const struct _u_request *req, struct _u_response *resp, void *user_data) { + const char *priority_str = u_map_get(req->map_url, "priority"); struct slot_mapping *map; json_t *json_body = json_object(); json_t *json_maps = json_array(); + int priority; + + priority = (priority_str) ? atoi(priority_str) : 0; slotmaps_rdlock(g_rps->slotmaps); llist_for_each_entry(map, &g_rps->slotmaps->mappings, list) { + if (map->priority != priority) + continue; json_array_append_new(json_maps, slotmap2json(map)); } slotmaps_unlock(g_rps->slotmaps); @@ -309,13 +315,18 @@ static int api_cb_slotmaps_post(const struct _u_request *req, struct _u_response *resp, void *user_data) { + const char *priority_str = u_map_get(req->map_url, "priority"); struct rspro_server *srv = g_rps; - struct slot_mapping slotmap, *map; + struct slot_mapping slotmap, *map, *other_map; struct rspro_client_conn *conn; json_error_t json_err; json_t *json_req = NULL; + bool suspending_map = false; + int priority; int rc; + priority = (priority_str) ? atoi(priority_str) : 0; + json_req = ulfius_get_json_body_request(req, &json_err); if (!json_req) { LOGP(DREST, LOGL_NOTICE, "REST: No JSON Body\n"); @@ -325,13 +336,47 @@ rc = json2slotmap(&slotmap, json_req); if (rc < 0) goto err; - map = slotmap_add(g_rps->slotmaps, &slotmap.bank, &slotmap.client, 0); + + if (slotmap_by_bank_and_prio(g_rps->slotmaps, &slotmap.bank, priority)) { + LOGP(DREST, LOGL_NOTICE, "REST: Slotmap to bank with same priority already exits.\n"); + goto err; + } + + other_map = slotmap_by_bank_and_highest_prio(g_rps->slotmaps, &slotmap.bank); + + /* Request suspension of mapping with lower priority, if not already requested. */ + if (other_map && priority > other_map->priority && !other_map->suspend_requested) { + suspending_map = true; + other_map->suspend_requested = true; + /* If the normal mapping is already active, trigger suspension. */ + if (other_map->state == SLMAP_S_ACTIVE) { + conn = bankd_conn_by_id(g_rps, other_map->bank.bank_id); + slotmap_state_change(other_map, SLMAP_S_DELETE_REQ, &conn->bank.maps_delreq); + /* Notify the conn FSM about delete request. */ + trigger_main_thread_via_eventfd(); + } + } + + map = slotmap_add(g_rps->slotmaps, &slotmap.bank, &slotmap.client, priority); if (!map) { LOGP(DREST, LOGL_NOTICE, "REST: Cannot add slotmap\n"); goto err; } slotmap_state_change(map, SLMAP_S_NEW, NULL); + /* If there is already a mapping with higher priority. */ + if (other_map && other_map->priority > priority) { + /* Put our map (not other map) into inactive state. */ + slotmap_state_change(map, SLMAP_S_INACTIVE, NULL); + goto done; + } + + /* If mapping with lower priority is suspending, wait in INACTIVE state. */ + if (suspending_map) { + slotmap_state_change(map, SLMAP_S_INACTIVE, NULL); + goto done; + } + /* check if any already-connected bankd matches this new map. If yes, associate it */ pthread_rwlock_rdlock(&srv->rwlock); llist_for_each_entry(conn, &srv->banks, list) { @@ -344,7 +389,7 @@ } pthread_rwlock_unlock(&srv->rwlock); - +done: json_decref(json_req); ulfius_set_empty_body_response(resp, 201); @@ -402,9 +447,11 @@ static int api_cb_slotmaps_del(const struct _u_request *req, struct _u_response *resp, void *user_data) { const char *slotmap_id_str = u_map_get(req->map_url, "slotmap_id"); + const char *priority_str = u_map_get(req->map_url, "priority"); struct slot_mapping *map; int status = 404; unsigned long map_id; + int priority; if (!slotmap_id_str) { status = 400; @@ -416,16 +463,17 @@ goto err; } + priority = (priority_str) ? atoi(priority_str) : 0; + slotmaps_wrlock(g_rps->slotmaps); llist_for_each_entry(map, &g_rps->slotmaps->mappings, list) { - if (slotmap_get_id(map) == map_id) { - _slotmap_mark_deleted(map); - status = 200; - break; - } + if (slotmap_get_id(map) != map_id || map->priority != priority) + continue; + _slotmap_mark_deleted(map); + status = 200; + break; } slotmaps_unlock(g_rps->slotmaps); - trigger_main_thread_via_eventfd(); ulfius_set_empty_body_response(resp, status); diff --git a/src/server/rspro_server.c b/src/server/rspro_server.c index 10c74e5..a6172b8 100644 --- a/src/server/rspro_server.c +++ b/src/server/rspro_server.c @@ -21,6 +21,8 @@ #define S(x) (1 << (x)) +extern struct rspro_server *g_rps; + static RsproPDU_t *slotmap2CreateMappingReq(const struct slot_mapping *slotmap) { ClientSlot_t clslot; @@ -381,6 +383,9 @@ /* Link all known mappings to this new bank */ slotmaps_wrlock(slotmaps); llist_for_each_entry(map, &slotmaps->mappings, list) { + /* Skip inactive mappings. */ + if (map->state == SLMAP_S_INACTIVE) + continue; if (map->bank.bank_id == conn->bank.bank_id) _slotmap_state_change(map, SLMAP_S_NEW, &conn->bank.maps_new); } @@ -410,7 +415,8 @@ struct rspro_client_conn *conn = fi->priv; struct slotmaps *slotmaps = conn->srv->slotmaps; const __attribute__((unused)) RsproPDU_t *rx = NULL; - struct slot_mapping *map, *map2; + struct slot_mapping *map, *map2, *other_map; + struct bank_slot bank; switch (event) { case CLNTC_E_CREATE_MAP_RES: /* Bankd acknowledges mapping was created */ @@ -427,6 +433,14 @@ _slotmap_state_change(map, SLMAP_S_ACTIVE, &conn->bank.maps_active); slotmaps_unlock(slotmaps); _update_client_for_slotmap(map, conn->srv, conn); + /* If mapping needs to be suspended while it was created, suspend it now. + * This solves the race condition, where the mapping needs to be suspended + * while it is being activated. */ + if (map->suspend_requested) { + RsproPDU_t *pdu = slotmap2RemoveMappingReq(map); + client_conn_send(conn, pdu); + slotmap_state_change(map, SLMAP_S_DELETING, &conn->bank.maps_deleting); + } break; case CLNTC_E_REMOVE_MAP_RES: /* Bankd acknowledges mapping was removed */ rx = data; @@ -443,8 +457,37 @@ /* update client! */ OSMO_ASSERT(map->state == SLMAP_S_DELETING); _update_client_for_slotmap(map, conn->srv, conn); + /* If mapping has been suspended, put it into INACTIVE state. */ + if (map->suspend_requested) { + slotmap_state_change(map, SLMAP_S_INACTIVE, NULL); + map->suspend_requested = false; + /* Search for mapping with the highest priority, so it can be created. */ + other_map = slotmap_by_bank_and_highest_prio(slotmaps, &map->bank); + if (other_map == map) { + /* If there is no higher priority mapping found, resume suspended mapping by sending + * a create request. This solves the race condition, where the higher priority mapping + * gets removed, while the lower priority mapping was suspended. */ + LOGPFSML(fi, LOGL_NOTICE, + "Mapping with higher priority is gone, resuming client=%d:%d\n", + map->client.client_id, map->client.slot_nr); + } + /* Send create request for the currently highest priority mapping. */ + RsproPDU_t *pdu = slotmap2CreateMappingReq(other_map); + client_conn_send(conn, pdu); + slotmap_state_change(other_map, SLMAP_S_UNACKNOWLEDGED, &conn->bank.maps_unack); + break; + } /* slotmap_del() will remove it from both global and bank list */ + bank = map->bank; slotmap_del(map->maps, map); + /* If there is a lower priority mapping, resume it. */ + other_map = slotmap_by_bank_and_highest_prio(slotmaps, &bank); + if (other_map) { + /* Send create request for resuming normal mapping. */ + RsproPDU_t *pdu = slotmap2CreateMappingReq(other_map); + client_conn_send(conn, pdu); + slotmap_state_change(other_map, SLMAP_S_UNACKNOWLEDGED, &conn->bank.maps_unack); + } break; case CLNTC_E_PUSH: /* check if any create or delete requests are pending */ slotmaps_wrlock(slotmaps); diff --git a/src/slotmap.h b/src/slotmap.h index b1180b4..756c29f 100644 --- a/src/slotmap.h +++ b/src/slotmap.h @@ -63,6 +63,8 @@ /* priority of mapping: any signed integer (negative, 0, or positive); * higher value means higher priority; default is 0 */ int priority; + /* this mapping needs to be suspended */ + bool suspend_requested; #endif }; -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/43745?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I885b3b529276f46fbbe6d86be2170b0bffbb8434 Gerrit-Change-Number: 43745 Gerrit-PatchSet: 12 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-remsim[master]: Add INACTIVE state to slot mapping
by laforge 19 Nov '26

19 Nov '26
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-remsim/+/43744?usp=email ) Change subject: Add INACTIVE state to slot mapping ...................................................................... Add INACTIVE state to slot mapping If multiple mapping (with different priorities) exist for the same bank/slot, only one client/slot can be connected to the bank/slot at the same time. The other mapping(s) will be in INACTIVE state. Related: SYS#8159 Change-Id: I95dff90deb965f8198effdd355d45419bb4c2b02 --- M src/server/rest_api.c M src/slotmap.c M src/slotmap.h 3 files changed, 4 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved laforge: Looks good to me, but someone else must approve diff --git a/src/server/rest_api.c b/src/server/rest_api.c index 2dc54a2..99c3238 100644 --- a/src/server/rest_api.c +++ b/src/server/rest_api.c @@ -368,7 +368,8 @@ switch (map->state) { case SLMAP_S_NEW: - /* new map, not yet sent to bank: we can remove it immediately */ + case SLMAP_S_INACTIVE: + /* new or inactive map, not yet sent to bank: we can remove it immediately */ /* delete from bank list (if any) */ llist_del(&map->bank_list); /* safely initialize list head to avoid trouble when del_slotmap() does another llist_del() */ diff --git a/src/slotmap.c b/src/slotmap.c index 57cb5b4..9f53ff7 100644 --- a/src/slotmap.c +++ b/src/slotmap.c @@ -38,6 +38,7 @@ { SLMAP_S_ACTIVE, "ACTIVE" }, { SLMAP_S_DELETE_REQ, "DELETE_REQ" }, { SLMAP_S_DELETING, "DELETING" }, + { SLMAP_S_INACTIVE, "INACTIVE" }, { 0, NULL } }; diff --git a/src/slotmap.h b/src/slotmap.h index 9128e70..b1180b4 100644 --- a/src/slotmap.h +++ b/src/slotmap.h @@ -38,6 +38,7 @@ SLMAP_S_ACTIVE, /* fully active map; acknowledged by bankd */ SLMAP_S_DELETE_REQ, /* fully active map; REST has requested deletion */ SLMAP_S_DELETING, /* RSPRO has issued Remove to bankd, but bankd hasn't confirmed yet */ + SLMAP_S_INACTIVE, /* suspended mapping is inactive */ }; extern const struct value_string slot_map_state_name[]; static inline const char *slotmap_state_name(enum slot_mapping_state st) -- To view, visit https://gerrit.osmocom.org/c/osmo-remsim/+/43744?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-remsim Gerrit-Branch: master Gerrit-Change-Id: I95dff90deb965f8198effdd355d45419bb4c2b02 Gerrit-Change-Number: 43744 Gerrit-PatchSet: 9 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • ...
  • 72
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.