fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42445?usp=email )
Change subject: enb_{proxy,registry}: signal MME conn info on SCTP comm_up ......................................................................
enb_{proxy,registry}: signal MME conn info on SCTP comm_up
Previously, mme_aid/mme_saddr/mme_sport were only signalled to the enb_registry once the S1 Setup procedure completed. This meant the REST API could not show MME connection details for eNBs stuck in wait_s1setup_rsp state (e.g. due to a slow or retrying MME).
Add notify_mme_comm_up/2, called at SCTP comm_up, which stores the full conn_info (including mme_aid, mme_saddr, mme_sport) in the registry as soon as the SCTP connection is established.
notify_mme_connected/2 is simplified to notify_mme_connected/1: it now only flips the state to 'connected', since conn_info is already stored.
Change-Id: Iea9ba4fdf961e6cd262edc154884a2eee3d95355 Related: SYS#7066 --- M src/enb_proxy.erl M src/enb_registry.erl 2 files changed, 22 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/45/42445/1
diff --git a/src/enb_proxy.erl b/src/enb_proxy.erl index 17296bd..6a7254e 100644 --- a/src/enb_proxy.erl +++ b/src/enb_proxy.erl @@ -251,12 +251,14 @@ {ok, {MmeLAddr, MmeLPort}} = inet:sockname(Socket), ?LOG_NOTICE("MME ~p: connection (id=~p, ~p:~p) established", [MmeName, Aid, MmeAddr, MmePort]), + NewS = S#state{mme_aid = Aid, + mme_saddr = MmeLAddr, + mme_sport = MmeLPort}, %% send the S1 SETUP REQUEST PDU to the MME - sctp_send_from_enb(S#state.s1setup_req, - S#state{mme_aid = Aid}), - {next_state, wait_s1setup_rsp, S#state{mme_aid = Aid, - mme_saddr = MmeLAddr, - mme_sport = MmeLPort}}; + sctp_send_from_enb(S#state.s1setup_req, NewS), + %% surface MME connection details before S1 Setup completes + enb_registry:notify_mme_comm_up(S#state.enb_handle, conn_info(NewS)), + {next_state, wait_s1setup_rsp, NewS}; _ -> ?LOG_NOTICE("MME ~p: connection establishment failed: ~p", [MmeName, ConnState]), @@ -352,7 +354,7 @@ %% CONNECTED state connected(enter, OldState, S) -> ?LOG_INFO("State change: ~p -> ~p", [OldState, ?FUNCTION_NAME]), - enb_registry:notify_mme_connected(S#state.enb_handle, conn_info(S)), + enb_registry:notify_mme_connected(S#state.enb_handle), {keep_state, S};
%% Handle an eNB -> MME data forwarding request (forward) diff --git a/src/enb_registry.erl b/src/enb_registry.erl index 0ad20ba..2bf6e47 100644 --- a/src/enb_registry.erl +++ b/src/enb_registry.erl @@ -46,8 +46,9 @@ notify_enb_connected/2, notify_genb_id/2, notify_mme_connecting/2, + notify_mme_comm_up/2, notify_mme_wait_rsp/1, - notify_mme_connected/2, + notify_mme_connected/1, fetch_enb_info/1, fetch_enb_list/0, fetch_enb_list/1, @@ -132,7 +133,15 @@ %% MME connection attempt in progress; stores selected MME info, clears any stale mme_conn_info -spec notify_mme_connecting(enb_handle(), mme_registry:mme_info()) -> ok. notify_mme_connecting(Handle, MmeInfo) -> - enb_update(Handle, [{state, connecting}, {mme_info, MmeInfo}, {mme_conn_info, undefined}]). + enb_update(Handle, [{state, connecting}, + {mme_info, MmeInfo}, + {mme_conn_info, undefined}]). + + +%% MME SCTP comm_up; connection details (aid, saddr, sport) are now known +-spec notify_mme_comm_up(enb_handle(), enb_proxy:conn_info()) -> ok. +notify_mme_comm_up(Handle, ConnInfo) -> + enb_update(Handle, [{mme_conn_info, ConnInfo}]).
%% MME SCTP link established; S1 SETUP REQUEST forwarded, awaiting response @@ -142,9 +151,9 @@
%% S1 SETUP complete; eNB is fully operational --spec notify_mme_connected(enb_handle(), enb_proxy:conn_info()) -> ok. -notify_mme_connected(Handle, ConnInfo) -> - enb_update(Handle, [{state, connected}, {mme_conn_info, ConnInfo}]). +-spec notify_mme_connected(enb_handle()) -> ok. +notify_mme_connected(Handle) -> + enb_update(Handle, [{state, connected}]).
-spec fetch_enb_info(enb_handle() | pid()) -> {ok, enb_info()} | error.