aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Santos <jrsantos@jonathanrsantos.com>2011-06-23 17:53:27 -0400
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-10-16 17:59:51 +0200
commit0b21bd9b92f1267dfb2a274189069e7fa6b9bd8c (patch)
treec736f9dbe8a93352db86a944dd5fe459b6adf8db
parent16073cf54640f1a71361ab80410fe937970006c6 (diff)
gprs: Fix LLC UI window
According to TS 44.064 section 8.4.2, the LLC layer should only drop UI frames if V(UR)-32 <= N(U) < V(UR). The code was dropping frames whenever N(U) < V(UR). Consequently, large amounts of packets could be dropped if, e.g., V(UR)==511 and the frame with N(U)==511 was lost. All frames would be dropped until the next time a frame with N(U)==511 is received.
-rw-r--r--openbsc/src/gprs/gprs_llc.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c
index d29694fe4..7d5c63f7a 100644
--- a/openbsc/src/gprs/gprs_llc.c
+++ b/openbsc/src/gprs/gprs_llc.c
@@ -483,17 +483,21 @@ static int gprs_llc_hdr_rx(struct gprs_llc_hdr_parsed *gph,
}
break;
case GPRS_LLC_UI:
- if (gph->seq_tx < lle->vu_recv) {
- LOGP(DLLC, LOGL_NOTICE, "TLLI=%08x dropping UI, vurecv %u <= %u\n",
- lle->llme ? lle->llme->tlli : -1,
- gph->seq_tx, lle->vu_recv);
- return -EIO;
- }
- /* Increment the sequence number that we expect in the next frame */
- lle->vu_recv = (gph->seq_tx + 1) % 512;
- /* Increment Overflow Counter */
- if ((gph->seq_tx + 1) / 512)
- lle->oc_ui_recv += 512;
+ {
+ int delta = (lle->vu_recv - gph->seq_tx) & 0x1ff;
+ if (0 < delta && delta < 32) {
+ LOGP(DLLC, LOGL_NOTICE, "TLLI=%08x dropping UI, vurecv %u <= %u\n",
+ lle->llme ? lle->llme->tlli : -1,
+ gph->seq_tx, lle->vu_recv);
+ return -EIO;
+ }
+ /* Increment the sequence number that we expect in the next frame */
+ lle->vu_recv = (gph->seq_tx + 1) & 0x1ff;
+ /* Increment Overflow Counter */
+ if (lle->vu_recv == 0) {
+ lle->oc_ui_recv += 512;
+ }
+ }
break;
}