Attention is currently required from: pespin.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29498 )
Change subject: osmux: Change order of lines to follow packet fill order
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29498
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I33feac834700d22ed06472d8971abd0567ce623b
Gerrit-Change-Number: 29498
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 28 Sep 2022 08:29:31 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29501 )
Change subject: osmux: Early return on error or batch full during osmux_replay_lost_packets()
......................................................................
osmux: Early return on error or batch full during osmux_replay_lost_packets()
If there's an error while replaying lost packets, return the error to
the caller.
If the batch is found full, early return indicating so, there's no need
to continue flow calling osmux_batch_enqueue() in osmux_batch_add()
again.
Change-Id: I62f494d2b2e7903a6683f6dea00781bb721a3d41
---
M src/osmux.c
1 file changed, 13 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/01/29501/1
diff --git a/src/osmux.c b/src/osmux.c
index bcf6e47..2a5dcc9 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -560,23 +560,24 @@
return amr_payload_len;
}
-static void osmux_replay_lost_packets(struct osmux_circuit *circuit,
+/* returns: 1 if batch is full, 0 if batch still not full, negative on error. */
+static int osmux_replay_lost_packets(struct osmux_circuit *circuit,
struct rtp_hdr *cur_rtph, int batch_factor)
{
int16_t diff;
struct msgb *last;
struct rtp_hdr *rtph;
- int i;
+ int i, rc;
/* Have we seen any RTP packet in this batch before? */
if (llist_empty(&circuit->msg_list))
- return;
+ return 0;
/* Get last RTP packet seen in this batch */
last = llist_entry(circuit->msg_list.prev, struct msgb, list);
rtph = osmo_rtp_get_hdr(last);
if (rtph == NULL)
- return;
+ return -1;
diff = ntohs(cur_rtph->sequence) - ntohs(rtph->sequence);
@@ -584,6 +585,7 @@
if (diff > 16)
diff = 16;
+ rc = 0;
/* If diff between last RTP packet seen and this one is > 1,
* then we lost several RTP packets, let's replay them.
*/
@@ -607,13 +609,15 @@
DELTA_RTP_TIMESTAMP);
/* No more room in this batch, skip padding with more clones */
- if (osmux_batch_enqueue(clone, circuit, batch_factor) != 0) {
+ rc = osmux_batch_enqueue(clone, circuit, batch_factor);
+ if (rc != 0) {
msgb_free(clone);
- break;
+ return rc;
}
LOGP(DLMUX, LOGL_ERROR, "adding cloned RTP\n");
}
+ return rc;
}
static struct osmux_circuit *
@@ -727,7 +731,9 @@
return 1;
/* Handle RTP packet loss scenario */
- osmux_replay_lost_packets(circuit, rtph, batch_factor);
+ rc = osmux_replay_lost_packets(circuit, rtph, batch_factor);
+ if (rc != 0)
+ return rc;
/* This batch is full, force batch delivery */
rc = osmux_batch_enqueue(msg, circuit, batch_factor);
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29501
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I62f494d2b2e7903a6683f6dea00781bb721a3d41
Gerrit-Change-Number: 29501
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29502 )
Change subject: osmux: assert no batch factor greater than 8 is used
......................................................................
osmux: assert no batch factor greater than 8 is used
Change-Id: Ie17a8174bc220d091cb7ff880363d22179b4f621
---
M src/osmux.c
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/02/29502/1
diff --git a/src/osmux.c b/src/osmux.c
index 2a5dcc9..9ac0a7e 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -318,7 +318,8 @@
/* Validate amount of messages per batch. The counter field of the
* osmux header is just 3 bits long, so make sure it doesn't overflow.
*/
- if (circuit->nmsgs >= batch_factor || circuit->nmsgs >= 8) {
+ OSMO_ASSERT(batch_factor <= 8);
+ if (circuit->nmsgs >= batch_factor) {
struct rtp_hdr *rtph;
rtph = osmo_rtp_get_hdr(msg);
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29502
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ie17a8174bc220d091cb7ff880363d22179b4f621
Gerrit-Change-Number: 29502
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29499 )
Change subject: cosmetic: osmux: Fix typo in comment
......................................................................
cosmetic: osmux: Fix typo in comment
Change-Id: Ieeaa5543e56a824752413dadf161329f5ea0e4e7
---
M src/osmux.c
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/99/29499/1
diff --git a/src/osmux.c b/src/osmux.c
index bd05f76..801372b 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -567,7 +567,7 @@
struct rtp_hdr *rtph;
int i;
- /* Have we see any RTP packet in this batch before? */
+ /* Have we seen any RTP packet in this batch before? */
if (llist_empty(&circuit->msg_list))
return;
@@ -597,7 +597,7 @@
memcpy(clone->data, last->data, last->len);
msgb_put(clone, last->len);
- /* The original RTP message has been already sanity check. */
+ /* The original RTP message has been already sanity checked. */
rtph = osmo_rtp_get_hdr(clone);
/* Adjust sequence number and timestamp */
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29499
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ieeaa5543e56a824752413dadf161329f5ea0e4e7
Gerrit-Change-Number: 29499
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29498 )
Change subject: osmux: Change order of lines to follow packet fill order
......................................................................
osmux: Change order of lines to follow packet fill order
The osmux header goes before in the packet, so let's move the line
checking is size before the content.
Change-Id: I33feac834700d22ed06472d8971abd0567ce623b
---
M src/osmux.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/98/29498/1
diff --git a/src/osmux.c b/src/osmux.c
index 51642ab..bd05f76 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -715,9 +715,9 @@
}
/* First check if there is room for this message in the batch */
- bytes += amr_payload_len;
if (circuit->nmsgs == 0)
bytes += sizeof(struct osmux_hdr);
+ bytes += amr_payload_len;
/* No room, sorry. You'll have to retry */
if (bytes > batch->remaining_bytes)
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29498
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I33feac834700d22ed06472d8971abd0567ce623b
Gerrit-Change-Number: 29498
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29500 )
Change subject: osmux: Unify return codes of osmux_batch_add() and osmux_batch_enqueue()
......................................................................
osmux: Unify return codes of osmux_batch_add() and osmux_batch_enqueue()
This way it's way easier to return the error to the caller, and the code
is easier to read.
Change-Id: Ib78c9b82b85c74be2c5e94dae7c212175244d5fa
---
M src/osmux.c
1 file changed, 8 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/00/29500/1
diff --git a/src/osmux.c b/src/osmux.c
index 801372b..bcf6e47 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -311,6 +311,7 @@
int dummy;
};
+/* returns: 1 if batch is full, 0 if batch still not full, negative on error. */
static int osmux_batch_enqueue(struct msgb *msg, struct osmux_circuit *circuit,
uint8_t batch_factor)
{
@@ -325,7 +326,7 @@
return -1;
LOGP(DLMUX, LOGL_DEBUG, "Batch is full for RTP sssrc=%u\n", rtph->ssrc);
- return -1;
+ return 1;
}
llist_add_tail(&msg->list, &circuit->msg_list);
@@ -606,7 +607,7 @@
DELTA_RTP_TIMESTAMP);
/* No more room in this batch, skip padding with more clones */
- if (osmux_batch_enqueue(clone, circuit, batch_factor) < 0) {
+ if (osmux_batch_enqueue(clone, circuit, batch_factor) != 0) {
msgb_free(clone);
break;
}
@@ -668,6 +669,7 @@
talloc_free(circuit);
}
+/* returns: 1 if batch is full, 0 if batch still not full, negative on error. */
static int
osmux_batch_add(struct osmux_batch *batch, uint32_t batch_factor, struct msgb *msg,
struct rtp_hdr *rtph, int ccid)
@@ -675,6 +677,7 @@
int bytes = 0, amr_payload_len;
struct osmux_circuit *circuit;
struct msgb *cur;
+ int rc;
circuit = osmux_batch_find_circuit(batch, ccid);
if (!circuit)
@@ -727,8 +730,9 @@
osmux_replay_lost_packets(circuit, rtph, batch_factor);
/* This batch is full, force batch delivery */
- if (osmux_batch_enqueue(msg, circuit, batch_factor) < 0)
- return 1;
+ rc = osmux_batch_enqueue(msg, circuit, batch_factor);
+ if (rc != 0)
+ return rc;
#ifdef DEBUG_MSG
LOGP(DLMUX, LOGL_DEBUG, "adding msg with ssrc=%u to batch\n",
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29500
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ib78c9b82b85c74be2c5e94dae7c212175244d5fa
Gerrit-Change-Number: 29500
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29497 )
Change subject: osmux: Avoid duplicated RTP msg trigger Tx of osmux frame
......................................................................
osmux: Avoid duplicated RTP msg trigger Tx of osmux frame
The RTP msg will be dropped, so it makes no sense to signal the caller
to deliver the batchbeing built, since it may still have space for next
non-duplicated message.
The exception is the case where the new packet has the M marker bit set,
since the sequence numbers can be reset or jump in those scenarios.
Change-Id: Idc457bc3b26bed68796d714bc3f37a2d016ba5c3
---
M src/osmux.c
1 file changed, 10 insertions(+), 10 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/97/29497/1
diff --git a/src/osmux.c b/src/osmux.c
index 4851998..51642ab 100644
--- a/src/osmux.c
+++ b/src/osmux.c
@@ -691,22 +691,12 @@
return -1;
}
- /* First check if there is room for this message in the batch */
- bytes += amr_payload_len;
- if (circuit->nmsgs == 0)
- bytes += sizeof(struct osmux_hdr);
-
- /* No room, sorry. You'll have to retry */
- if (bytes > batch->remaining_bytes)
- return 1;
-
/* Init of talkspurt (RTP M marker bit) needs to be in the first AMR slot
* of the OSMUX packet, enforce sending previous batch if required:
*/
if (rtph->marker && circuit->nmsgs != 0)
return 1;
-
/* Extra validation: check if this message already exists, should not
* happen but make sure we don't propagate duplicated messages.
*/
@@ -723,6 +713,16 @@
return -1;
}
}
+
+ /* First check if there is room for this message in the batch */
+ bytes += amr_payload_len;
+ if (circuit->nmsgs == 0)
+ bytes += sizeof(struct osmux_hdr);
+
+ /* No room, sorry. You'll have to retry */
+ if (bytes > batch->remaining_bytes)
+ return 1;
+
/* Handle RTP packet loss scenario */
osmux_replay_lost_packets(circuit, rtph, batch_factor);
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29497
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Idc457bc3b26bed68796d714bc3f37a2d016ba5c3
Gerrit-Change-Number: 29497
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange