From patchwork Wed May 28 12:38:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Michal_Grzn=C3=A1r?= X-Patchwork-Id: 353398 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5FF1E1400D8 for ; Wed, 28 May 2014 22:40:35 +1000 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1Wpd9Z-0008Fn-Fp; Wed, 28 May 2014 14:40:21 +0200 Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]) by ganesha.gnumonks.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.72) (envelope-from ) id 1Wpd8B-0008FH-P4 for openbsc@lists.osmocom.org; Wed, 28 May 2014 14:39:00 +0200 Received: by mail-ob0-f177.google.com with SMTP id wp4so10443041obc.36 for ; Wed, 28 May 2014 05:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/PQm7kudYcTj9X5lJaSI+msHp6Up15tt260TJ5vTy/U=; b=M3w2lGtf63nq6bF3HXbN7QgVUPKSqLgA8/C+P8k4m7gCoWEORvhhuNcd4zh45vgoYJ qqW67q2DtvvSR84h1WaOk7M+tIKRdnj4nGry0L4cLwIyJFi6nEvURSQrTfE6Z2Ls2C82 AjjhFMWQVrmBZJNbR2yZra4UWEId3zGJijnQZDRfOqbEoZ/Ju4aUQsaTXHjOaxGa2rZP GZ7IVG+AsYQm5k5ZJduMiliEUCYc7Oz/TSaUoksEsPgI9HgaNM5bFnPzXaxyvYxKBoYa RNwVqPFDMqc/AccHqEV8pso9hV0HPQibbCUvWI7XvAMjkAYgCXUsaBqvFafKXeidh8Vg eCNg== MIME-Version: 1.0 X-Received: by 10.60.124.202 with SMTP id mk10mr18925929oeb.67.1401280733038; Wed, 28 May 2014 05:38:53 -0700 (PDT) Received: by 10.182.154.67 with HTTP; Wed, 28 May 2014 05:38:52 -0700 (PDT) In-Reply-To: <20140523111650.GE21550@xiaoyu.lan> References: <20140517115033.GC14533@nataraja> <20140523111650.GE21550@xiaoyu.lan> Date: Wed, 28 May 2014 14:38:52 +0200 Message-ID: Subject: Re: OsmoSGSN [PATCH], Network Service From: =?UTF-8?Q?Michal_Grzn=C3=A1r?= To: Holger Hans Peter Freyther X-Spam-Score: -0.1 (/) Cc: openbsc@lists.osmocom.org, Harald Welte X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org Hi, it wasn´t handly written diffs but here I send diff made by using git diff. And the problem you can see in packets with number 27-40 (especially see in number 30 you see there the old tlli and newly generated P-TMSI in message attach accept and in number 31 there is new TLLI which is the same as generated P-TMSI in previous message) and that is the problem I needed to solve, that the new TLLI was not LOCAL. regards Michal 2014-05-23 13:16 GMT+02:00 Holger Hans Peter Freyther : > On Fri, May 23, 2014 at 11:44:40AM +0200, Michal Grznár wrote: > > Hi, > > > And the problem was as I said in Imsi attach procedure new TLLI == new > > allocated P-tmsi, and there was a problem that the function > gprs_tmsi2tlli() > > function there was not called and so I had to mask the upper bits in > > function where the p-tmsi is allocated, there is also a pcap trace where > > you can see it. > > Could you please elaborate of what/were (e.g. packet numbers) we > can see "it" and what it should be instead? And please use "git diff" > or preferable "git commit" and git format-patch. The "diff" you include > is hand-written and sadly not usable because of this. > > And as written by Harald before. The place you patch is not correct. > The method you patch should generate a unique P-TMSI. It might should > mask some of the higher bits. But you need to look at the callers of > this function if the tlli is not updated. > > e.g. in src/gprs/gprs_gmm.c you will see something like this: > > ctx->p_tmsi = sgsn_alloc_ptmsi(); > #endif > > /* Even if there is no P-TMSI allocated, the MS will switch from > * foreign TLLI to local TLLI */ > ctx->tlli_new = gprs_tmsi2tlli(ctx->p_tmsi, TLLI_LOCAL); > > /* Inform LLC layer about new TLLI but keep old active */ > gprs_llgmm_assign(ctx->llme, ctx->tlli, ctx->tlli_new, > GPRS_ALGO_GEA0, NULL); > > So this call to gprs_tmsi2tlli will make sure that 0xc0000000 will > be set. In fact I see two calls to sgsn_alloc_ptmsi and both of them > do the above and assign the new tlli to the context. So please could > you try to explain what you are trying to solve? > > holger > > diff --git a/home/michal/Plocha/gprs_ns_before_patch.c b/home/michal/Plocha/gprs_ns_patch.c index c939003..1bc965e 100644 --- a/home/michal/Plocha/gprs_ns_before_patch.c +++ b/home/michal/Plocha/gprs_ns_patch.c @@ -1217,16 +1217,14 @@ int gprs_ns_process_msg(struct gprs_ns_inst *nsi, struct msgb *msg, switch (nsh->pdu_type) { case NS_PDUT_ALIVE: - /* If we're dead and blocked and suddenly receive a - * NS-ALIVE out of the blue, we might have been re-started - * and should send a NS-RESET to make sure everything recovers - * fine. */ - -LOGP(DNS, LOGL_INFO, "Rx NS ALIVE\n"); -if ((*nsvc)->state == NSE_S_BLOCKED) - rc = gprs_ns_tx_reset((*nsvc), NS_CAUSE_PDU_INCOMP_PSTATE); - else - rc = gprs_ns_tx_alive_ack(*nsvc); + LOGP(DNS, LOGL_INFO, "Rx NS ALIVE\n"); + rc = gprs_ns_tx_alive_ack(*nsvc); + /*mark NS-VC as unblocked and active*/ + (*nsvc)->state = NSE_S_ALIVE; + (*nsvc)->remote_state = NSE_S_ALIVE; + /*Initiate TEST proc.: Send ALIVE_ACK and start timer*/ + rc = gprs_ns_tx_simple((*nsvc), NS_PDUT_ALIVE_ACK); + nsvc_start_timer((*nsvc), NSVC_TIMER_TNS_TEST); break; case NS_PDUT_ALIVE_ACK: /* stop Tns-alive and start Tns-test */ diff --git a/home/michal/Plocha/gprs_sgsn_before_patch.c b/home/michal/Plocha/gp index 753d85f..f637a82 100644 --- a/home/michal/Plocha/gprs_sgsn_before_patch.c +++ b/home/michal/Plocha/gprs_sgsn_patch.c @@ -361,7 +361,7 @@ uint32_t sgsn_alloc_ptmsi(void) uint32_t ptmsi; restart: - ptmsi = rand(); + ptmsi = rand() | 0xc0000000; //because of GPRS IMSI ATTACH llist_for_each_entry(mm, &sgsn_mm_ctxts, list) { if (mm->p_tmsi == ptmsi) goto restart;