NACC: delay CTRL conn socket init until it's needed

This way, we don't open a socket and do the IPA handshake in the event
the request is already cached.

Related: SYS#4909
Change-Id: Ib1ea85e1196c8b9dc40c8837ab5d4a54f2a1f2d4
This commit is contained in:
Pau Espin 2021-01-27 17:16:59 +01:00
parent 202a47886c
commit c0805e6389
1 changed files with 11 additions and 14 deletions

View File

@ -279,7 +279,7 @@ static void st_wait_resolve_rac_ci_on_enter(struct osmo_fsm_inst *fi, uint32_t p
struct gprs_rlcmac_bts *bts = ctx->ms->bts;
struct gprs_pcu *pcu = bts->pcu;
const struct osmo_cell_global_id_ps *cgi_ps;
struct ctrl_cmd *cmd;
struct ctrl_cmd *cmd = NULL;
int rc;
/* First try to find the value in the cache */
@ -295,6 +295,16 @@ static void st_wait_resolve_rac_ci_on_enter(struct osmo_fsm_inst *fi, uint32_t p
LOGPFSML(fi, LOGL_DEBUG, "No CGI-PS found in cache, resolving " NEIGH_CACHE_ENTRY_KEY_FMT "...\n",
NEIGH_CACHE_ENTRY_KEY_ARGS(&ctx->neigh_key));
rc = osmo_sock_init2_ofd(&ctx->neigh_ctrl_conn->write_queue.bfd,
AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP,
NULL, 0, pcu->vty.neigh_ctrl_addr, pcu->vty.neigh_ctrl_port,
OSMO_SOCK_F_CONNECT);
if (rc < 0) {
LOGPFSML(fi, LOGL_ERROR, "Can't connect to CTRL @ %s:%u\n",
pcu->vty.neigh_ctrl_addr, pcu->vty.neigh_ctrl_port);
goto err_term;
}
cmd = ctrl_cmd_create(ctx, CTRL_TYPE_GET);
if (!cmd) {
LOGPFSML(fi, LOGL_ERROR, "CTRL msg creation failed\n");
@ -603,11 +613,8 @@ static int nacc_fsm_ctx_talloc_destructor(struct nacc_fsm_ctx *ctx)
struct nacc_fsm_ctx *nacc_fsm_alloc(struct GprsMs* ms)
{
struct gprs_rlcmac_bts *bts = ms->bts;
struct gprs_pcu *pcu = bts->pcu;
struct nacc_fsm_ctx *ctx = talloc_zero(ms, struct nacc_fsm_ctx);
char buf[64];
int rc;
talloc_set_destructor(ctx, nacc_fsm_ctx_talloc_destructor);
@ -628,16 +635,6 @@ struct nacc_fsm_ctx *nacc_fsm_alloc(struct GprsMs* ms)
ctx->neigh_ctrl_conn->write_queue.bfd.fd = -1;
llist_add(&ctx->neigh_ctrl_conn->list_entry, &ctx->neigh_ctrl->ccon_list);
rc = osmo_sock_init2_ofd(&ctx->neigh_ctrl_conn->write_queue.bfd,
AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP,
NULL, 0, pcu->vty.neigh_ctrl_addr, pcu->vty.neigh_ctrl_port,
OSMO_SOCK_F_CONNECT);
if (rc < 0) {
LOGP(DNACC, LOGL_ERROR, "Can't connect to CTRL @ %s:%u\n",
pcu->vty.neigh_ctrl_addr, pcu->vty.neigh_ctrl_port);
goto free_ret;
}
return ctx;
free_ret:
talloc_free(ctx);