laforge has uploaded this change for review.

View Change

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
---
M src/octoi/e1oip.h
M src/octoi/octoi_clnt_fsm.c
M src/octoi/octoi_srv_fsm.c
3 files changed, 33 insertions(+), 11 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/42/27842/1
diff --git a/src/octoi/e1oip.h b/src/octoi/e1oip.h
index 54d299a..41f35cb 100644
--- a/src/octoi/e1oip.h
+++ b/src/octoi/e1oip.h
@@ -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,
diff --git a/src/octoi/octoi_clnt_fsm.c b/src/octoi/octoi_clnt_fsm.c
index a3d0518..697ff77 100644
--- a/src/octoi/octoi_clnt_fsm.c
+++ b/src/octoi/octoi_clnt_fsm.c
@@ -279,15 +279,25 @@
}

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);
}


diff --git a/src/octoi/octoi_srv_fsm.c b/src/octoi/octoi_srv_fsm.c
index 5f51003..c9fa66e 100644
--- a/src/octoi/octoi_srv_fsm.c
+++ b/src/octoi/octoi_srv_fsm.c
@@ -356,14 +356,24 @@
}

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 */

To view, visit change 27842. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: Iecd294b0174c9a0572df3dad612cb4efbd9cde07
Gerrit-Change-Number: 27842
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge@osmocom.org>
Gerrit-MessageType: newchange