Change in osmo-ttcn3-hacks[master]: ggsn: Verify that there are no duplicate PCO protocolIDs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri May 10 10:46:05 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13563 )

Change subject: ggsn: Verify that there are no duplicate PCO protocolIDs
......................................................................

ggsn: Verify that there are no duplicate PCO protocolIDs

Introduce a function to verify there's no duplicate ProtocolIDs
in the PCO returned from the GGSN.

Change-Id: I9d439dab1696196cd125f4d7113b426f1711a405
Related: OS#3914
---
M ggsn_tests/GGSN_Tests.ttcn
1 file changed, 37 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/ggsn_tests/GGSN_Tests.ttcn b/ggsn_tests/GGSN_Tests.ttcn
index 398aed3..d793d27 100644
--- a/ggsn_tests/GGSN_Tests.ttcn
+++ b/ggsn_tests/GGSN_Tests.ttcn
@@ -726,6 +726,33 @@
 		T_default.stop;
 	}
 
+	/* list of protocols where we don't accept duplicates */
+	const OCT2List protocol_ids_nodupes := { 'C021'O, 'C023'O, 'C223'O, '8021'O };
+	private function f_PCO_permits_duplicates(OCT2 id) return boolean {
+		var integer i;
+		for (i := 0; i < lengthof(protocol_ids_nodupes); i := i+1) {
+			if (id == protocol_ids_nodupes[i]) {
+				return false;
+			}
+		}
+		return true;
+	}
+
+	/* ensure that every given protocol Identifier exist only exactly once in the PCO */
+	function f_PCO_ensure_no_duplicates(ProtConfigOptions pco) {
+		var OCT2List protocol_ids := {};
+		var integer i, j;
+		for (i := 0; i < lengthof(pco.protocols); i := i+1) {
+			var OCT2 id := pco.protocols[i].protocolID;
+			for (j := 0; j < lengthof(protocol_ids); j := j+1) {
+				if (not f_PCO_permits_duplicates(id) and id == protocol_ids[j]) {
+					setverdict(fail,  "Duplicate ProtocolID ", id, " already present in ", pco.protocols);
+				}
+			}
+			protocol_ids := protocol_ids & { id };
+		}
+	}
+
 	/* Test IPv6 context activation for dynamic IPv6 EUA without request of IPv6 DNS */
 	testcase TC_pdp6_act_deact() runs on GT_CT {
 		f_init();
@@ -743,6 +770,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify PCO contains both primary and secondary 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)) {
@@ -765,6 +793,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		//f_send_gtpu(ctx, c_router_solicit);
 		//f_send_gtpu(ctx, c_neigh_solicit);
 
@@ -865,6 +894,7 @@
 		var PdpContext ctx := valueof(t_DefinePDP(f_rnd_imsi('26242'H), '1234'O, c_ApnInternet, valueof(t_EuaIPv4Dyn)));
 		ctx.pco_req := valueof(ts_PCO_IPv4_DNS_IPCP);
 		f_pdp_ctx_act(ctx);
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify IPCP is at all contained */
 		if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
 			setverdict(fail, "IPCP not found in PCO");
@@ -888,6 +918,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify PCO contains both primary and secondary 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)) {
@@ -910,6 +941,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		var OCT4 dns1_addr := f_PCO_extract_proto(ctx.pco_neg, '000d'O);
 
 		/* Check if we can use valid global src addr, should work */
@@ -986,6 +1018,7 @@
 		/* PCO with primary DNS only */
 		ctx.pco_req := valueof(ts_PCO_IPv4_PRI_DNS_IPCP);
 		f_pdp_ctx_act(ctx);
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		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:
@@ -1063,10 +1096,12 @@
 		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);
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* verify IPCP is at all contained */
 		if (not match(ctx.pco_neg, tr_PCO_Contains('8021'O))) {
 			setverdict(fail, "IPCP not found in PCO");
 		}
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* 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))) {
@@ -1101,6 +1136,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv4_DNS_CONT);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* 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)) {
@@ -1123,6 +1159,7 @@
 		ctx.pco_req := valueof(ts_PCO_IPv6_DNS);
 		f_pdp_ctx_act(ctx);
 
+		f_PCO_ensure_no_duplicates(ctx.pco_neg);
 		/* 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)) {

-- 
To view, visit https://gerrit.osmocom.org/13563
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9d439dab1696196cd125f4d7113b426f1711a405
Gerrit-Change-Number: 13563
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190510/f46af898/attachment.htm>


More information about the gerrit-log mailing list