aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-05-23 17:58:03 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-05-26 14:32:44 +0200
commit92f089732148bd6676d9663ed14d1c0799284b73 (patch)
tree5ba7ee90f6c0c447759d1d4c4db420142ed37b0f
parent29474c59dcb6ea2ec42393e3f7ea91813e7b3f34 (diff)
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. [Backported from master] Change-Id: I53789aad2809e19338ad3b2deb72c4757e7bd524 Related: OS#1733 Reviewed-on: https://gerrit.osmocom.org/102 Tested-by: Jenkins Builder Reviewed-by: Harald Welte <laforge@gnumonks.org> Reviewed-by: daniel <dwillmann@sysmocom.de> Reviewed-by: Holger Freyther <holger@freyther.de>
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_filter.c2
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c b/openbsc/src/osmo-bsc_nat/bsc_nat_filter.c
index 393aea3ce..e73529097 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 @@ int bsc_nat_filter_dt(struct bsc_connection *bsc, struct msgb *msg,
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 a4b313c91..6e1e64be6 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -978,10 +978,13 @@ static void test_dt_filter()
}
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) {