From 33e5261154f12e21321c8090c4fd276295066d45 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Wed, 30 May 2018 17:22:02 +0200 Subject: GGSN_Tests: test what happens when PCO contains only one DNS entry When the protocol configuration options (PCO) contain an IPCP container then lists only one one DNS server (normally there are two included, a primary and a secondary). Than the parser in osmo-ggsn runs into an endles loop. This testcase tries to provoke this behavior by sending PDP CONTEXT ACTIVATE messages with PCO that contain only a single DNS entry per IPCP container. The hanging of osmo-ggsn is already fixed (see Depends). However when Primary and Secondary DNS are in separate IPCP containers, then only the first IPCP container is parsed (see also OS#3381) Change-Id: I71761e1f9db7ceac3c3df43d2e539f8c8d53c4fc Depends: osmo-msc Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 Closes: OS#3288 Related: OS#3381 --- ggsn_tests/GGSN_Tests.ttcn | 82 +++++++++++++++++++++++++++++++++++++++++ ggsn_tests/expected-results.xml | 9 ++++- library/GTP_Templates.ttcn | 37 +++++++++++++++++++ 3 files changed, 127 insertions(+), 1 deletion(-) diff --git a/ggsn_tests/GGSN_Tests.ttcn b/ggsn_tests/GGSN_Tests.ttcn index d0996810..97abc4d7 100644 --- a/ggsn_tests/GGSN_Tests.ttcn +++ b/ggsn_tests/GGSN_Tests.ttcn @@ -932,6 +932,86 @@ module GGSN_Tests { T_default.stop; } + /* Test if the parser can cope with PCO that only contain either a + * single primary DNS or a secondary DNS. */ + testcase TC_pdp4_act_deact_with_single_dns() runs on GT_CT { + + /* Note: an unpatched osmo-ggsn version will enter an endless-loop when + * the test is executed. + * see also: Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */ + + f_init(); + var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); + 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 octetstring pco_neg_dns; + var octetstring pco_neg_dns_expected; + + /* PCO with primary DNS only */ + ctx.pco_req := valueof(ts_PCO_IPv4_PRI_DNS_IPCP); + f_pdp_ctx_act(ctx); + pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1); + pco_neg_dns_expected := '0200000A8106'O & ggsn_ip4_dns1 + /* Note: The prepended hex bytes encode the following information: + * 0x02 = Configuration ACK + * 0x00 = Identifier + * 0x000a = Length + * 0x81 = Type (Primary DNS Server Address) + * 0x06 = Length + * (4 byte IP-Address appended) */ + if (not match(pco_neg_dns, pco_neg_dns_expected)) { + setverdict(fail, "Primary DNS IPv4 PCO option not found"); + } + f_pdp_ctx_del(ctx, '1'B); + + /* PCO with secondary DNS only */ + ctx.pco_req := valueof(ts_PCO_IPv4_SEC_DNS_IPCP); + f_pdp_ctx_act(ctx); + pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1); + pco_neg_dns_expected := '0200000A8306'O & ggsn_ip4_dns2 + if (not match(pco_neg_dns, pco_neg_dns_expected)) { + setverdict(fail, "Secondary DNS IPv4 PCO option not found"); + } + f_pdp_ctx_del(ctx, '1'B); + } + + /* Test if the parser can cope with PCO that contains primary and secondary DNS in a separate IPCP container. + * Note: an unpatched osmo-ggsn version will enter an endless-loop when the test is run + * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288. */ + testcase TC_pdp4_act_deact_with_separate_dns() runs on GT_CT { + + /* Note: an unpatched osmo-ggsn version will enter an endless-loop when + * the test is executed. + * see also: Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */ + + f_init(); + var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn))); + 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 octetstring pco_neg_dns; + var octetstring pco_neg_dns_expected; + + ctx.pco_req := valueof(ts_PCO_IPv4_SEPARATE_DNS_IPCP); + f_pdp_ctx_act(ctx); + + /* Check if primary DNS is contained */ + pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1); + pco_neg_dns_expected := '0200000A8106'O & ggsn_ip4_dns1 + if (not match(pco_neg_dns, pco_neg_dns_expected)) { + setverdict(fail, "Primary DNS IPv4 PCO option not found"); + } + f_pdp_ctx_del(ctx, '1'B); + + /* Check if secondary DNS is contained */ + /* Note: this check fill fail due to a bug in osmo-ggsn, see also OS#3381 */ + pco_neg_dns := f_PCO_extract_proto(ctx.pco_neg, '8021'O, 1); + pco_neg_dns_expected := '0200000A8306'O & ggsn_ip4_dns2 + if (not match(pco_neg_dns, pco_neg_dns_expected)) { + setverdict(fail, "Secondary DNS IPv4 PCO option not found"); + } + f_pdp_ctx_del(ctx, '1'B); + } + control { execute(TC_pdp4_act_deact()); execute(TC_pdp4_act_deact_ipcp()); @@ -939,6 +1019,8 @@ module GGSN_Tests { execute(TC_pdp4_act_deact_gtpu_access()); execute(TC_pdp4_clients_interact_with_txseq()); execute(TC_pdp4_clients_interact_without_txseq()); + execute(TC_pdp4_act_deact_with_single_dns()); + execute(TC_pdp4_act_deact_with_separate_dns()); execute(TC_pdp6_act_deact()); execute(TC_pdp6_act_deact_pcodns()); diff --git a/ggsn_tests/expected-results.xml b/ggsn_tests/expected-results.xml index 1e5da384..383ea397 100644 --- a/ggsn_tests/expected-results.xml +++ b/ggsn_tests/expected-results.xml @@ -1,10 +1,17 @@ - + + + + Secondary DNS IPv4 PCO option not found + GGSN_Tests.ttcn:MASKED GGSN_Tests control part + GGSN_Tests.ttcn:MASKED TC_pdp4_act_deact_with_separate_dns testcase + + diff --git a/library/GTP_Templates.ttcn b/library/GTP_Templates.ttcn index 44ec4391..a222b2ef 100644 --- a/library/GTP_Templates.ttcn +++ b/library/GTP_Templates.ttcn @@ -400,6 +400,36 @@ module GTP_Templates { } } + template ProtConfigOptions ts_PCO_IPv4_PRI_DNS_IPCP modifies ts_PCO := { + protocols := { + /* dummy PAP entry to check if our parser can cope with a single primary DNS entry + * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */ + { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O }, + { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := + enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) } + } + } + template ProtConfigOptions ts_PCO_IPv4_SEC_DNS_IPCP modifies ts_PCO := { + protocols := { + /* dummy PAP entry to check if our parser can cope with a single secondary DNS entry + * see Change-Id Icffde89f9bc5d8fcadf6e2dd6c0b4de03440edd5 and OS#3288 */ + { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O }, + { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := + enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) } + } + } + template ProtConfigOptions ts_PCO_IPv4_SEPARATE_DNS_IPCP modifies ts_PCO := { + protocols := { + /* dummy PAP entry to check if our parser can cope with a primary and secondary DNS + * in separate IPCP containers OS#3381 */ + { protocolID := 'C023'O, lengthProtoID := 0, protoIDContents := ''O }, + { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := + enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Primary)) }, + { protocolID := '8021'O, lengthProtoID := 16, protoIDContents := + enc_IpcpPacket(valueof(ts_IPCP_ReqDNS_Secondary)) } + } + } + template ProtocolElement tr_PCO_Proto(OCT2 prot_id) := { protocolID := prot_id, lengthProtoID := ?, @@ -468,6 +498,13 @@ module GTP_Templates { ts_IPCP(LCP_Configure_Request, identifier, { tr_IPCP_PrimaryDns('00000000'O), tr_IPCP_SecondaryDns('00000000'O) }); + template IpcpPacket ts_IPCP_ReqDNS_Primary(uint8_t identifier := 0) := + ts_IPCP(LCP_Configure_Request, identifier, + { tr_IPCP_PrimaryDns('00000000'O) }); + template IpcpPacket ts_IPCP_ReqDNS_Secondary(uint8_t identifier := 0) := + ts_IPCP(LCP_Configure_Request, identifier, + { tr_IPCP_SecondaryDns('00000000'O) }); + function f_teardown_ind_IE(in template (omit) BIT1 ind) return template (omit) TearDownInd { if (istemplatekind(ind, "omit")) { return omit; -- cgit v1.2.3