blob: 203dcbf1456973c5eaced41130d9e068aa87f858 [file] [log] [blame]
Harald Welte379d45a2017-08-03 09:55:15 +02001module GGSN_Tests {
2
Harald Welte34b5a952019-05-27 11:54:11 +02003/* GGSN test suite in TTCN-3
4 * (C) 2017-2019 Harald Welte <laforge@gnumonks.org>
5 * (C) 2018-2019 sysmocom - s.f.m.c. GmbH
6 * All rights reserved.
7 *
8 * Released under the terms of GNU General Public License, Version 2 or
9 * (at your option) any later version.
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13
14
Harald Welte94ade362017-08-04 00:36:55 +020015 import from General_Types all;
Harald Welte811651e2017-08-05 15:25:06 +020016 import from Osmocom_Types all;
Pau Espin Pedrolc04c69e2020-03-03 16:46:29 +010017 import from Misc_Helpers all;
Harald Welte94ade362017-08-04 00:36:55 +020018 import from IPL4asp_PortType all;
19 import from IPL4asp_Types all;
20 import from GTP_CodecPort all;
21 import from GTP_CodecPort_CtrlFunct all;
Harald Weltec69cf4e2018-02-17 20:57:02 +010022 import from GTP_Templates all;
Harald Welte94ade362017-08-04 00:36:55 +020023 import from GTPC_Types all;
24 import from GTPU_Types all;
Harald Welte71a36022017-12-04 18:55:58 +010025 import from IPCP_Types all;
Harald Weltef8298542019-04-10 10:15:28 +020026 import from PAP_Types all;
Harald Welte231b9412017-08-09 17:16:31 +020027 import from IP_Types all;
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +010028 import from ICMP_Types all;
Harald Welte231b9412017-08-09 17:16:31 +020029 import from ICMPv6_Types all;
Harald Welteddeecbb2017-08-18 22:53:30 +020030 import from Native_Functions all;
Stefan Sperlingc479e4f2018-04-03 19:34:16 +020031 import from Osmocom_VTY_Functions all;
32 import from TELNETasp_PortType all;
Harald Welte94ade362017-08-04 00:36:55 +020033
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +010034 import from DIAMETER_Types all;
35 import from DIAMETER_Templates all;
36 import from DIAMETER_Emulation all;
37
Harald Welte94ade362017-08-04 00:36:55 +020038 const integer GTP0_PORT := 3386;
39 const integer GTP1C_PORT := 2123;
40 const integer GTP1U_PORT := 2152;
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +010041 const integer PCRF_PORT := 3868;
Harald Welteddeecbb2017-08-18 22:53:30 +020042
Pau Espin Pedrolc1b1ddf2022-01-19 18:10:30 +010043 type enumerated GGSN_Impl {
44 GGSN_IMPL_OSMOCOM,
45 GGSN_IMPL_OPEN5GS
46 };
47
Harald Welteddeecbb2017-08-18 22:53:30 +020048 modulepar {
Stefan Sperlingcb782b92018-04-03 16:03:15 +020049 /* Default IP addresses. May be overridden by GGSN_Tests configuration files. */
50
51 /* The SGSN simulated by TTCN3 will bind to these addresses for GTP control and GTP user planes. */
Harald Welteddeecbb2017-08-18 22:53:30 +020052 charstring m_bind_ip_gtpc := "127.23.42.1";
53 charstring m_bind_ip_gtpu := "127.23.42.1";
54
Stefan Sperlingcb782b92018-04-03 16:03:15 +020055 /* Addresses the GGSN which is being tested is listening on for SGSN connections. */
Harald Welteddeecbb2017-08-18 22:53:30 +020056 charstring m_ggsn_ip_gtpc := "127.0.0.6";
57 charstring m_ggsn_ip_gtpu := "127.0.0.6";
Pau Espin Pedrolf69a4382018-01-29 13:09:00 +010058
Stefan Sperlingcb782b92018-04-03 16:03:15 +020059 /*
60 * Our tests expect to see these DNS servers in 'Create PDP context responses' sent by the GGSN.
61 * These addresses must therefore match 'ip[v6] dns' options configured in osmo-ggsn.conf.
62 *
63 * These addresses are not expected to serve actual DNS requests. However, tests may expect to be
64 * able to ping these addresses (currently, IPv4 addresses must respond with an ICMP 'echo reply',
65 * and IPv6 addresses may respond with either ICMPv6 'echo reply' or 'destination unreachable').
66 */
Pau Espin Pedrolf69a4382018-01-29 13:09:00 +010067 charstring m_ggsn_ip4_dns1 := "192.168.100.1"
68 charstring m_ggsn_ip4_dns2 := "8.8.8.8"
Pau Espin Pedrol363ba482018-01-29 18:42:00 +010069 charstring m_ggsn_ip6_dns1 := "2001:4860:4860::8888"
70 charstring m_ggsn_ip6_dns2 := "2001:4860:4860::8844"
Stefan Sperlingcb782b92018-04-03 16:03:15 +020071
72 /*
73 * Additional address ranges are defined in osmo-ggsn.conf from which addresses are assigned
74 * to MS "behind" the simulated SGSN. These addresses appear on tun devices used by osmo-ggsn.
75 * The tests expect to be able to send ping packets between any two simulated MS within the same
76 * address range. This requires IP forwarding to be enabled on the corresponding tun interfaces.
77 */
Pau Espin Pedrolc1b1ddf2022-01-19 18:10:30 +010078
79 GGSN_Impl m_ggsn_impl := GGSN_IMPL_OSMOCOM;
Harald Welteddeecbb2017-08-18 22:53:30 +020080 }
Harald Welte94ade362017-08-04 00:36:55 +020081
Harald Welte811651e2017-08-05 15:25:06 +020082 type set PdpContext {
83 hexstring imsi,
84 octetstring msisdn optional,
85 octetstring apn,
Harald Welteed7a1772017-08-09 20:26:20 +020086 ProtConfigOptions pco_req optional,
87 ProtConfigOptions pco_neg optional,
Harald Welte811651e2017-08-05 15:25:06 +020088 EndUserAddress eua,
Harald Welte231b9412017-08-09 17:16:31 +020089 OCT16 ip6_prefix optional,
Harald Welte811651e2017-08-05 15:25:06 +020090 BIT4 nsapi,
91 /* TEI (Data) local side */
92 OCT4 teid,
93 /* TEI (Control) local side */
94 OCT4 teic,
95 /* TEI (Data) remote side */
96 OCT4 teid_remote,
97 /* TEI (Control) remote side */
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +010098 OCT4 teic_remote,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +010099 OCT1 ratType optional,
100 UserLocationInformation uli optional
Harald Welte811651e2017-08-05 15:25:06 +0200101 }
102
Harald Welte94ade362017-08-04 00:36:55 +0200103 type component GT_CT {
104 port GTPC_PT GTPC;
105 port GTPU_PT GTPU;
106
Harald Welte0be142b2017-08-13 13:28:10 +0200107 var boolean g_initialized := false;
108
Harald Welte94ade362017-08-04 00:36:55 +0200109 var OCT1 g_restart_ctr := '01'O;
110 /* FIXME: unify with g_bind_ip + parse from config file */
Harald Welteddeecbb2017-08-18 22:53:30 +0200111 var OCT4 g_sgsn_ip_c;
112 var OCT4 g_sgsn_ip_u;
Harald Welte94ade362017-08-04 00:36:55 +0200113 /* FIXME: parse remName from config file */
Harald Welteddeecbb2017-08-18 22:53:30 +0200114 var GtpPeer g_peer_c := { connId := 0, remName := m_ggsn_ip_gtpc, remPort := GTP1C_PORT };
115 var GtpPeer g_peer_u := { connId := 0, remName := m_ggsn_ip_gtpu, remPort := GTP1U_PORT };
Harald Welte94ade362017-08-04 00:36:55 +0200116 timer T_default := 3.0;
Harald Welte5438b9d2017-08-13 13:27:48 +0200117
118 /* next to-be-sent GTP-C sequence number */
119 var uint16_t g_c_seq_nr;
120 /* next to-be-sent GTP-U sequence number */
121 var uint16_t g_d_seq_nr;
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200122
123 port TELNETasp_PT GGSNVTY;
Harald Welted2394e92018-04-26 10:21:49 +0200124 var boolean use_gtpu_txseq := false;
Pau Espin Pedrol05118022022-02-17 19:49:13 +0100125 var integer g_use_echo_intval := 0; /* 0 = disabled */
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100126
127 /* emulated PCRF, used with m_ggsn_impl = GGSN_IMPL_OPEN5GS */
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100128 var DIAMETER_Emulation_CT vc_Gx;
129 port DIAMETER_PT Gx_UNIT;
130 port DIAMETEREM_PROC_PT Gx_PROC;
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200131 }
132
133 private function f_init_vty() runs on GT_CT {
134 map(self:GGSNVTY, system:GGSNVTY);
135 f_vty_set_prompts(GGSNVTY);
136 f_vty_transceive(GGSNVTY, "enable");
137 }
138
139 private function f_vty_set_gpdu_txseq(boolean enable) runs on GT_CT {
140 f_vty_enter_config(GGSNVTY);
141 f_vty_transceive(GGSNVTY, "ggsn ggsn0");
Pau Espin Pedrol205a3842018-07-06 13:24:14 +0200142
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200143 f_vty_transceive(GGSNVTY, "apn internet");
144 if (enable) {
145 f_vty_transceive(GGSNVTY, "g-pdu tx-sequence-numbers");
146 } else {
147 f_vty_transceive(GGSNVTY, "no g-pdu tx-sequence-numbers");
148 }
Pau Espin Pedrol205a3842018-07-06 13:24:14 +0200149 f_vty_transceive(GGSNVTY, "exit");
150
151 f_vty_transceive(GGSNVTY, "apn inet6");
152 if (enable) {
153 f_vty_transceive(GGSNVTY, "g-pdu tx-sequence-numbers");
154 } else {
155 f_vty_transceive(GGSNVTY, "no g-pdu tx-sequence-numbers");
156 }
157 f_vty_transceive(GGSNVTY, "exit");
158
159 f_vty_transceive(GGSNVTY, "apn inet46");
160 if (enable) {
161 f_vty_transceive(GGSNVTY, "g-pdu tx-sequence-numbers");
162 } else {
163 f_vty_transceive(GGSNVTY, "no g-pdu tx-sequence-numbers");
164 }
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200165 f_vty_transceive(GGSNVTY, "end");
166 }
167
168 private function f_verify_gtpu_txseq(in PDU_GTPU gtpu, in boolean expect_gptu_txseq) return boolean {
169 if (expect_gptu_txseq) {
170 if (gtpu.s_bit != '1'B) {
171 log("GTPU sequence number expected but not present")
172 return false;
173 }
174 } else {
175 if (gtpu.s_bit != '0'B) {
176 log("GTPU sequence number not expected but present")
177 return false;
178 }
179 }
180 return true;
Harald Welte94ade362017-08-04 00:36:55 +0200181 }
182
Pau Espin Pedrol05118022022-02-17 19:49:13 +0100183 private function f_vty_enable_echo_interval(integer intval_sec) runs on GT_CT {
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +0200184 f_vty_enter_config(GGSNVTY);
185 f_vty_transceive(GGSNVTY, "ggsn ggsn0");
Pau Espin Pedrol05118022022-02-17 19:49:13 +0100186 if (intval_sec > 0) {
187 f_vty_transceive(GGSNVTY, "echo-interval " & int2str(intval_sec));
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +0200188 } else {
189 f_vty_transceive(GGSNVTY, "no echo-interval");
190 }
191 f_vty_transceive(GGSNVTY, "end");
192 }
193
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100194 private function DiameterForwardUnitdataCallback(PDU_DIAMETER msg)
195 runs on DIAMETER_Emulation_CT return template PDU_DIAMETER {
196 DIAMETER_UNIT.send(msg);
197 return omit;
198 }
199
200 private function f_init_diameter(charstring id) runs on GT_CT {
201 var DIAMETEROps ops := {
202 create_cb := refers(DIAMETER_Emulation.ExpectedCreateCallback),
203 unitdata_cb := refers(DiameterForwardUnitdataCallback),
204 raw := true /* handler mode (single component for all IMSI)) */
205 };
206 var DIAMETER_conn_parameters pars := {
207 remote_ip := m_ggsn_ip_gtpc,
208 remote_sctp_port := -1,
209 local_ip := m_bind_ip_gtpc,
210 local_sctp_port := PCRF_PORT,
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100211 origin_host := "pcrf.localdomain",
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100212 origin_realm := "localdomain",
Pau Espin Pedrol33b47492022-03-08 17:43:01 +0100213 auth_app_id := omit,
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100214 vendor_app_id := c_DIAMETER_3GPP_Gx_AID
215 };
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100216 vc_Gx := DIAMETER_Emulation_CT.create(id);
217 map(vc_Gx:DIAMETER, system:DIAMETER_CODEC_PT);
218 connect(vc_Gx:DIAMETER_UNIT, self:Gx_UNIT);
219 connect(vc_Gx:DIAMETER_PROC, self:Gx_PROC);
220 vc_Gx.start(DIAMETER_Emulation.main(ops, pars, id));
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100221
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100222 f_diameter_wait_capability(Gx_UNIT);
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100223 /* Give some time for our emulation to get out of SUSPECT list of SUT (3 watchdong ping-pongs):
224 * RFC6733 sec 5.1
225 * RFC3539 sec 3.4.1 [5]
226 * https://github.com/freeDiameter/freeDiameter/blob/master/libfdcore/p_psm.c#L49
227 */
228 f_sleep(1.0);
229 }
230
Harald Welte94ade362017-08-04 00:36:55 +0200231 function f_init() runs on GT_CT {
Harald Welte0be142b2017-08-13 13:28:10 +0200232 if (g_initialized == true) {
233 return;
234 }
235 g_initialized := true;
236
Harald Welteddeecbb2017-08-18 22:53:30 +0200237 g_sgsn_ip_c := f_inet_addr(m_bind_ip_gtpc);
238 g_sgsn_ip_u := f_inet_addr(m_bind_ip_gtpu);
239
Harald Welte94ade362017-08-04 00:36:55 +0200240 var Result res;
241 map(self:GTPC, system:GTPC);
Harald Welteddeecbb2017-08-18 22:53:30 +0200242 res := GTP_CodecPort_CtrlFunct.f_IPL4_listen(GTPC, m_bind_ip_gtpc, GTP1C_PORT, {udp:={}});
Harald Welte94ade362017-08-04 00:36:55 +0200243 log("GTP1C ConnectionID: ", res.connId);
Harald Welte811651e2017-08-05 15:25:06 +0200244 g_peer_c.connId := res.connId;
Harald Welte94ade362017-08-04 00:36:55 +0200245
246 map(self:GTPU, system:GTPU);
Harald Welteddeecbb2017-08-18 22:53:30 +0200247 res := GTP_CodecPort_CtrlFunct.f_GTPU_listen(GTPU, m_bind_ip_gtpu, GTP1U_PORT, {udp:={}});
Harald Welte811651e2017-08-05 15:25:06 +0200248 g_peer_u.connId:= res.connId;
Harald Welte5438b9d2017-08-13 13:27:48 +0200249
250 g_restart_ctr := f_rnd_octstring(1);
Harald Welte11dbc7b2017-08-13 18:57:56 +0200251 g_c_seq_nr := f_rnd_int(65535);
252 g_d_seq_nr := f_rnd_int(65535);
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200253
Pau Espin Pedrolc1b1ddf2022-01-19 18:10:30 +0100254 if (m_ggsn_impl == GGSN_IMPL_OSMOCOM) {
255 f_init_vty();
256 f_vty_set_gpdu_txseq(use_gtpu_txseq);
Pau Espin Pedrol05118022022-02-17 19:49:13 +0100257 f_vty_enable_echo_interval(g_use_echo_intval);
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100258 } else if (m_ggsn_impl == GGSN_IMPL_OPEN5GS) {
259 f_init_diameter(testcasename());
Pau Espin Pedrolc1b1ddf2022-01-19 18:10:30 +0100260 }
Harald Welte94ade362017-08-04 00:36:55 +0200261 }
262
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +0100263 function f_shutdown_helper() runs on GT_CT {
264 /* Sleep N3_REQUESTS * T3_REQUEST seconds, nowadays 5*3=15s.
265 * This ensures all retransmit queues are cleared before jumping
266 * into next tests, hence avoding situation where a test resuses
267 * a seqnum still in the GGSN's resp queue (dup req detector).
268 * See OS#5485 avout decreasing time. We could also add a new
269 * VTY command that calls gtp_clear_queues() */
270 f_sleep(15.0);
271 setverdict(pass);
272 }
273
Harald Welte94ade362017-08-04 00:36:55 +0200274 /* Altstep implementing responses to any incoming echo requests */
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100275 private altstep pingpong() runs on GT_CT {
Harald Welte94ade362017-08-04 00:36:55 +0200276 var Gtp1cUnitdata ud;
Harald Welte3af89482017-08-04 16:20:23 +0200277 var Gtp1uUnitdata udu;
Pau Espin Pedrol05118022022-02-17 19:49:13 +0100278 [g_use_echo_intval > 0] GTPC.receive(tr_GTPC_PING(?)) -> value ud {
Harald Welte811651e2017-08-05 15:25:06 +0200279 var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber);
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +0200280 GTPC.send(ts_GTPC_PONG(ud.peer, seq, g_restart_ctr));
Harald Welte94ade362017-08-04 00:36:55 +0200281 repeat;
282 };
Pau Espin Pedrol05118022022-02-17 19:49:13 +0100283 [g_use_echo_intval == 0] GTPC.receive(tr_GTPC_PING(?)) {
Pau Espin Pedrolc04c69e2020-03-03 16:46:29 +0100284 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
285 "GTP Echo Req rceived but not enabled in VTY");
Harald Welte3af89482017-08-04 16:20:23 +0200286 };
Pau Espin Pedrolc04c69e2020-03-03 16:46:29 +0100287 [] T_default.timeout {
288 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
289 "pinpong T_default timeout");
290 };
Harald Welte94ade362017-08-04 00:36:55 +0200291 }
292
Harald Welte811651e2017-08-05 15:25:06 +0200293 /* 'internet' in DNS encoding */
Harald Welteed097432017-08-13 13:28:49 +0200294 const octetstring c_ApnInternet := '08696E7465726E6574'O;
295 const octetstring c_ApnInet6 := '05696E657436'O;
296 const octetstring c_ApnInet46 := '06696E65743436'O;
Harald Welte94ade362017-08-04 00:36:55 +0200297
Harald Welte811651e2017-08-05 15:25:06 +0200298 /* return random NSAPI */
299 function f_rnd_nsapi() return BIT4 {
300 return int2bit(f_rnd_int(16), 4);
301 }
302
303 /* return random TEI[DC] */
304 function f_rnd_tei() return OCT4 {
305 return int2oct(f_rnd_int(4294967296), 4);
306 }
307
308 /* define an (internal) representation of a PDP context */
309 template PdpContext t_DefinePDP(hexstring imsi, octetstring msisdn, octetstring apn,
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100310 EndUserAddress eua, OCT1 ratType := '02'O /* GERAN */) := {
Harald Welte811651e2017-08-05 15:25:06 +0200311 imsi := imsi,
312 msisdn := msisdn,
313 nsapi := f_rnd_nsapi(),
314 apn := apn,
Harald Welteed7a1772017-08-09 20:26:20 +0200315 pco_req := omit,
Harald Welte811651e2017-08-05 15:25:06 +0200316 eua := eua,
317 teid := f_rnd_tei(),
Pau Espin Pedrol38aeffb2022-02-01 20:46:29 +0100318 teic := f_rnd_tei(),
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100319 ratType := ratType,
320 uli := {
321 type_gtpc := '98'O,
322 lengthf := 0 /* filled in by encoder */,
323 geographicLocationType := '00'O /* CGI */,
324 geographicLocation := {
325 geographicLocationCGI := ts_GeographicLocationCGI('262'H, '42F'H, '0001'O, '0002'O)
326 }
327 }
Harald Welte811651e2017-08-05 15:25:06 +0200328 }
329
330 /* send GTP-C for a given context and increment sequence number */
Harald Welte41575e92017-08-13 13:49:57 +0200331 function f_send_gtpc(in template Gtp1cUnitdata data) runs on GT_CT {
Harald Welte811651e2017-08-05 15:25:06 +0200332 GTPC.send(data);
Harald Welte5438b9d2017-08-13 13:27:48 +0200333 g_c_seq_nr := g_c_seq_nr + 1;
Harald Welte811651e2017-08-05 15:25:06 +0200334 }
335
336 /* send GTP-U for a given context and increment sequence number */
Harald Welte231b9412017-08-09 17:16:31 +0200337 function f_send_gtpu(inout PdpContext ctx, in octetstring data) runs on GT_CT {
Harald Welte3e0b0392018-04-26 09:46:21 +0200338 if (use_gtpu_txseq) {
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200339 GTPU.send(ts_GTP1U_GPDU(g_peer_u, g_d_seq_nr, ctx.teid_remote, data));
340 g_d_seq_nr := g_d_seq_nr + 1;
341 } else {
342 GTPU.send(ts_GTP1U_GPDU(g_peer_u, omit, ctx.teid_remote, data));
343 }
Harald Welte811651e2017-08-05 15:25:06 +0200344 }
345
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100346 function f_handle_create_req(inout PdpContext ctx, in Gtp1cUnitdata ud, in template OCT1 exp_cause := '80'O) runs on GT_CT {
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200347 var CreatePDPContextResponse cpr := ud.gtpc.gtpc_pdu.createPDPContextResponse;
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100348
349 if (not match(cpr.cause.causevalue, exp_cause)) {
350 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
351 "CreatePDPContextResp: cause expectancies didn't match");
352 }
353
354 if (cpr.cause.causevalue == '80'O) { /* Accepted */
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200355 /* Check if EUA type corresponds to requested type */
356 if (match(ctx.eua, t_EuaIPv4(?)) and
357 not match(cpr.endUserAddress, tr_EuaIPv4(?))){
Pau Espin Pedrol8ad031a2022-02-16 17:33:43 +0100358 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
359 "EUAv4 expectancies didn't match");
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200360 }
361 if (match(ctx.eua, t_EuaIPv6(?)) and
362 not match(cpr.endUserAddress, tr_EuaIPv6(?))) {
Pau Espin Pedrol8ad031a2022-02-16 17:33:43 +0100363 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
364 "EUAv6 expectancies didn't match");
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200365 }
366 if (match(ctx.eua, t_EuaIPv4v6(?, ?)) and
367 not match(cpr.endUserAddress, tr_EuaIPv4v6(?, ?))) {
Pau Espin Pedrol8ad031a2022-02-16 17:33:43 +0100368 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
369 "EUAv4v6 expectancies didn't match");
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200370 }
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100371 } else if (cpr.cause.causevalue == '81'O) { /* Cause: New PDP type due to network preference */
372 /* ETSI TS 129 060 7.3.2 Create PDP Context Response. OS#5449 */
373 /* This should only happen if EUA requested type is v4v6: */
374 if (not ischosen(ctx.eua.endUserAddress.endUserAddressIPv4andIPv6)) {
375 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
376 "Cause not expected when requesting a non v4v6 EUA");
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200377 }
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100378 if (not match(cpr.endUserAddress, (tr_EuaIPv4(?), tr_EuaIPv6(?)))) {
379 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
380 "Cause not expected when requesting+receiving EUAv4v6");
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200381 }
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200382 } else {
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100383 if (ispresent(cpr.endUserAddress)) {
384 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
385 "EUA received on createPDPContextResponse cause=" & oct2str(cpr.cause.causevalue));
386 }
387 setverdict(pass);
388 return;
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200389 }
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100390
391 /* Check if PCO response corresponds to request */
392 if (ispresent(ctx.pco_req)) {
393 if (match(ctx.pco_req, ts_PCO_IPv4_DNS_CONT) and
394 not match(cpr.protConfigOptions, tr_PCO_IPv4_DNS_CONT_resp(?))) {
395 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
396 "IPv4 DNS Container requested, but missing");
397 }
398 if (match(ctx.pco_req, ts_PCO_IPv6_DNS) and
399 not match(cpr.protConfigOptions, tr_PCO_IPv6_DNS_resp(?))) {
400 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
401 "IPv6 DNS Container requested, but missing");
402 }
403 }
404 ctx.teid_remote := cpr.teidDataI.teidDataI;
405 ctx.teic_remote := cpr.teidControlPlane.teidControlPlane;
406 ctx.eua := cpr.endUserAddress;
407 ctx.pco_neg := cpr.protConfigOptions;
408 setverdict(pass);
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200409 }
410
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100411 function f_handle_update_req(inout PdpContext ctx, in Gtp1cUnitdata ud, in OCT1 exp_cause := '80'O) runs on GT_CT {
412 var UpdatePDPContextResponseGGSN upr := ud.gtpc.gtpc_pdu.updatePDPContextResponse.updatePDPContextResponseGGSN;
413 if (exp_cause == '80'O and exp_cause == upr.cause.causevalue) {
414 ctx.teid_remote := upr.teidDataI.teidDataI;
415 ctx.teic_remote := upr.teidControlPlane.teidControlPlane;
416 if (ispresent(upr.protConfigOptions)) {
417 ctx.pco_neg := upr.protConfigOptions;
418 }
419 setverdict(pass);
420 } else if (exp_cause != '80'O and exp_cause == upr.cause.causevalue) {
421 setverdict(pass);
422 } else {
Pau Espin Pedrol8ad031a2022-02-16 17:33:43 +0100423 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
424 "UpdatePDPContextResp: cause expectancies didn't match");
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100425 }
426 }
427
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100428 private altstep as_DIA_CCR(DCC_NONE_CC_Request_Type req_type) runs on GT_CT {
429 var PDU_DIAMETER rx_dia;
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100430 [] Gx_UNIT.receive(tr_DIA_CCR(req_type := req_type)) -> value rx_dia {
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100431 var template (omit) AVP avp;
432 var octetstring sess_id;
433 var AVP_Unsigned32 req_num;
434
435 avp := f_DIAMETER_get_avp(rx_dia, c_AVP_Code_BASE_NONE_Session_Id);
436 sess_id := valueof(avp.avp_data.avp_BASE_NONE_Session_Id);
437
438 avp := f_DIAMETER_get_avp(rx_dia, c_AVP_Code_DCC_NONE_CC_Request_Number);
439 req_num := valueof(avp.avp_data.avp_DCC_NONE_CC_Request_Number);
440
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100441 Gx_UNIT.send(ts_DIA_CCA(rx_dia.hop_by_hop_id, rx_dia.end_to_end_id, sess_id,
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100442 req_type, req_num));
443 }
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100444 [] Gx_UNIT.receive(PDU_DIAMETER:?) -> value rx_dia {
Pau Espin Pedrol8ad031a2022-02-16 17:33:43 +0100445 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
446 log2str("Received unexpected DIAMETER ", rx_dia));
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100447 }
448 }
449
Harald Welte811651e2017-08-05 15:25:06 +0200450 /* send a PDP context activation */
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100451 function f_pdp_ctx_act(inout PdpContext ctx, template OCT1 exp_cause := '80'O) runs on GT_CT return CreatePDPContextResponse {
Harald Welte94ade362017-08-04 00:36:55 +0200452 var Gtp1cUnitdata ud;
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100453 var CreatePDPContextResponse cpr;
Harald Welte94ade362017-08-04 00:36:55 +0200454 var default d;
455
456 log("sending CreatePDP");
Harald Welte41575e92017-08-13 13:49:57 +0200457 f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctx.imsi, g_restart_ctr,
Harald Welte811651e2017-08-05 15:25:06 +0200458 ctx.teid, ctx.teic, ctx.nsapi, ctx.eua, ctx.apn,
Pau Espin Pedrolca587f12022-02-02 10:42:01 +0100459 g_sgsn_ip_c, g_sgsn_ip_u, ctx.msisdn, ctx.pco_req, ctx.ratType, ctx.uli));
Harald Welte94ade362017-08-04 00:36:55 +0200460 T_default.start;
Harald Welte94ade362017-08-04 00:36:55 +0200461 d := activate(pingpong());
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100462 if (Gx_PROC.checkstate("Connected")) {
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100463 as_DIA_CCR(INITIAL_REQUEST);
464 }
Harald Welte94ade362017-08-04 00:36:55 +0200465 alt {
Harald Welte811651e2017-08-05 15:25:06 +0200466 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ctx.teic)) -> value ud {
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +0200467 f_handle_create_req(ctx, ud, exp_cause);
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100468 cpr := ud.gtpc.gtpc_pdu.createPDPContextResponse;
Harald Welte94ade362017-08-04 00:36:55 +0200469 }
470 }
471 deactivate(d);
Harald Welte811651e2017-08-05 15:25:06 +0200472 T_default.stop;
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +0100473 return cpr;
Harald Welte94ade362017-08-04 00:36:55 +0200474 }
475
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +0200476 function f_pdp_ctx_exp_del_req(PdpContext ctx, template (omit) OCT1 expect_cause := omit, boolean expect_teardown := false) runs on GT_CT {
477 var Gtp1cUnitdata ud;
478 var default d;
479
480 T_default.start;
481 d := activate(pingpong());
482 alt {
483 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextRequest, ctx.teic)) -> value ud {
484 if (istemplatekind(expect_cause, "omit") and not ispresent(ud.gtpc.gtpc_pdu.deletePDPContextRequest.cause.causevalue)) {
485 setverdict(pass);
486 } else if (not istemplatekind(expect_cause, "omit") and
487 ispresent(ud.gtpc.gtpc_pdu.deletePDPContextRequest.cause.causevalue) and
488 ud.gtpc.gtpc_pdu.deletePDPContextRequest.cause.causevalue == valueof(expect_cause)) {
489 setverdict(pass);
490 } else {
Pau Espin Pedrol8ad031a2022-02-16 17:33:43 +0100491 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
492 "DeletePDPContextReq: cause expectancies didn't match");
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +0200493 }
494
495 if (expect_teardown == ispresent(ud.gtpc.gtpc_pdu.deletePDPContextRequest.tearDownIndicator)) {
496 setverdict(pass);
497 } else {
498 setverdict(fail);
Pau Espin Pedrol8ad031a2022-02-16 17:33:43 +0100499 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
500 "DeletePDPContextReq: tearDownIndicator expectancies didn't match");
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +0200501 }
502 }
503 }
504 deactivate(d);
505 T_default.stop;
506 }
507
Pau Espin Pedrol10ec96e2022-02-09 17:03:15 +0100508 function f_pdp_ctx_del(PdpContext ctx, template BIT1 teardown_ind, OCT1 expect_causevalue := '80'O, boolean expect_diameter := true) runs on GT_CT {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200509 var Gtp1cUnitdata ud;
510 var default d;
Pau Espin Pedrol9a5f42f2019-05-27 20:04:35 +0200511 var OCT4 expect_teid;
512
513 /* 3GPP TS 29.060 sec 7.3.6 specifies TEID used in response
514 message with cause value "Non existent" shall be zero. */
515 if (expect_causevalue == 'C0'O) {
516 expect_teid := '00000000'O;
517 } else {
518 expect_teid := ctx.teic;
519 }
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200520
Harald Welte41575e92017-08-13 13:49:57 +0200521 f_send_gtpc(ts_GTPC_DeletePDP(g_peer_c, g_c_seq_nr, ctx.teic_remote, ctx.nsapi, teardown_ind));
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200522 T_default.start;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200523 d := activate(pingpong());
Pau Espin Pedrol45d57022022-03-08 13:49:02 +0100524 if (Gx_PROC.checkstate("Connected") and expect_diameter) {
Pau Espin Pedrol0bcfd9d2022-02-02 11:01:35 +0100525 as_DIA_CCR(TERMINATION_REQUEST);
526 }
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200527 alt {
Pau Espin Pedrol9a5f42f2019-05-27 20:04:35 +0200528 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, expect_teid)) -> value ud {
529 if (ud.gtpc.gtpc_pdu.deletePDPContextResponse.cause.causevalue == expect_causevalue) {
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200530 setverdict(pass);
531 } else {
Pau Espin Pedrol8ad031a2022-02-16 17:33:43 +0100532 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
533 "DeletePDPContextResp: cause expectancies didn't match");
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200534 }
535 }
536 }
537 deactivate(d);
Harald Welte811651e2017-08-05 15:25:06 +0200538 T_default.stop;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200539 }
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100540
541 /* send a Update PdP Context Request, expect Response */
542 function f_pdp_ctx_update(inout PdpContext ctx, OCT1 exp_cause := '80'O, template (omit) OCT4 new_teid := omit, template (omit) OCT4 new_teic := omit) runs on GT_CT {
543 var Gtp1cUnitdata ud;
544 var default d;
545
546 if (not istemplatekind(new_teid, "omit")) {
547 ctx.teid := valueof(new_teid);
548 }
549 if (not istemplatekind(new_teic, "omit")) {
550 ctx.teic := valueof(new_teic);
551 }
552
553 log("sending UpdatePDP");
554 f_send_gtpc(ts_GTPC_UpdatePDP(g_peer_c, ctx.teic_remote, g_c_seq_nr, ctx.imsi, g_restart_ctr,
555 ctx.teid, ctx.teic, ctx.nsapi, g_sgsn_ip_c, g_sgsn_ip_u,
556 ctx.pco_req, ctx.ratType, ctx.uli));
557 T_default.start;
558 d := activate(pingpong());
559 alt {
560 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, updatePDPContextResponse, ctx.teic)) -> value ud {
561 f_handle_update_req(ctx, ud, exp_cause);
562 }
563 }
564 deactivate(d);
565 T_default.stop;
566 }
567
Harald Welte811651e2017-08-05 15:25:06 +0200568 /* IPv6 router solicitation fe80::2 -> ff02::2 from 02:88:b5:1f:25:59 */
569 const octetstring c_router_solicit := '6000000000103afffe800000000000000000000000000002ff02000000000000000000000000000285009f2b0000000001010288b51f2559'O;
570 /* IPv6 neighbor solicitation fe80::2 -> ff02::1:ff00:2 from 02:88:b5:1f:25:59 */
571 const octetstring c_neigh_solicit:= '6000000000203afffe800000000000000000000000000002ff0200000000000000000001ff00000287009f9600000000fe80000000000000000000000000000201010288b51f2559'O;
Harald Weltef1e0d5a2017-08-05 08:51:22 +0200572
Stefan Sperling6cd217e2018-03-30 15:17:34 +0200573 /* template for sending an ICMPv4 echo request */
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100574 template PDU_ICMP ts_ICMPv4_ERQ := {
575 echo := {
576 type_field := 8,
577 code := 0,
578 checksum := '0000'O,
579 identifier := '0345'O,
580 sequence_number := '0001'O,
581 data := ''O
582 }
583 }
584
Stefan Sperling6cd217e2018-03-30 15:17:34 +0200585 /* template for receiving/matching an ICMPv4 echo request */
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +0100586 template PDU_ICMP tr_ICMPv4_ERQ := {
587 echo := {
588 type_field := 8,
589 code := 0,
590 checksum := ?,
591 identifier := ?,
592 sequence_number := ?,
593 data := ?
594 }
595 }
596
Stefan Sperling6cd217e2018-03-30 15:17:34 +0200597 /* template for receiving/matching an ICMPv4 echo reply */
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100598 template PDU_ICMP tr_ICMPv4_ERP(template octetstring data := *) := {
599 echo_reply := {
600 type_field := 0,
601 code := 0,
602 checksum := ?,
603 identifier := ?,
604 sequence_number := ?,
605 data := data
606 }
607 }
608
609 /* template for receiving/matching an ICMPv6 Destination Unreachable */
610 template PDU_ICMP tr_ICMPv4_DU := {
611 destination_unreachable := {
612 type_field := 1,
613 code := ?,
614 checksum := ?,
615 unused := ?,
616 original_ip_msg := ?
617 }
618 }
619
620 /* template to construct IPv4_packet from input arguments, ready for use in f_IPv4_enc() */
621 template IPv4_packet ts_IP4(OCT4 srcaddr, OCT4 dstaddr, LIN1 proto, LIN2_BO_LAST tlen, octetstring payload) := {
622 header := {
623 ver := 4,
624 hlen := 5,
625 tos := 0,
626 tlen := tlen,
627 id := 35902,
628 res := '0'B,
629 dfrag := '1'B,
630 mfrag := '0'B,
631 foffset := 0,
632 ttl := 64,
633 proto := proto,
634 cksum := 0,
635 srcaddr := srcaddr,
636 dstaddr := dstaddr
637 },
638 ext_headers := omit,
639 payload := payload
640 }
641
Harald Welte231b9412017-08-09 17:16:31 +0200642 /* template to generate a 'Prefix Information' ICMPv6 option */
643 template OptionField ts_ICMP6_OptPrefix(OCT16 prefix, INT1 prefix_len) := {
644 prefixInformation := {
645 typeField := 3,
646 lengthIndicator := 8,
647 prefixLength := prefix_len,
648 reserved1 := '000000'B,
649 a_Bit := '0'B,
650 l_Bit := '0'B,
651 validLifetime := oct2int('FFFFFFFF'O),
652 preferredLifetime := oct2int('FFFFFFFF'O),
653 reserved2 := '00000000'O,
654 prefix := prefix
655 }
656 }
657
Stefan Sperling6cd217e2018-03-30 15:17:34 +0200658 /* template for sending an ICMPv6 echo request */
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100659 template PDU_ICMPv6 ts_ICMPv6_ERQ := {
660 echoRequest := {
661 typeField := 128,
662 code := 0,
663 checksum := '0000'O,
664 identifier := 0,
665 sequenceNr := 0,
666 data := ''O
667 }
668 }
669
Stefan Sperling6cd217e2018-03-30 15:17:34 +0200670 /* template for sending an ICMPv6 router solicitation */
Harald Welte231b9412017-08-09 17:16:31 +0200671 template PDU_ICMPv6 ts_ICMPv6_RS := {
672 routerSolicitation := {
673 typeField := 133,
674 code := 0,
675 checksum := '0000'O,
676 reserved := '00000000'O,
677 /* TODO: do we need 'Source link-layer address' ? */
678 options := omit
679 }
680 }
681
Stefan Sperling6cd217e2018-03-30 15:17:34 +0200682 /* template for sending an ICMPv6 router advertisement */
Harald Welte231b9412017-08-09 17:16:31 +0200683 template PDU_ICMPv6 ts_ICMPv6_RA(OCT16 prefix, INT1 prefix_len) := {
684 routerAdvertisement := {
685 typeField := 134,
686 code := 0,
687 checksum := '0000'O,
688 curHopLimit := ?,
689 reserved := '000000'B,
690 o_Bit := '0'B,
691 m_Bit := '0'B,
692 routerLifetime := oct2int('FFFF'O),
693 reachableTime := oct2int('FFFFFFFF'O),
694 retransTimer := oct2int('FFFFFFFF'O),
695 options := {
696 ts_ICMP6_OptPrefix(prefix, prefix_len)
697 }
698 }
699 }
700
Stefan Sperling6cd217e2018-03-30 15:17:34 +0200701 /* template for sending an ICMPv6 neighbor solicitation */
Harald Welte231b9412017-08-09 17:16:31 +0200702 template PDU_ICMPv6 ts_ICMPv6_NS(OCT16 target_addr) := {
703 neighborSolicitation := {
704 typeField := 135,
705 code := 0,
706 checksum := '0000'O,
707 reserved := '00000000'O,
708 targetAddress := target_addr,
709 /* TODO: do we need 'Source link-layer address' ? */
710 options := omit
711 }
712 }
713
714 /* derive ICMPv6 link-local address from lower 64bit of link_id */
715 /* template for receiving/matching an ICMPv6 'Prefix Information' option */
716 template OptionField tr_ICMP6_OptPrefix(template OCT16 prefix, template INT1 prefix_len) := {
717 prefixInformation := {
718 typeField := 3,
719 lengthIndicator := 4,
720 prefixLength := prefix_len,
721 reserved1 := ?,
722 a_Bit := ?,
723 l_Bit := ?,
724 validLifetime := ?,
725 preferredLifetime := ?,
726 reserved2 := ?,
727 prefix := prefix
728 }
729 }
730
731 /* template for receiving/matching an ICMPv6 router advertisement */
732 template PDU_ICMPv6 tr_ICMPv6_RA(template OCT16 prefix, template INT1 prefix_len) := {
733 routerAdvertisement := {
734 typeField := 134,
735 code := 0,
736 checksum := ?,
737 curHopLimit := ?,
738 reserved := ?,
739 o_Bit := '0'B,
740 m_Bit := '0'B,
741 routerLifetime := ?,
742 reachableTime := ?,
743 retransTimer := ?,
744 options := {
745 tr_ICMP6_OptPrefix(prefix, prefix_len)
746 }
747 }
748 }
749
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100750 /* template for receiving/matching an ICMPv6 Destination Unreachable */
751 template PDU_ICMPv6 tr_ICMPv6_DU := {
752 destinationUnreachable := {
753 typeField := 1,
754 code := ?,
755 checksum := ?,
756 unused := ?,
757 originalIpMsg := ?
758 }
759 }
760
Stefan Sperling6cd217e2018-03-30 15:17:34 +0200761 /* template for receiving/matching an ICMPv6 echo request */
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +0100762 template PDU_ICMPv6 tr_ICMPv6_ERQ := {
763 echoRequest := {
764 typeField := 128,
765 code := 0,
766 checksum := ?,
767 identifier := ?,
768 sequenceNr := ?,
769 data := ?
770 }
771 }
772
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100773 /* template for receiving/matching an ICMPv6 echo reply */
774 template PDU_ICMPv6 tr_ICMPv6_ERP(template octetstring data := *) := {
775 echoReply := {
776 typeField := 129,
777 code := 0,
778 checksum := ?,
779 identifier := ?,
780 sequenceNr := ?,
781 data := data
782 }
783 }
784
Harald Welte231b9412017-08-09 17:16:31 +0200785 /* template to construct IPv6_packet from input arguments, ready for use in f_IPv6_enc() */
786 template IPv6_packet ts_IP6(OCT16 srcaddr, OCT16 dstaddr, LIN1 nexthead, octetstring payload, LIN1 hlim := 255) := {
787 header := {
788 ver := 6,
789 trclass := 0,
790 flabel := 0,
791 plen := 0,
792 nexthead := nexthead,
793 hlim := hlim,
794 srcaddr := srcaddr,
795 dstaddr := dstaddr
796 },
797 ext_headers := omit,
798 payload := payload
799 }
800
801 function f_ipv6_link_local(in OCT16 link_id) return OCT16 {
802 return 'FE80000000000000'O & substr(link_id, 8, 8);
803 }
804
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100805 function f_ipv6_global(in OCT16 link_id) return OCT16 {
806 return substr(link_id, 0, 8) & '1234123412341234'O;
807 }
808
809 /* Create a new different IPv6 addr from input. Starts mangling at byte prefix. */
810 function f_ipv6_mangle(in OCT16 addr, in integer prefix := 0) return OCT16 {
811 var integer i;
812 var octetstring res := substr(addr, 0, prefix);
813 for (i := prefix; i < lengthof(addr); i := i + 1) {
814 var octetstring a := addr[i] xor4b '11'O;
815 res := res & a;
816 }
817 return res;
818 }
819
Harald Welte231b9412017-08-09 17:16:31 +0200820 /* Compute solicited-node multicast address as per RFC4291 2.7.1 */
821 function f_ipv6_sol_node_mcast(in OCT16 addr) return OCT16 {
822 return 'FF0200000000000000000001FF'O & substr(addr, 13, 3);
823 }
824
825 /* generate and encode ICMPv6 router solicitation */
826 function f_gen_icmpv6_router_solicitation(in OCT16 link_id) return octetstring {
827 const OCT16 c_ip6_all_router_mcast := 'FF020000000000000000000000000002'O;
828 var OCT16 saddr := f_ipv6_link_local(link_id);
829
830 var octetstring tmp;
831 tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_RS), saddr, c_ip6_all_router_mcast);
832 var IPv6_packet ip6 := valueof(ts_IP6(saddr, c_ip6_all_router_mcast, 58, tmp));
833
834 return f_IPv6_enc(ip6);
835 }
836
Pau Espin Pedrol57604212022-02-14 16:54:18 +0100837 /* Get link-id from PDP Context EUA */
838 function f_ctx_get_ipv6_interface_id(in PdpContext ctx) return OCT16 {
839 var OCT16 interface_id;
840 if (ischosen(ctx.eua.endUserAddress.endUserAddressIPv4andIPv6)) {
841 interface_id := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address;
842 } else if (ischosen(ctx.eua.endUserAddress.endUserAddressIPv6)) {
843 interface_id := ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address;
844 } else {
845 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected request to submit icmpv6 rs in IPv4 PDP context");
846 }
847 return interface_id;
848 }
849
Harald Welte231b9412017-08-09 17:16:31 +0200850 /* create ICMPv6 router solicitation deriving link-id from PDP Context EUA */
851 function f_icmpv6_rs_for_pdp(in PdpContext ctx) return octetstring {
Pau Espin Pedrol57604212022-02-14 16:54:18 +0100852 var OCT16 interface_id := f_ctx_get_ipv6_interface_id(ctx);
Harald Welte231b9412017-08-09 17:16:31 +0200853 return f_gen_icmpv6_router_solicitation(interface_id);
854 }
855
856 /* generate and encode ICMPv6 neighbor solicitation */
857 function f_gen_icmpv6_neigh_solicit(in OCT16 saddr, in OCT16 daddr, in OCT16 tgt_addr) return octetstring {
858 var octetstring tmp;
859 tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_NS(tgt_addr)), saddr, daddr);
860 var IPv6_packet ip6 := valueof(ts_IP6(saddr, daddr, 58, tmp));
861 return f_IPv6_enc(ip6);
862 }
863
864 /* generate and encode ICMPv6 neighbor solicitation for PDP Context */
865 function f_gen_icmpv6_neigh_solicit_for_pdp(in PdpContext ctx) return octetstring {
Pau Espin Pedrol57604212022-02-14 16:54:18 +0100866 var OCT16 interface_id := f_ctx_get_ipv6_interface_id(ctx);
Harald Welte231b9412017-08-09 17:16:31 +0200867 var OCT16 link_local := f_ipv6_link_local(interface_id);
868 var OCT16 daddr := f_ipv6_sol_node_mcast(link_local);
869
870 return f_gen_icmpv6_neigh_solicit(link_local, daddr, link_local);
871 }
872
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100873 /* Send an ICMPv4 echo msg through GTP given pdp ctx, and ip src and dst addr */
874 function f_gen_icmpv4_echo(OCT4 saddr, OCT4 daddr) return octetstring {
875 var octetstring tmp := f_enc_PDU_ICMP(valueof(ts_ICMPv4_ERQ));
876 var IPv4_packet ip4 := valueof(ts_IP4(saddr, daddr, 1, 50, tmp));
877 var octetstring data := f_IPv4_enc(ip4);
878 var OCT2 cksum := f_IPv4_checksum(data);
879 data[10] := cksum[0];
880 data[11] := cksum[1];
881 return data;
882 }
883
884 /* Send an ICMPv6 echo msg through GTP given pdp ctx, and ip src and dst addr */
885 function f_gen_icmpv6_echo(OCT16 saddr, OCT16 daddr) return octetstring {
886 var octetstring tmp := f_enc_PDU_ICMPv6(valueof(ts_ICMPv6_ERQ), saddr, daddr);
887 var IPv6_packet ip6 := valueof(ts_IP6(saddr, daddr, 58, tmp));
888 var octetstring data := f_IPv6_enc(ip6);
889 return data;
890 }
891
892 /* Wait for ICMPv4 from GTP */
893 function f_wait_icmp4(PdpContext ctx, template PDU_ICMP expected) runs on GT_CT {
Harald Welte231b9412017-08-09 17:16:31 +0200894 var Gtp1uUnitdata ud;
895 T_default.start;
896 alt {
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100897 [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ctx.teid)) -> value ud {
Harald Welte3e0b0392018-04-26 09:46:21 +0200898 if (f_verify_gtpu_txseq(ud.gtpu, use_gtpu_txseq) == false) {
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200899 setverdict(fail);
900 stop;
901 }
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100902 var octetstring gpdu := ud.gtpu.gtpu_IEs.g_PDU_IEs.data;
903 var IPv4_packet ip4 := f_IPv4_dec(gpdu);
904 if (ip4.header.ver != 4) {
905 repeat;
906 }
907 var PDU_ICMP icmp4 := f_dec_PDU_ICMP(ip4.payload);
908 if (not match(icmp4, expected)) {
909 repeat;
910 }
911 }
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +0100912 [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value ud {
913 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
914 "Received wrong local TEID");
915 }
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100916 [] GTPU.receive { setverdict(fail); }
917 [] T_default.timeout { setverdict(fail); }
918 }
919 T_default.stop;
920 }
921
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +0100922 /* Wait for ICMPv4 echo request from GTP */
923 function f_wait_icmp4_echo_request(PdpContext ctx) runs on GT_CT {
924 f_wait_icmp4(ctx, tr_ICMPv4_ERQ);
925 }
926
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100927 /* Wait for ICMPv4 echo reply (or unreachable) from GTP */
928 function f_wait_icmp4_echo_reply(PdpContext ctx) runs on GT_CT {
929 f_wait_icmp4(ctx, (tr_ICMPv4_ERP, tr_ICMPv4_DU));
930 }
931
932 /* Wait for ICMPv6 from GTP */
933 function f_wait_icmp6(PdpContext ctx, template PDU_ICMPv6 expected) runs on GT_CT {
934 var Gtp1uUnitdata ud;
935 T_default.start;
936 alt {
Harald Welte231b9412017-08-09 17:16:31 +0200937 [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value ud {
Harald Welte3e0b0392018-04-26 09:46:21 +0200938 if (f_verify_gtpu_txseq(ud.gtpu, use_gtpu_txseq) == false) {
Stefan Sperlingc479e4f2018-04-03 19:34:16 +0200939 setverdict(fail);
940 stop;
941 }
Harald Welte231b9412017-08-09 17:16:31 +0200942 var octetstring gpdu := ud.gtpu.gtpu_IEs.g_PDU_IEs.data;
943 var IPv6_packet ip6 := f_IPv6_dec(gpdu);
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100944 if (ip6.header.ver != 6 or ip6.header.nexthead != 58) {
Harald Welte231b9412017-08-09 17:16:31 +0200945 repeat;
946 }
947 var PDU_ICMPv6 icmp6 := f_dec_PDU_ICMPv6(ip6.payload);
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100948 if (not match(icmp6, expected)) {
Harald Welte231b9412017-08-09 17:16:31 +0200949 repeat;
950 }
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100951 /* We are waiting for RA, update ctx */
952 if (match(icmp6, tr_ICMPv6_RA(?, 64))) {
953 ctx.ip6_prefix := icmp6.routerAdvertisement.options[0].prefixInformation.prefix;
954 log("RA with /64 prefix ", ctx.ip6_prefix);
955 }
Harald Welte231b9412017-08-09 17:16:31 +0200956 }
957 [] GTPU.receive(tr_GTPU_GPDU(?, ?)) { repeat; }
958 [] GTPU.receive { setverdict(fail); }
959 [] T_default.timeout { setverdict(fail); }
960 }
961 T_default.stop;
962 }
963
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100964 /* wait for GGSN to send us an ICMPv6 router advertisement */
965 function f_wait_rtr_adv(PdpContext ctx) runs on GT_CT {
966 f_wait_icmp6(ctx, tr_ICMPv6_RA(?, 64));
967 }
968
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +0100969 /* Wait for ICMPv6 echo request from GTP */
970 function f_wait_icmp6_echo_request(PdpContext ctx) runs on GT_CT {
971 f_wait_icmp6(ctx, tr_ICMPv6_ERQ);
972 }
973
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100974 /* Wait for ICMPv6 echo reply (or unreachable) from GTP */
975 function f_wait_icmp6_echo_reply(PdpContext ctx) runs on GT_CT {
976 f_wait_icmp6(ctx, (tr_ICMPv6_ERP,tr_ICMPv6_DU));
977 }
978
Oliver Smithee6a0882019-03-08 11:05:46 +0100979 /* create ICMPv6 router solicitation deriving link-id from PDP Context EUA */
980 function f_icmpv6_rs_for_pdp46(in PdpContext ctx) return octetstring {
981 var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address;
982 return f_gen_icmpv6_router_solicitation(interface_id);
983 }
984
985 /* generate and encode ICMPv6 neighbor solicitation for PDP Context */
986 function f_gen_icmpv6_neigh_solicit_for_pdp46(in PdpContext ctx) return octetstring {
987 var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address;
988 var OCT16 link_local := f_ipv6_link_local(interface_id);
989 var OCT16 daddr := f_ipv6_sol_node_mcast(link_local);
990
991 return f_gen_icmpv6_neigh_solicit(link_local, daddr, link_local);
992 }
993
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +0100994 /* Assert we don't receive a ICMPv4/6 echo reply (or unreachable) from GTP */
995 function f_wait_gtpu_fail(PdpContext ctx) runs on GT_CT {
996 T_default.start;
997 alt {
998 [] GTPU.receive { setverdict(fail); }
999 [] T_default.timeout { }
1000 }
1001 T_default.stop;
1002 }
1003
Harald Welte79737b42019-04-10 10:39:30 +02001004 /* list of protocols where we don't accept duplicates */
1005 const OCT2List protocol_ids_nodupes := { 'C021'O, 'C023'O, 'C223'O, '8021'O };
1006 private function f_PCO_permits_duplicates(OCT2 id) return boolean {
1007 var integer i;
1008 for (i := 0; i < lengthof(protocol_ids_nodupes); i := i+1) {
1009 if (id == protocol_ids_nodupes[i]) {
1010 return false;
1011 }
1012 }
1013 return true;
1014 }
1015
1016 /* ensure that every given protocol Identifier exist only exactly once in the PCO */
1017 function f_PCO_ensure_no_duplicates(ProtConfigOptions pco) {
1018 var OCT2List protocol_ids := {};
1019 var integer i, j;
1020 for (i := 0; i < lengthof(pco.protocols); i := i+1) {
1021 var OCT2 id := pco.protocols[i].protocolID;
1022 for (j := 0; j < lengthof(protocol_ids); j := j+1) {
1023 if (not f_PCO_permits_duplicates(id) and id == protocol_ids[j]) {
1024 setverdict(fail, "Duplicate ProtocolID ", id, " already present in ", pco.protocols);
1025 }
1026 }
1027 protocol_ids := protocol_ids & { id };
1028 }
1029 }
1030
Harald Welte0ef285b2017-08-13 20:06:01 +02001031 /* Test IPv6 context activation for dynamic IPv6 EUA without request of IPv6 DNS */
Harald Welteed7a1772017-08-09 20:26:20 +02001032 testcase TC_pdp6_act_deact() runs on GT_CT {
Harald Welte94ade362017-08-04 00:36:55 +02001033 f_init();
Harald Welte231b9412017-08-09 17:16:31 +02001034
Harald Welteed097432017-08-13 13:28:49 +02001035 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
Harald Welte811651e2017-08-05 15:25:06 +02001036 f_pdp_ctx_act(ctx);
Harald Welteed7a1772017-08-09 20:26:20 +02001037 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001038 f_shutdown_helper();
Harald Welteed7a1772017-08-09 20:26:20 +02001039 }
1040
Harald Welte0ef285b2017-08-13 20:06:01 +02001041 /* Test IPv6 context activation for dynamic IPv6 EUA wirh request of IPv6 DNS in PCO */
Harald Welteed7a1772017-08-09 20:26:20 +02001042 testcase TC_pdp6_act_deact_pcodns() runs on GT_CT {
1043 f_init();
1044
Harald Welteed097432017-08-13 13:28:49 +02001045 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
Harald Welteed7a1772017-08-09 20:26:20 +02001046 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1047 f_pdp_ctx_act(ctx);
Pau Espin Pedrol363ba482018-01-29 18:42:00 +01001048
Harald Welte79737b42019-04-10 10:39:30 +02001049 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Pau Espin Pedrol363ba482018-01-29 18:42:00 +01001050 /* verify PCO contains both primary and secondary DNS */
1051 var OCT4 ggsn_ip6_dns1 := f_inet6_addr(m_ggsn_ip6_dns1);
1052 if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 1), ggsn_ip6_dns1)) {
1053 setverdict(fail, "Primary DNS IPv6 PCO option not found");
1054 }
1055
1056 var OCT4 ggsn_ip6_dns2 := f_inet6_addr(m_ggsn_ip6_dns2);
1057 if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 2), ggsn_ip6_dns2)) {
1058 setverdict(fail, "Secondary DNS IPv6 PCO option not found");
1059 }
1060
Harald Welteed7a1772017-08-09 20:26:20 +02001061 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001062 f_shutdown_helper();
Harald Welteed7a1772017-08-09 20:26:20 +02001063 }
1064
Harald Welte0ef285b2017-08-13 20:06:01 +02001065 /* Test PDP context activation for dynamic IPv6 EUA with IPv6 DNS in PCO and router solicitation/advertisement */
Harald Welteed7a1772017-08-09 20:26:20 +02001066 testcase TC_pdp6_act_deact_icmp6() runs on GT_CT {
1067 f_init();
1068
Harald Welteed097432017-08-13 13:28:49 +02001069 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
Harald Welteed7a1772017-08-09 20:26:20 +02001070 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1071 f_pdp_ctx_act(ctx);
Harald Welte231b9412017-08-09 17:16:31 +02001072
Harald Welte79737b42019-04-10 10:39:30 +02001073 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Harald Welte231b9412017-08-09 17:16:31 +02001074 //f_send_gtpu(ctx, c_router_solicit);
1075 //f_send_gtpu(ctx, c_neigh_solicit);
1076
1077 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx));
1078 f_wait_rtr_adv(ctx);
1079 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx));
1080
Harald Welte811651e2017-08-05 15:25:06 +02001081 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001082 f_shutdown_helper();
Harald Welte94ade362017-08-04 00:36:55 +02001083 }
1084
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001085 /* Test PDP context activation for dynamic IPv6 EUA with IPv6 DNS in PCO and router solicitation/advertisement.
1086 Test we can send ICMPv6 ping over GTPU to DNS server. */
1087 testcase TC_pdp6_act_deact_gtpu_access() runs on GT_CT {
1088 f_init();
1089 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
1090 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1091 f_pdp_ctx_act(ctx);
1092
1093 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx));
1094 f_wait_rtr_adv(ctx);
1095 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx));
1096
1097 var OCT16 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '0003'O);
1098
1099 /* Check if we can use valid link-local src addr. */
1100 var OCT16 saddr_ll := f_ipv6_link_local(ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address);
1101 f_send_gtpu(ctx, f_gen_icmpv6_echo(saddr_ll, dns1_addr));
Pau Espin Pedrolb63d85f2022-02-07 16:11:47 +01001102 if (m_ggsn_impl == GGSN_IMPL_OSMOCOM) {
1103 f_wait_icmp6_echo_reply(ctx);
1104 } else {
1105 f_wait_gtpu_fail(ctx);
1106 }
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001107
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001108 /* Check if we can use valid global src addr, should work */
1109 var OCT16 saddr_glob := f_ipv6_global(ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address);
1110 f_send_gtpu(ctx, f_gen_icmpv6_echo(saddr_glob, dns1_addr));
1111 f_wait_icmp6_echo_reply(ctx);
1112
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001113 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001114 f_shutdown_helper();
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001115 }
1116
1117 /* Check that attempting RA with another ll src addr won't work, packet dropped: */
1118 testcase TC_pdp6_act_deact_gtpu_access_wrong_ll_saddr() runs on GT_CT {
1119 f_init();
1120 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
1121 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1122 f_pdp_ctx_act(ctx);
1123
1124 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx));
1125 f_wait_rtr_adv(ctx);
1126 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx));
1127
1128 var OCT16 saddr_ll := f_ipv6_link_local(ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address);
1129 var OCT16 saddr_ll_wrong := f_ipv6_mangle(saddr_ll, 8);
1130 f_send_gtpu(ctx, f_gen_icmpv6_router_solicitation(saddr_ll_wrong));
1131 f_wait_gtpu_fail(ctx);
1132
1133 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001134 f_shutdown_helper();
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001135 }
1136
1137 /* Assert that packets with wrong global src addr are dropped by GGSN */
1138 testcase TC_pdp6_act_deact_gtpu_access_wrong_global_saddr() runs on GT_CT {
1139 f_init();
1140 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
1141 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1142 f_pdp_ctx_act(ctx);
1143
1144 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx));
1145 f_wait_rtr_adv(ctx);
1146 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx));
1147
1148 var OCT16 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '0003'O);
1149 var OCT16 saddr_glob := f_ipv6_global(ctx.eua.endUserAddress.endUserAddressIPv6.ipv6_address);
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001150 var OCT16 saddr_wrong := f_ipv6_mangle(saddr_glob);
1151 f_send_gtpu(ctx, f_gen_icmpv6_echo(saddr_wrong, dns1_addr));
1152 f_wait_gtpu_fail(ctx);
1153
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001154 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001155 f_shutdown_helper();
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001156 }
1157
1158 /* Send an IPv4 ICMP ECHO REQUEST to APN6, should fail (packet dropped */
1159 testcase TC_pdp6_act_deact_gtpu_access_ipv4_apn6() runs on GT_CT {
1160 f_init();
1161 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
1162 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1163 f_pdp_ctx_act(ctx);
1164
1165 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx));
1166 f_wait_rtr_adv(ctx);
1167 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx));
1168
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001169 var OCT4 saddr_v4 := f_inet_addr("192.168.10.2");
1170 var OCT4 daddr_v4 := f_inet_addr("8.8.8.8");
1171 f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr_v4, daddr_v4));
1172 f_wait_gtpu_fail(ctx);
1173
1174 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001175 f_shutdown_helper();
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001176 }
1177
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +01001178 /* Validate if different clients (pdp ctx) can reach one another through GGSN. */
1179 testcase TC_pdp6_clients_interact() runs on GT_CT {
1180 f_init();
1181 var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
1182 var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet6, valueof(t_EuaIPv6Dyn)));
1183 f_pdp_ctx_act(ctxA);
1184 f_send_gtpu(ctxA, f_icmpv6_rs_for_pdp(ctxA));
1185 f_wait_rtr_adv(ctxA);
1186 f_send_gtpu(ctxA, f_gen_icmpv6_neigh_solicit_for_pdp(ctxA));
1187
1188 f_pdp_ctx_act(ctxB);
1189 f_send_gtpu(ctxB, f_icmpv6_rs_for_pdp(ctxB));
1190 f_wait_rtr_adv(ctxB);
1191 f_send_gtpu(ctxB, f_gen_icmpv6_neigh_solicit_for_pdp(ctxB));
1192
1193 var OCT16 addrA_ll := f_ipv6_link_local(ctxA.eua.endUserAddress.endUserAddressIPv6.ipv6_address);
1194 var OCT16 addrB_ll := f_ipv6_link_local(ctxB.eua.endUserAddress.endUserAddressIPv6.ipv6_address);
1195 var OCT16 addrA_glob := f_ipv6_global(ctxA.eua.endUserAddress.endUserAddressIPv6.ipv6_address);
1196 var OCT16 addrB_glob := f_ipv6_global(ctxB.eua.endUserAddress.endUserAddressIPv6.ipv6_address);
1197
1198 /* Validate if clients can interact using ll addr. */
1199 f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_ll, addrB_ll));
1200 f_wait_gtpu_fail(ctxB);
1201
1202 /* Validate if clients can interact using global addr. */
1203 f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_glob, addrB_glob));
1204 f_wait_gtpu_fail(ctxB);
1205
1206 f_pdp_ctx_del(ctxA, '1'B);
Pau Espin Pedrolbb2bb062019-09-03 12:28:12 +02001207 f_pdp_ctx_del(ctxB, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001208 f_shutdown_helper();
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +01001209 }
1210
Harald Welte0ef285b2017-08-13 20:06:01 +02001211 /* Test PDP context activation for dynamic IPv4 EUA without DNS request */
Harald Welteed7a1772017-08-09 20:26:20 +02001212 testcase TC_pdp4_act_deact() runs on GT_CT {
1213 f_init();
Harald Welteed097432017-08-13 13:28:49 +02001214 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
Harald Welteed7a1772017-08-09 20:26:20 +02001215 f_pdp_ctx_act(ctx);
1216 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001217 f_shutdown_helper();
Harald Welteed7a1772017-08-09 20:26:20 +02001218 }
1219
Harald Welte0ef285b2017-08-13 20:06:01 +02001220 /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in IPCP */
Harald Welteed7a1772017-08-09 20:26:20 +02001221 testcase TC_pdp4_act_deact_ipcp() runs on GT_CT {
1222 f_init();
Pau Espin Pedrolf69a4382018-01-29 13:09:00 +01001223 var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
1224 var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
Harald Welteed097432017-08-13 13:28:49 +02001225 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
Harald Weltedca80052017-08-13 20:01:38 +02001226 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP);
Harald Welteed7a1772017-08-09 20:26:20 +02001227 f_pdp_ctx_act(ctx);
Harald Welte79737b42019-04-10 10:39:30 +02001228 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Harald Welte71a36022017-12-04 18:55:58 +01001229 /* verify IPCP is at all contained */
1230 if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
1231 setverdict(fail, "IPCP not found in PCO");
1232 }
1233 /* verify IPCP contains both primary and secondary DNS */
1234 var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O));
Pau Espin Pedrolf69a4382018-01-29 13:09:00 +01001235 if (not match(ipcp, tr_IPCP_Ack_DNS(0, ggsn_ip4_dns1, ggsn_ip4_dns2))) {
1236 if (not match(ipcp, tr_IPCP_Ack_DNS(0))) {
1237 setverdict(fail, "Primary/Secondary DNS PCO IPCP option not found");
1238 } else {
1239 setverdict(fail, "Primary/Secondary DNS PCO IPCP option found but not matching expected values");
1240 }
Harald Welte71a36022017-12-04 18:55:58 +01001241 }
Harald Welteed7a1772017-08-09 20:26:20 +02001242 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001243 f_shutdown_helper();
Harald Welteed7a1772017-08-09 20:26:20 +02001244 }
1245
Harald Weltef8298542019-04-10 10:15:28 +02001246 /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in IPCP + PAP authentication (broken) */
1247 testcase TC_pdp4_act_deact_ipcp_pap_broken() runs on GT_CT {
1248 f_init();
1249 var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
1250 var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
1251 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1252 ctx.pco_req := valueof(ts_PCO_PAP_IPv4_DNS);
1253 f_pdp_ctx_act(ctx);
1254 f_PCO_ensure_no_duplicates(ctx.pco_neg);
1255 /* verify IPCP is at all contained */
1256 if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
1257 setverdict(fail, "IPCP not found in PCO");
1258 }
1259 /* verify IPCP contains both primary and secondary DNS */
1260 var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O));
1261 if (not match(ipcp, tr_IPCP_Ack_DNS(0, ggsn_ip4_dns1, ggsn_ip4_dns2))) {
1262 if (not match(ipcp, tr_IPCP_Ack_DNS(0))) {
1263 setverdict(fail, "Primary/Secondary DNS PCO IPCP option not found");
1264 } else {
1265 setverdict(fail, "Primary/Secondary DNS PCO IPCP option found but not matching expected values");
1266 }
1267 }
1268 /* verify that PAP is contained */
1269 if (not match(ctx.pco_neg, tr_PCO_Contains('C023'O))) {
1270 setverdict(fail, "PAP not found in PCO");
1271 }
1272 var PapPacket pap := dec_PapPacket(f_PCO_extract_proto(ctx.pco_neg, 'C023'O));
1273 if (not match(pap, tr_PAP_AuthAck)) {
1274 setverdict(fail, "PAP isn't an AuthenticateAck: ", pap);
1275 }
1276 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001277 f_shutdown_helper();
Harald Weltef8298542019-04-10 10:15:28 +02001278 }
1279
Harald Welte0ef285b2017-08-13 20:06:01 +02001280 /* Test PDP context activation for dynamic IPv4 EUA with IPv4 DNS in PCO */
Harald Welteed7a1772017-08-09 20:26:20 +02001281 testcase TC_pdp4_act_deact_pcodns() runs on GT_CT {
1282 f_init();
Harald Welteed097432017-08-13 13:28:49 +02001283 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
Harald Weltedca80052017-08-13 20:01:38 +02001284 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
Harald Welteed7a1772017-08-09 20:26:20 +02001285 f_pdp_ctx_act(ctx);
Pau Espin Pedrol363ba482018-01-29 18:42:00 +01001286
Harald Welte79737b42019-04-10 10:39:30 +02001287 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Pau Espin Pedrol363ba482018-01-29 18:42:00 +01001288 /* verify PCO contains both primary and secondary DNS */
1289 var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
1290 if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 1), ggsn_ip4_dns1)) {
1291 setverdict(fail, "Primary DNS IPv4 PCO option not found");
1292 }
1293
1294 var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
1295 if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 2), ggsn_ip4_dns2)) {
1296 setverdict(fail, "Secondary DNS IPv4 PCO option not found");
1297 }
1298
Harald Welteed7a1772017-08-09 20:26:20 +02001299 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001300 f_shutdown_helper();
Harald Welteed7a1772017-08-09 20:26:20 +02001301 }
1302
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001303 /* Test PDP context activation for dynamic IPv4 EUA.
1304 Test we can send ICMPv6 ping over GTPU to DNS server. */
1305 testcase TC_pdp4_act_deact_gtpu_access() runs on GT_CT {
1306 f_init();
1307 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1308 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1309 f_pdp_ctx_act(ctx);
1310
Harald Welte79737b42019-04-10 10:39:30 +02001311 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001312 var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O);
1313
1314 /* Check if we can use valid global src addr, should work */
1315 var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4.ipv4_address;
1316 f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr));
1317 f_wait_icmp4_echo_reply(ctx);
1318
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001319 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001320 f_shutdown_helper();
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001321 }
1322
1323 /* Assert that packets with wrong global src addr are dropped by GGSN */
1324 testcase TC_pdp4_act_deact_gtpu_access_wrong_saddr() runs on GT_CT {
1325 f_init();
1326 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1327 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1328 f_pdp_ctx_act(ctx);
1329
1330 f_PCO_ensure_no_duplicates(ctx.pco_neg);
1331 var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O);
1332 var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4.ipv4_address;
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001333 var OCT4 saddr_wrong := substr(saddr, 0, 3) & (saddr[3] xor4b '11'O);
1334 f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr_wrong, dns1_addr));
1335 f_wait_gtpu_fail(ctx);
1336
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001337 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001338 f_shutdown_helper();
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001339 }
1340
1341 /* Send an IPv6 RA to APN4, should fail (packet dropped) */
1342 testcase TC_pdp4_act_deact_gtpu_access_ipv6_apn4() runs on GT_CT {
1343 f_init();
1344 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1345 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1346 f_pdp_ctx_act(ctx);
1347
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001348 /* Send an IPv6 RA to APN4, should fail (packet dropped) */
1349 var OCT16 saddr_v6 := f_inet6_addr("fde4:8dba:82e1:2000:1:2:3:4");
1350 f_send_gtpu(ctx, f_gen_icmpv6_router_solicitation(saddr_v6));
1351 f_wait_gtpu_fail(ctx);
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001352
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001353 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001354 f_shutdown_helper();
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01001355 }
1356
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001357 /* Helper function for tests below. */
1358 function f_pdp4_clients_interact() runs on GT_CT {
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +01001359 f_init();
1360 var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1361 var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1362 f_pdp_ctx_act(ctxA);
1363 f_pdp_ctx_act(ctxB);
1364 var OCT4 addrA := ctxA.eua.endUserAddress.endUserAddressIPv4.ipv4_address;
1365 var OCT4 addrB := ctxB.eua.endUserAddress.endUserAddressIPv4.ipv4_address;
1366 f_send_gtpu(ctxA, f_gen_icmpv4_echo(addrA, addrB));
1367 f_wait_icmp4_echo_request(ctxB);
1368
1369 f_pdp_ctx_del(ctxA, '1'B);
Pau Espin Pedrolbb2bb062019-09-03 12:28:12 +02001370 f_pdp_ctx_del(ctxB, '1'B);
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +01001371 }
1372
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001373 /* Validate if different clients (pdp ctx) can reach one another through GGSN. */
1374 testcase TC_pdp4_clients_interact_with_txseq() runs on GT_CT {
Harald Welte3e0b0392018-04-26 09:46:21 +02001375 use_gtpu_txseq := true;
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001376 f_pdp4_clients_interact();
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001377 f_shutdown_helper();
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001378 }
1379
1380 /* Validate if different clients (pdp ctx) can reach one another through GGSN (without Tx sequence number). */
1381 testcase TC_pdp4_clients_interact_without_txseq() runs on GT_CT {
Harald Welte3e0b0392018-04-26 09:46:21 +02001382 use_gtpu_txseq := false;
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001383 f_pdp4_clients_interact();
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001384 f_shutdown_helper();
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02001385 }
1386
Harald Weltedca80052017-08-13 20:01:38 +02001387 testcase TC_echo_req_resp() runs on GT_CT {
1388 f_init();
1389 f_send_gtpc(ts_GTPC_PING(g_peer_c, g_c_seq_nr));
1390 T_default.start;
1391 alt {
1392 [] GTPC.receive(tr_GTPC_PONG(g_peer_c)) { setverdict(pass); };
1393 [] GTPC.receive { repeat; };
1394 [] T_default.timeout { setverdict(fail); }
1395 }
1396 T_default.stop;
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001397 f_shutdown_helper();
Harald Weltedca80052017-08-13 20:01:38 +02001398 }
1399
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001400 testcase TC_echo_req_resp_gtpu() runs on GT_CT {
1401 f_init();
1402 GTPU.send(ts_GTPU_PING(g_peer_u, g_d_seq_nr));
1403 T_default.start;
1404 alt {
1405 [] GTPU.receive(tr_GTPU_PONG(g_peer_u)) { setverdict(pass); };
1406 [] GTPU.receive { repeat; };
1407 [] T_default.timeout { setverdict(fail); }
1408 }
1409 T_default.stop;
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001410 f_shutdown_helper();
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01001411 }
1412
Philipp Maier33e52612018-05-30 17:22:02 +02001413 /* Test if the parser can cope with PCO that only contain either a
1414 * single primary DNS or a secondary DNS. */
1415 testcase TC_pdp4_act_deact_with_single_dns() runs on GT_CT {
1416
1417 /* Note: an unpatched osmo-ggsn version will enter an endless-loop when
1418 * the test is executed.
1419 * see also: Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
1420
1421 f_init();
1422 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1423 var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
1424 var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
1425 var octetstring pco_neg_dns;
1426 var octetstring pco_neg_dns_expected;
1427
1428 /* PCO with primary DNS only */
1429 ctx.pco_req := valueof(ts_PCO_IPv4_PRI_DNS_IPCP);
1430 f_pdp_ctx_act(ctx);
Harald Welte79737b42019-04-10 10:39:30 +02001431 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Philipp Maier33e52612018-05-30 17:22:02 +02001432 pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1);
1433 pco_neg_dns_expected := '0200000A8106'O & ggsn_ip4_dns1
1434 /* Note: The prepended hex bytes encode the following information:
1435 * 0x02 = Configuration ACK
1436 * 0x00 = Identifier
1437 * 0x000a = Length
1438 * 0x81 = Type (Primary DNS Server Address)
1439 * 0x06 = Length
1440 * (4 byte IP-Address appended) */
1441 if (not match(pco_neg_dns, pco_neg_dns_expected)) {
1442 setverdict(fail, "Primary DNS IPv4 PCO option not found");
1443 }
1444 f_pdp_ctx_del(ctx, '1'B);
1445
1446 /* PCO with secondary DNS only */
Harald Welte7ef6d102021-04-01 21:24:35 +02001447 ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
Philipp Maier33e52612018-05-30 17:22:02 +02001448 ctx.pco_req := valueof(ts_PCO_IPv4_SEC_DNS_IPCP);
1449 f_pdp_ctx_act(ctx);
1450 pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1);
1451 pco_neg_dns_expected := '0200000A8306'O & ggsn_ip4_dns2
1452 if (not match(pco_neg_dns, pco_neg_dns_expected)) {
1453 setverdict(fail, "Secondary DNS IPv4 PCO option not found");
1454 }
1455 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001456 f_shutdown_helper();
Philipp Maier33e52612018-05-30 17:22:02 +02001457 }
1458
1459 /* Test if the parser can cope with PCO that contains primary and secondary DNS in a separate IPCP container.
1460 * Note: an unpatched osmo-ggsn version will enter an endless-loop when the test is run
1461 * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288. */
1462 testcase TC_pdp4_act_deact_with_separate_dns() runs on GT_CT {
1463
1464 /* Note: an unpatched osmo-ggsn version will enter an endless-loop when
1465 * the test is executed.
1466 * see also: Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */
1467
1468 f_init();
1469 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1470 var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
1471 var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
1472 var octetstring pco_neg_dns;
1473 var octetstring pco_neg_dns_expected;
1474
1475 ctx.pco_req := valueof(ts_PCO_IPv4_SEPARATE_DNS_IPCP);
1476 f_pdp_ctx_act(ctx);
1477
1478 /* Check if primary DNS is contained */
1479 pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1);
1480 pco_neg_dns_expected := '0200000A8106'O & ggsn_ip4_dns1
1481 if (not match(pco_neg_dns, pco_neg_dns_expected)) {
1482 setverdict(fail, "Primary DNS IPv4 PCO option not found");
1483 }
Philipp Maier33e52612018-05-30 17:22:02 +02001484
1485 /* Check if secondary DNS is contained */
Stefan Sperling8e7a3962018-07-19 19:24:38 +02001486 /* This used to fail due to a bug in osmo-ggsn, see OS#3381 */
1487 pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 2);
Philipp Maier33e52612018-05-30 17:22:02 +02001488 pco_neg_dns_expected := '0200000A8306'O & ggsn_ip4_dns2
1489 if (not match(pco_neg_dns, pco_neg_dns_expected)) {
1490 setverdict(fail, "Secondary DNS IPv4 PCO option not found");
1491 }
1492 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001493 f_shutdown_helper();
Philipp Maier33e52612018-05-30 17:22:02 +02001494 }
1495
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +01001496 /* Validate that SUT updates remote TEIC when requested through UpdatePDPContextRequest */
1497 testcase TC_pdp4_act_update_teic() runs on GT_CT {
1498 f_init();
1499 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1500 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1501 f_pdp_ctx_act(ctx);
1502
1503 /* UpdatePDPContestRequest changing the local TEIC */
1504 var OCT4 new_teic := ctx.teic;
1505 new_teic[3] := new_teic[3] xor4b '11'O;
1506 f_pdp_ctx_update(ctx, new_teic := new_teic);
1507
1508 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001509 f_shutdown_helper();
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +01001510 }
1511
1512 /* Validate that SUT updates remote TEID when requested through UpdatePDPContextRequest */
1513 testcase TC_pdp4_act_update_teid() runs on GT_CT {
1514 f_init();
1515 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1516 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1517 f_pdp_ctx_act(ctx);
1518
1519 f_PCO_ensure_no_duplicates(ctx.pco_neg);
1520 var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O);
1521 var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4.ipv4_address;
1522
1523 /* Data is sent (back) to the local TEID established during CreatePDPContext */
1524 f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr));
1525 f_wait_icmp4_echo_reply(ctx);
1526
1527 /* UpdatePDPContestRequest changing the local TEID */
1528 var OCT4 new_teid := ctx.teid;
1529 new_teid[3] := new_teid[3] xor4b '11'O;
1530 f_pdp_ctx_update(ctx, new_teid := new_teid);
1531
1532 /* Check if we can send data after updating the PDP context. Answer should be sent to the new TEID */
1533 f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr));
1534 f_wait_icmp4_echo_reply(ctx);
1535
1536 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001537 f_shutdown_helper();
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +01001538 }
1539
Oliver Smithee6a0882019-03-08 11:05:46 +01001540 /* Test IPv4v6 context activation for dynamic IPv4v6 EUA without DNS request */
1541 testcase TC_pdp46_act_deact() runs on GT_CT {
1542 f_init();
1543 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1544 f_pdp_ctx_act(ctx);
1545 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001546 f_shutdown_helper();
Oliver Smithee6a0882019-03-08 11:05:46 +01001547 }
1548
1549 /* Test PDP context activation for dynamic IPv4v6 EUA with IPv4 DNS in IPCP */
1550 testcase TC_pdp46_act_deact_ipcp() runs on GT_CT {
1551 f_init();
1552 var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
1553 var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
1554 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1555 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP);
1556 f_pdp_ctx_act(ctx);
Harald Welte79737b42019-04-10 10:39:30 +02001557 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Oliver Smithee6a0882019-03-08 11:05:46 +01001558 /* verify IPCP is at all contained */
1559 if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
1560 setverdict(fail, "IPCP not found in PCO");
1561 }
Harald Welte79737b42019-04-10 10:39:30 +02001562 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Oliver Smithee6a0882019-03-08 11:05:46 +01001563 /* verify IPCP contains both primary and secondary IPv4 DNS */
1564 var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O));
1565 if (not match(ipcp, tr_IPCP_Ack_DNS(0, ggsn_ip4_dns1, ggsn_ip4_dns2))) {
1566 if (not match(ipcp, tr_IPCP_Ack_DNS(0))) {
1567 setverdict(fail, "Primary/Secondary DNS PCO IPCP option not found");
1568 } else {
1569 setverdict(fail, "Primary/Secondary DNS PCO IPCP option found but not matching expected values");
1570 }
1571 }
1572 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001573 f_shutdown_helper();
Oliver Smithee6a0882019-03-08 11:05:46 +01001574 }
1575
1576 /* Test PDP context activation for dynamic IPv4v6 EUA with IPv6 DNS in PCO and router solicitation/advertisement */
1577 testcase TC_pdp46_act_deact_icmp6() runs on GT_CT {
1578 f_init();
1579 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1580 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1581 f_pdp_ctx_act(ctx);
1582
1583 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp46(ctx));
1584 f_wait_rtr_adv(ctx);
1585 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp46(ctx));
1586
1587 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001588 f_shutdown_helper();
Oliver Smithee6a0882019-03-08 11:05:46 +01001589 }
1590
1591 /* Test IPv4v6 context activation for dynamic IPv4v6 EUA with request of IPv4 DNS in PCO */
1592 testcase TC_pdp46_act_deact_pcodns4() runs on GT_CT {
1593 f_init();
1594
1595 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1596 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1597 f_pdp_ctx_act(ctx);
1598
Harald Welte79737b42019-04-10 10:39:30 +02001599 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Oliver Smithee6a0882019-03-08 11:05:46 +01001600 /* verify PCO contains both primary and secondary IPv4 DNS */
1601 var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
1602 if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 1), ggsn_ip4_dns1)) {
1603 setverdict(fail, "Primary DNS IPv4 PCO option not found");
1604 }
1605
1606 var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
1607 if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 2), ggsn_ip4_dns2)) {
1608 setverdict(fail, "Secondary DNS IPv4 PCO option not found");
1609 }
1610
1611 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001612 f_shutdown_helper();
Oliver Smithee6a0882019-03-08 11:05:46 +01001613 }
1614
1615 /* Test IPv4v6 context activation for dynamic IPv4v6 EUA with request of IPv6 DNS in PCO */
1616 testcase TC_pdp46_act_deact_pcodns6() runs on GT_CT {
1617 f_init();
1618
1619 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1620 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1621 f_pdp_ctx_act(ctx);
1622
Harald Welte79737b42019-04-10 10:39:30 +02001623 f_PCO_ensure_no_duplicates(ctx.pco_neg);
Oliver Smithee6a0882019-03-08 11:05:46 +01001624 /* verify PCO contains both primary and secondary IPv6 DNS */
1625 var OCT4 ggsn_ip6_dns1 := f_inet6_addr(m_ggsn_ip6_dns1);
1626 if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 1), ggsn_ip6_dns1)) {
1627 setverdict(fail, "Primary DNS IPv6 PCO option not found");
1628 }
1629
1630 var OCT4 ggsn_ip6_dns2 := f_inet6_addr(m_ggsn_ip6_dns2);
1631 if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 2), ggsn_ip6_dns2)) {
1632 setverdict(fail, "Secondary DNS IPv6 PCO option not found");
1633 }
1634
1635 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001636 f_shutdown_helper();
Oliver Smithee6a0882019-03-08 11:05:46 +01001637 }
1638
1639 /* Test PDP context activation for dynamic IPv4v6 EUA.
1640 Test we can send ICMPv6 ping over GTPU to DNS server. */
1641 testcase TC_pdp46_act_deact_gtpu_access() runs on GT_CT {
1642 f_init();
1643 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1644 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1645 f_pdp_ctx_act(ctx);
1646
1647 var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O);
1648
1649 /* Check if we can use valid global src addr, should work */
1650 var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv4_address;
1651 f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr));
1652 f_wait_icmp4_echo_reply(ctx);
1653
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001654 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001655 f_shutdown_helper();
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001656 }
1657
1658 /* Assert that packets with wrong ipv4 src addr are dropped by GGSN on APN IPv4v6 */
1659 testcase TC_pdp46_act_deact_gtpu_access_wrong_saddr_ipv4() runs on GT_CT {
1660 f_init();
1661 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1662 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1663 f_pdp_ctx_act(ctx);
1664
1665 var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O);
1666 var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv4_address;
Oliver Smithee6a0882019-03-08 11:05:46 +01001667 var OCT4 saddr_wrong := substr(saddr, 0, 3) & (saddr[3] xor4b '11'O);
1668 f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr_wrong, dns1_addr));
1669 f_wait_gtpu_fail(ctx);
1670
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001671 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001672 f_shutdown_helper();
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001673 }
1674
Pau Espin Pedrolc6ac6952022-02-14 11:19:23 +01001675 /* Check that attempting RA with another ll src addr won't work, packet dropped: */
1676 testcase TC_pdp46_act_deact_gtpu_access_wrong_ll_saddr_ipv6() runs on GT_CT {
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001677 f_init();
1678 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1679 ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1680 f_pdp_ctx_act(ctx);
1681
Pau Espin Pedrolc6ac6952022-02-14 11:19:23 +01001682 var OCT16 saddr_ll := f_ipv6_link_local(ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
1683 var OCT16 saddr_ll_wrong := f_ipv6_mangle(saddr_ll, 8);
1684 f_send_gtpu(ctx, f_gen_icmpv6_router_solicitation(saddr_ll_wrong));
1685 f_wait_gtpu_fail(ctx);
1686
1687 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001688 f_shutdown_helper();
Pau Espin Pedrolc6ac6952022-02-14 11:19:23 +01001689 }
1690
1691 /* Assert that packets with wrong ipv6 global src addr are dropped by GGSN on APN IPv4v6 */
1692 testcase TC_pdp46_act_deact_gtpu_access_wrong_global_saddr_ipv6() runs on GT_CT {
1693 f_init();
1694 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1695 ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
1696 f_pdp_ctx_act(ctx);
1697
1698 f_send_gtpu(ctx, f_icmpv6_rs_for_pdp(ctx));
1699 f_wait_rtr_adv(ctx);
1700 f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp(ctx));
1701
1702 var OCT16 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '0003'O);
1703 var OCT16 saddr_glob := f_ipv6_global(ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
1704 var OCT16 saddr_wrong := f_ipv6_mangle(saddr_glob);
1705 f_send_gtpu(ctx, f_gen_icmpv6_echo(saddr_wrong, dns1_addr));
Oliver Smithee6a0882019-03-08 11:05:46 +01001706 f_wait_gtpu_fail(ctx);
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01001707
Oliver Smithee6a0882019-03-08 11:05:46 +01001708 f_pdp_ctx_del(ctx, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001709 f_shutdown_helper();
Oliver Smithee6a0882019-03-08 11:05:46 +01001710 }
1711
1712 /* Validate if different clients (pdp ctx) can reach one another through GGSN. */
1713 testcase TC_pdp46_clients_interact() runs on GT_CT {
1714 f_init();
1715 var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1716 var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
1717 f_pdp_ctx_act(ctxA);
1718 f_send_gtpu(ctxA, f_icmpv6_rs_for_pdp46(ctxA));
1719 f_wait_rtr_adv(ctxA);
1720 f_send_gtpu(ctxA, f_gen_icmpv6_neigh_solicit_for_pdp46(ctxA));
1721
1722 f_pdp_ctx_act(ctxB);
1723 f_send_gtpu(ctxB, f_icmpv6_rs_for_pdp46(ctxB));
1724 f_wait_rtr_adv(ctxB);
1725 f_send_gtpu(ctxB, f_gen_icmpv6_neigh_solicit_for_pdp46(ctxB));
1726
1727 var OCT16 addrA_ll := f_ipv6_link_local(ctxA.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
1728 var OCT16 addrB_ll := f_ipv6_link_local(ctxB.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
1729 var OCT16 addrA_glob := f_ipv6_global(ctxA.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
1730 var OCT16 addrB_glob := f_ipv6_global(ctxB.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
1731
1732 /* Validate if clients can interact using ll addr. */
1733 f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_ll, addrB_ll));
1734 f_wait_gtpu_fail(ctxB);
1735
1736 /* Validate if clients can interact using global addr. */
1737 f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_glob, addrB_glob));
1738 f_wait_gtpu_fail(ctxB);
1739
1740 f_pdp_ctx_del(ctxA, '1'B);
Pau Espin Pedrolbb2bb062019-09-03 12:28:12 +02001741 f_pdp_ctx_del(ctxB, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001742 f_shutdown_helper();
Oliver Smithee6a0882019-03-08 11:05:46 +01001743 }
1744
Pau Espin Pedrol22d597f2019-08-21 16:16:58 +02001745 /* Test IPv4v6 context activation for dynamic IPv4v6 EUA on a v4-only APN */
1746 testcase TC_pdp46_act_deact_apn4() runs on GT_CT {
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +01001747 const OCT1 cause_accept := '80'O; /* Normal accept cause */
1748 const OCT1 cause_new_pdp_type := '81'O; /* Cause: New PDP type due to network preference */
1749 const OCT1 cause_unknown_pdp := 'DC'O; /* Cause: Unknown PDP address or PDP type */
1750 var CreatePDPContextResponse cpr;
1751
Pau Espin Pedrol22d597f2019-08-21 16:16:58 +02001752 f_init();
Pau Espin Pedrol22d597f2019-08-21 16:16:58 +02001753 var PdpContext ctx46 := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dynv6Dyn)));
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +01001754 cpr := f_pdp_ctx_act(ctx46, (cause_unknown_pdp, cause_new_pdp_type));
Pau Espin Pedrol22d597f2019-08-21 16:16:58 +02001755
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +01001756 if (cpr.cause.causevalue == cause_new_pdp_type) {
1757 /* 3GPP TS 23.060 sec 9.2.1: "If the MS requests PDP type IPv4v6,
1758 * but the operator preferences dictate the use of a single IP
1759 * version only, the PDP type shall be changed to a single address
1760 * PDP type (IPv4 or IPv6) and a reason cause shall be returned to
1761 * the MS indicating that only the assigned PDP type is allowed. In
1762 * this case, the MS shall not request another PDP context for the
1763 * other PDP type during the existence of the PDP context." */
1764 f_pdp_ctx_del(ctx46, '1'B);
1765 } else {
1766 /* 3GPP TS 23.060 sec 9.2.1 NOTE 5: If the MS requests PDP type
1767 * IPv4v6, and the PDP context is rejected due to "unknown PDP
1768 * type", the MS can attempt to establish dual-stack connectivity
1769 * by performing two PDP context request procedures to activate an
1770 * IPv4 PDP context and an IPv6 PDP context, both to the same APN. A
1771 * typical MS first attempts v4v6, and if rejected, then tries v4
1772 * and v6 separetly */
1773 var PdpContext ctx4 := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1774 f_pdp_ctx_act(ctx4, cause_accept); /* Normal accept cause */
Pau Espin Pedrol22d597f2019-08-21 16:16:58 +02001775
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +01001776 var PdpContext ctx6 := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv6Dyn)));
1777 f_pdp_ctx_act(ctx6, cause_unknown_pdp); /* Cause: Unknown PDP address or PDP type */
Pau Espin Pedrol22d597f2019-08-21 16:16:58 +02001778
Pau Espin Pedrol0f464d62022-02-23 14:04:29 +01001779 f_pdp_ctx_del(ctx4, '1'B);
1780 }
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001781 f_shutdown_helper();
Pau Espin Pedrol22d597f2019-08-21 16:16:58 +02001782 }
1783
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +02001784 /* Validate if 2nd CtxCreateReq with increased Recovery IE causes ggsn to drop 1st one (while keeping 2nd one). */
1785 testcase TC_pdp_act2_recovery() runs on GT_CT {
1786 var Gtp1cUnitdata ud;
1787 var default d;
1788 var boolean ctxA_deleted := false;
1789 var boolean ctxB_created := false;
1790
1791 f_init();
1792 var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1793 var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1794 f_pdp_ctx_act(ctxA);
1795
Vadim Yanitskiyd344b4a2022-02-09 18:28:18 +06001796 g_restart_ctr := int2oct((oct2int(g_restart_ctr) + 1) mod 256, 1);
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +02001797
1798 log("sending 2nd CreatePDP (recovery increased)");
1799 f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctxB.imsi, g_restart_ctr,
1800 ctxB.teid, ctxB.teic, ctxB.nsapi, ctxB.eua, ctxB.apn,
1801 g_sgsn_ip_c, g_sgsn_ip_u, ctxB.msisdn, ctxB.pco_req));
1802 T_default.start;
1803 d := activate(pingpong());
1804 alt {
1805 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ctxB.teic)) -> value ud {
1806 f_handle_create_req(ctxB, ud);
1807 if (not ctxB_created) {
1808 ctxB_created := true;
1809 setverdict(pass);
1810 } else {
1811 setverdict(fail, "Repeated createPDPContextResponse(ctxB)");
1812 }
1813
1814 if (not ctxA_deleted) {
1815 repeat;
1816 }
1817 }
1818 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextRequest, ctxA.teic)) -> value ud {
1819 if (ispresent(ud.gtpc.gtpc_pdu.deletePDPContextRequest.tearDownIndicator)) {
1820 setverdict(pass);
1821 } else {
1822 setverdict(fail);
1823 }
1824
1825 if (not ctxA_deleted) {
1826 ctxA_deleted := true;
1827 setverdict(pass);
1828 } else {
1829 setverdict(fail, "Repeated deletePDPContextRequest(ctxA)");
1830 }
1831
1832 if (not ctxB_created) {
1833 repeat;
1834 }
1835 }
1836 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextRequest, ctxB.teic)) -> value ud {
1837 setverdict(fail, "GGSN dropping still valid pdp ctx");
1838 }
1839 }
1840 deactivate(d);
1841 T_default.stop;
1842
1843 f_pdp_ctx_del(ctxB, '1'B);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001844 f_shutdown_helper();
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +02001845 }
1846
1847
Pau Espin Pedrol9a5f42f2019-05-27 20:04:35 +02001848 /* Send a duplicate echo req. osmo-ggsn maintains a queue for sent
1849 responses (60 seconds): If same delete req is sent and duplicate is
1850 detected, saved duplicate response should be sent back. */
1851 testcase TC_act_deact_retrans_duplicate() runs on GT_CT {
1852 f_init();
1853 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1854 f_pdp_ctx_act(ctx);
1855 f_pdp_ctx_del(ctx, '1'B);
1856 /* leave some time in between to make sure retransmit response queue keeps packets for a while */
1857 f_sleep(1.0);
1858 /* g_c_seq_nr was increased during f_pdp_ctx_del(), we want a
1859 duplicate. If it was not a duplicate, osmo-ggsn would answer
1860 with a failure since that PDP ctx was already deleted. */
1861 g_c_seq_nr := g_c_seq_nr - 1;
Pau Espin Pedrol10ec96e2022-02-09 17:03:15 +01001862 f_pdp_ctx_del(ctx, '1'B, expect_diameter := false);
Pau Espin Pedrol9a5f42f2019-05-27 20:04:35 +02001863
1864 /* Now send a new pdp ctx del (increased seqnum). It should fail with cause "non-existent": */
1865 var OCT1 cause_nonexistent := 'C0'O;
Pau Espin Pedrol10ec96e2022-02-09 17:03:15 +01001866 f_pdp_ctx_del(ctx, '1'B, cause_nonexistent, expect_diameter := false);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001867 f_shutdown_helper();
Pau Espin Pedrol9a5f42f2019-05-27 20:04:35 +02001868 }
1869
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +02001870 /* Activate PDP context + trigger Recovery procedure through EchoResp */
1871 testcase TC_pdp_act_restart_ctr_echo() runs on GT_CT {
1872 var Gtp1cUnitdata ud;
Pau Espin Pedrol05118022022-02-17 19:49:13 +01001873 g_use_echo_intval := 5;
1874 timer T_echo;
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +02001875 f_init();
1876 var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1877 f_pdp_ctx_act(ctx);
1878
1879 /* Wait to receive echo request and send initial Restart counter */
Pau Espin Pedrol05118022022-02-17 19:49:13 +01001880 T_echo.start(int2float(g_use_echo_intval) + 1.0);
1881 alt {
1882 [] GTPC.receive(tr_GTPC_PING(?)) -> value ud {
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +02001883 var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber);
1884 GTPC.send(ts_GTPC_PONG(ud.peer, seq, g_restart_ctr));
Pau Espin Pedrol05118022022-02-17 19:49:13 +01001885 }
1886 [] T_echo.timeout {
1887 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1888 "Timeout waiting for ping");
1889 }
1890 }
1891 T_echo.stop;
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +02001892
1893 /* Wait to receive second echo request and send incremented Restart
1894 counter. This will fake a restarted SGSN, and pdp ctx allocated
1895 should be released by GGSN */
Vadim Yanitskiyd344b4a2022-02-09 18:28:18 +06001896 g_restart_ctr := int2oct((oct2int(g_restart_ctr) + 1) mod 256, 1);
Pau Espin Pedrol05118022022-02-17 19:49:13 +01001897 T_echo.start(int2float(g_use_echo_intval) + 1.0);
1898 alt {
1899 [] GTPC.receive(tr_GTPC_PING(?)) -> value ud {
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +02001900 var uint16_t seq := oct2int(ud.gtpc.opt_part.sequenceNumber);
1901 GTPC.send(ts_GTPC_PONG(ud.peer, seq, g_restart_ctr));
Pau Espin Pedrol05118022022-02-17 19:49:13 +01001902 }
1903 [] T_echo.timeout {
1904 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1905 "Timeout waiting for ping");
1906 }
1907 }
1908 T_echo.stop;
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +02001909 f_pdp_ctx_exp_del_req(ctx, omit, true);
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01001910 f_shutdown_helper();
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +02001911 }
1912
Pau Espin Pedrol68c2af52022-02-25 11:56:17 +01001913 /* Test creation, user plane and deletion of big amount (1000) of concurrent PDP context */
1914 testcase TC_lots_of_concurrent_pdp_ctx() runs on GT_CT {
1915 var Gtp1cUnitdata udc;
1916 var Gtp1uUnitdata udu;
1917 const integer num_ctx := 1000;
1918 var PdpContext ctx[num_ctx];
1919 timer T_next := 0.01;
1920 var integer next_req_ctx := 0;
1921 var integer rx_resp_ctx := 0;
1922 var integer rx_pong := 0;
1923 var OCT4 dns1_addr;
1924 var OCT4 saddr;
1925 var integer teic;
1926 var integer idx;
1927
1928 f_init();
1929
1930 for (var integer i := 0; i < num_ctx; i := i + 1) {
1931 ctx[i] := valueof(t_DefinePDP(f_rnd_imsi('26242'H), f_rnd_msisdn('1234'O), c_ApnInternet, valueof(t_EuaIPv4Dyn)));
1932 ctx[i].teic := int2oct(i+1, 4); /* +1: skip TEIC=0 */
1933 ctx[i].teid := int2oct(i+1, 4); /* +1: skip TEID=0 */
1934 ctx[i].pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
1935 }
1936
1937 T_default.start(60.0);
1938
1939 T_next.start;
1940 alt {
Pau Espin Pedrol45d57022022-03-08 13:49:02 +01001941 [Gx_PROC.checkstate("Connected")] as_DIA_CCR(INITIAL_REQUEST) { repeat; }
Pau Espin Pedrol68c2af52022-02-25 11:56:17 +01001942 [] pingpong();
1943 [] T_next.timeout {
1944 f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctx[next_req_ctx].imsi, g_restart_ctr,
1945 ctx[next_req_ctx].teid, ctx[next_req_ctx].teic, ctx[next_req_ctx].nsapi,
1946 ctx[next_req_ctx].eua, ctx[next_req_ctx].apn, g_sgsn_ip_c, g_sgsn_ip_u,
1947 ctx[next_req_ctx].msisdn, ctx[next_req_ctx].pco_req, ctx[next_req_ctx].ratType,
1948 ctx[next_req_ctx].uli));
1949 next_req_ctx := next_req_ctx + 1;
1950 if (next_req_ctx < num_ctx) {
1951 T_next.start;
1952 }
1953 repeat;
1954 }
1955 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ?)) -> value udc {
1956 teic := oct2int(udc.gtpc.teid);
1957 if (not match(teic, (1 .. num_ctx))) {
1958 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
1959 "Rx Unexpected TEIC");
1960 }
1961 idx := teic - 1;
1962 f_handle_create_req(ctx[idx], udc);
1963 rx_resp_ctx := rx_resp_ctx + 1;
1964
1965 dns1_addr := f_PCO_extract_proto(ctx[idx].pco_neg, '000d'O);
1966 saddr := ctx[idx].eua.endUserAddress.endUserAddressIPv4.ipv4_address;
1967 f_send_gtpu(ctx[idx], f_gen_icmpv4_echo(saddr, dns1_addr));
1968 repeat;
1969 }
1970 [] GTPU.receive(tr_GTPU_GPDU(g_peer_u, ?)) -> value udu {
1971 var octetstring gpdu := udu.gtpu.gtpu_IEs.g_PDU_IEs.data;
1972 var IPv4_packet ip4 := f_IPv4_dec(gpdu);
1973 if (ip4.header.ver != 4) {
1974 repeat;
1975 }
1976 var PDU_ICMP icmp4 := f_dec_PDU_ICMP(ip4.payload);
1977 if (not match(icmp4, (tr_ICMPv4_ERP, tr_ICMPv4_DU))) {
1978 repeat;
1979 }
1980 rx_pong := rx_pong + 1;
1981 if (rx_pong < num_ctx) {
1982 repeat;
1983 }
1984 setverdict(pass);
1985 }
1986 [] GTPC.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPC"); }
1987 [] GTPU.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPU"); }
1988 }
1989
1990 /* Let's close them now: */
1991 next_req_ctx := 0;
1992 rx_resp_ctx := 0;
1993 T_next.start;
1994 alt {
Pau Espin Pedrol45d57022022-03-08 13:49:02 +01001995 [Gx_PROC.checkstate("Connected")] as_DIA_CCR(TERMINATION_REQUEST) { repeat; }
Pau Espin Pedrol68c2af52022-02-25 11:56:17 +01001996 [] pingpong();
1997 [] T_next.timeout {
1998 f_send_gtpc(ts_GTPC_DeletePDP(g_peer_c, g_c_seq_nr, ctx[next_req_ctx].teic_remote, ctx[next_req_ctx].nsapi, '1'B));
1999 next_req_ctx := next_req_ctx + 1;
2000 if (next_req_ctx < num_ctx) {
2001 T_next.start;
2002 }
2003 repeat;
2004 }
2005 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, ?)) -> value udc {
2006 teic := oct2int(udc.gtpc.teid);
2007 if (not match(teic, (1 .. num_ctx))) {
2008 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2009 "Rx Unexpected TEIC");
2010 }
2011 rx_resp_ctx := rx_resp_ctx + 1;
2012 if (rx_resp_ctx < num_ctx) {
2013 repeat;
2014 }
2015 setverdict(pass);
2016 }
2017 [] GTPC.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPC"); }
2018 [] GTPU.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPU"); }
2019 }
2020 T_next.stop;
2021
2022 T_default.stop;
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01002023 f_shutdown_helper();
Pau Espin Pedrol68c2af52022-02-25 11:56:17 +01002024 }
2025
Pau Espin Pedrolbfea8352022-02-28 12:11:26 +01002026 /* Test callocation of PDP contexts until reaching addr pool exhaustion */
2027 type record of OCT4 TEIClist;
2028 testcase TC_addr_pool_exhaustion() runs on GT_CT {
2029 var Gtp1cUnitdata udc;
2030 var Gtp1uUnitdata udu;
2031 var PdpContext ctx;
2032 timer T_next := 0.005;
2033 var integer next_req_ctx := 0;
2034 var integer rx_resp_ctx := 0;
2035 var integer num_ctx;
2036 var boolean cont_req := true;
2037 var CreatePDPContextResponse cpr;
2038 var TEIClist teic_list := {};
2039 var integer teic;
2040
2041 f_init();
2042
2043 T_default.start(120.0);
2044
2045 T_next.start;
2046 alt {
Pau Espin Pedrol45d57022022-03-08 13:49:02 +01002047 [Gx_PROC.checkstate("Connected")] as_DIA_CCR(INITIAL_REQUEST) { repeat; }
Pau Espin Pedrolbfea8352022-02-28 12:11:26 +01002048 [] pingpong();
2049 [] T_next.timeout {
2050 if (cont_req) {
2051 if (next_req_ctx - rx_resp_ctx < 100) { /* if we have too many in progress, wait a bit to continue */
2052 ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), f_rnd_msisdn('1234'O), c_ApnInternet, valueof(t_EuaIPv4Dyn)));
2053 ctx.nsapi := '0001'B;
2054 ctx.teic := int2oct(next_req_ctx+1, 4); /* +1: skip TEIC=0 */
2055 ctx.teid := int2oct(next_req_ctx+1, 4); /* +1: skip TEID=0 */
2056 f_send_gtpc(ts_GTPC_CreatePDP(g_peer_c, g_c_seq_nr, ctx.imsi, g_restart_ctr,
2057 ctx.teid, ctx.teic, ctx.nsapi,
2058 ctx.eua, ctx.apn, g_sgsn_ip_c, g_sgsn_ip_u,
2059 ctx.msisdn, ctx.pco_req, ctx.ratType,
2060 ctx.uli));
2061 next_req_ctx := next_req_ctx + 1;
2062 }
2063 T_next.start;
2064 }
2065 repeat;
2066 }
2067 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, createPDPContextResponse, ?)) -> value udc {
2068 cpr := udc.gtpc.gtpc_pdu.createPDPContextResponse;
2069
2070 if (cpr.cause.causevalue == '80'O) {
2071 teic_list := teic_list & {cpr.teidControlPlane.teidControlPlane};
2072 } else {
2073 if (cont_req == true) {
2074 num_ctx := rx_resp_ctx;
2075 log("Successfully created ", num_ctx, " PDP contexts before exhausting the pool");
2076 setverdict(pass);
2077 }
2078 cont_req := false;
2079 }
2080 rx_resp_ctx := rx_resp_ctx + 1;
2081 if (not cont_req and next_req_ctx == rx_resp_ctx) {
2082 break;
2083 } else {
2084 repeat;
2085 }
2086 }
2087 [] GTPC.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPC"); }
2088 [] GTPU.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPU"); }
2089 }
2090
2091 /* Let's close them now: */
2092 next_req_ctx := 0;
2093 rx_resp_ctx := 0;
2094 T_next.start;
2095 alt {
Pau Espin Pedrol45d57022022-03-08 13:49:02 +01002096 [Gx_PROC.checkstate("Connected")] as_DIA_CCR(TERMINATION_REQUEST) { repeat; }
Pau Espin Pedrolbfea8352022-02-28 12:11:26 +01002097 [] pingpong();
2098 [] T_next.timeout {
2099 f_send_gtpc(ts_GTPC_DeletePDP(g_peer_c, g_c_seq_nr, teic_list[next_req_ctx], '0001'B, '1'B));
2100 next_req_ctx := next_req_ctx + 1;
2101 if (next_req_ctx < num_ctx) {
2102 T_next.start;
2103 }
2104 repeat;
2105 }
2106 [] GTPC.receive(tr_GTPC_MsgType(g_peer_c, deletePDPContextResponse, ?)) -> value udc {
2107 teic := oct2int(udc.gtpc.teid);
2108 if (not match(teic, (1 .. num_ctx))) {
2109 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
2110 "Rx Unexpected TEIC");
2111 }
2112 rx_resp_ctx := rx_resp_ctx + 1;
2113 if (rx_resp_ctx < num_ctx) {
2114 repeat;
2115 }
2116 setverdict(pass);
2117 }
2118 [] GTPC.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPC"); }
2119 [] GTPU.receive { Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Rx Unexpected GTPU"); }
2120 }
2121 T_next.stop;
2122
2123 T_default.stop;
Pau Espin Pedrolc441ce02022-03-07 14:35:45 +01002124 f_shutdown_helper();
Pau Espin Pedrolbfea8352022-02-28 12:11:26 +01002125 }
2126
Harald Welte94ade362017-08-04 00:36:55 +02002127 control {
Harald Welteed7a1772017-08-09 20:26:20 +02002128 execute(TC_pdp4_act_deact());
2129 execute(TC_pdp4_act_deact_ipcp());
Harald Weltef8298542019-04-10 10:15:28 +02002130 execute(TC_pdp4_act_deact_ipcp_pap_broken());
Harald Welteed7a1772017-08-09 20:26:20 +02002131 execute(TC_pdp4_act_deact_pcodns());
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01002132 execute(TC_pdp4_act_deact_gtpu_access());
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01002133 execute(TC_pdp4_act_deact_gtpu_access_wrong_saddr());
2134 execute(TC_pdp4_act_deact_gtpu_access_ipv6_apn4());
Stefan Sperlingc479e4f2018-04-03 19:34:16 +02002135 execute(TC_pdp4_clients_interact_with_txseq());
2136 execute(TC_pdp4_clients_interact_without_txseq());
Philipp Maier33e52612018-05-30 17:22:02 +02002137 execute(TC_pdp4_act_deact_with_single_dns());
2138 execute(TC_pdp4_act_deact_with_separate_dns());
Pau Espin Pedrolcd326c52022-02-14 18:57:43 +01002139 execute(TC_pdp4_act_update_teic());
2140 execute(TC_pdp4_act_update_teid());
Harald Welteed7a1772017-08-09 20:26:20 +02002141
2142 execute(TC_pdp6_act_deact());
2143 execute(TC_pdp6_act_deact_pcodns());
2144 execute(TC_pdp6_act_deact_icmp6());
Pau Espin Pedrol3d9338f2018-01-29 20:42:54 +01002145 execute(TC_pdp6_act_deact_gtpu_access());
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01002146 execute(TC_pdp6_act_deact_gtpu_access_wrong_ll_saddr());
2147 execute(TC_pdp6_act_deact_gtpu_access_wrong_global_saddr());
2148 execute(TC_pdp6_act_deact_gtpu_access_ipv4_apn6());
Pau Espin Pedrol6c7285d2018-01-30 17:20:22 +01002149 execute(TC_pdp6_clients_interact());
Harald Weltedca80052017-08-13 20:01:38 +02002150
Oliver Smithee6a0882019-03-08 11:05:46 +01002151 execute(TC_pdp46_act_deact());
2152 execute(TC_pdp46_act_deact_ipcp());
2153 execute(TC_pdp46_act_deact_icmp6());
2154 execute(TC_pdp46_act_deact_pcodns4());
2155 execute(TC_pdp46_act_deact_pcodns6());
2156 execute(TC_pdp46_act_deact_gtpu_access());
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01002157 execute(TC_pdp46_act_deact_gtpu_access_wrong_saddr_ipv4());
Pau Espin Pedrolc6ac6952022-02-14 11:19:23 +01002158 execute(TC_pdp46_act_deact_gtpu_access_wrong_ll_saddr_ipv6());
Pau Espin Pedrolc8c03412022-02-11 13:39:26 +01002159 execute(TC_pdp46_act_deact_gtpu_access_wrong_global_saddr_ipv6());
Oliver Smithee6a0882019-03-08 11:05:46 +01002160 execute(TC_pdp46_clients_interact());
Pau Espin Pedrol22d597f2019-08-21 16:16:58 +02002161 execute(TC_pdp46_act_deact_apn4());
Oliver Smithee6a0882019-03-08 11:05:46 +01002162
Harald Weltedca80052017-08-13 20:01:38 +02002163 execute(TC_echo_req_resp());
Pau Espin Pedrol480e67f2022-02-09 16:37:47 +01002164 execute(TC_echo_req_resp_gtpu());
Pau Espin Pedrolfa1ca022019-08-23 18:58:53 +02002165 execute(TC_pdp_act2_recovery());
Pau Espin Pedrol9a5f42f2019-05-27 20:04:35 +02002166 execute(TC_act_deact_retrans_duplicate());
Pau Espin Pedrol6916ec42019-08-23 16:15:07 +02002167
Pau Espin Pedrol6f319f92020-01-03 20:18:57 +01002168 execute(TC_pdp_act_restart_ctr_echo());
Pau Espin Pedrol68c2af52022-02-25 11:56:17 +01002169
2170 execute(TC_lots_of_concurrent_pdp_ctx());
Pau Espin Pedrolbfea8352022-02-28 12:11:26 +01002171 /* Keep at the end, crashes older osmo-ggsn versions (OS#5469): */
2172 execute(TC_addr_pool_exhaustion());
Harald Welte94ade362017-08-04 00:36:55 +02002173 }
Harald Welte379d45a2017-08-03 09:55:15 +02002174}