From patchwork Wed May 25 19:43:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gerrit-no-reply@lists.osmocom.org X-Patchwork-Id: 626441 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 3rFN4Y3HBCz9sdn for ; Thu, 26 May 2016 05:43:41 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 07A661329B; Wed, 25 May 2016 19:43:40 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from 127.0.1.12 (unknown [127.0.1.12]) by lists.osmocom.org (Postfix) with ESMTPA id 7FAA913288; Wed, 25 May 2016 19:43:38 +0000 (UTC) Date: Wed, 25 May 2016 19:43:38 +0000 From: Holger Freyther X-Gerrit-MessageType: merged Subject: [MERGED] openbsc[master]: filter/nat: Fix the context for the imsi assignment X-Gerrit-Change-Id: I53789aad2809e19338ad3b2deb72c4757e7bd524 X-Gerrit-ChangeURL: X-Gerrit-Commit: 5b692d0a5c1c388916c21e623edde28505ec1b02 In-Reply-To: References: MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/2.12.2-31-gb331dbd-dirty X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: holger@freyther.de Cc: daniel Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Message-Id: <20160525194340.07A661329B@lists.osmocom.org> Holger Freyther has submitted this change and it was merged. Change subject: filter/nat: Fix the context for the imsi assignment ...................................................................... filter/nat: Fix the context for the imsi assignment In c09f8a3b7fb94ccef41e33c32bfe2bff1ffe0e44 as part of a cleanup I accidently changed the talloc context from "con" to "bsc". The issue occurred at an earlier commit when assigning req.ctx to the "wrong" context. The allocation needs to be scoped by the struct nat_sccp_connection and not the connection from BSC to NAT. Before we have a nat_sccp_connection we scope the copied imsi to the bsc_connection and then steal it, but for the identity resp we will always have a nat_sccp_connection and can already use the right context. Change-Id: I53789aad2809e19338ad3b2deb72c4757e7bd524 Related: OS#1733 Reviewed-on: https://gerrit.osmocom.org/102 Tested-by: Jenkins Builder Reviewed-by: Harald Welte Reviewed-by: daniel Reviewed-by: Holger Freyther --- M openbsc/src/osmo-bsc_nat/bsc_nat_filter.c M openbsc/tests/bsc-nat/bsc_nat_test.c 2 files changed, 4 insertions(+), 1 deletion(-) Approvals: daniel: Looks good to me, but someone else must approve Harald Welte: Looks good to me, but someone else must approve Jenkins Builder: Verified Holger Freyther: Looks good to me, approved diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c b/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c index 393aea3..e735290 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c @@ -109,7 +109,7 @@ if (!hdr48) return -1; - req.ctx = bsc; + req.ctx = con; req.black_list = &bsc->nat->imsi_black_list; req.access_lists = &bsc->nat->access_lists; req.local_lst_name = bsc->cfg->acc_lst_name; diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c index a405763..b531c6b 100644 --- a/openbsc/tests/bsc-nat/bsc_nat_test.c +++ b/openbsc/tests/bsc-nat/bsc_nat_test.c @@ -978,10 +978,13 @@ } memset(&cause, 0, sizeof(cause)); + OSMO_ASSERT(!con->filter_state.imsi); if (bsc_nat_filter_dt(bsc, msg, con, parsed, &cause) != 1) { printf("FAIL: Should have passed..\n"); abort(); } + OSMO_ASSERT(con->filter_state.imsi); + OSMO_ASSERT(talloc_parent(con->filter_state.imsi) == con); /* just some basic length checking... */ for (i = ARRAY_SIZE(id_resp); i >= 0; --i) {