On Mon, Jul 29, 2013 at 08:26:32AM +0200, Holger Hans Peter Freyther wrote:
Hi,
> Okay, I will modify the lle_by_tlli_sapi look-up to not use the
> foreign conversion at all. This would fix my case.. but given the
> lack of unit tests I don't know what I break. :)
> > makes sense, particularly once we remove the foreign2local logic.
>
> okay.
the patches implement the above two. My case with pcu_emu appears to
work correctly (N(U) is counting up) and I have not looked into anything
beyond that.
If somebody at OHM or somewhere else could/want to apply this to their
SGSN installation it would be greatly appreciated.
kind regards
holger
>From b4ffe17b0aa3b0de6ddc61f8aad932e90255fea4 Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <[email protected]>
Date: Mon, 29 Jul 2013 09:06:46 +0200
Subject: [PATCH 1/2] gprs_llc: Lookup lle based on the real TLLI
During the GPRS Attach procedure we might have a foreign tlli and
in the RX create a LLME on the fly for this tlli. The GMM GPRS
Attach handling code will then assign a new TLLI and keep the
foreign tlli as the llme->old_tlli.
When the GMM is sending the identity request the msgb_tlli will
point to the foreign tlli. The GPRS LLC code will then try to find
that foreign tlli but due the conversion this will not be found.
Instead a new ad-hoc LLE/LLME will be created on the fly for
each message (this means there are duplicate LLE/LLMEs in the
list).
Make the code more strict and remove the tlli_foreign2local change
from the look-up routine. This will make the GPRS LLC code find
the right LLE/LLME and the N(U) will be handled correctly.
Addresses:
<0012> gprs_llc.c:773 LLC RX: unknown TLLI 0xadf11820, creating LLME on the fly
...
<0012> gprs_llc.c:357 LLC TX: unknown TLLI 0xedf11820, creating LLME on the fly
Reproducable:
Use pcu_emu (gprs attach) and observe with wireshark.
---
openbsc/src/gprs/gprs_llc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c
index 8af5367..57e557a 100644
--- a/openbsc/src/gprs/gprs_llc.c
+++ b/openbsc/src/gprs/gprs_llc.c
@@ -147,12 +147,10 @@ static inline uint32_t tlli_foreign2local(uint32_t tlli)
}
/* lookup LLC Entity based on DLCI (TLLI+SAPI tuple) */
-static struct gprs_llc_lle *lle_by_tlli_sapi(uint32_t tlli, uint8_t sapi)
+static struct gprs_llc_lle *lle_by_tlli_sapi(const uint32_t tlli, uint8_t sapi)
{
struct gprs_llc_llme *llme;
- tlli = tlli_foreign2local(tlli);
-
llist_for_each_entry(llme, &gprs_llc_llmes, list) {
if (llme->tlli == tlli || llme->old_tlli == tlli)
return &llme->lle[sapi];
--
1.8.3.2
>From f360a25a3c22a691409f1a221a890bb959d2cc54 Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <[email protected]>
Date: Mon, 29 Jul 2013 10:09:12 +0200
Subject: [PATCH 2/2] gprs_llc: Assert that we send frames with either tlli or
old_tlli
In case we have access to the context verify that the selected
msgb_tlli is either the old_tlli or the tlli. It is wrong to use
any other TLLI.
---
openbsc/src/gprs/gprs_llc.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c
index 57e557a..c3bd9d2 100644
--- a/openbsc/src/gprs/gprs_llc.c
+++ b/openbsc/src/gprs/gprs_llc.c
@@ -52,6 +52,10 @@ static int _bssgp_tx_dl_ud(struct msgb *msg, struct sgsn_mm_ctx *mmctx)
dup.drx_parms = mmctx->drx_parms;
dup.ms_ra_cap.len = mmctx->ms_radio_access_capa.len;
dup.ms_ra_cap.v = mmctx->ms_radio_access_capa.buf;
+
+ /* make sure we only send it to the right llme */
+ OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli
+ || msgb_tlli(msg) == mmctx->llme->old_tlli);
}
memcpy(&dup.qos_profile, qos_profile_default,
sizeof(qos_profile_default));
--
1.8.3.2