manawyrm has uploaded this change for review.

View Change

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
2 files changed, 8 insertions(+), 3 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/14/27714/1
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..823df15 100644
--- a/src/octoi/frame_rifo.c
+++ b/src/octoi/frame_rifo.c
@@ -106,14 +106,19 @@
* \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))
- return -ERANGE;
+ {
+ if ( fn < rifo->next_out_fn - FRAMES_PER_FIFO )
+ {
+ return -ERANGE;
+ }
+ }

bucket = bucket_for_fn(rifo, fn);
dst = rifo->buf + bucket * BYTES_PER_FRAME;

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

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I88abfc77543d5c64b01f40944b2914e03e57d08f
Gerrit-Change-Number: 27714
Gerrit-PatchSet: 1
Gerrit-Owner: manawyrm <osmocom.account@tbspace.de>
Gerrit-MessageType: newchange