daniel has submitted this change. ( 
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, 13 insertions(+), 7 deletions(-)

Approvals:
  lynxis lazus: Looks good to me, approved
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve




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..5c964ce 100644
--- a/src/tcap_as_loadshare.c
+++ b/src/tcap_as_loadshare.c
@@ -230,17 +230,22 @@

 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)
+               if (asp && osmo_ss7_asp_active(asp) && asp->tcap.enabled) {
+                       as->cfg.loadshare.tcap.last_asp_idx_sent = i;
                        return asp;
-       }
+               }
+               i = (i + 1) % ARRAY_SIZE(as->cfg.asps);
+       } while (i != first_idx);

-       return asp;
+       return NULL;
 }

 static bool ssn_contains_tcap(uint8_t ssn)

--
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: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I07e77548ecb75df9227487901b75018261bd1232
Gerrit-Change-Number: 42064
Gerrit-PatchSet: 2
Gerrit-Owner: daniel <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: lynxis lazus <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to