aboutsummaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2021-07-13gprs_ns2: ensure the NSE becomes dead when FR link went downAlexander Couzens2-0/+58
The FR code is using force unconfigured to change the state of the NSVC when the FR link goes down. The force unconfigured state didn't notified the NSE when changing into this state. Related: SYS#5533 Change-Id: I4d7bbbbce26f7cde99eebe96995c50b1e812e5bd
2021-07-06gprs_ns2_vty: dump_nsvc: change output depending on NSVCIAlexander Couzens1-8/+8
If the NSVCI is valid, there is no signalling or data weight defined (internally this is 1). For NSVC with NSVCI don't print the signalling or data weight. For NSVC without NSVCI, don't print NSVCI at all. Related: OS#5180 Change-Id: Iaadc806a9136436468e2b02eb0bc1f4570a10ecc
2021-07-06gprs_ns2: use gprs_ns2_free_bind() to clean up a bindAlexander Couzens1-0/+4
gprs_ns2_free_bind() takes care of all required steps to clean up a bind. The driver->free_bind() operation only cleans up the driver internal state but not NSVCs and other generic things. Fixes a crash when free'ing a bind from the vty which has active NSVCs. Related: OS#5195 Change-Id: I0a2ad22905bcacb929b9b5f5b034af0da3081826
2021-07-02gprs_ns2: fix crash when changing the MTUAlexander Couzens1-2/+11
When the MTU changes for any fr device, all NSE will recalculate their MTU. If any NSE is alive, libosmocore will crash. Related: OS#5192 Change-Id: I31ba5cefea7bbb0b74060d6664b42c58815ee2a1
2021-06-25gprs_ns2: fix missing notify towards the NSE when NSVC become blockedAlexander Couzens2-0/+72
The NSE wasn't notified when a NSVC went into the BLOCKED state from an UNBLOCKED state. Related: OS#5182 Change-Id: I09634e414e9bb966e6b5809b7de1b59fbabd413d
2021-06-25gprs_ns2: use llist_add_tail to keep orderAlexander Couzens1-4/+4
When configuring multiple NSE/BINDs the order of the configuration should be keeped. Related: OS#5181 Change-Id: Ibbc03f0780b49543b5bd97ee059f11cfd6c2a126
2021-06-15ctrl: Pre-calculate required size before allocating msgbPau Espin Pedrol1-3/+6
This commit fixes crash when response is more than ~4096 chars. Furthermore, we now allocate only the required memory, not 4096 for all messages, which usually don't require it. Test needs to be adapted since it assumed there was more available space at the end of the msgb. Related: OS#5169 Change-Id: I0b8f370f7b08736207f9efed13a0663b5e482824
2021-06-04Use new stat item/ctr getter APIsPau Espin Pedrol2-46/+46
Generated with spatch: """ @@ expression E1, E2; @@ - &E2->ctr[E1] + rate_ctr_group_get_ctr(E2, E1) """ """ @@ expression E1, E2, E3; @@ - E2->items[E1] + osmo_stat_item_group_get_item(E2, E1) """ Change-Id: I41297a8df68e28dfc6016330ac82b0ed5dd0ebc1
2021-04-29ns2: Allow setting the socket priority for a UDP bindHarald Welte1-3/+3
Change-Id: Ifdfa086ce1c8d62b256abb3454b70cf53da9dcdb
2021-04-12vty/logging: logp: properly handle library specific sub-systemsVadim Yanitskiy1-0/+3
The library specific sub-systems are kind of special, because their position in the 'osmo_log_info' may vary depending on the number of application specific sub-systems. This is why their associated constant values (like DLGLOBAL) are negative, and this is what the LOGP() macro expects as the first argument. Before this change, invoking 'logp' command with any library specific logging sub-system would result in getting messages printed with the fall-back DLGLOBAL sub-systems. Change-Id: If86563e169fe1243adfa7b09c9d65d9f88c8a99e
2021-04-07stats: log error when missing stats values (v2)Oliver Smith2-0/+6
Related: SYS#4877 Change-Id: I5140d967c2f1d36dadf93b03e52b9bbd42e2a3a6
2021-04-07stats_test: restore stat_item_get_next assertsOliver Smith1-18/+18
This is a partial revert of b27b352e ("stats: Use a global index for stat item values"). Now that osmo_stat_item_get_next correctly returns how many values have been skipped, we can use the accurate asserts on its return value again. Fix the initial values of next_id_a,b (1 instead of 0), so we don't get a skipped value on the first read. This is needed, because b27b352e refactored osmo_stat_item_get_next to have the next id as parameter instead of the last read one, and the initial value was not adjusted in the tests. Related: OS#5088 Change-Id: I9d4cda2487a62f52361c24058363dfa90e502c63
2021-04-07stat_item: make value ids item specificOliver Smith1-15/+0
Fix counting of values missed because of FIFO overflow in osmo_stat_item_get_next(), by assigning a new item value id effectively as item->value[n + 1].id = item->value[n].id + 1, instead of increasing a global_value_id that is shared between all items and groups. With global_value_id, the count of values missed was wrong for one item, as soon as a new value was added to another item. This partially reverts b27b352e ("stats: Use a global index for stat item values") from 2015, right after stats was added to libosmocore. It was supposed to make multiple readers (reporters) possible, which could read independently from stat_item (and later added comments explain it like that). But this remained unused, stats has implemented multiple reporters by reading all stat_items once and sending the same data to all enabled reporters. The patch caused last_value_index in struct osmo_stat_item to always remain at -1. Replace this unused last_value_index with stats_next_id, so stats can store the item-specific next_id in the struct again. It appears that stats is the only direct user of osmo_stat_item, but if there are others, they can bring their own item-specific next_id: functions in stat_item.c still accept a next_id argument. Related: OS#5088 Change-Id: Ie65dcdf52c8fc3d916e20d7f0455f6223be6b64f
2021-04-07vty/logging: ensure consistent '%' prefix for warningsVadim Yanitskiy1-1/+1
Change-Id: I2b2bab61e46668c3b4b0ccad88d02b6d00a83544
2021-04-06stat_item: make next_id argument name consistentOliver Smith1-27/+27
Let osmo_stat_item_get_next, osmo_stat_item_discard, osmo_stat_item_discard_all consistently refer to their next_id arg as such (and not idx or next_idx). It refers to an ID (item->values[i].id), not an index (item->values[i]), and it is always the next one, never the current one. Do the same change for _index/_idx variables in stats.c, which are used as arguments to these functions. Replace rd_ with next_id_ in stats_test.c, too. Related: OS#5088 Change-Id: I5dd566b08dff7174d1790f49abd2d6ac020e120e
2021-03-31gprs_ns2: vty: remove a white space in `show binds`Alexander Couzens1-3/+3
Change-Id: Ia3579ec5599f5f5c58eebab03f1ed9e17f171177
2021-03-24gprs_ns2: dump_nsvc: correct indentionAlexander Couzens1-8/+8
As both `show ns entities` and `show ns binds` looking similiar correct the indention. Change-Id: I55794188bec7e62f0341188dbf23ac04006974fe
2021-03-24gprs_ns2_vty: make the `show ns entities` and `show ns binds` look similiarAlexander Couzens1-0/+2
`show ns binds` prints a count of NSVCs. Add the same line to `show ns entities`. Change-Id: I15c58a1c0fe94dda728afb29e7e5ca41e3fa8966
2021-03-24gprs_ns2: always use the same method to print NSVCsAlexander Couzens1-4/+4
The binds also print a list of associated NSVC when dumping the bind. However the binds using their own representation of printing the NSVC which is different to `show ns entities`. Use the same function to print NS-VC. Before: NSVCI 00000: udp)[127.0.0.1]:23000<>[127.0.0.1]:22000 After: NSVCI none: UNCONFIGURED DYNAMIC data_weight=1 sig_weight=1 udp)[127.0.0.1]:23000<>[127.0.0.1]:22000 Change-Id: If31ec6c1c07dc134ab1ddeb915bc89747c7be048
2021-03-24gprs_ns2: rework logging of Rx and Tx NS PDUAlexander Couzens1-28/+30
Introduce 2 new logging sub systems for signal and unit data. Unify log messages so all log messages look similiar. Log also Rx PDUs. Ensure dropped Tx packets (BLOCK/RESET on SNS) contain *Tx*. Change-Id: I34b8fde2955ecc010d1dcd9512e1bba9211e2c0d
2021-03-24gprs_ns2_vty: Allow creating NSE in sgsn-roleHarald Welte1-1/+1
Change-Id: I694fa6c80d04d13cb1afaae93a9ae43b6dfd2207 Related: OS#3373
2021-03-19Revert "stats: log error when missing stats values"Oliver Smith2-151/+0
This reverts commit d290439b4afe928e7e341540cb92f1abf36a82cb, which caused "stats values skipped" messages to appear even if they were not skipped. Revert for now, replace with a proper version in the future. Related: SYS#4877 Change-Id: Ib43bd53188a4d31d771feb921ea14abe1a3ec877
2021-03-18tlv: Fix length returned by t{l16,16l}v_putDaniel Willmann1-0/+32
Every other function returns a pointer to the first byte after the tlv that was just written. tl16v seems to be a copy and paste error from tlv16 above and t16lv seems to count the 16-bit tag twice. The new tests verify that the return value of *_put(buf, tag, len, val) points to buf + *_GROSS_LEN(len). Change-Id: I268a7e11fb5dce67ce1bd7974ab86c4d2bd002f7
2021-03-17stats: log error when missing stats valuesOliver Smith2-0/+151
Let the user know when the stats were not consumed fast enough for the given FIFO length. Related: SYS#4877 Change-Id: If0e8ab55103007693101538fb6ea310075217774
2021-03-17tests/stats: enable logging in test outputOliver Smith5-164/+179
Move test output from stdout to stderr and enable logging to stderr. This is in preparation for the next patch, which will add a new log message when osmo_stat_item_get_next() skips a value. Related: SYS#4877 Change-Id: Ie0eaec2f93ac6859397a6bfca45039fdcc27cb9e
2021-03-09stats: Ensure that each osmo_stat_item only reports once per intervalDaniel Willmann2-0/+20
We should never report multiple values for a metric. It is confusing for the log reporter and wrong for statsd. Statsd will record only one value, but will it be the first, last, ...? This can happen if an osmo_stat_item changes more than once within the same reporting interval. With this patch only one aggregate value is sent to the log reporters. The value reported is the maximum during this interval. Other aggregations could be possible (min, last), but reporting a (useful) average is not because the values don't include a timestamp and most osmo_stat_items change at unregular intervals. Change-Id: I366ab1c66f4ae6363111ea4e41b66b7d5bcade9c Related: SYS#4877
2021-02-25tests/gb: Fix printf format errors on ARM 32 bitsPau Espin Pedrol1-6/+6
Seen building on RPI4 32 bits raspbian: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=] Change-Id: I62199bfc7f3a78403334f5580f31fa5743223c9b
2021-02-20Drop use of log_set_print_filename() API inside libosmocorePau Espin Pedrol14-18/+15
Let's use log_set_print_filename2() API instead, which has less ackward behavior implications like changing the print status of category-hex. Related: OS#5034 Change-Id: Ifc78e1dcba5baf0b41f6ccbbbd1e3f06552d73da
2021-02-20tests: Set print_category values explicitlyPau Espin Pedrol11-0/+19
This will alow easily changing default values for print_category vs print_category_hex later. In any case, every test relying on logging output validation should always explicitly state the config to avoid issues in the future if default values change. Related: OS#5034 Change-Id: If29b40557d5c2bcda04b964f344070bad58d8f28
2021-02-19logging: Allow prefixing thread ID to each log linePau Espin Pedrol1-0/+1
Related: OS#5032 Change-Id: I38fc93ab0182b4edbd639c7ed0f31ce51964ee18
2021-02-19gprs_ns2: ensure no duplicate UDP NSVC can be createdAlexander Couzens1-0/+20
Change-Id: I58a95817e2730bbbaa851a43a5b072d1de2db037
2021-02-19gprs_ns2: implement a simple load sharing for UDPAlexander Couzens2-0/+102
Implement the load sharing based on modulo of the LSP. As long the gprs_ns2 doesn't support the resource distribution function (48.016 § 4.4a) this simple approach is good enought. Fixes: OS#4836 Change-Id: I8c2fe5d647694886ac600470fca6ea5d5d210a85
2021-02-19gprs_ns2_vty: add optional argument signalling and data weights to `nsvc udp`Alexander Couzens1-0/+29
A static configured UDP NSVC can have signalling and data weights Related: SYS#5354 Change-Id: Id363937c64e786c55e3136401ebdb44052415e0f
2021-02-19gprs_ns2: rework IP-SNS bindsAlexander Couzens1-0/+1
Introduce a `ip-sns-bind BINDID` vty command within a `nse` vty object. The ip-sns-bind defines the binds which will be used by the dynamic configuration with IP-SNS. This is only the first part which only uses the binds when doing a new SNS configuration. The outgoing add procedure will be supported in a later patch when the SNS fsm supports outgoing procedures. This is a behaviour change of the API and must be synchronized with the osmo-pcu. Otherwise SNS won't work with osmo-pcu. Related: SYS#5354 Change-Id: I9ab8092bf286e7d90e92f5702a5404425e959c84
2021-02-18gsm: Introduce API osmo_gsm48_rest_octets_si13_decodePau Espin Pedrol4-0/+133
Related: SYS#5358 Change-Id: I74fb0a3afc1ac4aadbfc609b882d929401f790eb
2021-02-16gprs_ns2: inform the NS user (BSSGP) about the MTU of a NSEAlexander Couzens2-0/+69
The BSSGP layer needs to know the MTU of the NS UNIDATA payload. The MTU can be 0 if the NSE doesn't contain any NSVC. Every status indication will contain the mtu value. The MTU in the status indication contains the maximum transfer unit of a BSSGP message. From NS side the maximum SDU. Related: OS#4889 Change-Id: I5016b295db6185ec131d83089cf6c806e34ef1b6
2021-02-15gsm: Fix encoding of gsm0808_cell_id_list2 with CGI-PS typesPau Espin Pedrol1-0/+43
CGI-PS type doesn't exist in GSM 08.08 Cell Id lists. That type of cell id is osmocom-specific and used internally. In here CGI-PS is automatically converted to CGI (since the later is an extension of this one). The encode/decode_cell_id_u are left intact (comment added) since those can still be used (and are used by RIM code) to encode/decode TS 48.018 Cell Identifiers. Related: SYS#4909 Change-Id: Id74f4577c397c1ba696f00395858311bd82cb2c8
2021-02-15comsetic: gsm0808_test: Fix trailing whitespacePau Espin Pedrol1-2/+2
Change-Id: I7f48e292fefe555939129f4000303e630a12cc50
2021-02-12tests/gb: Add more complex osmo-ns-dummy.cfgDaniel Willmann1-0/+24
write config will not print out any configuration for bind/nse unless we configure some. This way we can catch more issues with incompatible configs such as https://gerrit.osmocom.org/c/libosmocore/+/22878 Change-Id: Iad422ee013c82a6cb96af8ce4eb3af8b0936a4c9 Related: OS#4887
2021-02-12gprs_ns2: add signalling & data weights for UDP bindsAlexander Couzens1-0/+1
Allow to assign a signalling and data weight to UDP binds. Those weights will be used when doing dynamic configuration over IP-SNS. This is only the first part which only uses the assigned weights when doing a new SNS configuration. The outgoing change weight procedure will be supported in a later patch when the SNS fsm supports outgoing procedures. Related: SYS#5354 Change-Id: I5133e4229377d44772a9af28628a2bc420fea34b
2021-02-01gsm_7bit_encode_n(): fix integer overflow in gsm_septets2octets()Vadim Yanitskiy2-12/+7
Using 'uint8_t' for the length argument is definitely a bad idea. Because of this, packing more than 255 septets would not work as expected. Deprecate the old function and use 'size_t' instead. Change-Id: Ib1aac538afeb0a5c76a1df472d555139a496e12e
2021-02-01gsm_7bit_encode_n(): test encoding of more than 250 septetsVadim Yanitskiy2-0/+70
As can be seen, this unit test reveals problems with encoding of more than 250 septets using gsm_7bit_encode_n(). The problem is that some API functions use type 'uint8_t' for the length, so we basically suffer from integer overflows. Change-Id: I723300578d5ab0c7b94cf49c14d962b2dbf47740
2021-02-01ns2: Move to one common/shared ns2_bind_alloc()Harald Welte1-10/+4
Avoid code duplication between three different drivers by sharing the "core" of the bind initialization in a new, shared ns2_bind_alloc(). Change-Id: I535fc68e94fcd695de827dd922706adc1c5a2cb7
2021-01-28gprs_ns2: refactor: ensure all enums have GPRS_NS2_Alexander Couzens1-9/+9
All public enum should have the prefix GPRS_NS2_. API change which must be synchronized with osmo-pcu, osmo-gbproxy, osmo-sgsn. Change-Id: I548ff12f7277cbb7e1a630a3dc02b738ce89be72
2021-01-25gprs_ns2: drop prefix of all internal exposed functionAlexander Couzens1-5/+5
All functions which are exposed by gprs_ns2_internal.h should not contain the public prefix gprs_. Internal function should only contain ns2_ prefix. Change-Id: Icecc5a918902cd10efac72bbac20780d39aab272
2021-01-25tests: gprs_ns2: add unitdata unit testAlexander Couzens2-0/+148
test sending unitdata over a alive and blocked NSVC. Change-Id: I2c44b711d004d2ca08e05d4f54519ad8dbd77c27
2021-01-21tests/*: fix control reaches end of non-void funcOliver Smith2-0/+2
Prepare to set -std=gnu89 in a future commit, which will cause gcc warn about "control reaches end of non-void function" in main(). Change-Id: I7c33cac30e5859060f083813d8433011f5eaf0d0
2021-01-21gprs_ns2_test: Fix compilation on Debian 8Harald Welte1-1/+2
[ 352s] gb/gprs_ns2_test.c: In function 'test_block_unblock_nsvc': [ 352s] gb/gprs_ns2_test.c:200:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode [ 352s] for (int i=0; i<2; i++) { [ 352s] ^ [ 352s] gb/gprs_ns2_test.c:200:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code Change-Id: I72310886bef4db635078b75715c9d98ee45391cc
2021-01-19gprs_ns2: implement BLOCK/UNBLOCK of a NSVC by vtyAlexander Couzens2-0/+91
The vty should be able to block or unblock a specific NSVC. Further more this case is special for the UNITDATA as those can be still received until the other side response to the BLOCK PDU. Related: OS#4939 Change-Id: Ic0ce3c5fabc8644cc1ee71a8f6dd783fadf7b84d
2021-01-19test: gprs_ns2: free the nsi after each testAlexander Couzens1-0/+1
Change-Id: I700da48d7afe6b1a81484a0725faf0c56073446d