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/.
dexter gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/8054 a_reset: cleanup + remove dead code a_reset.c/h was originally developed to be used in both, bsc and msc without changes. Unfortunately no suitable library has been found for a_reset.c/h so the file ended up as duplicated code in both split brances. Eventually we decided to specialize the generalized code again, which means some of the functions needed only by osmo-bsc are removed. - Remove dead code - Fix counter number - Minor cosmetic fixes Change-Id: I8e489eb494d358d130e51cb2167929edeaa12e92 Related: OS#3103 --- M include/osmocom/msc/a_reset.h M src/libmsc/a_reset.c 2 files changed, 7 insertions(+), 81 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/54/8054/1 diff --git a/include/osmocom/msc/a_reset.h b/include/osmocom/msc/a_reset.h index cdb17c2..31b7d4a 100644 --- a/include/osmocom/msc/a_reset.h +++ b/include/osmocom/msc/a_reset.h @@ -20,21 +20,11 @@ #pragma once - - /* Reset context data (callbacks, state machine etc...) */ struct a_reset_ctx { /* FSM instance, which handles the reset procedure */ struct osmo_fsm_inst *fsm; - - /* Connection failure counter. When this counter - * reaches a certain threshold, the reset procedure - * will be triggered */ - int conn_loss_counter; - - /* A human readable name to display in the logs */ - char name[256]; /* Callback function to be called when a connection * failure is detected and a rest must occur */ @@ -48,17 +38,8 @@ struct a_reset_ctx *a_reset_alloc(const void *ctx, const char *name, void *cb, void *priv, bool already_connected); -/* Tear down state machine */ -void a_reset_free(struct a_reset_ctx *reset); - /* Confirm that we sucessfully received a reset acknowlege message */ void a_reset_ack_confirm(struct a_reset_ctx *reset); - -/* Report a failed connection */ -void a_reset_conn_fail(struct a_reset_ctx *reset); - -/* Report a successful connection */ -void a_reset_conn_success(struct a_reset_ctx *reset); /* Check if we have a connection to a specified msc */ bool a_reset_conn_ready(struct a_reset_ctx *reset); diff --git a/src/libmsc/a_reset.c b/src/libmsc/a_reset.c index 701066f..5629fbe 100644 --- a/src/libmsc/a_reset.c +++ b/src/libmsc/a_reset.c @@ -29,8 +29,7 @@ #include <osmocom/msc/a_reset.h> #define RESET_RESEND_INTERVAL 2 /* sec */ -#define RESET_RESEND_TIMER_NO 1234 /* FIXME: dig out the real timer number */ -#define BAD_CONNECTION_THRESOLD 3 /* connection failures */ +#define RESET_RESEND_TIMER_NO 16/* See also 3GPP TS 48.008 Chapter 3.1.4.1.3.2 */ enum fsm_states { ST_DISC, /* Disconnected from remote end */ @@ -39,14 +38,10 @@ enum fsm_evt { EV_RESET_ACK, /* got reset acknowlegement from remote end */ - EV_N_DISCONNECT, /* lost a connection */ - EV_N_CONNECT, /* made a successful connection */ }; static const struct value_string fsm_event_names[] = { OSMO_VALUE_STRING(EV_RESET_ACK), - OSMO_VALUE_STRING(EV_N_DISCONNECT), - OSMO_VALUE_STRING(EV_N_CONNECT), {0, NULL} }; @@ -58,7 +53,6 @@ OSMO_ASSERT(reset->fsm); LOGPFSML(reset->fsm, LOGL_NOTICE, "SIGTRAN connection succeded.\n"); - reset->conn_loss_counter = 0; osmo_fsm_inst_state_chg(fi, ST_CONN, 0, 0); } @@ -67,19 +61,8 @@ { struct a_reset_ctx *reset = (struct a_reset_ctx *)data; OSMO_ASSERT(reset); - - switch (event) { - case EV_N_DISCONNECT: - if (reset->conn_loss_counter >= BAD_CONNECTION_THRESOLD) { - LOGPFSML(reset->fsm, LOGL_NOTICE, "SIGTRAN connection down, reconnecting...\n"); - osmo_fsm_inst_state_chg(fi, ST_DISC, RESET_RESEND_INTERVAL, RESET_RESEND_TIMER_NO); - } else - reset->conn_loss_counter++; - break; - case EV_N_CONNECT: - reset->conn_loss_counter = 0; - break; - } + OSMO_ASSERT(reset->fsm); + LOGPFSML(reset->fsm, LOGL_NOTICE, "SIGTRAN connection (already) succeded.\n"); } /* Timer callback to retransmit the reset signal */ @@ -99,13 +82,13 @@ static struct osmo_fsm_state fsm_states[] = { [ST_DISC] = { .in_event_mask = (1 << EV_RESET_ACK), - .out_state_mask = (1 << ST_DISC) | (1 << ST_CONN), + .out_state_mask = (1 << ST_CONN), .name = "DISC", .action = fsm_disc_cb, }, [ST_CONN] = { - .in_event_mask = (1 << EV_N_DISCONNECT) | (1 << EV_N_CONNECT), - .out_state_mask = (1 << ST_DISC) | (1 << ST_CONN), + .in_event_mask = (1 << EV_RESET_ACK), + .out_state_mask = 0, .name = "CONN", .action = fsm_conn_cb, }, @@ -138,7 +121,6 @@ OSMO_ASSERT(reset); reset->priv = priv; reset->cb = cb; - reset->conn_loss_counter = 0; reset->fsm = osmo_fsm_inst_alloc(&fsm, NULL, NULL, LOGL_DEBUG, name); OSMO_ASSERT(reset->fsm); reset->fsm->priv = reset; @@ -154,19 +136,6 @@ return reset; } -/* Tear down state machine */ -void a_reset_free(struct a_reset_ctx *reset) -{ - OSMO_ASSERT(reset); - OSMO_ASSERT(reset->fsm); - - osmo_fsm_inst_free(reset->fsm); - reset->fsm = NULL; - - memset(reset, 0, sizeof(*reset)); - talloc_free(reset); -} - /* Confirm that we sucessfully received a reset acknowlege message */ void a_reset_ack_confirm(struct a_reset_ctx *reset) { @@ -176,31 +145,7 @@ osmo_fsm_inst_dispatch(reset->fsm, EV_RESET_ACK, reset); } -/* Report a failed connection */ -void a_reset_conn_fail(struct a_reset_ctx *reset) -{ - /* If no reset context is supplied, just drop the info */ - if (!reset) - return; - - OSMO_ASSERT(reset->fsm); - - osmo_fsm_inst_dispatch(reset->fsm, EV_N_DISCONNECT, reset); -} - -/* Report a successful connection */ -void a_reset_conn_success(struct a_reset_ctx *reset) -{ - /* If no reset context is supplied, just drop the info */ - if (!reset) - return; - - OSMO_ASSERT(reset->fsm); - - osmo_fsm_inst_dispatch(reset->fsm, EV_N_CONNECT, reset); -} - -/* Check if we have a connection to a specified msc */ +/* Check if we have a connection to a specified bsc */ bool a_reset_conn_ready(struct a_reset_ctx *reset) { /* If no reset context is supplied, we assume that -- To view, visit https://gerrit.osmocom.org/8054 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8e489eb494d358d130e51cb2167929edeaa12e92 Gerrit-PatchSet: 1 Gerrit-Project: osmo-msc Gerrit-Branch: master Gerrit-Owner: dexter <pmaier at sysmocom.de>