After libosmocore I96a9b6b6a3a5e0b80513aa9eaa727ae8c9c7d7a1 the CTRL interface
returns stricter errors. Adjust the expectations of
test_subscriber_errors.ctrl to fix the external tests on master.
Change-Id: I9337b6b4f3fa8822c91760deb01f18a77a073d19
Don't log "deriving 2G from 3G" when we're actually calculating separately; log
it when we're actually deriving from 3G.
Add log "calculating 2G separately" in the right place.
The test output changes show that each test said "separate 2G" at the top while
logging "deriving 2G from 3G" further down, which was obviously wrong.
Change-Id: I6679d7ef8fdcae39a0c2aff7ac638e63dddb10dc
libosmocore Ie35a02555b76913bb12734a76fc40fde7ffb244d
"ctrl: on parse errors, return a detailed message to sender"
the test_subscriber_errors.ctrl test fails.
Adjust the expected error message.
Change-Id: I3aee1507721cd073f72369150d0fb3cff0fdf66f
Verify that it returns -ENOENT on non-existing IMSI and -ENOKEY for no auth
data.
Move the auc_compute_vectors() stub to the top near the db_get_auc() call, and
just return num_vec to get a successful return value when auth data is present.
Change-Id: Ic0158228afbd78b8ca21f62dffa9f868674682b9
For unknown IMSI and no auth data for a known IMSI, log respective messages on
NOTICE level.
For database error, log on ERROR level.
Change-Id: I3838fa78567e7e92d797d90b8b90865d9ebba90a
Differentiate between "IMSI unknown" and "IMSI has no auth data": in case of
known IMSI lacking auth data, return -ENOKEY instead of -ENOENT.
Fix API doc comments to reflect what the functions actually return, on top of
adding the -ENOKEY detail.
Adjust db_test expectations from -ENOENT to -ENOKEY where appropriate.
Adjust VTY and CTRL command rc evaluation.
A subsequent patch will use these return values to log details on each of these
situations.
Change-Id: Icf6304d23585f2ed45e050fa27c787f2d66fd3f7
If we have a subscriber entry that lacks auth data, we currently return
GMM_CAUSE_NET_FAIL, which in the MSC log looks like the HLR is not connected or
something grave. Instead, return GMM_CAUSE_IMSI_UNKNOWN.
This changes the OsmoMSC log in this way:
Before:
DVLR <001e> VLR_Authenticate(901700000014701)[0x5555558dabb0]{VLR_SUB_AS_NEEDS_AUTH_WAIT_AI}: GSUP: rx Auth Info Error cause: 17: Network failure
After:
DVLR <001e> VLR_Authenticate(901700000014701)[0x5555558dabb0]{VLR_SUB_AS_NEEDS_AUTH_WAIT_AI}: GSUP: rx Auth Info Error cause: 2: IMSI unknown in HLR
A better cause value would be something that says "IMSI known, but we have no
auth data", but since such cause value is not defined, the plain "IMSI unknown"
seems to be the best match.
Change-Id: I90df7b255317df1e5d968e7ce3b9d2c404b98db8
Prepare for tweaking error handling in a subsequent patch: use switch() instead
of if().
Prepares-for: I90df7b255317df1e5d968e7ce3b9d2c404b98db8
Change-Id: I1f628aa9d62b778951726bebec8cf338444fc897
A user on openbsc@ complained that with SQLite 3.8.2, the db_test fails with
--- expected
+++ stderr
-DDB (2067) abort at 18 in [INSERT INTO subscriber (imsi) VALUES ($imsi)]: UNIQUE constraint failed: subscriber.imsi
+DDB (2067) abort at 35 in [INSERT INTO subscriber (imsi) VALUES ($imsi)]: UNIQUE constraint failed: subscriber.imsi
i.e. a trivial difference in the error message issued by SQLite.
For db_test, don't output any SQLite error messages: Add argument
enable_sqlite_logging, pass as true, except in db_test.c.
Remove the SQLite error messages from expected output.
(Note that there is a src/db_test.c program that's not of interest here, this
is about the tests/db/db_test.c)
Change-Id: I2513d71cc0072aef8d08f47d0a1959f311176229
Each arg parsing should increment optind, so if there are any surplus args in
the end, that's an error.
Change-Id: I9fc0a87d11db8c35061568e3f8b5a5547931a961
Coverity wants us to evaluate sqlite3_reset, but it is of no use to do so.
Related: coverity CID#178653
Change-Id: I64ac8c148f48be60f9c0d346df0c5152bb527494
It appears that hlr_subscriber.imsi is 16 buffers in size:
15 chars for IMSI + 1 byte NUL. However, osmo_gsup_message.imsi
is 17 bytes (for whatever reason), so we cannot simply do a strpy()
as this might overflow the hlr_subscriber.imsi field!
TODO: check if weactually ever receive a too-long IMSI in GSUP and
reject that at an earlier time in the code flow.
Fixes: Coverity CID#164746
Change-Id: I9ff94e6bb0ad2ad2a7c010d3ea7dad9af0f3c048
The db API returns negative errno values, need to flip the sign before feeding
to strerror.
Fixes: coverity CID#178658
Change-Id: Iaab46f565a1112d8a7def8ea90a5cd440c0a3b41
vty_install_default() and install_default() will soon be deprecated.
Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I09762f110c7bcaf85c0ef2f472eb43ac543c74e9
Move macro copy_sqlite3_text_to_buf() to db.h, so it can be used in
hlr_db_tool.c.
Add _dbd_decode_binary() from libdbi to avoid depending on the entire libdbi
just for KI BLOB decoding. Add it in a separate file, copying its own license,
the lGPL.
Offer commandline option "import-nitb-db" to read in an old osmo-nitb database
and copy subscriber IMSIs and 2G auth data to OsmoHLR db format.
Anticipate future command line options like "import-csv", so keep the code
generalized.
Change-Id: I0dfa6ec033dd93161c1adc2ce1637195fe5b7a63
Tweak unit test binaries to still used DEBUG loglevels, so that their expected
outputs remain unchanged (and nicely verbose).
Adjust test_nodes.vty, now expecting the 'notice' log levels upon
'show running-config'.
Change-Id: Ic061e61c9625b49cef8bc2a2c0b936e262c22268
Rename SL3_TXT to more accurate copy_sqlite3_text_to_buf(), and use
osmo_strlcpy() instead of essentially dup'ing it.
The macro will also be used by hlr_db_tool.c in upcoming patch. This patch
prepares for a move to db.h.
Change-Id: I1dadeddddcfe0109195c09c0e706201b0df009cc
By moving the comments inside the table row definitions, they are dumped back
during 'sqlite3 hlr.db .dump'. When they are between SQL statements like before
this patch, the comments are lost.
Tweak wording.
Change-Id: I280c2e2d3e9b7f1dc632722724d9e1c54d041820
If a database file is missing, osmo-hlr creates it, as is the default sqlite3
API behavior -- before this patch, that db file is created, but lacks useful
tables. Actually also create initial tables in it, as osmo-nitb did.
In effect, the 'vty-test' target in tests/Makefile.am no longer needs to create
a database manually. (The 'ctrl-test' still does, because it also wants to add
subscriber data on top of the bare tables.)
Note: it could be desirable to bail if the desired database file does not
exist. That is however a different semantic from this patch; this is not
changing the fact that a db file is created, this just creates a usable one.
Note: I am about to add osmo-hlr-db-tool to do database migration from
osmo-nitb. For that, it is desirable to bootstrap a usable database, which is
the core reason for this patch.
Don't plainly duplicate hlr.sql to .c, but create db_bootstrap.h as a
BUILT_SOURCE from reading in sql/hlr.sql and mangling via sed to a list of SQL
statement strings. On each db_open(), run this bootstrap sequence.
In sql/hlr.sql, these tweaks are necessary:
* Add 'IF NOT EXISTS' to 'CREATE TABLE', so that the bootstrap sequence can be
run on an already bootstrapped db.
* Drop the final comment at the bottom, which ended up being an empty SQL
statement and causing sqlite3 API errors, seemed to have no purpose anyway.
Note: by composing the statement strings as multiline and including the SQL
comments, sqlite3 actually retains the comments contained in table definitions
and prints them back during 'sqlite3 hlr.db .dump'.
Change-Id: If77dbbfe1af3e66aaec91cb6295b687f37678636
The -I includes should be in CFLAGS, not CPPFLAGS.
I noticed problems with it when trying to add an -I$(builddir) in an upcoming
patch that adds a BUILT_SOURCE, If77dbbfe1af3e66aaec91cb6295b687f37678636.
Change-Id: Ie57a04b7efc7a1e16cf0e3625d8ad2f0ef0089b0
See osmo-ci change I2409b2928b4d7ebbd6c005097d4ad7337307dd93 for rationale.
Depends: I2409b2928b4d7ebbd6c005097d4ad7337307dd93
Change-Id: I9d35913f9cd60ff121d29f357919a0b0d62d6835
Add a large enough subscriber id and add a test that ensures a leading zero is
not interpreted as octal, and that a leading 0x is invalid and not interpreted
as hexadecimal.
Change-Id: Ib468b7cb595cf52331ebb41e6de0e8f57f69e173
The previous commands are not conforming to how the CTRL interface is intended
to work:
SET enable-ps <IMSI>
SET disable-ps <IMSI>
SET status-ps <IMSI>
'status-ps' is a write-only command even though it returns the status.
'enable-ps' / 'disable-ps' indicate the value instead of a variable name of an
entity. The entity <IMSI> takes the place of the variable value.
See also https://lists.osmocom.org/pipermail/openbsc/2017-September/011236.html
Instead, replace with
SET subscriber.by-imsi-123456.ps-enabled {0,1}
GET subscriber.by-imsi-123456.ps-enabled
and also provide further CTRL functions while at it:
{SET,GET} subscriber.by-{imsi,msisdn,id}-123456.{cs,ps}-enabled {0,1}
GET subscriber.by-{imsi,msisdn,id}-123456.{info,info-aud,info-all}
Provide CTRL tests in the form of transcripts.
Adjust tests/test_subscriber.sql to feature nonzero SQN, to see some values for
SQN in the CTRL transcript tests. (This does not affect the VTY tests, because
that creates its own subscribers, and there's no VTY command to set the SQN.)
This is the first time an application uses CTRL_NODE ids that are defined
outside of libosmocore, see 'Depends' below.
Implementation choice: the first idea was to have a '.' between the 'by-xxx'
and the value, like:
subscriber.by-xxx.123456.function
but the difficulty with subscribers is that they are not in RAM, and I can't
just point node_data at a struct instance that is always there (like, say, a
global bts[0] struct in osmo-bsc). Instead, I want to store the selector and
later decide whether to read from the DB or whatever. With a '.' separating
things, the only way in a ctrl function to obtain both 'by-xxx' and '123456'
for picking a subscriber record would be to parse the entire variable path
string elements, including 'subscriber' and 'function', which would then also
clumsily fix at which node level we hook these commands; there could have been
separate CTRL_NODE_SUBSCR_BY_{IMSI,MSISDN,ID} parent nodes, but we cannot
introspect the current parent node dynamically within a ctrl function handler
(plus I'm not sure whether it's possible and a good idea to have the same
command under multiple parent nodes).
Rather than that, I store the 'by-foo-123' token in the node_data pointer to
have both bits of information pointed at by a single pointer; I use the
incoming command parsing to get this token pre-separated from surrounding node
names, and no need to re-allocate it, since the vector of tokens lives until
after command execution is complete. Each leaf command obtains this token from
cmd->node (aka node_data), and feeds this token to a common static function to
parse selector and value from it and to retrieve a subscriber record as needed.
(BTW, I have mentioned on the mailing list that this way might be necessary to
avoid numeric-only CTRL node names, but we don't need to, and that is not at
all related to this choice of structure.)
Depends: libosmocore I1bd62ae0d4eefde7e1517db15a2155640a1bab58
libosmocore Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005
Change-Id: I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50
Cosmetically prepare for adding new CTRL commands in hlr_controlif_setup():
- drop unused 'gs' param.
- use ctrl_interface_setup_dynip2(), so far with default CTRL nodes; custom
nodes will be added soon.
Prepares: I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50
Change-Id: I63004a7953b04988449697dbc5d55d7ed0c6d82d
Check *subscr->imsi, not subscr->imsi, since it is a char[]; same as msisdn
below already does.
Was introduced in change I42b3b70a0439a8f2e4964d7cc31e593c1f0d7537 / commit
183e7009af.
Fixes: coverity CID 178166
Change-Id: I72e13efefbac0495b8dd1949a39fa44ebfd46b56
Each GSUP client creates a luop, but since lu_op_tx_del_subscr_data() doesn't
free the luop, each allocated luop leaks memory.
Change-Id: If912dc992bc7f18c49d22ec0436d9679c1cd04f6
Use the new osmo_verify_transcript_ctrl.py from osmo-python-tests to completely
replace current ctrl_test_runner.py with a CTRL interaction transcript.
Add missing EXTRA_DIST entry of test_subscriber.sql.
Depends: osmo-python-tests Id47331009910e651372b9c9c76e12f2e8964cc2c
Change-Id: Iff93abe370b8f3ecf42082d1d0eaa1fbeca5b122
Implement VTY commands for subscriber manipulation:
- create / delete subscriber
- modify MSISDN
- add/edit/remove 2G and 3G authentication data
- show by IMSI, MSISDN or DB ID.
(enable/disable CS/PS and purge/unpurge to follow later.)
Implement VTY unit tests for the new commands using new
osmo_verify_transcript_vty.py from osmo-python-tests.
Depends: libosmocore I1e94f5b0717b947d2a7a7d36bacdf04a75cb3522
osmo-python-tests Id47331009910e651372b9c9c76e12f2e8964cc2c
Change-Id: I42b3b70a0439a8f2e4964d7cc31e593c1f0d7537
db_subscr_get_by_*() failed to clear the out-param struct, meaning that data
could remain in a struct even though it is not present in the database. Always
zero out the struct before writing to it.
Adjust the db_test to catch this error by writing "-invalid-data-" to each
struct before running db get functions.
Change-Id: I038bd437452c87841d709fcdd5ac30ab1356b2db
At some point we should rather offer DB bootstrap as a DB API function instead
of an external .sql file, which would remove the dep on the sqlite3 binary.
For now, we need the binary to build debian packages for the 'make check' step.
Change-Id: I71938dff688675dcf1dbfbce2feb8b72b1de0910
To make the db_bind_text() error reporting mention "imsi", change the
DB_STMT_AUC_BY_IMSI to use a named parameter.
Change-Id: I49bd5eb78170cf4cdf8abb386c766d20d9f1cf73