fixeria has submitted this change. (
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39556?usp=email )
Change subject: s1ap_proxy: catch exceptions in handle_pdu/2
......................................................................
s1ap_proxy: catch exceptions in handle_pdu/2
We do have a try-catch block in handle_pdu_bin/2 that does catch
exceptions happening in decode_pdu/1, but does not catch anything
else. For instance, if something goes wrong in handle_pdu/2,
the whole process will be terminated, among with all the linked
E-RAB FSMs. This should definitely be avoided.
Change-Id: Ib1e6674f5b85557866c7beaea710ea903e4eeaca
---
M src/s1ap_proxy.erl
1 file changed, 7 insertions(+), 1 deletion(-)
Approvals:
pespin: Looks good to me, but someone else must approve
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/s1ap_proxy.erl b/src/s1ap_proxy.erl
index 56e5dee..0cef81e 100644
--- a/src/s1ap_proxy.erl
+++ b/src/s1ap_proxy.erl
@@ -215,7 +215,7 @@
try decode_pdu(OrigData) of
{ok, PDU} ->
?LOG_DEBUG("Rx S1AP PDU: ~p", [PDU]),
- case handle_pdu(PDU, S0) of
+ try handle_pdu(PDU, S0) of
{{Action, NewPDU}, S1} ->
{ok, NewData} = encode_pdu(NewPDU),
?LOG_DEBUG("Tx (~p) S1AP PDU: ~p", [Action, NewPDU]),
@@ -232,6 +232,12 @@
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_ALL),
s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_UNMODIFIED),
{{forward, OrigData}, S1}
+ catch
+ Exception:Reason:StackTrace ->
+ ?LOG_ERROR("An exception occurred: ~p, ~p, ~p", [Exception,
Reason, StackTrace]),
+ s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_EXCEPTION),
+ s1gw_metrics:ctr_inc(?S1GW_CTR_S1AP_PROXY_OUT_PKT_FWD_UNMODIFIED),
+ {{forward, OrigData}, S0} %% XXX: proxy as-is or drop?
end;
{error, {asn1, Error}} ->
?LOG_ERROR("S1AP PDU decoding failed: ~p", [Error]),
--
To view, visit
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/39556?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: Ib1e6674f5b85557866c7beaea710ea903e4eeaca
Gerrit-Change-Number: 39556
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>