aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-02-22 17:25:25 +0100
committerStefan Sperling <ssperling@sysmocom.de>2018-02-22 17:25:25 +0100
commit251e1d698d5e947858cd68033199a178643871b0 (patch)
tree35a6dc12db26d8220004bfb266056a235ea3d988
parentcc6ed397a63df49316dde1fd5e2385ca83f51aaf (diff)
destroy hnb context from the txflush() callbackstsp/destroy_conn_with_txflush_callback
These are the osmo-iuh changes corresponding to the libosmo-netif branch 'destroy_conn_with_txflush_callback'. Change-Id: I380e9e41161cbf51b272c7f3725ccaeef625546c
-rw-r--r--include/osmocom/iuh/hnbgw.h4
-rw-r--r--src/hnbgw.c11
-rw-r--r--src/hnbgw_hnbap.c10
3 files changed, 24 insertions, 1 deletions
diff --git a/include/osmocom/iuh/hnbgw.h b/include/osmocom/iuh/hnbgw.h
index db49dc1..4e02d5f 100644
--- a/include/osmocom/iuh/hnbgw.h
+++ b/include/osmocom/iuh/hnbgw.h
@@ -101,6 +101,10 @@ struct hnb_context {
* this entire data structure is freed if the HNB sends HNB-DE-REGISTER-REQ. */
bool hnb_registered;
+ /*! True if a HNB-REGISTER-REJECT has been sent to this HNB. If this flag
+ * is set we will close the connection once its Tx queue has been flushed. */
+ bool hnb_rejected;
+
/* linked list of hnbgw_context_map */
struct llist_head map_list;
};
diff --git a/src/hnbgw.c b/src/hnbgw.c
index cd492bb..188b292 100644
--- a/src/hnbgw.c
+++ b/src/hnbgw.c
@@ -267,6 +267,15 @@ out:
return rc;
}
+static void txflushed_cb(struct osmo_stream_srv *conn, void *data)
+{
+ struct hnb_context *hnb = osmo_stream_srv_get_data(conn);
+
+ /* Close connection after sending HNB-REGISTER-REJECT and the Tx queue has been flushed. */
+ if (hnb->hnb_rejected)
+ hnb_context_release(hnb);
+}
+
struct hnb_context *hnb_context_alloc(struct hnb_gw *gw, struct osmo_stream_srv_link *link, int new_fd)
{
struct hnb_context *ctx;
@@ -284,6 +293,8 @@ struct hnb_context *hnb_context_alloc(struct hnb_gw *gw, struct osmo_stream_srv_
return NULL;
}
+ osmo_stream_srv_set_txflushed_cb(ctx->conn, txflushed_cb);
+
llist_add_tail(&ctx->list, &gw->hnb_list);
return ctx;
}
diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c
index c9a8807..207f49f 100644
--- a/src/hnbgw_hnbap.c
+++ b/src/hnbgw_hnbap.c
@@ -428,7 +428,15 @@ static int hnbgw_rx_hnb_register_req(struct hnb_context *ctx, ANY_t *in)
"MCC=%u,MNC=%u,LAC=%u,RAC=%u,SAC=%u,CID=%u from %s\n",
ctx->id.mcc, ctx->id.mnc, ctx->id.lac, ctx->id.rac, ctx->id.sac, ctx->id.cid, name);
talloc_free(name);
- return hnbgw_tx_hnb_register_rej(ctx);
+ rc = hnbgw_tx_hnb_register_rej(ctx);
+ if (rc != 0) {
+ /* The message was not queued. Clean up HNB right away. */
+ hnb_context_release(ctx);
+ } else {
+ /* Release the HNB once the message has been sent. */
+ ctx->hnb_rejected = true;
+ }
+ return rc;
}
}