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

March 2026

  • 1 participants
  • 1933 discussions
[S] Change in osmo-ttcn3-hacks[master]: library/PFCP_Emulation: add f_PFCPEM_set_recovery_timestamp()
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42492?usp=email ) Change subject: library/PFCP_Emulation: add f_PFCPEM_set_recovery_timestamp() ...................................................................... library/PFCP_Emulation: add f_PFCPEM_set_recovery_timestamp() Companion setter for the existing f_PFCPEM_get_recovery_timestamp(). A follow-up patch uses this to inject a specific Recovery Timestamp value into the emulation, so the IUT does not detect a spurious PFCP peer restart between test cases. Change-Id: If47e06d26b42081a28aacb6e06b5aeabf945362c --- M library/PFCP_Emulation.ttcn 1 file changed, 12 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/92/42492/1 diff --git a/library/PFCP_Emulation.ttcn b/library/PFCP_Emulation.ttcn index a5ec818..861fce8 100644 --- a/library/PFCP_Emulation.ttcn +++ b/library/PFCP_Emulation.ttcn @@ -305,6 +305,9 @@ [] CLIENT_PROC.getcall(PFCPEM_get_recovery_timestamp:{?}) -> sender vc_conn { CLIENT_PROC.reply(PFCPEM_get_recovery_timestamp:{g_recovery_timestamp}) to vc_conn; } + [] CLIENT_PROC.getcall(PFCPEM_set_recovery_timestamp:{?}) -> param(g_recovery_timestamp) sender vc_conn { + CLIENT_PROC.reply(PFCPEM_set_recovery_timestamp:{g_recovery_timestamp}) to vc_conn; + } } } } @@ -322,6 +325,7 @@ signature PFCPEM_subscribe_seid(in OCT8 seid, out boolean success); signature PFCPEM_unsubscribe_seid(in OCT8 seid, out boolean success); signature PFCPEM_get_recovery_timestamp(out integer rts); +signature PFCPEM_set_recovery_timestamp(in integer rts); type port PFCPEM_PROC_PT procedure { inout PFCPEM_subscribe_bcast; @@ -329,6 +333,7 @@ inout PFCPEM_subscribe_seid; inout PFCPEM_unsubscribe_seid; inout PFCPEM_get_recovery_timestamp; + inout PFCPEM_set_recovery_timestamp; } with { extension "internal" }; /*********************************************************************** @@ -391,6 +396,13 @@ return rts; } +function f_PFCPEM_set_recovery_timestamp(integer rts) +runs on PFCP_ConnHdlr { + PFCP_PROC.call(PFCPEM_set_recovery_timestamp:{rts}) { + [] PFCP_PROC.getreply(PFCPEM_set_recovery_timestamp:{?}) {}; + } +} + altstep as_pfcp_ignore(PFCPEM_PT pt, template PDU_PFCP pfcp_expect := ?) { var PDU_PFCP pdu; -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42492?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: If47e06d26b42081a28aacb6e06b5aeabf945362c Gerrit-Change-Number: 42492 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: s1gw: f_ConnHdlr_pfcp_assoc_handler(): handle already-connected case
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42493?usp=email ) Change subject: s1gw: f_ConnHdlr_pfcp_assoc_handler(): handle already-connected case ...................................................................... s1gw: f_ConnHdlr_pfcp_assoc_handler(): handle already-connected case Previously, f_pfcp_assoc() would skip spawning a connection handler entirely if the IUT was already PFCP-associated. This was fine for tests that only need an association to be present, but upcoming PFCP Heartbeat test cases need the emulation's Recovery Timestamp to be synced with what the IUT has stored, even when re-using an existing association. Move the state check into f_ConnHdlr_pfcp_assoc_handler(): if the IUT is already connected, sync PFCPEM's Recovery Timestamp to the value the IUT remembers (rrts); otherwise perform the full Association Setup as before. Remove the now-redundant g_pfcp_assoc component variable from test_CT - it's not accessible by ConnHdlr(s) anyway. Change-Id: Id9d2ebb1ddb3d3896dd24e2a37e9d21335441d52 --- M s1gw/S1GW_ConnHdlr.ttcn M s1gw/S1GW_Tests.ttcn 2 files changed, 19 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/93/42493/1 diff --git a/s1gw/S1GW_ConnHdlr.ttcn b/s1gw/S1GW_ConnHdlr.ttcn index fd171d3..297eccd 100644 --- a/s1gw/S1GW_ConnHdlr.ttcn +++ b/s1gw/S1GW_ConnHdlr.ttcn @@ -39,6 +39,9 @@ import from HTTP_Adapter all; import from HTTPmsg_Types all; +import from S1GW_REST_Types all; +import from S1GW_REST_Functions all; + import from StatsD_Types all; import from StatsD_Checker all; @@ -434,7 +437,17 @@ function f_ConnHdlr_pfcp_assoc_handler(charstring id) runs on ConnHdlr { - f_ConnHdlr_pfcp_assoc_setup(); + var PfcpAssocInfo assoc_info := f_REST_PfcpAssocState(); + + if (assoc_info.state == connected) { + /* IUT already connected: sync PFCPEM's RTS to match what IUT remembers */ + f_PFCPEM_set_recovery_timestamp(assoc_info.rrts); + } else { + /* IUT is not connected: perform the Association Setup procedure */ + log("Waiting for IUT to associate over PFCP"); + f_ConnHdlr_pfcp_assoc_setup(); + } + setverdict(pass); } diff --git a/s1gw/S1GW_Tests.ttcn b/s1gw/S1GW_Tests.ttcn index f86546c..121d717 100644 --- a/s1gw/S1GW_Tests.ttcn +++ b/s1gw/S1GW_Tests.ttcn @@ -76,7 +76,6 @@ var S1AP_ServerList vc_S1APSRVs := {}; var PFCP_Emulation_CT vc_PFCP; var StatsD_Checker_CT vc_STATSD; - var PfcpAssocInfo g_pfcp_assoc; }; private altstep as_Tguard() runs on test_CT { @@ -141,16 +140,11 @@ var verdicttype verdict; var ConnHdlr vc_conn; - g_pfcp_assoc := f_REST_PfcpAssocState(); - if (g_pfcp_assoc.state != connected) { - log("Waiting for IUT to associate over PFCP"); - vc_conn := f_ConnHdlr_spawn(refers(f_ConnHdlr_pfcp_assoc_handler), - pars := valueof(t_ConnHdlrPars)); - vc_conn.done -> value verdict; - if (verdict != pass) { - Misc_Helpers.f_shutdown(__BFILE__, __LINE__); - } - g_pfcp_assoc := f_REST_PfcpAssocState(); + vc_conn := f_ConnHdlr_spawn(refers(f_ConnHdlr_pfcp_assoc_handler), + pars := valueof(t_ConnHdlrPars)); + vc_conn.done -> value verdict; + if (verdict != pass) { + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); } } -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42493?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Id9d2ebb1ddb3d3896dd24e2a37e9d21335441d52 Gerrit-Change-Number: 42493 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[XS] Change in osmo-ttcn3-hacks[master]: s1gw/rest: PfcpAssocInfo: field 'lrts' is mandatory
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42491?usp=email ) Change subject: s1gw/rest: PfcpAssocInfo: field 'lrts' is mandatory ...................................................................... s1gw/rest: PfcpAssocInfo: field 'lrts' is mandatory Change-Id: I332e95a32935e0c8da99e600e8d30af14bd36b16 Related: osmo-s1gw.git Ic766ebc56ce1810fc27cb49ddcac50bc94e539d9 --- M s1gw/S1GW_REST_Types.ttcn 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/91/42491/1 diff --git a/s1gw/S1GW_REST_Types.ttcn b/s1gw/S1GW_REST_Types.ttcn index 696df3d..21f4f31 100644 --- a/s1gw/S1GW_REST_Types.ttcn +++ b/s1gw/S1GW_REST_Types.ttcn @@ -65,7 +65,7 @@ PfcpAssocState state, /* Current association state */ charstring laddr, /* Local (bind) IP address */ charstring raddr, /* Remote (connect) IP address */ - integer lrts optional, /* Local Recovery TimeStamp */ + integer lrts, /* Local Recovery TimeStamp */ integer rrts optional /* Remote Recovery TimeStamp */ }; -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42491?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I332e95a32935e0c8da99e600e8d30af14bd36b16 Gerrit-Change-Number: 42491 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[S] Change in osmo-ttcn3-hacks[master]: s1gw: TC_pfcp_heartbeat: validate RTS in Heartbeat Response
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42494?usp=email ) Change subject: s1gw: TC_pfcp_heartbeat: validate RTS in Heartbeat Response ...................................................................... s1gw: TC_pfcp_heartbeat: validate RTS in Heartbeat Response The test case had a TODO noting that the Recovery Timestamp in the Heartbeat Response was not yet validated. Let's get this resolved: query the IUT's PFCP association state via REST to obtain its local Recovery Timestamp (lrts), and verify that the IUT echoes back that same value in the Heartbeat Response. Change-Id: I000cc82e7582baded96a33cb0da2103906972ff9 --- M s1gw/S1GW_Tests.ttcn 1 file changed, 22 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/94/42494/1 diff --git a/s1gw/S1GW_Tests.ttcn b/s1gw/S1GW_Tests.ttcn index 121d717..38a5e7d 100644 --- a/s1gw/S1GW_Tests.ttcn +++ b/s1gw/S1GW_Tests.ttcn @@ -1030,16 +1030,33 @@ function f_TC_pfcp_heartbeat(charstring id) runs on ConnHdlr { var integer rts := f_PFCPEM_get_recovery_timestamp(); + var PfcpAssocInfo assoc_info; var PDU_PFCP pfcp_pdu; + timer T; + + /* Query IUT's PFCP assoc state via REST to get its RTS: + * assoc_info.lrts - IUT's RTS, + * assoc_info.rrts - PFCPEM's RTS */ + assoc_info := f_REST_PfcpAssocState(); /* Tx Heartbeat Request */ PFCP.send(ts_PFCP_Heartbeat_Req(rts)); - /* Expect Heartbeat Response - * TODO: validate the indicated Recovery Time Stamp against - * the one that we received in the PFCP Association Setup. */ - pfcp_pdu := f_ConnHdlr_pfcp_expect(tr_PFCP_Heartbeat_Resp); - setverdict(pass); + /* Expect Heartbeat Resp with RTS that we learned from the Association Setup Req */ + T.start(2.0); + alt { + [] PFCP.receive(tr_PFCP_Heartbeat_Resp(assoc_info.lrts)) { + setverdict(pass); + } + [] PFCP.receive(tr_PFCP_Heartbeat_Resp) -> value pfcp_pdu { + setverdict(fail, "Rx Heartbeat Response with unexpected RTS: ", pfcp_pdu); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + [] T.timeout { + setverdict(fail, "Timeout waiting for Heartbeat Response"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + } } testcase TC_pfcp_heartbeat() runs on test_CT { f_TC_exec(refers(f_TC_pfcp_heartbeat)); -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42494?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I000cc82e7582baded96a33cb0da2103906972ff9 Gerrit-Change-Number: 42494 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[L] Change in osmo-ttcn3-hacks[master]: s1gw: add more PFCP Heartbeat test cases
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42495?usp=email ) Change subject: s1gw: add more PFCP Heartbeat test cases ...................................................................... s1gw: add more PFCP Heartbeat test cases TC_pfcp_heartbeat_periodic: verify that the IUT sends periodic PFCP Heartbeat Requests and that the heartbeat timer re-arms correctly after each successful response (at least 2 periodic HBs must be observed). TC_pfcp_heartbeat_miss_threshold: verify that the IUT resets the PFCP association after mp_pfcp_heartbeat_miss_count consecutive unanswered Heartbeat Requests (a new Association Setup Request is expected). TC_pfcp_heartbeat_miss_reset: verify that a successful Heartbeat Response resets the miss counter; run 2 cycles of missing (miss_count - 1) HBs then responding to one, expecting no association reset throughout. TC_pfcp_heartbeat_rts_mismatch: verify that the IUT detects a UPF restart when a Heartbeat Response carries a different Recovery Timestamp than the one observed during Association Setup, and that it promptly resets and re-establishes the PFCP association. Also add module parameters for the heartbeat configuration (mp_pfcp_heartbeat_interval, mp_pfcp_heartbeat_req_timeout, mp_pfcp_heartbeat_miss_count) and update osmo-s1gw.config accordingly. Change-Id: Ie5ac25b1ca4bb11e61bff220449397c271b11464 Related: osmo-s1gw.git Iba954746fe20e6b9eeaec3196e1f83e3fc3e7fc2 Related: osmo-s1gw.git I306324f8eca325202a3fa23125854db9d5eaab38 Related: osmo-s1gw.git I00a8384db1ea9c38d0ad9ff90b3d45ad86c3a020 --- M s1gw/S1GW_ConnHdlr.ttcn M s1gw/S1GW_Tests.ttcn M s1gw/expected-results.xml M s1gw/osmo-s1gw.config 4 files changed, 278 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/95/42495/1 diff --git a/s1gw/S1GW_ConnHdlr.ttcn b/s1gw/S1GW_ConnHdlr.ttcn index 297eccd..aeda4c5 100644 --- a/s1gw/S1GW_ConnHdlr.ttcn +++ b/s1gw/S1GW_ConnHdlr.ttcn @@ -398,6 +398,15 @@ Misc_Helpers.f_shutdown(__BFILE__, __LINE__); } +function f_PFCPEM_tx_assoc_setup_resp(LIN3_BO_LAST seq_nr) +runs on PFCP_ConnHdlr +{ + PFCP.send(ts_PFCP_Assoc_Setup_Resp(seq_nr, + ts_PFCP_Node_ID_fqdn("\07osmocom\03org"), + ts_PFCP_Cause(REQUEST_ACCEPTED), + f_PFCPEM_get_recovery_timestamp())); +} + private function f_ConnHdlr_pfcp_assoc_setup() runs on ConnHdlr { @@ -406,10 +415,7 @@ f_PFCPEM_subscribe_bcast(); /* ask PFCPEM to route all PDUs to us */ rx := f_ConnHdlr_pfcp_expect(tr_PFCP_Assoc_Setup_Req, Tval := 10.0); f_PFCPEM_unsubscribe_bcast(); /* ask PFCPEM to *not* route all PDUs to us */ - PFCP.send(ts_PFCP_Assoc_Setup_Resp(rx.sequence_number, - ts_PFCP_Node_ID_fqdn("\07osmocom\03org"), - ts_PFCP_Cause(REQUEST_ACCEPTED), - f_PFCPEM_get_recovery_timestamp())); + f_PFCPEM_tx_assoc_setup_resp(rx.sequence_number); } function f_ConnHdlr_pfcp_expect(template (present) PDU_PFCP exp_rx := ?, diff --git a/s1gw/S1GW_Tests.ttcn b/s1gw/S1GW_Tests.ttcn index 38a5e7d..198bc7b 100644 --- a/s1gw/S1GW_Tests.ttcn +++ b/s1gw/S1GW_Tests.ttcn @@ -68,6 +68,11 @@ charstring mp_rest_host := "127.0.0.1"; integer mp_rest_port := 8080; + + /* PFCP heartbeat test parameters (must match IUT's pfcp_peer configuration) */ + float mp_pfcp_heartbeat_interval := 4.0; + float mp_pfcp_heartbeat_req_timeout := 2.0; + integer mp_pfcp_heartbeat_miss_count := 3; } type component test_CT extends StatsD_Checker_CT, http_CT { @@ -87,6 +92,7 @@ function f_init(boolean s1apsrv_start := true, integer num_mmes := 1, boolean upf_start := true, + boolean pfcp_answer_heartbeat := true, float Tval := 20.0) runs on test_CT { g_Tguard.start(Tval); activate(as_Tguard()); @@ -100,7 +106,7 @@ } f_init_rest(); if (upf_start) { - f_init_pfcp(); + f_init_pfcp(pfcp_answer_heartbeat); f_pfcp_assoc(); } } @@ -121,14 +127,14 @@ } } -function f_init_pfcp() runs on test_CT { +function f_init_pfcp(boolean answer_heartbeat_req := true) runs on test_CT { var PFCP_Emulation_Cfg pfcp_cfg := { pfcp_bind_ip := mp_upf_bind_ip, pfcp_bind_port := PFCP_PORT, pfcp_remote_ip := mp_s1gw_upf_ip, pfcp_remote_port := PFCP_PORT, role := UPF, - answer_heartbeat_req := true + answer_heartbeat_req := answer_heartbeat_req }; vc_PFCP := PFCP_Emulation_CT.create("PFCPEM-" & testcasename()) alive; @@ -1028,6 +1034,29 @@ f_TC_exec(refers(f_TC_handover_res_alloc_fail), 1, 6); } +/* Like f_TC_exec() but without S1AP server and with answer_heartbeat_req := false, + * allowing test functions to observe and control IUT-initiated HB requests via bcast. + * The PFCP association is established via f_pfcp_assoc() before the ConnHdlr starts. */ +private function f_TC_exec_pfcp_hb(void_fn fn, float Tval := 60.0) runs on test_CT { + var ConnHdlr vc_conn; + + f_init(s1apsrv_start := false, pfcp_answer_heartbeat := false, Tval := Tval); + vc_conn := f_ConnHdlr_spawn(fn, valueof(t_ConnHdlrPars)); + vc_conn.done; +} + +/* Send a PFCP Heartbeat Response with an explicit RTS value */ +private function f_pfcp_send_hb_resp_rts(PDU_PFCP req, integer rts) runs on ConnHdlr { + var PDU_PFCP resp := valueof(ts_PFCP_Heartbeat_Resp(rts)); + resp.sequence_number := req.sequence_number; + PFCP.send(resp); +} + +/* Send a PFCP Heartbeat Response with the PFCPEM's own recovery timestamp */ +private function f_pfcp_send_hb_resp(PDU_PFCP req) runs on ConnHdlr { + f_pfcp_send_hb_resp_rts(req, f_PFCPEM_get_recovery_timestamp()); +} + function f_TC_pfcp_heartbeat(charstring id) runs on ConnHdlr { var integer rts := f_PFCPEM_get_recovery_timestamp(); var PfcpAssocInfo assoc_info; @@ -1062,6 +1091,225 @@ f_TC_exec(refers(f_TC_pfcp_heartbeat)); } +/* Verify that the IUT sends periodic PFCP Heartbeat Requests when heartbeat_interval > 0. + * The test subscribes to PFCPEM broadcast, responds to each HB request, and verifies + * that at least 2 periodic HBs are received (proving the timer re-arms correctly). + * The PFCP association is assumed to be already established (done by f_TC_exec_pfcp_hb). */ +function f_TC_pfcp_heartbeat_periodic(charstring id) runs on ConnHdlr { + var PDU_PFCP pfcp_pdu; + timer T; + + if (mp_pfcp_heartbeat_interval == 0.0) { + setverdict(inconc, "periodic HB is disabled, skipped"); + return; + } + + /* Subscribe to bcast so we receive IUT-initiated HB requests */ + f_PFCPEM_subscribe_bcast(); + + /* Expect at least 2 periodic HB requests, responding to each */ + for (var integer i := 0; i < 2; i := i + 1) { + T.start(mp_pfcp_heartbeat_interval + + mp_pfcp_heartbeat_req_timeout + 2.0); + alt { + [] PFCP.receive(tr_PFCP_Heartbeat_Req) -> value pfcp_pdu { + f_pfcp_send_hb_resp(pfcp_pdu); + T.stop; + } + [] T.timeout { + setverdict(fail, "Timeout waiting for periodic PFCP Heartbeat Request"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + } + } + + f_PFCPEM_unsubscribe_bcast(); + setverdict(pass); +} +testcase TC_pfcp_heartbeat_periodic() runs on test_CT { + const float Tval := (mp_pfcp_heartbeat_interval + mp_pfcp_heartbeat_req_timeout) * 3.0 + 10.0; + f_TC_exec_pfcp_hb(refers(f_TC_pfcp_heartbeat_periodic), Tval := Tval); +} + +/* Verify that the IUT resets the PFCP association after miss_count consecutive unanswered + * Heartbeat Requests. The test ignores all HB requests and waits for the IUT to initiate + * a new PFCP Association Setup (proving the association was reset). + * The PFCP association is assumed to be already established (done by f_TC_exec_pfcp_hb). */ +function f_TC_pfcp_heartbeat_miss_threshold(charstring id) runs on ConnHdlr { + var PDU_PFCP pfcp_pdu; + var float Tval := (mp_pfcp_heartbeat_interval + mp_pfcp_heartbeat_req_timeout) + * int2float(mp_pfcp_heartbeat_miss_count) + 10.0; + timer T; + + if (mp_pfcp_heartbeat_interval == 0.0) { + setverdict(inconc, "periodic HB is disabled, skipped"); + return; + } + + /* Subscribe to bcast: we'll receive both HB requests and the new assoc setup req */ + f_PFCPEM_subscribe_bcast(); + + /* Do NOT respond to any HB requests; wait for the IUT to reset and re-associate */ + T.start(Tval); + alt { + [] PFCP.receive(tr_PFCP_Assoc_Setup_Req) -> value pfcp_pdu { + /* IUT reset the association and started a new one - success */ + f_PFCPEM_tx_assoc_setup_resp(pfcp_pdu.sequence_number); + } + [] PFCP.receive(tr_PFCP_Heartbeat_Req) { + /* Discard unanswered HB requests and keep waiting */ + repeat; + } + [] T.timeout { + setverdict(fail, "Timeout: IUT did not reset PFCP association after ", + mp_pfcp_heartbeat_miss_count, " missed heartbeats"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + } + + f_PFCPEM_unsubscribe_bcast(); + setverdict(pass); +} +testcase TC_pfcp_heartbeat_miss_threshold() runs on test_CT { + var float Tval := (mp_pfcp_heartbeat_interval + mp_pfcp_heartbeat_req_timeout) + * int2float(mp_pfcp_heartbeat_miss_count + 1) + 15.0; + f_TC_exec_pfcp_hb(refers(f_TC_pfcp_heartbeat_miss_threshold), Tval := Tval); +} + +/* Verify that a successful HB response resets the miss counter. The test misses + * (miss_count - 1) HBs, then responds to one, then misses (miss_count - 1) again + * and responds to one. If the miss counter is properly reset on success, the IUT + * should NOT reset the association during this sequence. + * The PFCP association is assumed to be already established (done by f_TC_exec_pfcp_hb). */ +function f_TC_pfcp_heartbeat_miss_reset(charstring id) runs on ConnHdlr { + var PDU_PFCP pfcp_pdu; + var float Tval := mp_pfcp_heartbeat_interval + mp_pfcp_heartbeat_req_timeout + 2.0; + timer T; + + if (mp_pfcp_heartbeat_interval == 0.0) { + setverdict(inconc, "periodic HB is disabled, skipped"); + return; + } + + /* Subscribe to bcast: we'll receive HB requests (and assoc setup if reset occurs) */ + f_PFCPEM_subscribe_bcast(); + + /* Run 2 full miss-then-recover cycles */ + for (var integer i := 0; i < 2; i := i + 1) { + /* Miss (mp_pfcp_heartbeat_miss_count - 1) heartbeats */ + for (var integer j := 0; j < mp_pfcp_heartbeat_miss_count - 1; j := j + 1) { + T.start(Tval); + alt { + [] PFCP.receive(tr_PFCP_Heartbeat_Req) { + /* Discard without responding */ + T.stop; + } + [] PFCP.receive(tr_PFCP_Assoc_Setup_Req) { + setverdict(fail, "IUT reset association unexpectedly"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + [] T.timeout { + setverdict(fail, "Timeout waiting for periodic PFCP Heartbeat Request"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + } + } + + /* Respond to the next HB to reset the miss counter */ + T.start(Tval); + alt { + [] PFCP.receive(tr_PFCP_Heartbeat_Req) -> value pfcp_pdu { + T.stop; + f_pfcp_send_hb_resp(pfcp_pdu); + } + [] PFCP.receive(tr_PFCP_Assoc_Setup_Req) { + setverdict(fail, "IUT reset association unexpectedly (miss counter not reset?)"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + [] T.timeout { + setverdict(fail, "Timeout waiting for periodic PFCP Heartbeat Request"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + } + } + + f_PFCPEM_unsubscribe_bcast(); + setverdict(pass); +} +testcase TC_pfcp_heartbeat_miss_reset() runs on test_CT { + var float Tval := (mp_pfcp_heartbeat_interval + mp_pfcp_heartbeat_req_timeout) + * int2float(mp_pfcp_heartbeat_miss_count) * 2.0 + 15.0; + f_TC_exec_pfcp_hb(refers(f_TC_pfcp_heartbeat_miss_reset), Tval := Tval); +} + +/* Verify that the IUT detects a UPF restart when the Recovery Timestamp in a Heartbeat + * Response differs from the value stored during Association Setup, and resets the + * PFCP association as a result. + * The PFCP association is assumed to be already established (done by f_TC_exec_pfcp_hb). */ +function f_TC_pfcp_heartbeat_rts_mismatch(charstring id) runs on ConnHdlr { + var PDU_PFCP pfcp_pdu; + timer T; + + if (mp_pfcp_heartbeat_interval == 0.0) { + setverdict(inconc, "periodic HB is disabled, skipped"); + return; + } + + /* Subscribe to bcast so we receive IUT-initiated HB requests */ + f_PFCPEM_subscribe_bcast(); + + /* Wait for the first periodic HB request */ + T.start(mp_pfcp_heartbeat_interval + mp_pfcp_heartbeat_req_timeout + 2.0); + alt { + [] PFCP.receive(tr_PFCP_Heartbeat_Req) -> value pfcp_pdu { + T.stop; + /* Respond with a mismatched RTS to simulate a UPF restart */ + f_pfcp_send_hb_resp_rts(pfcp_pdu, f_PFCPEM_get_recovery_timestamp() + 1); + } + [] T.timeout { + setverdict(fail, "Timeout waiting for periodic PFCP Heartbeat Request"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + } + + /* IUT should detect the RTS mismatch and reset the association immediately */ + T.start(2.0); + alt { + [] PFCP.receive(tr_PFCP_Assoc_Setup_Req) -> value pfcp_pdu { + T.stop; + /* Verify via REST that the IUT is in connecting state (association was reset) */ + var PfcpAssocInfo assoc := f_REST_PfcpAssocState(); + if (assoc.state != connecting) { + setverdict(fail, "Unexpected PFCP assoc state ", assoc.state); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + /* Complete the new association setup */ + f_PFCPEM_tx_assoc_setup_resp(pfcp_pdu.sequence_number); + /* Allow the IUT to process the response, then verify it re-associated */ + f_sleep(0.5); + assoc := f_REST_PfcpAssocState(); + if (assoc.state != connected) { + setverdict(fail, "Unexpected PFCP assoc state ", assoc.state); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + } + [] PFCP.receive(tr_PFCP_Heartbeat_Req) { + repeat; /* discard any further HBs while waiting for the assoc reset */ + } + [] T.timeout { + setverdict(fail, "Timeout: IUT did not reset PFCP association after RTS mismatch"); + Misc_Helpers.f_shutdown(__BFILE__, __LINE__); + } + } + + f_PFCPEM_unsubscribe_bcast(); + setverdict(pass); +} +testcase TC_pfcp_heartbeat_rts_mismatch() runs on test_CT { + var float Tval := mp_pfcp_heartbeat_interval + mp_pfcp_heartbeat_req_timeout + 20.0; + f_TC_exec_pfcp_hb(refers(f_TC_pfcp_heartbeat_rts_mismatch), Tval := Tval); +} + /* MME pool test: eNB connects, the first MME rejects, the second one accepts */ function f_TC_mme_pool_reject_fallback(charstring id) runs on ConnHdlr { f_ConnHdlr_s1ap_connect(mp_enb_bind_ip, mp_s1gw_enb_ip); @@ -1410,6 +1658,10 @@ execute( TC_handover_res_alloc() ); execute( TC_handover_res_alloc_fail() ); execute( TC_pfcp_heartbeat() ); + execute( TC_pfcp_heartbeat_periodic() ); + execute( TC_pfcp_heartbeat_miss_threshold() ); + execute( TC_pfcp_heartbeat_miss_reset() ); + execute( TC_pfcp_heartbeat_rts_mismatch() ); execute( TC_mme_pool_reject_fallback() ); execute( TC_mme_pool_timeout_fallback() ); execute( TC_mme_pool_all_reject() ); diff --git a/s1gw/expected-results.xml b/s1gw/expected-results.xml index b2b6cdb..d5fa997 100644 --- a/s1gw/expected-results.xml +++ b/s1gw/expected-results.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<testsuite name='S1GW_Tests' tests='41' failures='0' errors='0' skipped='0' inconc='0' time='MASKED'> +<testsuite name='S1GW_Tests' tests='45' failures='0' errors='0' skipped='0' inconc='0' time='MASKED'> <testcase classname='S1GW_Tests' name='TC_setup' time='MASKED'/> <testcase classname='S1GW_Tests' name='TC_setup_multi' time='MASKED'/> <testcase classname='S1GW_Tests' name='TC_conn_term_by_mme' time='MASKED'/> @@ -35,6 +35,10 @@ <testcase classname='S1GW_Tests' name='TC_handover_res_alloc' time='MASKED'/> <testcase classname='S1GW_Tests' name='TC_handover_res_alloc_fail' time='MASKED'/> <testcase classname='S1GW_Tests' name='TC_pfcp_heartbeat' time='MASKED'/> + <testcase classname='S1GW_Tests' name='TC_pfcp_heartbeat_periodic' time='MASKED'/> + <testcase classname='S1GW_Tests' name='TC_pfcp_heartbeat_miss_threshold' time='MASKED'/> + <testcase classname='S1GW_Tests' name='TC_pfcp_heartbeat_miss_reset' time='MASKED'/> + <testcase classname='S1GW_Tests' name='TC_pfcp_heartbeat_rts_mismatch' time='MASKED'/> <testcase classname='S1GW_Tests' name='TC_mme_pool_reject_fallback' time='MASKED'/> <testcase classname='S1GW_Tests' name='TC_mme_pool_timeout_fallback' time='MASKED'/> <testcase classname='S1GW_Tests' name='TC_mme_pool_all_reject' time='MASKED'/> diff --git a/s1gw/osmo-s1gw.config b/s1gw/osmo-s1gw.config index 5788446..f7fad64 100644 --- a/s1gw/osmo-s1gw.config +++ b/s1gw/osmo-s1gw.config @@ -30,6 +30,14 @@ #{name => "mme1", laddr => "127.0.2.1", raddr => "127.0.2.11"}, #{name => "mme2", laddr => "127.0.2.1", raddr => "127.0.2.12"} ]}, + {pfcp_peer, #{ + laddr => "127.0.3.1", + raddr => "127.0.3.10", + heartbeat_interval => 4_000, + heartbeat_req_timeout => 2_000, + heartbeat_miss_count => 3 + }}, + %% XXX: pfcp_{loc,rem}_addr kept for compatibility with the -latest (<= 0.4.0) {pfcp_loc_addr, "127.0.3.1"}, %% local address for incoming PFCP PDUs from the UPF {pfcp_rem_addr, "127.0.3.10"} %% remote address for outgoing PFCP PDUs to the UPF ]}, -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42495?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: Ie5ac25b1ca4bb11e61bff220449397c271b11464 Gerrit-Change-Number: 42495 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[M] Change in ...osmo-s1gw[master]: pfcp_peer: make assoc_setup and heartbeat_req timeouts configurable
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42486?usp=email ) Change subject: pfcp_peer: make assoc_setup and heartbeat_req timeouts configurable ...................................................................... pfcp_peer: make assoc_setup and heartbeat_req timeouts configurable Add assoc_setup_timeout and heartbeat_req_timeout as optional fields in the pfcp_peer config map, with 2000 ms defaults. Store the full cfg() map in #peer_state{} and read values from it with maps:get/3 at the point of use. Change-Id: I58a472a3bbbbad029a2f0246b084428ab3b1905c --- M config/sys.config M contrib/openapi.yaml M doc/manuals/chapters/configuration.adoc M doc/manuals/chapters/rest.adoc M include/osmo_s1gw.hrl M priv/openapi.json M src/osmo_s1gw_sup.erl M src/pfcp_peer.erl M src/rest_server.erl 9 files changed, 62 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/86/42486/1 diff --git a/config/sys.config b/config/sys.config index af6480b..5bebbe6 100644 --- a/config/sys.config +++ b/config/sys.config @@ -32,6 +32,10 @@ laddr => "127.0.1.1", %% remote address for outgoing PFCP PDUs to the UPF raddr => "127.0.1.2" + %% optional: PFCP Association Setup timeout in milliseconds (default: 2000) + %% assoc_setup_timeout => 2000, + %% optional: PFCP Heartbeat Request timeout in milliseconds (default: 2000) + %% heartbeat_req_timeout => 2000 }} %% Optional PFCP Network Instance IEs (omitted if not configured) %% {pfcp_net_inst_core, "core-side"}, %% PFCP Network Instance IE value (to core) diff --git a/contrib/openapi.yaml b/contrib/openapi.yaml index 59de93f..8ca18aa 100644 --- a/contrib/openapi.yaml +++ b/contrib/openapi.yaml @@ -529,6 +529,12 @@ raddr: type: string description: Remote IP address of the UPF (PFCP peer) + assoc_setup_timeout: + type: integer + description: PFCP Association Setup response timeout in milliseconds + heartbeat_req_timeout: + type: integer + description: PFCP Heartbeat Request response timeout in milliseconds GtpuKpiCfg: type: object diff --git a/doc/manuals/chapters/configuration.adoc b/doc/manuals/chapters/configuration.adoc index a43c9ad..a361730 100644 --- a/doc/manuals/chapters/configuration.adoc +++ b/doc/manuals/chapters/configuration.adoc @@ -137,6 +137,8 @@ {pfcp_peer, #{ laddr => "127.0.1.1", %% local address for PFCP (UDP) raddr => "127.0.1.2" %% remote address of the UPF + %% assoc_setup_timeout => 2000, %% optional, milliseconds + %% heartbeat_req_timeout => 2000 %% optional, milliseconds }}, %% Optional Network Instance IEs: @@ -151,6 +153,14 @@ `raddr`:: Remote IP address of the UPF. Default: `"127.0.1.2"`. +`assoc_setup_timeout`:: + How long (in milliseconds) to wait for a PFCP Association Setup Response + before retrying. Default: `2000`. + +`heartbeat_req_timeout`:: + How long (in milliseconds) to wait for a PFCP Heartbeat Response before + declaring the heartbeat timed out. Default: `2000`. + NOTE: The legacy flat keys `pfcp_loc_addr` and `pfcp_rem_addr` are still accepted for backwards compatibility. The `pfcp_peer` map takes priority if both are present. diff --git a/doc/manuals/chapters/rest.adoc b/doc/manuals/chapters/rest.adoc index 92b4f7a..c3f53af 100644 --- a/doc/manuals/chapters/rest.adoc +++ b/doc/manuals/chapters/rest.adoc @@ -78,7 +78,9 @@ }, "pfcp": { "laddr": "127.0.1.1", - "raddr": "127.0.1.2" + "raddr": "127.0.1.2", + "assoc_setup_timeout": 2000, + "heartbeat_req_timeout": 2000 }, "gtpu_kpi": { "enable": false, @@ -107,6 +109,8 @@ `pfcp`:: `laddr`::: Local PFCP bind address. `raddr`::: Remote UPF (PFCP peer) address. + `assoc_setup_timeout`::: PFCP Association Setup response timeout in milliseconds. + `heartbeat_req_timeout`::: PFCP Heartbeat Request response timeout in milliseconds. `gtpu_kpi`:: `enable`::: Whether GTP-U KPI reporting via nftables counters is active. diff --git a/include/osmo_s1gw.hrl b/include/osmo_s1gw.hrl index 91bd2e6..692a6ff 100644 --- a/include/osmo_s1gw.hrl +++ b/include/osmo_s1gw.hrl @@ -41,6 +41,8 @@ -define(ENV_DEFAULT_MME_REM_PORT, 36412). -define(ENV_DEFAULT_PFCP_LOC_ADDR, "127.0.1.1"). -define(ENV_DEFAULT_PFCP_REM_ADDR, "127.0.1.2"). +-define(ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT, 2000). +-define(ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT, 2000). -define(ENV_DEFAULT_GTPU_KPI_ENABLE, false). -define(ENV_DEFAULT_GTPU_KPI_TABLE_NAME, "osmo-s1gw"). -define(ENV_DEFAULT_GTPU_KPI_INTERVAL, 3000). diff --git a/priv/openapi.json b/priv/openapi.json index cf2fb50..3153505 100644 --- a/priv/openapi.json +++ b/priv/openapi.json @@ -763,6 +763,14 @@ "raddr": { "type": "string", "description": "Remote IP address of the UPF (PFCP peer)" + }, + "assoc_setup_timeout": { + "type": "integer", + "description": "PFCP Association Setup response timeout in milliseconds" + }, + "heartbeat_req_timeout": { + "type": "integer", + "description": "PFCP Heartbeat Request response timeout in milliseconds" } } }, diff --git a/src/osmo_s1gw_sup.erl b/src/osmo_s1gw_sup.erl index 573f2cb..9809fff 100644 --- a/src/osmo_s1gw_sup.erl +++ b/src/osmo_s1gw_sup.erl @@ -159,7 +159,11 @@ %% parse the new pfcp configuration block (takes priority) Cfg = maps:merge(OldCfg, osmo_s1gw:get_env(pfcp_peer, #{ })), #{laddr => maps:get(laddr, Cfg, ?ENV_DEFAULT_PFCP_LOC_ADDR), - raddr => maps:get(raddr, Cfg, ?ENV_DEFAULT_PFCP_REM_ADDR)}. + raddr => maps:get(raddr, Cfg, ?ENV_DEFAULT_PFCP_REM_ADDR), + assoc_setup_timeout => maps:get(assoc_setup_timeout, Cfg, + ?ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT), + heartbeat_req_timeout => maps:get(heartbeat_req_timeout, Cfg, + ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT)}. -spec gtpu_kpi_cfg() -> gtpu_kpi:cfg(). diff --git a/src/pfcp_peer.erl b/src/pfcp_peer.erl index 3423237..a6f4b03 100644 --- a/src/pfcp_peer.erl +++ b/src/pfcp_peer.erl @@ -55,14 +55,14 @@ -include_lib("kernel/include/logger.hrl"). -include_lib("pfcplib/include/pfcp_packet.hrl"). + +-include("osmo_s1gw.hrl"). -include("s1gw_metrics.hrl"). %% 3GPP TS 29.244, section 4.2 "UDP Header and Port Numbers" -define(PFCP_PORT, 8805). -define(PFCP_SEQ_NR_MAX, 16#ffffff). -define(PFCP_SEID_MAX, 16#ffffffffffffffff). --define(PFCP_ASSOC_SETUP_TIMEOUT, 2000). --define(PFCP_HEARTBEAT_REQ_TIMEOUT, 2000). -type pfcp_session_rsp() :: ok | {error, term()}. @@ -75,7 +75,9 @@ -type pfcp_pdu() :: #pfcp{}. -type cfg() :: #{laddr := string() | inet:ip_address(), - raddr := string() | inet:ip_address()}. + raddr := string() | inet:ip_address(), + assoc_setup_timeout => pos_integer(), + heartbeat_req_timeout => pos_integer()}. -type peer_info() :: #{state := atom(), laddr := inet:ip_address(), @@ -98,7 +100,8 @@ tref :: reference() }). --record(peer_state, {seid :: pfcp_seid(), +-record(peer_state, {cfg :: cfg(), + seid :: pfcp_seid(), sock :: gen_udp:socket(), loc_addr :: inet:ip_address(), rem_addr :: inet:ip_address(), @@ -189,7 +192,8 @@ {reuseaddr, true}, {active, true}]), ?LOG_INFO("PFCP peer @ ~p will talk to UPF @ ~p", [LocAddr, RemAddr]), - {ok, connecting, #peer_state{seid = 1, %% SEID=0 is special, see 7.2.2.4.2 + {ok, connecting, #peer_state{cfg = Cfg, + seid = 1, %% SEID=0 is special, see 7.2.2.4.2 sock = Sock, loc_addr = LocAddr, rem_addr = RemAddr, @@ -204,12 +208,13 @@ %% CONNECTING state connecting(enter, OldState, - #peer_state{} = S0) -> + #peer_state{cfg = Cfg} = S0) -> ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), s1gw_metrics:gauge_set(?S1GW_GAUGE_PFCP_ASSOCIATED, 0), %% Tx PFCP Association Setup {ok, S1} = send_assoc_setup(S0), - {keep_state, S1, [{state_timeout, ?PFCP_ASSOC_SETUP_TIMEOUT, assoc_setup_timeout}]}; + TVal = maps:get(assoc_setup_timeout, Cfg, ?ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT), + {keep_state, S1, [{state_timeout, TVal, assoc_setup_timeout}]}; %% Handle Association Setup timeout connecting(state_timeout, assoc_setup_timeout, S) -> @@ -571,7 +576,8 @@ ?LOG_ERROR("Another Heartbeat Request is still pending (SeqNr=~p)", [SeqNr]), {{error, heartbeat_req_pending}, S}; -send_heartbeat_request(From, #peer_state{heartbeat = undefined, +send_heartbeat_request(From, #peer_state{cfg = Cfg, + heartbeat = undefined, seq_nr = SeqNr, loc_rts = LRTS} = S0) -> ReqIEs = #{recovery_time_stamp => #recovery_time_stamp{time = LRTS}}, @@ -579,8 +585,9 @@ case send_pdu({heartbeat_request, ReqIEs}, S0) of {ok, S1} -> s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_HEARTBEAT_REQ_TX), - TRef = erlang:start_timer(?PFCP_HEARTBEAT_REQ_TIMEOUT, self(), - heartbeat_request_watchdog), + TVal = maps:get(heartbeat_req_timeout, Cfg, + ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT), + TRef = erlang:start_timer(TVal, self(), heartbeat_request_watchdog), HB = #heartbeat_state{from = From, seq_nr = SeqNr, tref = TRef}, diff --git a/src/rest_server.erl b/src/rest_server.erl index 24ca33b..7960ffa 100644 --- a/src/rest_server.erl +++ b/src/rest_server.erl @@ -281,7 +281,11 @@ config_pfcp() -> Cfg = osmo_s1gw:get_env(pfcp_peer, #{}), #{<<"laddr">> => bval(maps:get(laddr, Cfg, ?ENV_DEFAULT_PFCP_LOC_ADDR)), - <<"raddr">> => bval(maps:get(raddr, Cfg, ?ENV_DEFAULT_PFCP_REM_ADDR))}. + <<"raddr">> => bval(maps:get(raddr, Cfg, ?ENV_DEFAULT_PFCP_REM_ADDR)), + <<"assoc_setup_timeout">> => maps:get(assoc_setup_timeout, Cfg, + ?ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT), + <<"heartbeat_req_timeout">> => maps:get(heartbeat_req_timeout, Cfg, + ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT)}. -spec config_gtpu_kpi() -> map(). -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42486?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I58a472a3bbbbad029a2f0246b084428ab3b1905c Gerrit-Change-Number: 42486 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[M] Change in ...osmo-s1gw[master]: pfcp_peer: implement periodic PFCP heartbeat
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42487?usp=email ) Change subject: pfcp_peer: implement periodic PFCP heartbeat ...................................................................... pfcp_peer: implement periodic PFCP heartbeat Add a heartbeat_interval parameter to the pfcp_peer config section. When non-zero, pfcp_peer sends a periodic Heartbeat Request to the UPF at the configured interval using a named gen_statem timeout (hb_timer). The timer is started on entry to the connected state and cancelled on re-entry to the connecting state. Default is 0 (disabled). Change-Id: I306324f8eca325202a3fa23125854db9d5eaab38 --- M config/sys.config M contrib/openapi.yaml M doc/manuals/chapters/configuration.adoc M doc/manuals/chapters/rest.adoc M include/osmo_s1gw.hrl M priv/openapi.json M src/osmo_s1gw_sup.erl M src/pfcp_peer.erl M src/rest_server.erl 9 files changed, 46 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/87/42487/1 diff --git a/config/sys.config b/config/sys.config index 5bebbe6..ac4a428 100644 --- a/config/sys.config +++ b/config/sys.config @@ -35,7 +35,9 @@ %% optional: PFCP Association Setup timeout in milliseconds (default: 2000) %% assoc_setup_timeout => 2000, %% optional: PFCP Heartbeat Request timeout in milliseconds (default: 2000) - %% heartbeat_req_timeout => 2000 + %% heartbeat_req_timeout => 2000, + %% optional: periodic PFCP heartbeat interval in milliseconds (default: 0, disabled) + %% heartbeat_interval => 0 }} %% Optional PFCP Network Instance IEs (omitted if not configured) %% {pfcp_net_inst_core, "core-side"}, %% PFCP Network Instance IE value (to core) diff --git a/contrib/openapi.yaml b/contrib/openapi.yaml index 8ca18aa..c9d668a 100644 --- a/contrib/openapi.yaml +++ b/contrib/openapi.yaml @@ -535,6 +535,9 @@ heartbeat_req_timeout: type: integer description: PFCP Heartbeat Request response timeout in milliseconds + heartbeat_interval: + type: integer + description: Periodic PFCP heartbeat interval in milliseconds (0 = disabled) GtpuKpiCfg: type: object diff --git a/doc/manuals/chapters/configuration.adoc b/doc/manuals/chapters/configuration.adoc index a361730..a8ea114 100644 --- a/doc/manuals/chapters/configuration.adoc +++ b/doc/manuals/chapters/configuration.adoc @@ -138,7 +138,8 @@ laddr => "127.0.1.1", %% local address for PFCP (UDP) raddr => "127.0.1.2" %% remote address of the UPF %% assoc_setup_timeout => 2000, %% optional, milliseconds - %% heartbeat_req_timeout => 2000 %% optional, milliseconds + %% heartbeat_req_timeout => 2000, %% optional, milliseconds + %% heartbeat_interval => 0 %% optional, milliseconds (0 = disabled) }}, %% Optional Network Instance IEs: @@ -161,6 +162,11 @@ How long (in milliseconds) to wait for a PFCP Heartbeat Response before declaring the heartbeat timed out. Default: `2000`. +`heartbeat_interval`:: + Interval (in milliseconds) between periodic PFCP Heartbeat Requests sent + by OsmoS1GW while associated with the UPF. Set to `0` to disable periodic + heartbeats entirely. Default: `0`. + NOTE: The legacy flat keys `pfcp_loc_addr` and `pfcp_rem_addr` are still accepted for backwards compatibility. The `pfcp_peer` map takes priority if both are present. diff --git a/doc/manuals/chapters/rest.adoc b/doc/manuals/chapters/rest.adoc index c3f53af..2a5dcbf 100644 --- a/doc/manuals/chapters/rest.adoc +++ b/doc/manuals/chapters/rest.adoc @@ -80,7 +80,8 @@ "laddr": "127.0.1.1", "raddr": "127.0.1.2", "assoc_setup_timeout": 2000, - "heartbeat_req_timeout": 2000 + "heartbeat_req_timeout": 2000, + "heartbeat_interval": 0 }, "gtpu_kpi": { "enable": false, @@ -111,6 +112,7 @@ `raddr`::: Remote UPF (PFCP peer) address. `assoc_setup_timeout`::: PFCP Association Setup response timeout in milliseconds. `heartbeat_req_timeout`::: PFCP Heartbeat Request response timeout in milliseconds. + `heartbeat_interval`::: Periodic PFCP heartbeat interval in milliseconds (0 = disabled). `gtpu_kpi`:: `enable`::: Whether GTP-U KPI reporting via nftables counters is active. diff --git a/include/osmo_s1gw.hrl b/include/osmo_s1gw.hrl index 692a6ff..95dabfc 100644 --- a/include/osmo_s1gw.hrl +++ b/include/osmo_s1gw.hrl @@ -43,6 +43,7 @@ -define(ENV_DEFAULT_PFCP_REM_ADDR, "127.0.1.2"). -define(ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT, 2000). -define(ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT, 2000). +-define(ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL, 0). %% disabled -define(ENV_DEFAULT_GTPU_KPI_ENABLE, false). -define(ENV_DEFAULT_GTPU_KPI_TABLE_NAME, "osmo-s1gw"). -define(ENV_DEFAULT_GTPU_KPI_INTERVAL, 3000). diff --git a/priv/openapi.json b/priv/openapi.json index 3153505..bf5aaf2 100644 --- a/priv/openapi.json +++ b/priv/openapi.json @@ -771,6 +771,10 @@ "heartbeat_req_timeout": { "type": "integer", "description": "PFCP Heartbeat Request response timeout in milliseconds" + }, + "heartbeat_interval": { + "type": "integer", + "description": "Periodic PFCP heartbeat interval in milliseconds (0 = disabled)" } } }, diff --git a/src/osmo_s1gw_sup.erl b/src/osmo_s1gw_sup.erl index 9809fff..832d30f 100644 --- a/src/osmo_s1gw_sup.erl +++ b/src/osmo_s1gw_sup.erl @@ -163,7 +163,9 @@ assoc_setup_timeout => maps:get(assoc_setup_timeout, Cfg, ?ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT), heartbeat_req_timeout => maps:get(heartbeat_req_timeout, Cfg, - ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT)}. + ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT), + heartbeat_interval => maps:get(heartbeat_interval, Cfg, + ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL)}. -spec gtpu_kpi_cfg() -> gtpu_kpi:cfg(). diff --git a/src/pfcp_peer.erl b/src/pfcp_peer.erl index a6f4b03..2002a19 100644 --- a/src/pfcp_peer.erl +++ b/src/pfcp_peer.erl @@ -77,7 +77,8 @@ -type cfg() :: #{laddr := string() | inet:ip_address(), raddr := string() | inet:ip_address(), assoc_setup_timeout => pos_integer(), - heartbeat_req_timeout => pos_integer()}. + heartbeat_req_timeout => pos_integer(), + heartbeat_interval => non_neg_integer()}. -type peer_info() :: #{state := atom(), laddr := inet:ip_address(), @@ -214,7 +215,8 @@ %% Tx PFCP Association Setup {ok, S1} = send_assoc_setup(S0), TVal = maps:get(assoc_setup_timeout, Cfg, ?ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT), - {keep_state, S1, [{state_timeout, TVal, assoc_setup_timeout}]}; + {keep_state, S1, [{{timeout, hb_timer}, cancel}, + {state_timeout, TVal, assoc_setup_timeout}]}; %% Handle Association Setup timeout connecting(state_timeout, assoc_setup_timeout, S) -> @@ -269,10 +271,23 @@ %% CONNECTED state -connected(enter, OldState, S) -> +connected(enter, OldState, + #peer_state{cfg = Cfg} = S) -> ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), s1gw_metrics:gauge_set(?S1GW_GAUGE_PFCP_ASSOCIATED, 1), - {keep_state, S}; + case maps:get(heartbeat_interval, Cfg, ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL) of + 0 -> {keep_state, S}; %% periodic heartbeat is disabled + Interval -> + ?LOG_INFO("Starting periodic PFCP heartbeat (interval=~p ms)", [Interval]), + {keep_state, S, [{{timeout, hb_timer}, Interval, heartbeat}]} + end; + +%% Periodic heartbeat timer +connected({timeout, hb_timer}, heartbeat, + #peer_state{cfg = Cfg} = S0) -> + {_, S1} = send_heartbeat_request(undefined, S0), + Interval = maps:get(heartbeat_interval, Cfg, ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL), + {keep_state, S1, [{{timeout, hb_timer}, Interval, heartbeat}]}; connected({call, From}, {session_establish_req, SEID, PDRs, FARs}, diff --git a/src/rest_server.erl b/src/rest_server.erl index 7960ffa..bff37fc 100644 --- a/src/rest_server.erl +++ b/src/rest_server.erl @@ -285,7 +285,9 @@ <<"assoc_setup_timeout">> => maps:get(assoc_setup_timeout, Cfg, ?ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT), <<"heartbeat_req_timeout">> => maps:get(heartbeat_req_timeout, Cfg, - ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT)}. + ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT), + <<"heartbeat_interval">> => maps:get(heartbeat_interval, Cfg, + ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL)}. -spec config_gtpu_kpi() -> map(). -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42487?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I306324f8eca325202a3fa23125854db9d5eaab38 Gerrit-Change-Number: 42487 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[XS] Change in ...osmo-s1gw[master]: pfcp_peer: tune Heartbeat Request/Response logging
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42488?usp=email ) Change subject: pfcp_peer: tune Heartbeat Request/Response logging ...................................................................... pfcp_peer: tune Heartbeat Request/Response logging Change-Id: I6435cdf64fd86fa5358d57ea4d56dcad8eb9e69e --- M src/pfcp_peer.erl 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/88/42488/1 diff --git a/src/pfcp_peer.erl b/src/pfcp_peer.erl index 2002a19..9dd25ea 100644 --- a/src/pfcp_peer.erl +++ b/src/pfcp_peer.erl @@ -596,7 +596,7 @@ seq_nr = SeqNr, loc_rts = LRTS} = S0) -> ReqIEs = #{recovery_time_stamp => #recovery_time_stamp{time = LRTS}}, - ?LOG_INFO("Tx Heartbeat Request (SeqNr=~p): ~p", [SeqNr, ReqIEs]), + ?LOG_DEBUG("Tx Heartbeat Request (SeqNr=~p): ~p", [SeqNr, ReqIEs]), case send_pdu({heartbeat_request, ReqIEs}, S0) of {ok, S1} -> s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_HEARTBEAT_REQ_TX), @@ -618,7 +618,7 @@ ie = RspIEs}, {_FromIp, _FromPort}, #peer_state{heartbeat = HB} = S) -> - ?LOG_INFO("Rx Heartbeat Response (SeqNr=~p): ~p", [SeqNr, RspIEs]), + ?LOG_DEBUG("Rx Heartbeat Response (SeqNr=~p): ~p", [SeqNr, RspIEs]), s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_HEARTBEAT_RESP_RX), case HB of #heartbeat_state{from = From, @@ -643,7 +643,7 @@ ie = ReqIEs}, {FromIp, FromPort}, #peer_state{loc_rts = LRTS} = S) -> - ?LOG_INFO("Rx Heartbeat Request from ~p:~p: ~p", [FromIp, FromPort, ReqIEs]), + ?LOG_DEBUG("Rx Heartbeat Request from ~p:~p: ~p", [FromIp, FromPort, ReqIEs]), s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_HEARTBEAT_REQ_RX), s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_HEARTBEAT_RESP_TX), RspIEs = #{recovery_time_stamp => #recovery_time_stamp{time = LRTS}}, -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42488?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I6435cdf64fd86fa5358d57ea4d56dcad8eb9e69e Gerrit-Change-Number: 42488 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[S] Change in ...osmo-s1gw[master]: pfcp_peer: detect UPF restart via RTS mismatch in Heartbeat Response
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42490?usp=email ) Change subject: pfcp_peer: detect UPF restart via RTS mismatch in Heartbeat Response ...................................................................... pfcp_peer: detect UPF restart via RTS mismatch in Heartbeat Response Check the Recovery Timestamp (RTS) in each Heartbeat Response against the value stored during Association Setup (`rem_rts`). A mismatch means the UPF has restarted; log a warning, increment the new `pfcp.peer_restart counter`, and reset the PFCP association so it is re-established with the restarted peer. The `is_integer(ExpRTS)` guard prevents a spurious reset when a stale Heartbeat Response arrives in the connecting state (where `rem_rts` is still undefined). Change-Id: I00a8384db1ea9c38d0ad9ff90b3d45ad86c3a020 --- M doc/manuals/chapters/metrics.adoc M include/s1gw_metrics.hrl M src/pfcp_peer.erl M src/s1gw_metrics.erl 4 files changed, 32 insertions(+), 16 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/90/42490/1 diff --git a/doc/manuals/chapters/metrics.adoc b/doc/manuals/chapters/metrics.adoc index 4ea8a53..42a3d54 100644 --- a/doc/manuals/chapters/metrics.adoc +++ b/doc/manuals/chapters/metrics.adoc @@ -49,6 +49,7 @@ | `pfcp.assoc_setup_resp.rx_ack` | PFCP Association Setup Responses with success cause | `pfcp.assoc_setup_resp.rx_nack` | PFCP Association Setup Responses with failure cause | `pfcp.unexpected_pdu` | Unexpected or unrecognised PFCP PDUs received +| `pfcp.peer_restart` | UPF peer restarts detected via Recovery Timestamp mismatch in Heartbeat Responses |=== [[metrics_s1ap_counters]] diff --git a/include/s1gw_metrics.hrl b/include/s1gw_metrics.hrl index 06a9719..9f3450d 100644 --- a/include/s1gw_metrics.hrl +++ b/include/s1gw_metrics.hrl @@ -9,6 +9,7 @@ -define(S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_ACK, [ctr, pfcp, assoc_setup_resp, rx_ack]). -define(S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_NACK, [ctr, pfcp, assoc_setup_resp, rx_nack]). -define(S1GW_CTR_PFCP_UNEXPECTED_PDU, [ctr, pfcp, unexpected_pdu]). +-define(S1GW_CTR_PFCP_PEER_RESTART, [ctr, pfcp, peer_restart]). -define(S1GW_CTR_S1AP_ENB_ALL_RX, [ctr, s1ap, enb, all, rx]). -define(S1GW_CTR_S1AP_ENB_ALL_RX_UNKNOWN_ENB, [ctr, s1ap, enb, all, rx_unknown_enb]). -define(S1GW_CTR_S1AP_PROXY_EXCEPTION, [ctr, s1ap, proxy, exception]). diff --git a/src/pfcp_peer.erl b/src/pfcp_peer.erl index 34c570c..145eca0 100644 --- a/src/pfcp_peer.erl +++ b/src/pfcp_peer.erl @@ -319,8 +319,13 @@ {_, S1} = recv_heartbeat_request(PDU, {FromIp, FromPort}, S0), {keep_state, S1}; #pfcp{type = heartbeat_response} -> - {_, S1} = recv_heartbeat_response(PDU, {FromIp, FromPort}, S0), - {keep_state, S1}; + case recv_heartbeat_response(PDU, {FromIp, FromPort}, S0) of + {restart, S1} -> + %% RTS mismatch detected, reset the association + {next_state, connecting, S1#peer_state{rem_rts = undefined}}; + {_, S1} -> + {keep_state, S1} + end; #pfcp{seid = SEID} when is_integer(SEID) -> route_pdu(PDU, S0), {keep_state, S0}; @@ -384,12 +389,7 @@ tref = TRef} -> ?LOG_NOTICE("Heartbeat Request (SeqNr=~p) timeout", [SeqNr]), s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_HEARTBEAT_REQ_TIMEOUT), - if - From =/= undefined -> - gen_statem:reply(From, {error, timeout}); - true -> - ok - end, + maybe_reply(From, {error, timeout}), S1 = S#peer_state{heartbeat = undefined}, MaxMiss = maps:get(heartbeat_miss_count, Cfg, ?ENV_DEFAULT_PFCP_HEARTBEAT_MISS_COUNT), @@ -537,6 +537,11 @@ end. +-spec maybe_reply(gen_statem:from() | undefined, term()) -> ok. +maybe_reply(undefined, _Reply) -> ok; +maybe_reply(From, Reply) -> gen_statem:reply(From, Reply). + + -spec get_node_id(peer_state()) -> binary(). get_node_id(#peer_state{loc_addr = LocAddr}) -> list_to_binary(tuple_to_list(LocAddr)). @@ -635,7 +640,8 @@ seq_no = SeqNr, ie = RspIEs}, {_FromIp, _FromPort}, - #peer_state{heartbeat = HB} = S) -> + #peer_state{heartbeat = HB, + rem_rts = ExpRTS} = S) -> ?LOG_DEBUG("Rx Heartbeat Response (SeqNr=~p): ~p", [SeqNr, RspIEs]), s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_HEARTBEAT_RESP_RX), case HB of @@ -643,13 +649,20 @@ seq_nr = SeqNr, tref = TRef} -> erlang:cancel_timer(TRef), - if - From =/= undefined -> - gen_statem:reply(From, ok); - true -> - ok - end, - {ok, S#peer_state{heartbeat = undefined, hb_missed = 0}}; + S1 = S#peer_state{heartbeat = undefined, hb_missed = 0}, + case RspIEs of + #{recovery_time_stamp := #recovery_time_stamp{time = RecvRTS}} + when is_integer(ExpRTS), RecvRTS =/= ExpRTS -> + ?LOG_WARNING("UPF restart detected via Heartbeat Response " + "(old RTS=~p =/= new RTS=~p), resetting association", + [ExpRTS, RecvRTS]), + s1gw_metrics:ctr_inc(?S1GW_CTR_PFCP_PEER_RESTART), + maybe_reply(From, {error, peer_restarted}), + {restart, S1}; + _ -> + maybe_reply(From, ok), + {ok, S1} + end; _ -> ?LOG_NOTICE("Heartbeat Response (SeqNr=~p) was not expected", [SeqNr]), {{error, unexpected}, S} diff --git a/src/s1gw_metrics.erl b/src/s1gw_metrics.erl index 551b821..306b418 100644 --- a/src/s1gw_metrics.erl +++ b/src/s1gw_metrics.erl @@ -63,6 +63,7 @@ ?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_ACK, ?S1GW_CTR_PFCP_ASSOC_SETUP_RESP_RX_NACK, ?S1GW_CTR_PFCP_UNEXPECTED_PDU, + ?S1GW_CTR_PFCP_PEER_RESTART, ?S1GW_CTR_S1AP_ENB_ALL_RX, ?S1GW_CTR_S1AP_ENB_ALL_RX_UNKNOWN_ENB, ?S1GW_CTR_S1AP_PROXY_EXCEPTION, %% exception(s) occurred -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42490?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I00a8384db1ea9c38d0ad9ff90b3d45ad86c3a020 Gerrit-Change-Number: 42490 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
[M] Change in ...osmo-s1gw[master]: pfcp_peer: add configurable heartbeat miss count + association reset
by fixeria 24 Mar '26

24 Mar '26
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42489?usp=email ) Change subject: pfcp_peer: add configurable heartbeat miss count + association reset ...................................................................... pfcp_peer: add configurable heartbeat miss count + association reset Introduce heartbeat_miss_count (default: 3) that tracks consecutive unanswered PFCP Heartbeat Requests and resets the association when the threshold is reached. The counter applies to both periodic heartbeats and those triggered via the REST API, and resets to zero on any successful Heartbeat Response. Change-Id: I8cb0fb23468aba4dead9865a90d893c78c6ae074 --- M config/sys.config M contrib/openapi.yaml M doc/manuals/chapters/configuration.adoc M doc/manuals/chapters/rest.adoc M include/osmo_s1gw.hrl M priv/openapi.json M src/osmo_s1gw_sup.erl M src/pfcp_peer.erl M src/rest_server.erl 9 files changed, 53 insertions(+), 13 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/89/42489/1 diff --git a/config/sys.config b/config/sys.config index ac4a428..aa784b4 100644 --- a/config/sys.config +++ b/config/sys.config @@ -37,7 +37,9 @@ %% optional: PFCP Heartbeat Request timeout in milliseconds (default: 2000) %% heartbeat_req_timeout => 2000, %% optional: periodic PFCP heartbeat interval in milliseconds (default: 0, disabled) - %% heartbeat_interval => 0 + %% heartbeat_interval => 0, + %% optional: missed heartbeat responses before resetting the association (default: 3) + %% heartbeat_miss_count => 3 }} %% Optional PFCP Network Instance IEs (omitted if not configured) %% {pfcp_net_inst_core, "core-side"}, %% PFCP Network Instance IE value (to core) diff --git a/contrib/openapi.yaml b/contrib/openapi.yaml index c9d668a..523c143 100644 --- a/contrib/openapi.yaml +++ b/contrib/openapi.yaml @@ -538,6 +538,9 @@ heartbeat_interval: type: integer description: Periodic PFCP heartbeat interval in milliseconds (0 = disabled) + heartbeat_miss_count: + type: integer + description: Missed heartbeat responses before resetting the PFCP association GtpuKpiCfg: type: object diff --git a/doc/manuals/chapters/configuration.adoc b/doc/manuals/chapters/configuration.adoc index a8ea114..9c31985 100644 --- a/doc/manuals/chapters/configuration.adoc +++ b/doc/manuals/chapters/configuration.adoc @@ -167,6 +167,12 @@ by OsmoS1GW while associated with the UPF. Set to `0` to disable periodic heartbeats entirely. Default: `0`. +`heartbeat_miss_count`:: + Number of consecutive unanswered Heartbeat Requests after which OsmoS1GW + considers the UPF unreachable and resets the PFCP association (transitions + back to the connecting state). Applies to both periodic heartbeats and + those triggered via the REST API. Default: `3`. + NOTE: The legacy flat keys `pfcp_loc_addr` and `pfcp_rem_addr` are still accepted for backwards compatibility. The `pfcp_peer` map takes priority if both are present. diff --git a/doc/manuals/chapters/rest.adoc b/doc/manuals/chapters/rest.adoc index 2a5dcbf..a20cf28 100644 --- a/doc/manuals/chapters/rest.adoc +++ b/doc/manuals/chapters/rest.adoc @@ -81,7 +81,8 @@ "raddr": "127.0.1.2", "assoc_setup_timeout": 2000, "heartbeat_req_timeout": 2000, - "heartbeat_interval": 0 + "heartbeat_interval": 0, + "heartbeat_miss_count": 3 }, "gtpu_kpi": { "enable": false, @@ -113,6 +114,7 @@ `assoc_setup_timeout`::: PFCP Association Setup response timeout in milliseconds. `heartbeat_req_timeout`::: PFCP Heartbeat Request response timeout in milliseconds. `heartbeat_interval`::: Periodic PFCP heartbeat interval in milliseconds (0 = disabled). + `heartbeat_miss_count`::: Consecutive unanswered heartbeats before resetting the association. `gtpu_kpi`:: `enable`::: Whether GTP-U KPI reporting via nftables counters is active. diff --git a/include/osmo_s1gw.hrl b/include/osmo_s1gw.hrl index 95dabfc..3b3f290 100644 --- a/include/osmo_s1gw.hrl +++ b/include/osmo_s1gw.hrl @@ -44,6 +44,7 @@ -define(ENV_DEFAULT_PFCP_ASSOC_SETUP_TIMEOUT, 2000). -define(ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT, 2000). -define(ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL, 0). %% disabled +-define(ENV_DEFAULT_PFCP_HEARTBEAT_MISS_COUNT, 3). -define(ENV_DEFAULT_GTPU_KPI_ENABLE, false). -define(ENV_DEFAULT_GTPU_KPI_TABLE_NAME, "osmo-s1gw"). -define(ENV_DEFAULT_GTPU_KPI_INTERVAL, 3000). diff --git a/priv/openapi.json b/priv/openapi.json index bf5aaf2..67a83db 100644 --- a/priv/openapi.json +++ b/priv/openapi.json @@ -775,6 +775,10 @@ "heartbeat_interval": { "type": "integer", "description": "Periodic PFCP heartbeat interval in milliseconds (0 = disabled)" + }, + "heartbeat_miss_count": { + "type": "integer", + "description": "Missed heartbeat responses before resetting the PFCP association" } } }, diff --git a/src/osmo_s1gw_sup.erl b/src/osmo_s1gw_sup.erl index 832d30f..fc1c054 100644 --- a/src/osmo_s1gw_sup.erl +++ b/src/osmo_s1gw_sup.erl @@ -165,7 +165,9 @@ heartbeat_req_timeout => maps:get(heartbeat_req_timeout, Cfg, ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT), heartbeat_interval => maps:get(heartbeat_interval, Cfg, - ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL)}. + ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL), + heartbeat_miss_count => maps:get(heartbeat_miss_count, Cfg, + ?ENV_DEFAULT_PFCP_HEARTBEAT_MISS_COUNT)}. -spec gtpu_kpi_cfg() -> gtpu_kpi:cfg(). diff --git a/src/pfcp_peer.erl b/src/pfcp_peer.erl index 9dd25ea..34c570c 100644 --- a/src/pfcp_peer.erl +++ b/src/pfcp_peer.erl @@ -78,7 +78,8 @@ raddr := string() | inet:ip_address(), assoc_setup_timeout => pos_integer(), heartbeat_req_timeout => pos_integer(), - heartbeat_interval => non_neg_integer()}. + heartbeat_interval => non_neg_integer(), + heartbeat_miss_count => pos_integer()}. -type peer_info() :: #{state := atom(), laddr := inet:ip_address(), @@ -110,7 +111,8 @@ rem_rts :: undefined | pos_integer(), seq_nr :: pfcp_seq_nr(), registry :: dict:dict(), - heartbeat :: undefined | #heartbeat_state{} + heartbeat :: undefined | #heartbeat_state{}, + hb_missed :: non_neg_integer() }). -type peer_state() :: #peer_state{}. @@ -200,7 +202,8 @@ rem_addr = RemAddr, seq_nr = 0, loc_rts = get_recovery_timestamp(), - registry = dict:new()}}. + registry = dict:new(), + hb_missed = 0}}. callback_mode() -> @@ -276,10 +279,10 @@ ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), s1gw_metrics:gauge_set(?S1GW_GAUGE_PFCP_ASSOCIATED, 1), case maps:get(heartbeat_interval, Cfg, ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL) of - 0 -> {keep_state, S}; %% periodic heartbeat is disabled + 0 -> {keep_state, S#peer_state{hb_missed = 0}}; %% periodic heartbeat is disabled Interval -> ?LOG_INFO("Starting periodic PFCP heartbeat (interval=~p ms)", [Interval]), - {keep_state, S, [{{timeout, hb_timer}, Interval, heartbeat}]} + {keep_state, S#peer_state{hb_missed = 0}, [{{timeout, hb_timer}, Interval, heartbeat}]} end; %% Periodic heartbeat timer @@ -370,9 +373,11 @@ end; %% Heartbeat Req (timeout) -handle_event(_State, +handle_event(State, info, {timeout, TRef, heartbeat_request_watchdog}, - #peer_state{heartbeat = HB} = S) -> + #peer_state{cfg = Cfg, + heartbeat = HB, + hb_missed = Missed} = S) -> case HB of #heartbeat_state{from = From, seq_nr = SeqNr, @@ -385,7 +390,20 @@ true -> ok end, - {keep_state, S#peer_state{heartbeat = undefined}}; + S1 = S#peer_state{heartbeat = undefined}, + MaxMiss = maps:get(heartbeat_miss_count, Cfg, + ?ENV_DEFAULT_PFCP_HEARTBEAT_MISS_COUNT), + if + State =:= connected, Missed + 1 >= MaxMiss -> + ?LOG_ERROR("UPF not responding to heartbeats (~p/~p), " + "resetting association", [Missed + 1, MaxMiss]), + {next_state, connecting, + S1#peer_state{rem_rts = undefined, hb_missed = 0}}; + State =:= connected -> + {keep_state, S1#peer_state{hb_missed = Missed + 1}}; + true -> + {keep_state, S1} + end; _ -> {keep_state, S} end; @@ -631,7 +649,7 @@ true -> ok end, - {ok, S#peer_state{heartbeat = undefined}}; + {ok, S#peer_state{heartbeat = undefined, hb_missed = 0}}; _ -> ?LOG_NOTICE("Heartbeat Response (SeqNr=~p) was not expected", [SeqNr]), {{error, unexpected}, S} diff --git a/src/rest_server.erl b/src/rest_server.erl index bff37fc..4b051e0 100644 --- a/src/rest_server.erl +++ b/src/rest_server.erl @@ -287,7 +287,9 @@ <<"heartbeat_req_timeout">> => maps:get(heartbeat_req_timeout, Cfg, ?ENV_DEFAULT_PFCP_HEARTBEAT_REQ_TIMEOUT), <<"heartbeat_interval">> => maps:get(heartbeat_interval, Cfg, - ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL)}. + ?ENV_DEFAULT_PFCP_HEARTBEAT_INTERVAL), + <<"heartbeat_miss_count">> => maps:get(heartbeat_miss_count, Cfg, + ?ENV_DEFAULT_PFCP_HEARTBEAT_MISS_COUNT)}. -spec config_gtpu_kpi() -> map(). -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42489?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: erlang/osmo-s1gw Gerrit-Branch: master Gerrit-Change-Id: I8cb0fb23468aba4dead9865a90d893c78c6ae074 Gerrit-Change-Number: 42489 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • ...
  • 194
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.