pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/29365 )
Change subject: ipa: Allow users closing lower layer tcp/ipa connections ......................................................................
ipa: Allow users closing lower layer tcp/ipa connections
This is useful for users to abort connections which are in "connecting" state, since the higher layer struct e1inp_sign_link is not provided to the user until the TCP+IPA handshake in the socket becomes fully established (sign_link_up() callback).
This is intended for osmo-bts: when something fails and may enter into SHUTDOWN state, it is desirable to close new RSL links (sockets) which are in progress to connect, while it waits for a while to complete shutdown (power ramping down, etc.).
Change-Id: Ia6418321f3b6f1f7274efd414625a4b10a09a362 --- M include/osmocom/abis/e1_input.h M src/input/ipaccess.c 2 files changed, 28 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/65/29365/1
diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h index 9c3fe56..29cc942 100644 --- a/include/osmocom/abis/e1_input.h +++ b/include/osmocom/abis/e1_input.h @@ -336,7 +336,8 @@
int e1inp_ipa_bts_rsl_connect_n(struct e1inp_line *line, const char *rem_addr, uint16_t rem_port, - uint8_t trx_id); + uint8_t trx_nr); +int e1inp_ipa_bts_rsl_close(struct e1inp_line *line, uint8_t trx_nr);
void e1inp_sign_link_destroy(struct e1inp_sign_link *link); int e1inp_line_update(struct e1inp_line *line); diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c index 07fd814..9331d07 100644 --- a/src/input/ipaccess.c +++ b/src/input/ipaccess.c @@ -1149,7 +1149,6 @@ return ret; }
- /* backwards compatibility */ int e1inp_ipa_bts_rsl_connect(struct e1inp_line *line, const char *rem_addr, uint16_t rem_port) @@ -1171,17 +1170,13 @@ return -EINVAL; }
+ /* Drop previous line */ + e1inp_ipa_bts_rsl_close(line, trx_nr); + if (!line->driver_data) line->driver_data = talloc_zero(line, struct ipaccess_line); il = line->driver_data;
- /* Drop previous line */ - if (il->ipa_cli[1 + trx_nr]) { - ipa_client_conn_close(il->ipa_cli[1 + trx_nr]); - ipa_client_conn_destroy(il->ipa_cli[1 + trx_nr]); - il->ipa_cli[1 + trx_nr] = NULL; - } - rsl_link = ipa_client_conn_create2(tall_ipa_ctx, e1inp_line_ipa_rsl_ts(line, trx_nr), E1INP_SIGN_RSL+trx_nr, @@ -1210,6 +1205,29 @@ return 0; }
+/* Close the underlaying IPA TCP socket of an RSL link */ +int e1inp_ipa_bts_rsl_close(struct e1inp_line *line, uint8_t trx_nr) +{ + struct ipaccess_line *il; + + if (E1INP_SIGN_RSL+trx_nr-1 >= NUM_E1_TS) { + LOGP(DLINP, LOGL_ERROR, "cannot close RSL BTS link: " + "trx_nr (%d) out of range\n", trx_nr); + return -EINVAL; + } + + il = line->driver_data; + if (!il) + return 0; /* Nothing to do, no lines created */ + + if (il->ipa_cli[1 + trx_nr]) { + ipa_client_conn_close(il->ipa_cli[1 + trx_nr]); + ipa_client_conn_destroy(il->ipa_cli[1 + trx_nr]); + il->ipa_cli[1 + trx_nr] = NULL; + } + return 0; +} + void e1inp_ipaccess_init(void) { tall_ipa_ctx = talloc_named_const(libosmo_abis_ctx, 1, "ipa");