[M] Change in ...osmo-epdg[master]: Use call() instead of cast() in ue_fsm
pespin has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35675?usp=email ) Change subject: Use call() instead of cast() in ue_fsm .. Use call() instead of cast() in ue_fsm This allows accounting for problems in the FSM from the calling code, and act accordingly, eg. rejecting a message. Change-Id: I235d3c8fb3a863d288b5433c39e0da65f747936b --- M src/gsup_server.erl M src/ue_fsm.erl 2 files changed, 90 insertions(+), 27 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/gsup_server.erl b/src/gsup_server.erl index 521d4c3..30e8864 100644 --- a/src/gsup_server.erl +++ b/src/gsup_server.erl @@ -202,9 +202,18 @@ {noreply, S#gsups_state{socket=Socket}}; % send auth info / requesting authentication tuples -handle_info({ipa, _Socket, ?IPAC_PROTO_EXT_GSUP, _GsupMsgRx = #{message_type := send_auth_info_req, imsi := Imsi}}, State0) -> +handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, _GsupMsgRx = #{message_type := send_auth_info_req, imsi := Imsi}}, State0) -> {UE, State1} = find_or_new_gsups_ue(Imsi, State0), - ue_fsm:auth_request(UE#gsups_ue.pid), + case ue_fsm:auth_request(UE#gsups_ue.pid) of + ok -> ok; + {error, _} -> + Resp = #{message_type => send_auth_info_err, +imsi => Imsi, +message_class => 5, +cause => ?GSUP_CAUSE_NET_FAIL + }, + tx_gsup(Socket, Resp) + end, {noreply, State1}; % location update request / when a UE wants to connect to a specific APN. This will trigger a AAA->HLR Request Server Assignment Request @@ -212,15 +221,24 @@ handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, _GsupMsgRx = #{message_type := location_upd_req, imsi := Imsi}}, State) -> UE = find_gsups_ue_by_imsi(Imsi, State), case UE of - #gsups_ue{imsi = Imsi} -> - ue_fsm:lu_request(UE#gsups_ue.pid); - undefined -> + #gsups_ue{imsi = Imsi} -> + case ue_fsm:lu_request(UE#gsups_ue.pid) of + ok -> ok; + {error, _} -> Resp = #{message_type => location_upd_err, imsi => Imsi, message_class => 5, -cause => ?GSUP_CAUSE_IMSI_UNKNOWN +cause => ?GSUP_CAUSE_NET_FAIL }, tx_gsup(Socket, Resp) + end; + undefined -> + Resp = #{message_type => location_upd_err, +imsi => Imsi, +message_class => 5, +cause => ?GSUP_CAUSE_IMSI_UNKNOWN + }, + tx_gsup(Socket, Resp) end, {noreply, State}; @@ -230,15 +248,24 @@ lager:info("GSUP: Rx ~p~n", [GsupMsgRx]), UE = find_gsups_ue_by_imsi(Imsi, State), case UE of - #gsups_ue{imsi = Imsi} -> - ue_fsm:tunnel_request(UE#gsups_ue.pid); - undefined -> + #gsups_ue{imsi = Imsi} -> + case ue_fsm:tunnel_request(UE#gsups_ue.pid) of + ok -> ok; + {error, _} -> Resp = #{message_type => epdg_tunnel_error, -imsi => Imsi, -message_class => 5, -cause => ?GSUP_CAUSE_IMSI_UNKNOWN + imsi => Imsi, + message_class => 5, + cause => ?GSUP_CAUSE_NET_FAIL }, tx_gsup(Socket, Resp) + end; + undefined -> + Resp = #{message_type => epdg_tunnel_error, + imsi => Imsi, + message_class => 5, + cause => ?GSUP_CAUSE_IMSI_UNKNOWN + }, + tx_gsup(Socket, Resp) end, {noreply, State}; diff --git a/src/ue_fsm.erl b/src/ue_fsm.erl index f6b2b7e..c0b8872 100644 --- a/src/ue_fsm.erl +++ b/src/ue_fsm.erl @@ -50,19 +50,39 @@ auth_request(Pid) -> lager:info("ue_fsm auth_request~n", []), -gen_statem:cast(Pid, auth_request). +try +gen_statem:call(Pid, auth_request) +catch +exit:Err -> +{error, Err} +end. lu_request(Pid) -> lager:info("ue_fsm lu_request~n", []), -gen_statem:cast(Pid, lu_request). +try +gen_statem:call(Pid, lu_request) +catch +exit:Err -> +{error, Err} +end. tunnel_request(Pid) ->
[M] Change in ...osmo-epdg[master]: Use call() instead of cast() in ue_fsm
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35675?usp=email ) Change subject: Use call() instead of cast() in ue_fsm .. Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35675?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: I235d3c8fb3a863d288b5433c39e0da65f747936b Gerrit-Change-Number: 35675 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: pespin Gerrit-Comment-Date: Thu, 25 Jan 2024 14:44:46 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in ...osmo-epdg[master]: Use call() instead of cast() in ue_fsm
Attention is currently required from: pespin. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35675?usp=email ) Change subject: Use call() instead of cast() in ue_fsm .. Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35675?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: I235d3c8fb3a863d288b5433c39e0da65f747936b Gerrit-Change-Number: 35675 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Attention: pespin Gerrit-Comment-Date: Thu, 25 Jan 2024 12:24:12 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in ...osmo-epdg[master]: Use call() instead of cast() in ue_fsm
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/erlang/osmo-epdg/+/35675?usp=email ) Change subject: Use call() instead of cast() in ue_fsm .. Use call() instead of cast() in ue_fsm This allows accounting for problems in the FSM from the calling code, and act accordingly, eg. rejecting a message. Change-Id: I235d3c8fb3a863d288b5433c39e0da65f747936b --- M src/gsup_server.erl M src/ue_fsm.erl 2 files changed, 90 insertions(+), 27 deletions(-) git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-epdg refs/changes/75/35675/1 diff --git a/src/gsup_server.erl b/src/gsup_server.erl index 521d4c3..30e8864 100644 --- a/src/gsup_server.erl +++ b/src/gsup_server.erl @@ -202,9 +202,18 @@ {noreply, S#gsups_state{socket=Socket}}; % send auth info / requesting authentication tuples -handle_info({ipa, _Socket, ?IPAC_PROTO_EXT_GSUP, _GsupMsgRx = #{message_type := send_auth_info_req, imsi := Imsi}}, State0) -> +handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, _GsupMsgRx = #{message_type := send_auth_info_req, imsi := Imsi}}, State0) -> {UE, State1} = find_or_new_gsups_ue(Imsi, State0), - ue_fsm:auth_request(UE#gsups_ue.pid), + case ue_fsm:auth_request(UE#gsups_ue.pid) of + ok -> ok; + {error, _} -> + Resp = #{message_type => send_auth_info_err, +imsi => Imsi, +message_class => 5, +cause => ?GSUP_CAUSE_NET_FAIL + }, + tx_gsup(Socket, Resp) + end, {noreply, State1}; % location update request / when a UE wants to connect to a specific APN. This will trigger a AAA->HLR Request Server Assignment Request @@ -212,15 +221,24 @@ handle_info({ipa, Socket, ?IPAC_PROTO_EXT_GSUP, _GsupMsgRx = #{message_type := location_upd_req, imsi := Imsi}}, State) -> UE = find_gsups_ue_by_imsi(Imsi, State), case UE of - #gsups_ue{imsi = Imsi} -> - ue_fsm:lu_request(UE#gsups_ue.pid); - undefined -> + #gsups_ue{imsi = Imsi} -> + case ue_fsm:lu_request(UE#gsups_ue.pid) of + ok -> ok; + {error, _} -> Resp = #{message_type => location_upd_err, imsi => Imsi, message_class => 5, -cause => ?GSUP_CAUSE_IMSI_UNKNOWN +cause => ?GSUP_CAUSE_NET_FAIL }, tx_gsup(Socket, Resp) + end; + undefined -> + Resp = #{message_type => location_upd_err, +imsi => Imsi, +message_class => 5, +cause => ?GSUP_CAUSE_IMSI_UNKNOWN + }, + tx_gsup(Socket, Resp) end, {noreply, State}; @@ -230,15 +248,24 @@ lager:info("GSUP: Rx ~p~n", [GsupMsgRx]), UE = find_gsups_ue_by_imsi(Imsi, State), case UE of - #gsups_ue{imsi = Imsi} -> - ue_fsm:tunnel_request(UE#gsups_ue.pid); - undefined -> + #gsups_ue{imsi = Imsi} -> + case ue_fsm:tunnel_request(UE#gsups_ue.pid) of + ok -> ok; + {error, _} -> Resp = #{message_type => epdg_tunnel_error, -imsi => Imsi, -message_class => 5, -cause => ?GSUP_CAUSE_IMSI_UNKNOWN + imsi => Imsi, + message_class => 5, + cause => ?GSUP_CAUSE_NET_FAIL }, tx_gsup(Socket, Resp) + end; + undefined -> + Resp = #{message_type => epdg_tunnel_error, + imsi => Imsi, + message_class => 5, + cause => ?GSUP_CAUSE_IMSI_UNKNOWN + }, + tx_gsup(Socket, Resp) end, {noreply, State}; diff --git a/src/ue_fsm.erl b/src/ue_fsm.erl index f6b2b7e..c0b8872 100644 --- a/src/ue_fsm.erl +++ b/src/ue_fsm.erl @@ -50,19 +50,39 @@ auth_request(Pid) -> lager:info("ue_fsm auth_request~n", []), -gen_statem:cast(Pid, auth_request). +try +gen_statem:call(Pid, auth_request) +catch +exit:Err -> +{error, Err} +end. lu_request(Pid) -> lager:info("ue_fsm lu_request~n", []), -gen_statem:cast(Pid, lu_request). +try +gen_statem:call(Pid, lu_request) +catch +exit:Err -> +{error, Err} +end. tunnel_request(Pid) -> lager:info("ue_fsm tunnel_request~n", []), -