This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. Change subject: Add control command to expire subscriber ...................................................................... Add control command to expire subscriber It's equivalent of existing vty command: common part is extracted into shared helper function. Change-Id: I267886b7c79ed6d9c2f34a2e60d2972b7f4f4036 --- M include/osmocom/msc/vlr.h M src/libmsc/ctrl_commands.c M src/libmsc/vty_interface_layer3.c M src/libvlr/vlr.c 4 files changed, 56 insertions(+), 10 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/msc/vlr.h b/include/osmocom/msc/vlr.h index b4bb27f..0b61a59 100644 --- a/include/osmocom/msc/vlr.h +++ b/include/osmocom/msc/vlr.h @@ -279,7 +279,7 @@ /* tell the VLR that the subscriber connection is gone */ int vlr_subscr_disconnected(struct vlr_subscr *vsub); - +bool vlr_subscr_expire(struct vlr_subscr *vsub); int vlr_subscr_rx_id_resp(struct vlr_subscr *vsub, const uint8_t *mi, size_t mi_len); int vlr_subscr_rx_auth_resp(struct vlr_subscr *vsub, bool is_r99, bool is_utran, const uint8_t *res, uint8_t res_len); diff --git a/src/libmsc/ctrl_commands.c b/src/libmsc/ctrl_commands.c index c6236ed..b0625bb 100644 --- a/src/libmsc/ctrl_commands.c +++ b/src/libmsc/ctrl_commands.c @@ -59,11 +59,49 @@ } CTRL_CMD_DEFINE_RO(subscriber_list, "subscriber-list-active-v1"); +CTRL_CMD_DEFINE_WO_NOVRF(sub_expire, "subscriber-expire"); +static int set_sub_expire(struct ctrl_cmd *cmd, void *data) +{ + struct vlr_subscr *vsub; + + if (!msc_ctrl_net) { + cmd->reply = "MSC CTRL commands not initialized"; + return CTRL_CMD_ERROR; + } + + if (!msc_ctrl_net->vlr) { + cmd->reply = "VLR not initialized"; + return CTRL_CMD_ERROR; + } + + vsub = vlr_subscr_find_by_imsi(msc_ctrl_net->vlr, cmd->value); + if (!vsub) { + LOGP(DCTRL, LOGL_ERROR, "Attempt to expire unknown subscriber IMSI=%s\n", cmd->value); + cmd->reply = "IMSI unknown"; + return CTRL_CMD_ERROR; + } + + LOGP(DCTRL, LOGL_NOTICE, "Expiring subscriber IMSI=%s\n", cmd->value); + + if (vlr_subscr_expire(vsub)) + LOGP(DCTRL, LOGL_NOTICE, "VLR released subscriber %s\n", vlr_subscr_name(vsub)); + + if (vsub->use_count > 1) + LOGP(DCTRL, LOGL_NOTICE, "Subscriber %s is still in use, should be released soon\n", + vlr_subscr_name(vsub)); + + vlr_subscr_put(vsub); + + return CTRL_CMD_REPLY; +} + int msc_ctrl_cmds_install(struct gsm_network *net) { int rc = 0; msc_ctrl_net = net; rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_subscriber_list); + rc |= ctrl_cmd_install(CTRL_NODE_ROOT, &cmd_sub_expire); + return rc; } diff --git a/src/libmsc/vty_interface_layer3.c b/src/libmsc/vty_interface_layer3.c index 65ba178..c7ec586 100644 --- a/src/libmsc/vty_interface_layer3.c +++ b/src/libmsc/vty_interface_layer3.c @@ -572,12 +572,9 @@ return CMD_WARNING; } - if (vsub->lu_complete) { - vsub->lu_complete = false; - vlr_subscr_put(vsub); + if (vlr_subscr_expire(vsub)) vty_out(vty, "%% VLR released subscriber %s%s", vlr_subscr_name(vsub), VTY_NEWLINE); - } if (vsub->use_count > 1) vty_out(vty, "%% Subscriber %s is still in use," diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c index 73c3f13..f57df8e 100644 --- a/src/libvlr/vlr.c +++ b/src/libvlr/vlr.c @@ -948,17 +948,28 @@ } } +bool vlr_subscr_expire(struct vlr_subscr *vsub) +{ + if (vsub->lu_complete) { + vsub->lu_complete = false; + vlr_subscr_put(vsub); + + return true; + } + + return false; +} + int vlr_subscr_rx_imsi_detach(struct vlr_subscr *vsub) { /* paranoia: should any LU or PARQ FSMs still be running, stop them. */ vlr_subscr_cancel(vsub, GMM_CAUSE_IMPL_DETACHED); vsub->imsi_detached_flag = true; - if (vsub->lu_complete) { - vsub->lu_complete = false; - /* balancing the get from vlr_lu_compl_fsm_success() */ - vlr_subscr_put(vsub); - } + + /* balancing the get from vlr_lu_compl_fsm_success() */ + vlr_subscr_expire(vsub); + return 0; } -- To view, visit https://gerrit.osmocom.org/5598 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I267886b7c79ed6d9c2f34a2e60d2972b7f4f4036 Gerrit-PatchSet: 2 Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu> Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>