pespin has submitted this change. (
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37857?usp=email )
Change subject: erab_fsm: properly omit Network Instance IE
......................................................................
erab_fsm: properly omit Network Instance IE
If the access/core Network Instance IE value is not configured, the
'network_instance' field shall not be added to PDRs and FARs.
Otherwise we hit a function_clause exception in pfcplib.
Change-Id: I643a23eeb1cfb699cda44f973cb8098edb0a9a83
Fixes: 3d8119c "erab_fsm: include Network Instance IE in PDRs and FARs"
---
M src/erab_fsm.erl
1 file changed, 42 insertions(+), 28 deletions(-)
Approvals:
pespin: Looks good to me, approved
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
diff --git a/src/erab_fsm.erl b/src/erab_fsm.erl
index 931b47f..544f5ab 100644
--- a/src/erab_fsm.erl
+++ b/src/erab_fsm.erl
@@ -81,6 +81,10 @@
-type erab_state() :: #erab_state{}.
+-type iface() :: 'Core' | 'Access'.
+-type pfcp_ie() :: map().
+
+
%% ------------------------------------------------------------------
%% public API
%% ------------------------------------------------------------------
@@ -375,68 +379,78 @@
logger:set_process_metadata(#{prefix => Prefix}).
--spec net_inst(atom()) -> undefined | binary().
-net_inst(Param) ->
- case application:get_env(osmo_s1gw, Param) of
- {ok, Val} -> Val;
- undefined -> undefined
- end.
-
-
-spec session_establish_req(erab_state()) -> pfcp_peer:pfcp_session_rsp().
session_establish_req(#erab_state{seid_loc = F_SEID, %% used as F-SEID
u2c = U2C}) ->
- %% Network Instance IE values for core/access
- NI_Core = net_inst(pfcp_net_inst_core),
- NI_Access = net_inst(pfcp_net_inst_access),
%% Packet Detection Rules
OHR = #outer_header_removal{header = 'GTP-U/UDP/IPv4'},
PDRs = [#{pdr_id => {pdr_id, 1}, %% -- for Core -> Access
far_id => {far_id, 1}, %% see FARs below
precedence => {precedence, 255},
outer_header_removal => OHR,
- pdi => #{f_teid => #f_teid{teid = choose,
- ipv4 = choose},
- network_instance => NI_Core,
- source_interface => {source_interface, 'Core'}}},
+ pdi => pdi('Core')},
#{pdr_id => {pdr_id, 2}, %% -- for Access -> Core
far_id => {far_id, 2}, %% see FARs below
precedence => {precedence, 255},
outer_header_removal => OHR,
- pdi => #{f_teid => #f_teid{teid = choose,
- ipv4 = choose},
- network_instance => NI_Access,
- source_interface => {source_interface, 'Access'}}}],
+ pdi => pdi('Access')}],
%% Forwarding Action Rules
+ FPars = #{outer_header_creation => ohc(U2C),
+ destination_interface => {destination_interface, 'Core'}},
+ FParsNI = add_net_inst(FPars, 'Core'), %% optional Network Instance IE
FARs = [#{far_id => {far_id, 1}, %% -- for Core -> Access
%% We don't know the Access side TEID / GTP-U address yet, so we set
%% this FAR to DROP and modify it when we get E-RAB SETUP RESPONSE.
apply_action => #{'DROP' => []}},
#{far_id => {far_id, 2}, %% -- for Access -> Core
apply_action => #{'FORW' => []},
- forwarding_parameters =>
- #{outer_header_creation => ohc(U2C),
- network_instance => NI_Core,
- destination_interface => {destination_interface,
'Core'}}}],
+ forwarding_parameters => FParsNI}],
pfcp_peer:session_establish_req(F_SEID, PDRs, FARs).
-spec session_modify_req(erab_state()) -> pfcp_peer:pfcp_session_rsp().
session_modify_req(#erab_state{seid_rem = SEID, %% SEID allocated to us
u2a = U2A}) ->
- %% Network Instance IE value for access
- NI_Access = net_inst(pfcp_net_inst_access),
%% Forwarding Action Rules
+ FPars = #{outer_header_creation => ohc(U2A)},
+ FParsNI = add_net_inst(FPars, 'Access'), %% optional Network Instance IE
FARs = [#{far_id => {far_id, 1}, %% -- for Core -> Access
%% Now we know the Access side TEID / GTP-U address, so we modify
%% this FAR (which was previously set to DROP) to FORW.
apply_action => #{'FORW' => []},
- update_forwarding_parameters =>
- #{outer_header_creation => ohc(U2A),
- network_instance => NI_Access}}],
+ update_forwarding_parameters => FParsNI}],
pfcp_peer:session_modify_req(SEID, [], FARs).
+%% Network Instance IE env parameter name
+-spec net_inst_param(iface()) -> atom().
+net_inst_param('Core') -> pfcp_net_inst_core;
+net_inst_param('Access') -> pfcp_net_inst_access.
+
+
+%% if configured, add Network Instance IE (optional)
+-spec add_net_inst(pfcp_ie(), iface()) -> pfcp_ie().
+add_net_inst(IE, Iface) ->
+ Param = net_inst_param(Iface),
+ case application:get_env(osmo_s1gw, Param) of
+ {ok, NI} ->
+ IE#{network_instance => NI};
+ undefined ->
+ IE
+ end.
+
+
+%% Packet Detection Information IE generator
+-spec pdi(iface()) -> pfcp_ie().
+pdi(SrcIface) ->
+ IE = #{f_teid => #f_teid{teid = choose,
+ ipv4 = choose},
+ source_interface => {source_interface, SrcIface}},
+ %% if configured, add Network Instance IE (optional)
+ add_net_inst(IE, SrcIface).
+
+
+%% Outer Header Creation IE generator
ohc({TEID, Addr}) ->
OHC = #outer_header_creation{n6 = false,
n19 = false,
--
To view, visit
https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/37857?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: I643a23eeb1cfb699cda44f973cb8098edb0a9a83
Gerrit-Change-Number: 37857
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: iedemam <michael(a)kapsulate.com>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>