laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-e1d/+/27716 ) Change subject: RIFO: fix frame_rifo_in check on frame number wrap-around ...................................................................... RIFO: fix frame_rifo_in check on frame number wrap-around frame_rifo_in would previously return -ERANGE when a frame was written which was at the edge of the wrap-around of the frame number (because the maximum value was already across the boundary) Also: fixed some typos Change-Id: I88abfc77543d5c64b01f40944b2914e03e57d08f --- M src/octoi/e1oip.c M src/octoi/frame_rifo.c M src/octoi/frame_rifo.h 3 files changed, 12 insertions(+), 3 deletions(-) Approvals: laforge: Looks good to me, approved; Verified diff --git a/src/octoi/e1oip.c b/src/octoi/e1oip.c index 176db01..00c671d 100644 --- a/src/octoi/e1oip.c +++ b/src/octoi/e1oip.c @@ -98,7 +98,7 @@ rc = frame_fifo_out(&iline->e1o.fifo, buf[i]); if (rc < 0) { /* this situation cannot really happen: The FIFO called us that - * a certain threshold is reached, ubt now it cannot provide + * a certain threshold is reached, but now it cannot provide * frames? */ LOGPEER(iline->peer, LOGL_ERROR, "frame_fifo_out failure for frame %u/%u\n", iline->e1o.next_seq + i, i); diff --git a/src/octoi/frame_rifo.c b/src/octoi/frame_rifo.c index 0ddaae5..fbcbbfa 100644 --- a/src/octoi/frame_rifo.c +++ b/src/octoi/frame_rifo.c @@ -106,14 +106,16 @@ * \param rifo The RIFO to which we want to put (append) multiple frames * \param frame Pointer to memory containing the frame data * \param fn Absolute frame number at which to insert the frame. - * \returns 0 on success; -1 on error (overflow */ + * \returns 0 on success; -1 on error (overflow) */ int frame_rifo_in(struct frame_rifo *rifo, const uint8_t *frame, uint32_t fn) { uint32_t bucket; uint8_t *dst; - if (fn > frame_rifo_max_in_fn(rifo)) + if (fn > frame_rifo_max_in_fn(rifo) && fn < frame_rifo_min_in_fn(rifo)) + { return -ERANGE; + } bucket = bucket_for_fn(rifo, fn); dst = rifo->buf + bucket * BYTES_PER_FRAME; diff --git a/src/octoi/frame_rifo.h b/src/octoi/frame_rifo.h index 22379ac..f107537 100644 --- a/src/octoi/frame_rifo.h +++ b/src/octoi/frame_rifo.h @@ -19,6 +19,13 @@ return ff->next_out_fn + FRAMES_PER_FIFO - 1; } +/* minimum frame number we currently can store in the rifo */ +static inline uint32_t frame_rifo_min_in_fn(const struct frame_rifo *ff) +{ + return ff->next_out_fn - 1; +} + + void frame_rifo_init(struct frame_rifo *rifo); /* number of frames currently available in FIFO */ -- To view, visit https://gerrit.osmocom.org/c/osmo-e1d/+/27716 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-e1d Gerrit-Branch: laforge/rifo Gerrit-Change-Id: I88abfc77543d5c64b01f40944b2914e03e57d08f Gerrit-Change-Number: 27716 Gerrit-PatchSet: 2 Gerrit-Owner: manawyrm <osmocom.account@tbspace.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Reviewer: tnt <tnt@246tNt.com> Gerrit-MessageType: merged