fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37122?usp=email )
Change subject: sctp_proxy: add a safe wrapper for s1ap_proxy:handle_pdu/1
......................................................................
sctp_proxy: add a safe wrapper for s1ap_proxy:handle_pdu/1
We want to keep the SCTP connection alive even if we hit a bug in
s1ap_proxy:handle_pdu/1. Otherwise, all the PDN contexts of all
the subscribers served by the respective eNB will be killed.
Change-Id: Ie6a7c9ff40789695e37be11344f5ea97fbcb8cfa
---
M src/sctp_proxy.erl
1 file changed, 27 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/erlang/osmo-s1gw refs/changes/22/37122/1
diff --git a/src/sctp_proxy.erl b/src/sctp_proxy.erl
index 9f9072b..39bc4d7 100644
--- a/src/sctp_proxy.erl
+++ b/src/sctp_proxy.erl
@@ -155,8 +155,7 @@
{[#sctp_sndrcvinfo{assoc_id = Aid}], Data}}, S) ->
logger:debug("MME connection (id=~p, ~p:~p) -> eNB: ~p",
[Aid, MmeAddr, MmePort, Data]),
- sctp_server:send_data(maps:get(enb_aid, S),
- s1ap_proxy:handle_pdu(Data)),
+ sctp_server:send_data(maps:get(enb_aid, S), handle_pdu(Data)),
{keep_state, S};
%% Catch-all for other kinds of SCTP events
@@ -193,10 +192,21 @@
%% private API
%% ------------------------------------------------------------------
+%% A safe wrapper for s1ap_proxy:handle_pdu/1
+-spec handle_pdu(binary()) -> binary().
+handle_pdu(Data) when is_binary(Data) ->
+ try s1ap_proxy:handle_pdu(Data) of
+ NewData -> NewData
+ catch
+ Exception:Reason ->
+ logger:error("An exception occured: ~p, ~p", [Exception, Reason]),
+ Data %% proxy as-is
+ end.
+
+
%% Send a single message to the MME
sctp_send(#{sock := Sock, mme_aid := Aid}, Data) ->
- sctp_client:send_data({Sock, Aid},
- s1ap_proxy:handle_pdu(Data)).
+ sctp_client:send_data({Sock, Aid}, handle_pdu(Data)).
%% Send pending messages to the MME
--
To view, visit
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37122?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: Ie6a7c9ff40789695e37be11344f5ea97fbcb8cfa
Gerrit-Change-Number: 37122
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange