daniel has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-sigtran/+/42064?usp=email )


Change subject: tcap_as_loadshare: Fix asp selection if no tcap-range was found
......................................................................

tcap_as_loadshare: Fix asp selection if no tcap-range was found

Keep doing loadshare round-robin style, but select only active asps that
have tcap enabled in the config.

Related: SYS#5423
Change-Id: I07e77548ecb75df9227487901b75018261bd1232
---
M src/ss7_as.h
M src/tcap_as_loadshare.c
2 files changed, 12 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran 
refs/changes/64/42064/1

diff --git a/src/ss7_as.h b/src/ss7_as.h
index 50df338..252e863 100644
--- a/src/ss7_as.h
+++ b/src/ss7_as.h
@@ -159,6 +159,7 @@
                        struct {
                                bool enabled;
                                unsigned int timeout_s;
+                               uint8_t last_asp_idx_sent;
                        } tcap;
 #endif /* WITH_TCAP_LOADSHARING */
                } loadshare;
diff --git a/src/tcap_as_loadshare.c b/src/tcap_as_loadshare.c
index 623bd3b..d1daaeb 100644
--- a/src/tcap_as_loadshare.c
+++ b/src/tcap_as_loadshare.c
@@ -230,15 +230,19 @@

 static struct osmo_ss7_asp *find_asp_no_tcap_range(struct osmo_ss7_as *as)
 {
-       struct osmo_ss7_asp *asp = NULL;
+       struct osmo_ss7_asp *asp;
+       unsigned int i;
+       unsigned int first_idx;

-       for (int i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
+       first_idx = (as->cfg.loadshare.tcap.last_asp_idx_sent + 1) % 
ARRAY_SIZE(as->cfg.asps);
+       i = first_idx;
+       do {
                asp = as->cfg.asps[i];
-               if (!asp)
-                       continue;
-               if (!asp->tcap.enabled)
-                       return asp;
-       }
+               if (asp && osmo_ss7_asp_active(asp) && asp->tcap.enabled)
+                       break;
+               i = (i + 1) % ARRAY_SIZE(as->cfg.asps);
+       } while (i != first_idx);
+       as->cfg.loadshare.tcap.last_asp_idx_sent = i;

        return asp;
 }

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/42064?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I07e77548ecb75df9227487901b75018261bd1232
Gerrit-Change-Number: 42064
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <[email protected]>

Reply via email to