fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/36152?usp=email )
Change subject: xua_accept_cb(): distinguish ASPs using different trans_proto ......................................................................
xua_accept_cb(): distinguish ASPs using different trans_proto
This fixes a problem found by TTCN-3 testcases: two ASPs can have identical socket address/port, but different transport protocols. We need to take this into account in ss7_asp_find_by_socket_addr().
Change-Id: I28aab37e8967de51ad2714543fd235d407e304c5 Related: osmo-ttcn3-hacks.git I1e2a887aa22f317783b3207494fd707d7b426439 Related: SYS#5424 --- M src/osmo_ss7_asp.c M src/osmo_ss7_xua_srv.c M src/ss7_internal.h 3 files changed, 20 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/52/36152/1
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c index f211872..5bab5ff 100644 --- a/src/osmo_ss7_asp.c +++ b/src/osmo_ss7_asp.c @@ -458,7 +458,7 @@ * \param[in] fd socket descriptor of given socket * \returns SS7 ASP in case a matching one is found; NULL otherwise */ struct osmo_ss7_asp * -ss7_asp_find_by_socket_addr(int fd) +ss7_asp_find_by_socket_addr(int fd, int trans_proto) { struct osmo_ss7_instance *inst; struct sockaddr_storage sa_l, sa_r; @@ -505,6 +505,8 @@ llist_for_each_entry(inst, &osmo_ss7_instances, list) { struct osmo_ss7_asp *asp; llist_for_each_entry(asp, &inst->asp_list, list) { + if (asp->cfg.trans_proto != trans_proto) + continue; if (asp->cfg.local.port != local_port) continue; if (asp->cfg.remote.port && asp->cfg.remote.port != remote_port) diff --git a/src/osmo_ss7_xua_srv.c b/src/osmo_ss7_xua_srv.c index 0b83b19..6da7b7a 100644 --- a/src/osmo_ss7_xua_srv.c +++ b/src/osmo_ss7_xua_srv.c @@ -101,7 +101,7 @@ return -1; }
- asp = ss7_asp_find_by_socket_addr(fd); + asp = ss7_asp_find_by_socket_addr(fd, oxs->cfg.trans_proto); if (asp) { LOGP(DLSS7, LOGL_INFO, "%s: matched connection to ASP %s\n", sock_name, asp->cfg.name); diff --git a/src/ss7_internal.h b/src/ss7_internal.h index ed4fae7..758da90 100644 --- a/src/ss7_internal.h +++ b/src/ss7_internal.h @@ -20,7 +20,7 @@ bool ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp); bool ss7_asp_is_started(const struct osmo_ss7_asp *asp); int ss7_asp_get_fd(const struct osmo_ss7_asp *asp); -struct osmo_ss7_asp *ss7_asp_find_by_socket_addr(int fd); +struct osmo_ss7_asp *ss7_asp_find_by_socket_addr(int fd, int trans_proto);
bool ss7_asp_protocol_check_trans_proto(enum osmo_ss7_asp_protocol proto, int trans_proto); int ss7_default_trans_proto_for_asp_proto(enum osmo_ss7_asp_protocol proto);