fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42427?usp=email )
Change subject: enb_proxy: signal mme_info() to the enb_registry ......................................................................
enb_proxy: signal mme_info() to the enb_registry
When an MME is selected from the pool, pass the mme_registry:mme_info() to the enb_registry via notify_mme_connecting/2 (replacing /1). This makes all MME configuration details (name, address, port, TAC list) available to consumers such as the REST server, without having to look them up separately from the mme_registry.
Change-Id: I22e705b8196c9dcf436ed3c4d91c5c5a912e7282 Related: SYS#7052 --- M src/enb_proxy.erl M src/enb_registry.erl M src/rest_server.erl 3 files changed, 29 insertions(+), 20 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/27/42427/1
diff --git a/src/enb_proxy.erl b/src/enb_proxy.erl index 1d479d6..f2c0cbf 100644 --- a/src/enb_proxy.erl +++ b/src/enb_proxy.erl @@ -58,12 +58,10 @@ -include("S1AP-Constants.hrl").
-%% XXX: replace/merge with mme_registry:mme_info()? -type conn_info() :: #{handler := pid(), - mme_addr := inet:ip_address(), - mme_port := inet:port_number(), enb_aid := gen_sctp:assoc_id(), mme_aid => gen_sctp:assoc_id() + %% TODO: add mme_saddr / mme_sport }.
-record(state, {enb_aid :: gen_sctp:assoc_id(), @@ -206,7 +204,7 @@ rport => maps:get(rport, MmeInfo), sockopts => MmeSockOpts}, {ok, Sock} = sctp_client:connect(MmeConnCfg), - enb_registry:notify_mme_connecting(S#state.enb_handle), + enb_registry:notify_mme_connecting(S#state.enb_handle, MmeInfo), {next_state, ?FUNCTION_NAME, %% loop transition to enable state_timeout S#state{sock = Sock, mme_aid = undefined, @@ -469,10 +467,8 @@
-spec conn_info(state()) -> conn_info(). -conn_info(#state{mme_conn_cfg = MmeConnCfg} = S) -> +conn_info(S) -> Info = #{handler => S#state.handler, - mme_addr => maps:get(raddr, MmeConnCfg), - mme_port => maps:get(rport, MmeConnCfg), enb_aid => S#state.enb_aid, mme_aid => S#state.mme_aid}, maps:filter(fun(_K, V) -> V =/= undefined end, Info). diff --git a/src/enb_registry.erl b/src/enb_registry.erl index 61f0c59..0ad20ba 100644 --- a/src/enb_registry.erl +++ b/src/enb_registry.erl @@ -45,7 +45,7 @@ enb_unregister/1, notify_enb_connected/2, notify_genb_id/2, - notify_mme_connecting/1, + notify_mme_connecting/2, notify_mme_wait_rsp/1, notify_mme_connected/2, fetch_enb_info/1, @@ -66,6 +66,7 @@ -type enb_prop() :: {state, atom()} | {enb_conn_info, sctp_server:conn_info()} | {mme_conn_info, undefined | enb_proxy:conn_info()} + | {mme_info, mme_registry:mme_info()} | {genb_id, s1ap_utils:genb_id()}. -type enb_proplist() :: [enb_prop()].
@@ -84,7 +85,8 @@ genb_id => s1ap_utils:genb_id(), %% Global-eNB-ID genb_id_str => string(), %% Global-eNB-ID string enb_conn_info => sctp_server:conn_info(), %% eNB -> S1GW connection info - mme_conn_info => enb_proxy:conn_info() %% S1GW -> MME connection info + mme_conn_info => enb_proxy:conn_info(), %% S1GW -> MME connection info + mme_info => mme_registry:mme_info() %% selected MME configuration }.
-record(state, {enbs :: #{enb_handle() => enb_info()}, @@ -127,10 +129,10 @@ enb_update(Handle, [{genb_id, GENBId}]).
-%% MME connection attempt in progress; clears any stale mme_conn_info --spec notify_mme_connecting(enb_handle()) -> ok. -notify_mme_connecting(Handle) -> - enb_update(Handle, [{state, connecting}, {mme_conn_info, undefined}]). +%% 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}]).
%% MME SCTP link established; S1 SETUP REQUEST forwarded, awaiting response @@ -342,6 +344,9 @@ enb_update_prop({mme_conn_info, ConnInfo}, EnbInfo) -> EnbInfo#{mme_conn_info => ConnInfo};
+enb_update_prop({mme_info, MmeInfo}, EnbInfo) -> + EnbInfo#{mme_info => MmeInfo}; + enb_update_prop({genb_id, GENBId}, EnbInfo) -> GlobalENBId = s1ap_utils:genb_id_str(GENBId), enb_metrics_register(GlobalENBId), @@ -374,8 +379,8 @@ enb_filter_by_sub_field({enb_conn_info, port, Port}, Item) end;
enb_filter({mme_addr_port, {Addr, Port}}) -> - fun(_, Item) -> enb_filter_by_sub_field({mme_conn_info, mme_addr, Addr}, Item) andalso - enb_filter_by_sub_field({mme_conn_info, mme_port, Port}, Item) end; + fun(_, Item) -> enb_filter_by_sub_field({mme_info, raddr, Addr}, Item) andalso + enb_filter_by_sub_field({mme_info, rport, Port}, Item) end;
enb_filter(Filter) -> ?LOG_ERROR("Unknown eNB filter: ~p", [Filter]), diff --git a/src/rest_server.erl b/src/rest_server.erl index 79090e8..e515445 100644 --- a/src/rest_server.erl +++ b/src/rest_server.erl @@ -328,7 +328,8 @@ M1 = enb_item_add_enb_info(M0, EnbInfo), M2 = enb_item_add_enb_conn_info(M1, EnbInfo), M3 = enb_item_add_mme_conn_info(M2, EnbInfo), - rsp_map(M3). + M4 = enb_item_add_mme_info(M3, EnbInfo), + rsp_map(M4).
-spec enb_item_add_enb_info(map(), enb_registry:enb_info()) -> map(). @@ -353,16 +354,23 @@ enb_item_add_mme_conn_info(M0, #{mme_conn_info := ConnInfo}) -> Pid = maps:get(handler, ConnInfo), ERABs = s1ap_proxy:fetch_erab_list(Pid), - M0#{mme_daddr => maps:get(mme_addr, ConnInfo), %% XXX inet:ntoa - mme_dport => maps:get(mme_port, ConnInfo), - %% TODO: mme_sport - mme_sctp_aid => maps:get(mme_aid, ConnInfo), + %% TODO: mme_sport (source port) is not yet available in conn_info() + M0#{mme_sctp_aid => maps:get(mme_aid, ConnInfo), erab_count => length(ERABs) };
enb_item_add_mme_conn_info(M0, _) -> M0.
+-spec enb_item_add_mme_info(map(), enb_registry:enb_info()) -> map(). +enb_item_add_mme_info(M0, #{mme_info := MmeInfo}) -> + M0#{mme_daddr => inet:ntoa(maps:get(raddr, MmeInfo)), + mme_dport => maps:get(rport, MmeInfo) + }; + +enb_item_add_mme_info(M0, _) -> M0. + + -spec fetch_enb_info(binary()) -> [enb_registry:enb_info()] | error. fetch_enb_info(<< "handle:", Val/bytes >>) -> Handle = binary_to_integer(Val),