diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2019-11-29 14:19:41 +0100 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2020-04-30 19:22:24 +0200 |
commit | af748923bd23c1d02a76ef23653a7ea1ec64ed23 (patch) | |
tree | e819d44e6240b6037f4f754ca17993b4718e55f8 | |
parent | 76328bdc9165ef7355528c86d655d3b5086607d6 (diff) |
gsup_server: send routing error back to the correct peer
If a peer attempts to add a route to an ipa-name that we already have in the
routing system, don't send the routing error to the peer that already has the
name, but to the peer that attempts to re-use it and would cause the collision.
This is fixing a situation where for example a locally attached MSC has name
'MSC-1', and a remote site is proxying GSUP here for a remote MSC that also has
the name 'MSC-1'. Send the routing error back to the proxy, not local 'MSC-1'.
Change-Id: Icafaedc11b5925149d338bdcb987ae985a7323d6
-rw-r--r-- | src/gsup_server.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/gsup_server.c b/src/gsup_server.c index 15d2f83..a5d496e 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -65,19 +65,30 @@ int osmo_gsup_conn_send(struct osmo_gsup_conn *conn, struct msgb *msg) static void gsup_server_send_req_response(struct osmo_gsup_req *req, struct osmo_gsup_message *response) { struct osmo_gsup_server *server = req->cb_data; + struct osmo_cni_peer_id *routing; struct osmo_gsup_conn *conn = NULL; struct msgb *msg = osmo_gsup_msgb_alloc("GSUP Tx"); int rc; - switch (req->source_name.type) { + if (response->message_type == OSMO_GSUP_MSGT_ROUTING_ERROR + && !osmo_cni_peer_id_is_empty(&req->via_proxy)) { + /* If a routing error occured, we need to route back via the immediate sending peer, not via the + * intended final recipient -- because one source of routing errors is a duplicate name for a recipient. + * If we resolve to req->source_name, we may send to a completely unrelated recipient. */ + routing = &req->via_proxy; + } else { + routing = &req->source_name; + } + switch (routing->type) { case OSMO_CNI_PEER_ID_IPA_NAME: - conn = gsup_route_find_by_ipa_name(server, &req->source_name.ipa_name); + conn = gsup_route_find_by_ipa_name(server, &routing->ipa_name); break; default: LOG_GSUP_REQ(req, LOGL_ERROR, "GSUP peer id kind not supported: %s\n", - osmo_cni_peer_id_type_name(req->source_name.type)); + osmo_cni_peer_id_type_name(routing->type)); break; } + if (!conn) { LOG_GSUP_REQ(req, LOGL_ERROR, "GSUP client that sent this request not found, cannot respond\n"); msgb_free(msg); |