fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/42428?usp=email )
Change subject: enb_proxy: obtain sctp_client sockopts from the env directly ......................................................................
enb_proxy: obtain sctp_client sockopts from the env directly
Instead of passing the MmeConnCfg (sctp_client:cfg()) all the way from osmo_s1gw_sup through sctp_server (as priv) into enb_proxy (as state), read the sctp_client configuration in-place via osmo_s1gw:get_env/2 when it is actually needed (connecting/enter).
This works because osmo_s1gw_sup already normalizes and writes back the complete sctp_client config to the application env (set_env/2) before starting the supervision tree.
As a result, mme_conn_cfg is removed from enb_proxy's state record, start_link/2 no longer uses its Priv argument, and server_cfg/1 is simplified to server_cfg/0.
Change-Id: Ic77d3eb3351c8981c87fa4b6febcdeb814b9187b --- M src/enb_proxy.erl M src/osmo_s1gw_sup.erl 2 files changed, 9 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/28/42428/1
diff --git a/src/enb_proxy.erl b/src/enb_proxy.erl index f2c0cbf..c76ac42 100644 --- a/src/enb_proxy.erl +++ b/src/enb_proxy.erl @@ -67,7 +67,6 @@ -record(state, {enb_aid :: gen_sctp:assoc_id(), mme_aid :: undefined | gen_sctp:assoc_id(), enb_conn_info :: sctp_server:conn_info(), - mme_conn_cfg :: sctp_client:cfg(), s1setup_req :: undefined | binary(), tried_mmes :: [mme_registry:mme_name()], enb_tacs :: undefined | [s1ap_utils:tac()], @@ -88,10 +87,10 @@
-spec start_link(ConnInfo, Priv) -> Result when ConnInfo :: sctp_server:conn_info(), - Priv :: sctp_client:cfg(), + Priv :: term(), Result :: gen_statem:start_ret(). -start_link(ConnInfo, Priv) -> - gen_statem:start_link(?MODULE, [ConnInfo, Priv], []). +start_link(ConnInfo, _Priv) -> + gen_statem:start_link(?MODULE, [ConnInfo], []).
-spec send_data(pid(), binary()) -> ok. @@ -113,13 +112,12 @@ %% gen_statem API %% ------------------------------------------------------------------
-init([EnbConnInfo, MmeConnCfg]) -> +init([EnbConnInfo]) -> {ok, EnbHandle} = enb_registry:enb_register(), {ok, Pid} = s1ap_proxy:start_link(self()), {ok, wait_s1setup_req, #state{enb_aid = maps:get(aid, EnbConnInfo), enb_conn_info = EnbConnInfo, - mme_conn_cfg = MmeConnCfg, enb_handle = EnbHandle, tried_mmes = [], handler = Pid}}. @@ -198,7 +196,7 @@ %% Close the old connection, if any close_sock(S), %% Initiate connection establishment with the MME - MmeSockOpts = maps:get(sockopts, S#state.mme_conn_cfg), + MmeSockOpts = maps:get(sockopts, osmo_s1gw:get_env(sctp_client, #{})), MmeConnCfg = #{laddr => maps:get(laddr, MmeInfo), raddr => maps:get(raddr, MmeInfo), rport => maps:get(rport, MmeInfo), @@ -208,7 +206,6 @@ {next_state, ?FUNCTION_NAME, %% loop transition to enable state_timeout S#state{sock = Sock, mme_aid = undefined, - mme_conn_cfg = MmeConnCfg, tried_mmes = [MmeName | TriedMMEs]}, [{state_timeout, 2_000, conn_est_timeout}]}; error -> diff --git a/src/osmo_s1gw_sup.erl b/src/osmo_s1gw_sup.erl index 875e19b..447dfc4 100644 --- a/src/osmo_s1gw_sup.erl +++ b/src/osmo_s1gw_sup.erl @@ -67,7 +67,7 @@ PfcpRemAddr = osmo_s1gw:get_env(pfcp_rem_addr, ?ENV_DEFAULT_PFCP_REM_ADDR),
ClientCfg = client_cfg(), - ServerCfg = server_cfg(ClientCfg), + ServerCfg = server_cfg(),
%% Set a complete 'sctp_client' section with all fields populated. %% This may be used by mme_registry:mme_list_from_sctp_client/0 @@ -144,8 +144,8 @@ sockopts => sctp_common:gen_sockopts(SockOpts)}.
--spec server_cfg(term()) -> sctp_server:cfg(). -server_cfg(Priv) -> +-spec server_cfg() -> sctp_server:cfg(). +server_cfg() -> %% parse old/legacy environment options, if any DefCfg = parse_env_map(#{laddr => s1gw_bind_addr, lport => s1gw_bind_port}), @@ -159,7 +159,7 @@ lport => maps:get(lport, Cfg, ?ENV_DEFAULT_S1GW_BIND_PORT), sockopts => sctp_common:gen_sockopts(SockOpts), handler => enb_proxy, - priv => Priv}. + priv => undefined}.
-spec gtpu_kpi_cfg() -> gtpu_kpi:cfg().