Commit Graph

2379 Commits

Author SHA1 Message Date
Max 3ef14a241a Do not allocate already existing counter group
Check that no group with the given name and index already exist before
allocating it. Add corresponding test case.

Change-Id: I563764af1d28043e909234ebb048239125ce6ecd
Related: OS#2757
2017-12-17 20:12:34 +00:00
Harald Welte 62e40855c2 gsm0808_create_cipher_reject: Fix encoding of Cause IE
The Cause IE in the 08.08 CIPHER MODE REJECT is a normal TLV IE,
and not just a value.  Let's make sure we encode the cause value
properly.

Change-Id: I4f5b231edf6dcb0a9c2bbafb2a59f301f3b2402b
Closes: OS#2766
2017-12-17 20:51:48 +01:00
Neels Hofmeyr 84ea2e0374 logging vty: describe 'logging set-log-mask' command, add OSMO_STRINGIFY_VAL()
Change-Id: I73ac5873ede858da44e1486d8a5c81da1ed5b19f
2017-12-12 18:00:24 +00:00
Max 32e5641dbb Add functions for extended RACH coding
Add support for extended RACH (11 bit) according 3GPP TS 45.003 §5.3.2:

* convolutional code with puncturing
* encoding/decoding routines
* corresponding tests

Change-Id: I85a34a82d5cd39a594ee89d91a2338226066ab5d
Related: OS#1548
2017-12-11 10:36:47 +00:00
Pau Espin 9dd3bf0cb4 Fix malformed Abis/RSL messages with extra L3 Information field
Some Abis/RSL messages such as "Release Indication" contained 3 extra
bytes from an L3 Information header which should not be there according
to specs in GSM 08.58 (section 8.3 "Radio link layer management
messages"). Other RSL messages were affected by the same issue, except
for "Establish Indication", which had already a workaround in
send_rslms_dlsap.

This commit fixes the issue in a generic way, removes the "Establish
Indication" and fixes the test accounting for the bug, as it otherwise
fails after applying the changes.

Fixes: OS#1635, OS#2336

Change-Id: Ibb116214e8b1798d65a8b0917150496a3c14f344
2017-12-10 14:44:19 +00:00
Jean-Francois Dionne 893979cb08 Fix LAPD UA msgb memory leak.
Change-Id: Ia4f0606810e00aa6f1779d11893e4acc01976f9a
2017-12-10 14:31:12 +00:00
Pau Espin a99e110106 cosmetic: Fix trailing whitespace
Change-Id: I0c7a414789f8ce6516369327430f71164e2cbd94
2017-12-10 14:07:54 +00:00
Neels Hofmeyr dc75b114b4 comment: utils: more accurately describe OSMO_STRINGIFY macro
Change-Id: I7b057c026f9df90608b7cbd12481ab9e7a41d88c
2017-12-10 13:34:36 +00:00
Neels Hofmeyr a73656501a vty reference: merge_doc.xsl: do not omit description tag
vty_additions.xml files provide <description>s for <node> tags, but for unknown
reasons, merge_doc.xsl explicitly omits description tags. Do not omit
<description>s so that they show up in the merged document.

This will take effect when next building the osmo-gsm-manuals using this file.

Change-Id: I418e61705043d4df047d8038c5d61623ba64f2e0
2017-12-10 13:34:36 +00:00
Neels Hofmeyr 3b6815715f vty: set name for VIEW+ENABLE nodes, for VTY reference
This leaves no unnamed chapters in future VTY reference documents.

Change-Id: Iefb8b78094208a1a4c5d70bd6c69a3deca8da54f
2017-12-10 13:34:35 +00:00
Neels Hofmeyr 453e37e3c8 VTY reference: use node names as section names
In 'show online-help' output, add the node names (currently all derived from
the prompt) as <node><name> entry, so that in the osmo-gsm-manuals, each
section of node commands gets a title. So far, each section of commands has no
name at all, and it is entirely up for guessing which part of the VTY the
commands are about.

Node section names, e.g. for OsmoHLR, will be like

  1 VTY reference
  1.4 config
  1.5 config-log
  1.6 config-line
  1.7 config-ctrl
  1.8 config-hlr
  1.9 config-hlr-gsup

Before this patch, all but '1 VTY reference' were plain empty.

A better solution would be to list the actual command name that enters the
node, and to nest the commands identically to VTY node nesting, but since this
information is currently hidden in node command implementations, it is
impossible to derive it. So we should actually make the VTY reflect the node
nesting structure in its data model, which would resolve both the accurate node
name problem as well as produce well-structured output to generate the VTY
references from. This patch is a workaround for lack of a more profound fix of
the VTY data model. At least it makes the VTY references' sections even
remotely useful.

Change-Id: Iaf745b2ab3d9b02fc47025a0eba3beb711068bfe
2017-12-10 13:34:35 +00:00
Neels Hofmeyr f7162771d7 VTY reference: do not list empty nodes
In 'show online-help' output, don't list nodes that have no commands (the
'Password' node).

Change-Id: I3bd6883a87b8b893e560ceadfffbf41bc380109c
2017-12-10 13:34:35 +00:00
Neels Hofmeyr 69054e28ad vty XML export: avoid repeating common node commands for each node
We use 'show online-help' to generate VTY reference manuals. It is not helpful
to include the common node commands on each and every node level, it clutters
the actual useful help.

Have a separate first section called 'Common Commands', but omit them
elsewhere.

Change-Id: Ie802eccad80887968b10269ff9c0e9797268e0d4
2017-12-10 13:34:35 +00:00
Holger Hans Peter Freyther 53aa0f51b8 license: Fix the license to GPL
This was always intended to be GPL and not AGPL. "kat" did the
development as part of an internship paid by me and we agreed
to shared copyright.

Change-Id: Ied2041ba20c5737bd967dfaa3017edf72a95b31c
2017-12-09 13:03:29 +00:00
Max a6a40dcbfd Embedded: fix sercomm test
The external sercomm_drv_[un]lock() functions are defined as stubs in
case of non-embedded build only which causes linking issue with
sercomm_test. Let's define the same stubs in sercomm_test
unconditionally - the implementation details of the locking are
irrelevant for the test anyway.

Related: OS#2708
Change-Id: I3dab4f3348871b66b5d6c9fd10b2e448c61f9e73
2017-12-05 18:43:14 +00:00
Alexander Couzens 06dbdf59eb vty: show asciidoc counters: don't create an empty table for osmo_counters
When creating asciidocs for osmo_counter an empty is not useful.
If there aren't any counter, output a hidden comment
Change-Id: Ie2768100e69dcd7d8d77533688585dd9b43c4a5e
2017-12-05 16:12:18 +01:00
Alexander Couzens 18ba26cfab counters: add osmo_counters_count() returns the amount of counters
Change-Id: I9068231d71876e06d27ee67a688d7fb611ac3a1b
2017-12-05 16:06:27 +01:00
Max ad1797e359 embedded: fix tests
In case of embedded build some tests are failing to link properly. Fix
it:

* do not run fsm_test unless CTRL is enabled
* do not run fr_test unless GB is enabled
* do not link loggingrb_test with libosmovty

Change-Id: Icedad5ba3ed311ccdb97fa3ccd3002f5fda8be68
2017-12-04 09:40:39 +00:00
Max 38b1723533 Fix embedded build
Do not attempt to load auth plugins - this does not make sense on
embedded target anyway.

Change-Id: Ie92d2eea21e19e499b3f3bb4d5a82e31fbbea3f0
2017-12-04 09:40:32 +00:00
Holger Hans Peter Freyther 37a83405a5 logging: Extend the LOGPSRC macro to put cont in it as well
For the lua console printing I need to print several values with
continuation but also specify the filename. Add a "C" for continue
and forward arguments.

Change-Id: I1d6dcb2567b9ed2c8767f661737b979bc3d1377e
2017-12-01 12:01:38 +00:00
Max 33dbecbbeb coding test: use OSMO_ASSERT
Change-Id: I896d6aaae3c36b87243b7dc270267090dcb44afe
2017-11-30 13:16:58 +01:00
Max 458a6f59e3 coding test: move bit dump into functions
Change-Id: I65c75e56831420d3daf386ea280c13ae9cb64d1b
2017-11-28 18:08:52 +01:00
Max 0176b4a978 coding test: enable debug output
Change-Id: I1ec23ca3cf0d973c77b8c4e7e23e0e75a4f0a7a3
2017-11-28 18:08:31 +01:00
Max 29d489f081 coding test: cosmetic cleanup
* remove duplicate code: use function from libosmocore
* use utility function to dump ubits
* reformat for easier reading
* link against libosmocore

Change-Id: I8c31b0954176a2c53305936a025c92a793b6d9b6
2017-11-28 18:02:03 +01:00
Max 7dc8e88d64 ctrl: make response easier to parse
Previously ctrl request for all counters in
group (e. g. 'rate_ctr.abs.msc.0') will result in human-readable
description which is not regular enough and is hard to both parse and
generate. The ctrl interface is intended for m2m, not for human
interaction. Let's simplify things by making response similar to counter
group request ('rate_ctr.*').

Reply now looks as follows:
GET_REPLY 9084354783926137287 rate_ctr.abs.msc.0 loc_update_type:attach 0;loc_update_type:normal 0;

Previously it was:
GET_REPLY 9084354783926137287 rate_ctr.abs.msc.0 All counters in msc.0
loc_update_type:attach 0
loc_update_type:normal 0

Change-Id: I7a24cc307450efdcd28168fffe477320c59fcd36
Related: OS#2550
2017-11-27 16:44:25 +00:00
Neels Hofmeyr 19ec7b9483 fsm_tmr_cb: don't set T=0, the fi may no longer exist
When calling the timer_cb, that may have effected an fi termination and
deallocation, e.g. from dispatching events and/or complex choices made.

Current timer_cb implementations expect T to reflect the fired timer number, so
we can't actually set T=0 before calling the timer_cb.

Instead, never reset T to zero, let it always reflect the timer that last
fired. When a new timer starts, T will be set to its new value.

Adding a T arg to the timer_cb() would have been the cleanest solution, so that
fi->T can be set to zero before dispatching the timer_cb. But since we've
already rolled out this FSM API, we should stay backwards compatible.

In the case where the timer returned 1 to request termination, we can assume
that the fi still exists, but to be consistent, don't set T = 0 in that code
path either.

Change-Id: I18626b55a1491098b3ed602df1b331f08d25625a
2017-11-25 17:45:04 +00:00
Max b4718fd233 Improve get_rate_ctr() error handling
Report back expected interval values.

Change-Id: I05ca7f716342af4f7424b28216ed6c1bf2bd589f
Related: OS#2550
2017-11-24 13:33:19 +00:00
Max b214af5360 ctrl: log incorrect interval values
This should never happen with the current code, but if it ever does, we
should log the error instead of silently returning 0.

Change-Id: I544001d3072e5f12a96a67e4178f9b945c5f6b6c
Related: OS#2550
2017-11-24 13:51:57 +01:00
Max 52a38ddfde Ctrl: add rate counter group introspection
Before user have to know group name and index in advance to request rate
counter value. Introduce introspection function which allows user to
obtain all the groups and their indexes by requesting 'rate_ctr.*'
variable.

This simplifies KPI dumping over ctrl interface.

Change-Id: Ifad8b4f0360c8bcd123a838676516476e84c246a
Related: OS#2550
2017-11-24 10:44:28 +00:00
Harald Welte f9b1e5556a gsmtap.h: Introduce new GSMTAP type for LTE NAS messages
Change-Id: I6e1274f17e2d9d2eee16481940642216ca96e3e3
2017-11-23 22:30:57 +01:00
Neels Hofmeyr ebd3cddb4c osmo_strlcpy: sanitize: don't memcpy from NULL src even if len is 0
Some callers pass NULL and len == 0. The semantics are that we then
nul-terminate an emtpy string. Avoid a sanitizer warning by not calling
memcpy() for the NULL case.

Change-Id: I883048cf2807e606c6481634dbd569fc12aed889
2017-11-21 13:29:02 +00:00
Neels Hofmeyr fe1ed39846 sercomm_test: sanitize: fix msgb mem leak
This should fix the last current remaining sanitizer build failure in
libosmocore regression tests.

Helps fix sanitizer build on debian 9.

Change-Id: I4d6dd7f4348675bc77d4df5a7a0ce41f12d4a043
2017-11-20 17:22:42 +01:00
Neels Hofmeyr e750980d6c tlv_put: guard against NULL val and 0 len
For example encode_auth_info() from gsup.c calls
  msgb_tlv_put(msg, iei, 0, NULL)
to put a tag and len with content data following later.

However, this would cause a memcpy() from a NULL pointer, in tlv_put(). Allow
passing NULL and len = 0 for cases like the above:

If val is NULL, use memset(0) instead of memcpy().
If len is zero, do not copy nor memset anything.

Hence make tlv_put() behave in a well-defined and valid way for any and all
input args; no negative fallout is possible from this patch.

Add proper API doc comment.

Fixes a sanitizer build failure in gsup_test:

  ../../../../src/libosmocore/include/osmocom/gsm/tlv.h:99:2: runtime error: null pointer passed as argument 2, which is declared to never be null

Helps fix sanitizer build on debian 9.

Change-Id: I13dce9cd1228817890d3e81edeeb660c893c1d64
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 85f5a2cd9c bssgp_fc_test: sanitize: free fc struct when done
Helps fix sanitizer build on debian 9.

Change-Id: I0ef95ee8185a4789f0732b9420243dda5104d181
2017-11-20 17:22:42 +01:00
Neels Hofmeyr cd325efae5 gprs_bssgp: bssgp_fc_in(): fix mem leak on queue overflow
All successful and all error code paths of bssgp_fc_in() free the msgb, except
the code path calling fc_enqueue() when the msg is dropped (due to queue being
full, or failure to allocate).

Callers could theoretically catch the -ENOSPC return value and discard the
msgb. However, in other code paths, a callback's return value is returned,
which is expected to free the msgb, so such callback would have to never return
-ENOSPC when it freed the msgb. Much simpler semantics would be to free the
msgb in every code path, no matter which kind of error occurred.

Who is currently calling bssgp_fc_in and how do they handle the return value?
- bssgp_fc_test.c ignores the return value (and hits a mem leak aka sanitizer
  build failure if the queue is full).
- fc_timer_cb() ignores the return value.
- bssgp_tx_dl_ud() returns the bssgp_fc_in() rc.
  - which is returned by a cascade of functions leading up to being returned,
    for example, by gprs_llgmm_reset(), which is usually called with ignored
    return code.
At this point it is already fairly clear that bssgp_fc_in() should always free
the msgb, since the callers don't seem to distinguish even between error or
success, let alone between -ENOSPC or other errors.

bssgp_fc_test: assert that no msgbs remain unfreed after the tests.
Adjust expected results.

Helps fix sanitizer build on debian 9.

Change-Id: I00c62a104baeaad6a85883c380259c469aebf0df
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 0128c78ffe bssgp_fc_test: sanitizer: free msgb context when done
Print remaining msgbs when done, then free the entire tall_msgb_context. To be
able to do that, call msgb_talloc_ctx_init() and use its return value.

A subsequent patch will fix a known mem leak and add assertions for 0b in 1
blocks remaining in the tall_msgb_context.

Helps fix sanitizer build on debian 9.

Change-Id: I67d347ab2642b0bfc27b21b44231a7f3146ff641
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 9541a68378 bssgp_fc_test: clarify by outputting ok / failure messages
The test fills up the queue / sends too large PDUs on purpose. Make that
obvious by outputting returned errors in the expected output.

Cosmetic:
- fc_in()'s return value is ignored, hence don't return anything.
- add comment.

Change-Id: I57d6fce2515a65f6dd037e75af5397079215cb46
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 568f8e2017 bssgp_fc_test: remove rounding to deciseconds
Ever since this test was changed to use osmo_gettimeofday_override, the times
it sees are exact every time and don't need rounding to pass the expected
output.

Change-Id: I4a9a5d31fc02eb55caf7ba9c141426d8115bb740
2017-11-20 17:22:42 +01:00
Neels Hofmeyr 10ee73a7b3 rate_ctr: fix mem leak for mangled desc
Using the NULL context creates mem leaks that bother sanitizer builds.
Allocate as talloc "child" of the rate_ctr_group, so that the mangled desc (if
any) gets freed when the rate_ctr group is freed.

Remove the comment concerning osmo-msc: the way to fix the unexpected talloc
state in osmo-msc tests is to have no invalid rate counter names in osmo-msc.
See Ib1db8e3dc6c833174f1b0b1ca051b0861f477408 (osmo-msc).

Change-Id: Ief9abfeb78b7706200bcc6aaa5dcb04fbeaa9b5b
2017-11-20 16:21:44 +00:00
Neels Hofmeyr 3fad5d782a msgb: add inline msgb_queue_free()
Related: Iaad35f03e3bdfabf3ba82b16e563c0a5d1f03639 (libosmo-netif)
Change-Id: Ia291832ca445d4071f0ed9a01730d945ff691cf7
2017-11-20 14:22:15 +01:00
Harald Welte abcd0e37b7 ports.h: Use same VTY port number for osmo-mgw and osmo-bsc_mgcp
It was decided that osmo-mgw as direct successor of osmo-bsc_mgcp
will use the same VTY port number (similar to osmo-nitb, osmo-bsc
and osmo-bsc-sccplite all using the same VTY port number)

Change-Id: Iec1da9f3b4d170416279f05876d9e1ae2970c577
2017-11-20 09:46:45 +00:00
Neels Hofmeyr 9a938ae882 gsm0808_test: sanitize: fix msgb memleak
Helps fix sanitizer build on debian 9.

Change-Id: I0097d63bbb4e7ee20eb4a8474f4fef32d39e625f
2017-11-18 10:30:58 +00:00
Neels Hofmeyr d8e79c7fff gsm0408_test: sanitize: cleanup msgb
Remove initial msgb talloc context creation: if we create a root ctx for msgb
that all msgb are allocated in, we would in a final cleanup discard all msgbs,
i.e. we would not verify that all msgb are cleaned up properly.

If we create the msgb context and *don't* clean it up in the end, the sanitizer
build fails because the context root is not cleaned up.

Easiest is to actually allocate all msgb at NULL ctx, because then any msgb
that aren't cleaned up properly would still linger, while we don't leave a root
ctx that we need to clean up either.

Helps fix sanitizer build on debian 9.

Change-Id: I1f2d1d05c75bbf4d92787f9735083f18cdc90f6f
2017-11-18 10:30:58 +00:00
Neels Hofmeyr dd24560433 lapd_test: sanitize: fix msgb memleaks
Helps fix sanitizer build on debian 9.

Change-Id: I0add9eac7225db23bc02fc2aaee5f42258d34e25
2017-11-18 10:30:58 +00:00
Neels Hofmeyr 39720acb06 abis_test: sanitize: fix msgb memleak
Helps fix sanitizer build on debian 9.

Change-Id: I69750d9cd2b8f30bfc6d2dfd9e62576e46989fab
2017-11-18 10:30:58 +00:00
Neels Hofmeyr 00393e1a04 memleak: osmo_config_list_parse: getline() needs free also on error
Helps fix sanitizer build on debian 9.

Change-Id: Iddf0a6cc733cd81d5f6c1eb62fc079ad319db119
2017-11-18 10:30:57 +00:00
Harald Welte b93f60f7cd conv_acc: Our code requires SSSE3, not just SSE3
The accelerated convolutional decoder uses SSSE3 instructions such
as PSIGNW (via _mm_sign_epi16) which go beyond what SSE3 offers.  So
let's make sure we use the right compiler flag (-mssse3) and also the
right runtime check.

Without this patch, we would use illegal instructions e.g. on Opteron
Gen3 such as Opteron 2427, which are also used as build.opensuse.org
build hosts (build31 through build36) where we wouldn't pass "make
check" as a result.

Change-Id: I2754164384109f2821fd98ffb48f625893f2923d
Fixes: OS#2386
2017-11-17 11:44:22 +01:00
Harald Welte d068210896 Print /proc/cpuinfo before executing testsuite
The testsuite fails on some specific build machines in the OBS
build cluster.  Let's try to figure out which CPU flags they have
to narrow down the cause of this.

Change-Id: Ib23e5bfb3c894206fad62d6cc6151583b1bb75a6
2017-11-16 16:57:33 +00:00
Pau Espin c30a76b2d4 utils: Fix false positive in compiler warning
Fixes the warning below:
warning: ‘sqn’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    fprintf(stderr, "Requesting --sqn %"PRIu64" implies IND=%u,"
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     " so no further --ind argument is allowed.\n",
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     sqn, test_aud.u.umts.ind);
     ~~~~~~~~~~~~~~~~~~~~~~~~~

The warning is a false positive as sqn is only used in case
sqn_is_set!=0, and in that code path, sqn is set.

Change-Id: Ib5903db01ea6765bd6bb688e63f70925c5012f98
2017-11-16 16:16:08 +00:00
Pau Espin e2640ef763 gsm: Use correct include for getrandom
"man getrandom" states sys/random.h is required.

Fixes warning below:
 warning: implicit declaration of function ‘getrandom’; did you mean ‘srandom’? [-Wimplicit-function-declaration]
  rc = getrandom(out, len, GRND_NONBLOCK);
       ^~~~~~~~~

Change-Id: I2e73fd018e887893dc5527d6d73644d627eb963a
2017-11-16 16:33:57 +01:00