laforge has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-sccp/+/36115?usp=email )
Change subject: ipa: Use pseudo-random number for SLS in IPA->M3UA direction
......................................................................
ipa: Use pseudo-random number for SLS in IPA->M3UA direction
In Change-Id Ice7bab997b84cfed00c7d6d780c70f4e9fac6002 we introduced
code that would make the LSB of the file descriptor be used as SLS
when passing packets from IPA in M3UA direction.
This did however not achieve sufficient entropy in real-world use cases.
In this change, we change over to allocating a pseudo-random SLS to each
IPA connection at the time it is established; We then assign that SLS
to each packet received on that IPA connection.
Change-Id: Ia4e66d660b6057338f66a47fffc8a0d32759f733
Related: SYS#6543
Closes: SYS#6802
---
M src/osmo_ss7_asp.c
M stp/stp_main.c
2 files changed, 32 insertions(+), 3 deletions(-)
Approvals:
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
dexter: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index 1f45749..f290fdb 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -803,9 +803,9 @@
msg->dst = asp;
rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL);
- /* we can use the 'fd' return value of osmo_stream_srv_get_fd() here unverified
as all we do
- * is 'roll the dice' to obtain a 4-bit SLS value. */
- return ipa_rx_msg(asp, msg, fd & 0xf);
+ /* we simply use the lower 4 bits of the asp_id, which is initialized to a pseudo-random
value upon
+ * connect */
+ return ipa_rx_msg(asp, msg, asp->asp_id & 0xf);
}
/* netif code tells us we can read something from the socket */
@@ -916,6 +916,12 @@
if (asp->cfg.trans_proto == IPPROTO_SCTP) {
rc = ss7_asp_apply_peer_primary_address(asp);
rc = ss7_asp_apply_primary_address(asp);
+ } else {
+ if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA) {
+ /* we use the lower 4 bits of the asp_id feld as SLS; let's initialize it here
from a
+ * pseudo-random value */
+ asp->asp_id = rand() & 0xf;
+ }
}
if (asp->lm && asp->lm->prim_cb) {
diff --git a/stp/stp_main.c b/stp/stp_main.c
index 01d1865..d630032 100644
--- a/stp/stp_main.c
+++ b/stp/stp_main.c
@@ -213,6 +213,8 @@
{
int rc;
+ srand(time(NULL));
+
tall_stp_ctx = talloc_named_const(NULL, 1, "osmo-stp");
msgb_talloc_ctx_init(tall_stp_ctx, 0);
osmo_init_logging2(tall_stp_ctx, &log_info);
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/36115?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: Ia4e66d660b6057338f66a47fffc8a0d32759f733
Gerrit-Change-Number: 36115
Gerrit-PatchSet: 4
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged