pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43733?usp=email )


Change subject: GTPv2_Emulation: Fix SeqTable entries never reused after 
unregister
......................................................................

GTPv2_Emulation: Fix SeqTable entries never reused after unregister

Using the "seq := -" during unregister don't set back the values to
"unbound" if already set; the values stay the same.
As a result, entries being used couldn't be reused afterwards, which
could end up in running out of free entries.

Change-Id: I8d4d8f0de6fb3253d5876ebb9724750869ad5e06
---
M library/GTPv2_Emulation.ttcn
1 file changed, 15 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/33/43733/1

diff --git a/library/GTPv2_Emulation.ttcn b/library/GTPv2_Emulation.ttcn
index 7ef5283..75e5cd5 100644
--- a/library/GTPv2_Emulation.ttcn
+++ b/library/GTPv2_Emulation.ttcn
@@ -178,10 +178,20 @@
        testcase.stop("No Space in TidTable for ", teic);
 }

+private function f_seq_tbl_init() runs on GTPv2_Emulation_CT {
+       var integer i;
+       for (i := 0; i < sizeof(SeqTable); i := i+1) {
+               SeqTable[i] := {
+                       seq := '000000'O,
+                       vc_conn := null
+               }
+       }
+}
+
 private function f_seq_tbl_add(OCT3 seq, GTP2_ConnHdlr vc_conn) runs on 
GTPv2_Emulation_CT {
        var integer i;
        for (i := 0; i < sizeof(SeqTable); i := i+1) {
-               if (not isbound(SeqTable[i].seq)) {
+               if (SeqTable[i].vc_conn == null) {
                        SeqTable[i].seq := seq;
                        SeqTable[i].vc_conn := vc_conn;
                        return;
@@ -193,9 +203,9 @@
 private function f_seq_tbl_del(OCT3 seq) runs on GTPv2_Emulation_CT {
        var integer i;
        for (i := 0; i < sizeof(SeqTable); i := i+1) {
-               if (isbound(SeqTable[i].seq) and SeqTable[i].seq == seq) {
+               if (SeqTable[i].vc_conn != null and SeqTable[i].seq == seq) {
                        SeqTable[i] := {
-                               seq := -,
+                               seq := '000000'O,
                                vc_conn := null
                        }
                }
@@ -414,6 +424,8 @@
 private function f_init(Gtp2EmulationCfg cfg) runs on GTPv2_Emulation_CT {
        var Result res;

+       f_seq_tbl_init();
+
        map(self:GTP2C, system:GTP2C);
        res := GTPv2_CodecPort_CtrlFunct.f_IPL4_listen(GTP2C, cfg.gtpc_bind_ip,
                                                     cfg.gtpc_bind_port, 
{udp:={}});

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43733?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I8d4d8f0de6fb3253d5876ebb9724750869ad5e06
Gerrit-Change-Number: 43733
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to