pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35893?usp=email )
Change subject: AAA-Server: s6b: Fetch UE FSM Pid without asking SWm module
......................................................................
AAA-Server: s6b: Fetch UE FSM Pid without asking SWm module
Instead, keep the implementation in the UE FSM module itself, and take
advantage of the fact that the PID is registered and can be derived from
the IMSI.
Change-Id: I0e62f3715da61d2d8cfabaf89557aeb1cd95f89a
---
M src/aaa_diameter_s6b_cb.erl
M src/aaa_diameter_swm.erl
M src/aaa_ue_fsm.erl
3 files changed, 34 insertions(+), 26 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-epdg refs/changes/93/35893/1
diff --git a/src/aaa_diameter_s6b_cb.erl b/src/aaa_diameter_s6b_cb.erl
index 339f735..7e3915d 100644
--- a/src/aaa_diameter_s6b_cb.erl
+++ b/src/aaa_diameter_s6b_cb.erl
@@ -59,15 +59,15 @@
'Auth-Request-Type' = AuthReqType,
'User-Name' = [UserName],
'Service-Selection' = [Apn]} = Req,
- Result = aaa_diameter_swm:get_ue_fsm_by_imsi(UserName),
- case Result of
- {ok, Pid} ->
- ok = aaa_ue_fsm:ev_rx_s6b_aar(Pid, Apn),
+ PidRes = aaa_ue_fsm:get_pid_by_imsi(UserName),
+ case PidRes of
+ PidRes when is_pid(PidRes) ->
+ ok = aaa_ue_fsm:ev_rx_s6b_aar(PidRes, Apn),
lager:debug("Waiting for S6b AAA~n", []),
receive
{aaa, ResultCode} -> lager:debug("Rx AAA with ResultCode=~p~n",
[ResultCode])
end;
- _ -> lager:error("Error looking up FSM for IMSI~n", [UserName]),
+ undefined -> lager:error("Error looking up FSM for IMSI~n",
[UserName]),
ResultCode = ?'RULE-FAILURE-CODE_CM_AUTHORIZATION_REJECTED'
end,
Resp = #'AAA'{'Session-Id'= SessionId,
@@ -88,10 +88,10 @@
'Auth-Application-Id' = _AuthAppId,
'Termination-Cause' = _TermCause,
'User-Name' = [UserName]} = Req,
- Result = aaa_diameter_swm:get_ue_fsm_by_imsi(UserName),
- case Result of
- {ok, Pid} ->
- case aaa_ue_fsm:ev_rx_s6b_str(Pid) of
+ PidRes = aaa_ue_fsm:get_pid_by_imsi(UserName),
+ case PidRes of
+ PidRes when is_pid(PidRes) ->
+ case aaa_ue_fsm:ev_rx_s6b_str(PidRes) of
ok ->
lager:debug("Waiting for S6b STA~n", []),
receive
@@ -104,7 +104,7 @@
{error, _} ->
ResultCode = ?'RULE-FAILURE-CODE_CM_AUTHORIZATION_REJECTED'
end;
- _ -> lager:error("Error looking up FSM for IMSI~n", [UserName]),
+ undefined -> lager:error("Error looking up FSM for IMSI~n",
[UserName]),
ResultCode = ?'RULE-FAILURE-CODE_CM_AUTHORIZATION_REJECTED'
end,
% 3GPP TS 29.273 9.2.2.3.2 Session-Termination-Answer (STA) Command:
diff --git a/src/aaa_diameter_swm.erl b/src/aaa_diameter_swm.erl
index bcedcac..ee3a8cb 100644
--- a/src/aaa_diameter_swm.erl
+++ b/src/aaa_diameter_swm.erl
@@ -19,7 +19,6 @@
-export([start_link/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2]).
-export([code_change/3, terminate/2]).
--export([get_ue_fsm_by_imsi/1]).
-export([auth_request/1, auth_compl_request/2, session_termination_request/1]).
-export([auth_response/2, auth_compl_response/2, session_termination_answer/2]).
@@ -33,9 +32,6 @@
TableId = ets:new(auth_req, [bag, named_table]),
{ok, #swm_state{table_id = TableId}}.
-get_ue_fsm_by_imsi(Imsi) ->
- _Result = gen_server:call(?SERVER, {get_ue_fsm_by_imsi, Imsi}).
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tx over emulated SWm wire:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -101,16 +97,6 @@
error_logger:error_report(["unknown handle_info", {module, ?MODULE}, {info,
Info}, {state, S}]),
{noreply, S}.
-handle_call({get_ue_fsm_by_imsi, Imsi}, _From, State) ->
- Sess = find_swm_session_by_imsi(Imsi, State),
- lager:debug("find_swm_session_by_imsi(~p) returned ~p~n", [Imsi, Sess]),
- case Sess of
- #swm_session{} ->
- {reply, {ok ,Sess#swm_session.pid}, State};
- undefined ->
- {reply, {error, imsi_unknown}, State}
- end;
-
handle_call({epdg_auth_resp, Imsi, Result}, _From, State) ->
epdg_diameter_swm:auth_response(Imsi, Result),
{reply, ok, State};
diff --git a/src/aaa_ue_fsm.erl b/src/aaa_ue_fsm.erl
index 52918d2..5cdb553 100644
--- a/src/aaa_ue_fsm.erl
+++ b/src/aaa_ue_fsm.erl
@@ -40,6 +40,7 @@
-export([start_link/1]).
-export([init/1,callback_mode/0,terminate/3]).
+-export([get_server_name_by_imsi/1, get_pid_by_imsi/1]).
-export([ev_swm_auth_req/1, ev_swm_auth_compl/2, ev_rx_swm_str/1, ev_rx_swx_maa/2,
ev_rx_swx_saa/2,
ev_rx_s6b_aar/2, ev_rx_s6b_str/1]).
-export([state_new/3, state_wait_swx_maa/3, state_wait_swx_saa/3, state_authenticated/3,
state_authenticated_wait_swx_saa/3]).
@@ -52,10 +53,18 @@
s6b_resp_pid :: pid()
}).
-start_link(Imsi) ->
+get_server_name_by_imsi(Imsi) ->
ServerName = lists:concat([?NAME, "_", Imsi]),
+ list_to_atom(ServerName).
+
+get_pid_by_imsi(Imsi) ->
+ ServerName = get_server_name_by_imsi(Imsi),
+ whereis(ServerName).
+
+start_link(Imsi) ->
+ ServerName = get_server_name_by_imsi(Imsi),
lager:info("ue_fsm start_link(~p)~n", [ServerName]),
- gen_statem:start_link({local, list_to_atom(ServerName)}, ?MODULE, Imsi, [{debug,
[trace]}]).
+ gen_statem:start_link({local, ServerName}, ?MODULE, Imsi, [{debug, [trace]}]).
ev_swm_auth_req(Pid) ->
lager:info("ue_fsm ev_swm_auth_req~n", []),
--
To view, visit
https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35893?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: erlang/osmo-epdg
Gerrit-Branch: master
Gerrit-Change-Id: I0e62f3715da61d2d8cfabaf89557aeb1cd95f89a
Gerrit-Change-Number: 35893
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange