summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Smith <osmith@sysmocom.de>2019-03-08 11:05:46 +0100
committerosmith <osmith@sysmocom.de>2019-03-14 09:10:45 +0000
commitee6a088f376d820262ec0813353e84b0c0943e6e (patch)
treee3bd3acfaef4b6132fced93ec3d787ee3b33e509
parent0f7429ad10cb19fd055f7a68709291de4efb2769 (diff)
ggsn: add tests to validate IPv4v6 pdp ctx
Add related templates based on 3GPP TS 29.060 Figure 37A and create tests based on existing IPv4 and v6 ones. Related: OS#2900 Change-Id: I3bab7df5caddc5c8b973c81544f954d5473ac234
-rw-r--r--ggsn_tests/GGSN_Tests.ttcn175
-rw-r--r--library/GTP_Templates.ttcn23
2 files changed, 198 insertions, 0 deletions
diff --git a/ggsn_tests/GGSN_Tests.ttcn b/ggsn_tests/GGSN_Tests.ttcn
index 3c99fd9..398aed3 100644
--- a/ggsn_tests/GGSN_Tests.ttcn
+++ b/ggsn_tests/GGSN_Tests.ttcn
@@ -257,6 +257,10 @@ module GGSN_Tests {
not match(cpr.endUserAddress, tr_EuaIPv6(?))) {
setverdict(fail);
}
+ if (match(ctx.eua, t_EuaIPv4v6(?, ?)) and
+ not match(cpr.endUserAddress, tr_EuaIPv4v6(?, ?))) {
+ setverdict(fail);
+ }
/* Check if PCO response corresponds to request */
if (ispresent(ctx.pco_req)) {
if (match(ctx.pco_req, ts_PCO_IPv4_DNS_CONT) and
@@ -697,6 +701,21 @@ module GGSN_Tests {
f_wait_icmp6(ctx, (tr_ICMPv6_ERP,tr_ICMPv6_DU));
}
+ /* create ICMPv6 router solicitation deriving link-id from PDP Context EUA */
+ function f_icmpv6_rs_for_pdp46(in PdpContext ctx) return octetstring {
+ var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address;
+ return f_gen_icmpv6_router_solicitation(interface_id);
+ }
+
+ /* generate and encode ICMPv6 neighbor solicitation for PDP Context */
+ function f_gen_icmpv6_neigh_solicit_for_pdp46(in PdpContext ctx) return octetstring {
+ var OCT16 interface_id := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address;
+ var OCT16 link_local := f_ipv6_link_local(interface_id);
+ var OCT16 daddr := f_ipv6_sol_node_mcast(link_local);
+
+ return f_gen_icmpv6_neigh_solicit(link_local, daddr, link_local);
+ }
+
/* Assert we don't receive a ICMPv4/6 echo reply (or unreachable) from GTP */
function f_wait_gtpu_fail(PdpContext ctx) runs on GT_CT {
T_default.start;
@@ -1028,6 +1047,154 @@ module GGSN_Tests {
f_pdp_ctx_del(ctx, '1'B);
}
+ /* Test IPv4v6 context activation for dynamic IPv4v6 EUA without DNS request */
+ testcase TC_pdp46_act_deact() runs on GT_CT {
+ f_init();
+ var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
+ f_pdp_ctx_act(ctx);
+ f_pdp_ctx_del(ctx, '1'B);
+ }
+
+ /* Test PDP context activation for dynamic IPv4v6 EUA with IPv4 DNS in IPCP */
+ testcase TC_pdp46_act_deact_ipcp() runs on GT_CT {
+ f_init();
+ var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
+ var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
+ var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
+ ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP);
+ f_pdp_ctx_act(ctx);
+ /* verify IPCP is at all contained */
+ if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
+ setverdict(fail, "IPCP not found in PCO");
+ }
+ /* verify IPCP contains both primary and secondary IPv4 DNS */
+ var IpcpPacket ipcp := dec_IpcpPacket(f_PCO_extract_proto(ctx.pco_neg, '8021'O));
+ if (not match(ipcp, tr_IPCP_Ack_DNS(0, ggsn_ip4_dns1, ggsn_ip4_dns2))) {
+ if (not match(ipcp, tr_IPCP_Ack_DNS(0))) {
+ setverdict(fail, "Primary/Secondary DNS PCO IPCP option not found");
+ } else {
+ setverdict(fail, "Primary/Secondary DNS PCO IPCP option found but not matching expected values");
+ }
+ }
+ f_pdp_ctx_del(ctx, '1'B);
+ }
+
+ /* Test PDP context activation for dynamic IPv4v6 EUA with IPv6 DNS in PCO and router solicitation/advertisement */
+ testcase TC_pdp46_act_deact_icmp6() runs on GT_CT {
+ f_init();
+ var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
+ ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
+ f_pdp_ctx_act(ctx);
+
+ f_send_gtpu(ctx, f_icmpv6_rs_for_pdp46(ctx));
+ f_wait_rtr_adv(ctx);
+ f_send_gtpu(ctx, f_gen_icmpv6_neigh_solicit_for_pdp46(ctx));
+
+ f_pdp_ctx_del(ctx, '1'B);
+ }
+
+ /* Test IPv4v6 context activation for dynamic IPv4v6 EUA with request of IPv4 DNS in PCO */
+ testcase TC_pdp46_act_deact_pcodns4() runs on GT_CT {
+ f_init();
+
+ var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
+ ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
+ f_pdp_ctx_act(ctx);
+
+ /* verify PCO contains both primary and secondary IPv4 DNS */
+ var OCT4 ggsn_ip4_dns1 := f_inet_addr(m_ggsn_ip4_dns1);
+ if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 1), ggsn_ip4_dns1)) {
+ setverdict(fail, "Primary DNS IPv4 PCO option not found");
+ }
+
+ var OCT4 ggsn_ip4_dns2 := f_inet_addr(m_ggsn_ip4_dns2);
+ if (not match(f_PCO_extract_proto(ctx.pco_neg, '000d'O, 2), ggsn_ip4_dns2)) {
+ setverdict(fail, "Secondary DNS IPv4 PCO option not found");
+ }
+
+ f_pdp_ctx_del(ctx, '1'B);
+ }
+
+ /* Test IPv4v6 context activation for dynamic IPv4v6 EUA with request of IPv6 DNS in PCO */
+ testcase TC_pdp46_act_deact_pcodns6() runs on GT_CT {
+ f_init();
+
+ var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
+ ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
+ f_pdp_ctx_act(ctx);
+
+ /* verify PCO contains both primary and secondary IPv6 DNS */
+ var OCT4 ggsn_ip6_dns1 := f_inet6_addr(m_ggsn_ip6_dns1);
+ if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 1), ggsn_ip6_dns1)) {
+ setverdict(fail, "Primary DNS IPv6 PCO option not found");
+ }
+
+ var OCT4 ggsn_ip6_dns2 := f_inet6_addr(m_ggsn_ip6_dns2);
+ if (not match(f_PCO_extract_proto(ctx.pco_neg, '0003'O, 2), ggsn_ip6_dns2)) {
+ setverdict(fail, "Secondary DNS IPv6 PCO option not found");
+ }
+
+ f_pdp_ctx_del(ctx, '1'B);
+ }
+
+ /* Test PDP context activation for dynamic IPv4v6 EUA.
+ Test we can send ICMPv6 ping over GTPU to DNS server. */
+ testcase TC_pdp46_act_deact_gtpu_access() runs on GT_CT {
+ f_init();
+ var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
+ ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
+ f_pdp_ctx_act(ctx);
+
+ var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O);
+
+ /* Check if we can use valid global src addr, should work */
+ var OCT4 saddr := ctx.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv4_address;
+ f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr, dns1_addr));
+ f_wait_icmp4_echo_reply(ctx);
+
+ /* Assert that packets with wrong global src addr are dropped by GGSN */
+ var OCT4 saddr_wrong := substr(saddr, 0, 3) & (saddr[3] xor4b '11'O);
+ f_send_gtpu(ctx, f_gen_icmpv4_echo(saddr_wrong, dns1_addr));
+ f_wait_gtpu_fail(ctx);
+
+ /* Send an IPv6 RA to APN4, should fail (packet dropped) */
+ var OCT16 saddr_v6 := f_inet6_addr("fde4:8dba:82e1:2000:1:2:3:4");
+ f_send_gtpu(ctx, f_gen_icmpv6_router_solicitation(saddr_v6));
+ f_wait_gtpu_fail(ctx);
+ f_pdp_ctx_del(ctx, '1'B);
+ }
+
+ /* Validate if different clients (pdp ctx) can reach one another through GGSN. */
+ testcase TC_pdp46_clients_interact() runs on GT_CT {
+ f_init();
+ var PdpContext ctxA := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
+ var PdpContext ctxB := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInet46, valueof(t_EuaIPv4Dynv6Dyn)));
+ f_pdp_ctx_act(ctxA);
+ f_send_gtpu(ctxA, f_icmpv6_rs_for_pdp46(ctxA));
+ f_wait_rtr_adv(ctxA);
+ f_send_gtpu(ctxA, f_gen_icmpv6_neigh_solicit_for_pdp46(ctxA));
+
+ f_pdp_ctx_act(ctxB);
+ f_send_gtpu(ctxB, f_icmpv6_rs_for_pdp46(ctxB));
+ f_wait_rtr_adv(ctxB);
+ f_send_gtpu(ctxB, f_gen_icmpv6_neigh_solicit_for_pdp46(ctxB));
+
+ var OCT16 addrA_ll := f_ipv6_link_local(ctxA.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
+ var OCT16 addrB_ll := f_ipv6_link_local(ctxB.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
+ var OCT16 addrA_glob := f_ipv6_global(ctxA.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
+ var OCT16 addrB_glob := f_ipv6_global(ctxB.eua.endUserAddress.endUserAddressIPv4andIPv6.ipv6_address);
+
+ /* Validate if clients can interact using ll addr. */
+ f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_ll, addrB_ll));
+ f_wait_gtpu_fail(ctxB);
+
+ /* Validate if clients can interact using global addr. */
+ f_send_gtpu(ctxA, f_gen_icmpv6_echo(addrA_glob, addrB_glob));
+ f_wait_gtpu_fail(ctxB);
+
+ f_pdp_ctx_del(ctxA, '1'B);
+ }
+
control {
execute(TC_pdp4_act_deact());
execute(TC_pdp4_act_deact_ipcp());
@@ -1044,6 +1211,14 @@ module GGSN_Tests {
execute(TC_pdp6_act_deact_gtpu_access());
execute(TC_pdp6_clients_interact());
+ execute(TC_pdp46_act_deact());
+ execute(TC_pdp46_act_deact_ipcp());
+ execute(TC_pdp46_act_deact_icmp6());
+ execute(TC_pdp46_act_deact_pcodns4());
+ execute(TC_pdp46_act_deact_pcodns6());
+ execute(TC_pdp46_act_deact_gtpu_access());
+ execute(TC_pdp46_clients_interact());
+
execute(TC_echo_req_resp());
}
}
diff --git a/library/GTP_Templates.ttcn b/library/GTP_Templates.ttcn
index 018f6da..bd39e27 100644
--- a/library/GTP_Templates.ttcn
+++ b/library/GTP_Templates.ttcn
@@ -161,6 +161,29 @@ module GTP_Templates {
}
}
+ /* 3GPP TS 29.060 Figure 37A: End User Address Information Element for IPv4v6 (both static) */
+ template EndUserAddress t_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) := {
+ type_gtpc := '80'O,
+ endUserAddress := {
+ endUserAddressIPv4andIPv6 := {
+ lengthf := 2,
+ pdp_typeorg := '0001'B,
+ spare := '1111'B,
+ pdp_typenum := '8D'O,
+ ipv4_address := ip_addr4,
+ ipv6_address := ip_addr6
+ }
+ }
+ }
+ template EndUserAddress t_EuaIPv4Dynv6Dyn := t_EuaIPv4v6(omit, omit);
+ template EndUserAddress tr_EuaIPv4v6(template OCT4 ip_addr4, template OCT16 ip_addr6) modifies t_EuaIPv4v6 := {
+ endUserAddress := {
+ endUserAddressIPv4andIPv6 := {
+ lengthf := 2+lengthof(ip_addr4)+lengthof(ip_addr6)
+ }
+ }
+ }
+
template AccessPointName ts_APN(octetstring apn) := {
type_gtpc := '83'O,
lengthf := lengthof(apn),