octoi: Terminate connection on too high RIFO OVERFLOW rates

If we are permanently overflowing the RIFO in IP->E1 direction, the
peer clock is consistently faster than our E1 clock.  There's no smart
way to recover from this. Log an error and disconnect.

This is the opposite situation from the high RIFO UNDERFLOW situation
whose logging + disconnect handling was added in
Ie3fffa1c1c20962b40320c8cc088c140b8d64e77

Change-Id: Iecd294b0174c9a0572df3dad612cb4efbd9cde07
This commit is contained in:
Harald Welte 2022-04-20 10:48:00 +02:00
parent 6e5fc3ecde
commit c0fbd5a7b8
3 changed files with 33 additions and 11 deletions

View File

@ -13,6 +13,8 @@
#define iline_stat_set(iline, idx, add) \
osmo_stat_item_set(osmo_stat_item_group_get_item((iline)->stats, idx), add)
#define FRAMES_PER_SEC_THRESHOLD 7500
enum e1oip_line_ctr {
LINE_CTR_E1oIP_UNDERRUN,
LINE_CTR_E1oIP_SUBSTITUTED,

View File

@ -279,15 +279,25 @@ static void clnt_rx_alive_timer_cb(void *data)
}
rate = iline_ctr_get_rate_1s(st->peer->iline, LINE_CTR_E1oIP_UNDERRUN);
if (rate > 7500) {
LOGPFSML(fi, LOGL_ERROR, "More than 7500 RIFO underruns per second: "
"Your clock appears to be too fast. Disconnecting.\n");
osmo_fsm_inst_state_chg(fi, CLNT_ST_WAIT_RECONNECT, 10, 0);
osmo_fsm_inst_dispatch(fi, OCTOI_CLNT_EV_REQUEST_SERVICE, NULL);
return;
if (rate > FRAMES_PER_SEC_THRESHOLD) {
LOGPFSML(fi, LOGL_ERROR, "More than %u RIFO underruns per second: "
"Your clock appears to be too fast. Disconnecting.\n", FRAMES_PER_SEC_THRESHOLD);
goto reconnect;
}
rate = iline_ctr_get_rate_1s(st->peer->iline, LINE_CTR_E1oIP_E1T_OVERFLOW);
if (rate > FRAMES_PER_SEC_THRESHOLD) {
LOGPFSML(fi, LOGL_ERROR, "More than %u RIFO overflows per second: "
"Your clock appears to be too slow. Disconnecting.\n", FRAMES_PER_SEC_THRESHOLD);
goto reconnect;
}
osmo_timer_schedule(&st->rx_alive_timer, 3, 0);
return;
reconnect:
osmo_fsm_inst_state_chg(fi, CLNT_ST_WAIT_RECONNECT, 10, 0);
osmo_fsm_inst_dispatch(fi, OCTOI_CLNT_EV_REQUEST_SERVICE, NULL);
}

View File

@ -356,14 +356,24 @@ static void srv_rx_alive_timer_cb(void *data)
}
rate = iline_ctr_get_rate_1s(st->peer->iline, LINE_CTR_E1oIP_UNDERRUN);
if (rate > 7500) {
LOGPFSML(fi, LOGL_ERROR, "More than 7500 RIFO underruns per second: "
"Peer clock is too slow. Disconnecting.\n");
osmo_fsm_inst_term(fi, OSMO_FSM_TERM_ERROR, NULL);
return;
if (rate > FRAMES_PER_SEC_THRESHOLD) {
LOGPFSML(fi, LOGL_ERROR, "More than %u RIFO underruns per second: "
"Peer clock is too slow. Disconnecting.\n", FRAMES_PER_SEC_THRESHOLD);
goto term;
}
rate = iline_ctr_get_rate_1s(st->peer->iline, LINE_CTR_E1oIP_E1T_OVERFLOW);
if (rate > FRAMES_PER_SEC_THRESHOLD) {
LOGPFSML(fi, LOGL_ERROR, "More than %u RIFO overflows per second: "
"Peer clock is too fast. Disconnecting.\n", FRAMES_PER_SEC_THRESHOLD);
goto term;
}
osmo_timer_schedule(&st->rx_alive_timer, 3, 0);
return;
term:
osmo_fsm_inst_term(fi, OSMO_FSM_TERM_ERROR, NULL);
}
/* call-back function for every received OCTOI socket message for given peer */