Commit Graph

4008 Commits

Author SHA1 Message Date
Vadim Yanitskiy 4b46b7eb53 vty/logging: logp: properly handle library specific sub-systems
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-12 12:15:17 +00:00
Neels Hofmeyr 47c7b4fc24 add osmo_bts_features_names: short BTS feature strings
This will be used by osmo-bts-omldummy to parse features strings from
the cmdline.

Note that osmo_bts_feature_name() already exists to return the longer
descriptive value_strings from osmo_bts_features_descs (_descs!).
Luckily that misses the plural 'features' in the name, so that I can
still add a properly named osmo_bts_features_name() function that only
returns the name, matching the common pattern used in osmocom code.

Related: SYS#4895
Change-Id: I699cd27512887d64d824be680303e70fff3677c1
2021-04-09 00:10:44 +02:00
Neels Hofmeyr 524b4f802f deprecate osmo_bts_feature_name(), add osmo_bts_features_desc()
The function osmo_bts_feature_name() is ill-named for two reasons:
- it returns descriptive text instead of just a string representation of
  the name.
- The enum is named "osmo_bts_features", so the function name lacks the
  "s" for "features".

Rationale: An upcoming patch adds a function to return just the name,
properly called osmo_bts_features_name(), so deprecate the weirdly named
one first.

Change-Id: I9dfdb5e81037b6000effbd340af4e5db0dcfd69c
2021-04-08 23:11:45 +02:00
Oliver Smith d4393608a4 stats: have_value is a bool, not int
Change-Id: Id92c63f4e54ec1bf3411205be1bd268e1d184b03
2021-04-07 18:39:05 +00:00
Oliver Smith 2623fca8ad stats: log error when missing stats values (v2)
Related: SYS#4877
Change-Id: I5140d967c2f1d36dadf93b03e52b9bbd42e2a3a6
2021-04-07 18:38:54 +00:00
Oliver Smith c7930589fd stats_test: restore stat_item_get_next asserts
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-07 18:38:54 +00:00
Oliver Smith 6140194347 stat_item: make value ids item specific
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-07 18:38:54 +00:00
Vadim Yanitskiy 2d1a9fabcc vty/logging: ensure consistent '%' prefix for warnings
Change-Id: I2b2bab61e46668c3b4b0ccad88d02b6d00a83544
2021-04-07 16:33:18 +00:00
Vadim Yanitskiy ad34465349 vty/logging: use consistent quiting in warning messages
Change-Id: Ifded63a38caac26e174fc6cb69dead7bc83db344
2021-04-07 16:33:18 +00:00
Alexander Couzens e7dfeac8dc gprs_ns2_vty: print a response to vty `nsvc <nsvci> (block|unblock|reset)
The vty wasn't printing anything to the user if it was a success or not

Change-Id: Idbb83ea319bbdc94177febdd66e79c49fce7fdd2
2021-04-07 16:25:35 +00:00
Alexander Couzens 53e7009049 gprs_ns2: sns: remove the initial SNS NSVC if it's not part
A SNS configuration can be done over a NSVC, however this initial NSVC doesn't
need to be part of the configuration.
Those NSVC need to be removed when the configuration is done.
This wrong behaviour can be seen in the vty `show ns` on

NSEI 00001: UDP, ALIVE
 FSM Instance Name: 'GPRS-NS2-SNS-BSS(NSE00001-SNS)[0x55c72c09b420]', ID: 'NSE00001-SNS'
  Log-Level: 'DEBUG', State: 'CONFIGURED'
 Maximum number of remote  NS-VCs: 8192, IPv4 Endpoints: 8192, IPv6 Endpoints: 8192
 Local IPv4 Endpoints:
  10.0.0.1:23000, Signalling Weight: 1, Data Weight: 1
 Remote IPv4 Endpoints:
  10.0.2.2:23000, Signalling Weight: 1, Data Weight: 0
  10.0.2.2:23001, Signalling Weight: 0, Data Weight: 1
  3 NS-VC:
   NSVCI none: UNBLOCKED DYNAMIC data_weight=1 sig_weight=0 udp)[10.0.0.1]:23000<>[10.0.2.2]:23000
   NSVCI none: UNBLOCKED DYNAMIC data_weight=0 sig_weight=1 udp)[10.0.0.1]:23000<>[10.0.2.2]:23001
   NSVCI none: UNCONFIGURED DYNAMIC data_weight=1 sig_weight=1 udp)[10.0.0.1]:23000<>[10.0.2.2]:8888

The UNCONFIGURED NSVC should not be present in when SNS is in CONFIGURED.

Related: SYS#5416
Change-Id: I4045ac6c033ae084743b17a16eef4fcff76589b9
2021-04-07 16:12:34 +02:00
Alexander Couzens cdb2baaa0c gprs_ns2: sns: ensure the sns->alive state is correct
The SNS fsms also track the NSE however since the NSVC
starts now in ALIVE for SNS the SNS must check when synchronize
the alive state when entering the ST_CONFIGURED.

Related: SYS#5416
Change-Id: Ib6a1cc1fd84959e69c07b72ef780642205d2cd18
2021-04-06 14:30:19 +00:00
Alexander Couzens 5b72247dde gprs_ns2: nsvc_fsm: reorder notification st_alive_on_enter()
The start_procedure() can't be called after ns2_nse_notify_unblocked()
because ns2_nse_notify_unblocked() might free the nsvc.
Otherwise the fsm will do use-after-free on the NSVC memory.

Related: SYS#5416
Change-Id: If97dfd123eefd71fc6c3fe886a243a21784aeeb4
2021-04-06 14:30:19 +00:00
Oliver Smith 43686dacd6 stat_item: add comment with struct overview
Related: OS#5088
Change-Id: Ic63a5884da778938197c658c5f478c23a85a4587
2021-04-06 11:27:34 +02:00
Oliver Smith d3490bc442 stat_item: make next_id argument name consistent
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-04-06 11:27:34 +02:00
Alexander Couzens 8bd63b667e gprs_ns2: vty: remove a white space in `show binds`
Change-Id: Ia3579ec5599f5f5c58eebab03f1ed9e17f171177
2021-03-31 06:00:44 +00:00
Alexander Couzens 7619ed4304 gprs_ns2: fix memory leaks when receiving SNS or invalid packets
Change-Id: I8834d3f092e6cbe4f527e95e1eebd8133a386207
2021-03-29 21:26:46 +00:00
Harald Welte c2fbbd7307 gprs_ns2_sns: Fix memory leak when creating ip[46]_local arrays
Prior to this patch, we would unconditionally allocate new memory
for the local SNS IP endpoints.   This results in a memory leak
on every SNS-SIZE procedure.

Let's move to talloc_realloc() which recycles any previously allocated
memory.

Change-Id: I12cb670e087c6d6190f3f5bf8483ea62008ae06f
2021-03-29 10:20:08 +02:00
Neels Hofmeyr 158bc795e5 add BTS_FEAT_VAMOS
Change-Id: Ic3bd1b8075f76d1f35499faa68fad70698ee9a00
2021-03-27 17:14:57 +01:00
Pau Espin 1c4195fad0 Skip RPM checks if no *.spec.in available
Some projects don't necessarily have RPM packaging yet. Hence, avoid
running into unexpected check results in that case.

Related: OS#5094
Change-Id: Id306256af1ab3bf081b7df5a6c271628e3b8715c
2021-03-26 13:50:45 +01:00
Harald Welte 3053bbb3f3 gprs_ns2_sns: Don't create NS-VCs for binds outside the NSE
We may very well have any number of binds configured, but which
are not part of the current NSE.  When creating the "full mesh" of
NS-VCs after SNS-CONFIG, we must only iterate over those binds that
are part of the NSE (or 'ipa-sns-default bind' in cae of SGSN role),
but not over all the other binds that may exist in the system.

Closes: OS#5092
Change-Id: Ida361fa02ad1d86844d54c8f0664c996ed28e30a
2021-03-24 16:18:15 +00:00
Harald Welte e8c6106c2e gprs_ns2_sns: remove code duplication in create_missing_nsvcs()
Change-Id: I78d79c3bc92f0c0bebbbbe639b8406c4b188582f
2021-03-24 16:18:15 +00:00
Alexander Couzens 27e5873c8d gprs_ns2: add vty command `nsvc <nsvci> reset`
Change-Id: I436dd0367e83548acfc8f8e36ae4707496a252d9
2021-03-24 15:42:45 +00:00
Alexander Couzens 1dd9cbf45e gprs_ns2: dump_nsvc: correct indention
As both `show ns entities` and `show ns binds` looking similiar
correct the indention.

Change-Id: I55794188bec7e62f0341188dbf23ac04006974fe
2021-03-24 15:42:45 +00:00
Alexander Couzens 0ea4a4e0c4 gprs_ns2_vty: make the `show ns entities` and `show ns binds` look similiar
`show ns binds` prints a count of NSVCs. Add the same line
to `show ns entities`.

Change-Id: I15c58a1c0fe94dda728afb29e7e5ca41e3fa8966
2021-03-24 15:42:45 +00:00
Alexander Couzens 3e539ed127 gprs_ns2_vty: hide dynamic NSE information when ask for persistant only
dump_nse() should only print persistant NSE when persistant_only
argument is set. A NSE can be persistant or dynamic configured.
Depending on the NSE all NS-VC must be the same as the NSE.

Change-Id: Ibd2c6962eda39a850ab61cf347063934378d2fdc
2021-03-24 15:42:45 +00:00
Alexander Couzens 75b6188974 gprs_ns2: always use the same method to print NSVCs
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-24 15:42:45 +00:00
Alexander Couzens 6cf65d9d81 gprs_ns2: rework logging of Rx and Tx NS PDU
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-24 15:42:45 +00:00
Harald Welte 2d807b6c7d gprs_ns2_sns: Compute local endpoints before using them
This fixes some bug introduced in Change-Id I1638f04ba45fef3ba0b237948dff6022267141fb

Related: OS#3373

Change-Id: Ic0873e63f1f046b674c7898480ff070a18a7abc7
2021-03-24 01:58:52 +01:00
Harald Welte 5e4083166a gprs_ns2: Actually start Tns-test after SNS-CONFIG creates NS-VC
the previous commit fixed the state transition, but also caused
neither Tns-alive nor Tns-test to run

Change-Id: I07ea3fd5cec3d4acf4051930a1a3c746d6fd597c
2021-03-24 01:04:21 +01:00
Harald Welte c51ddf27b4 gprs_ns2_vc_fsm: In IP-SNS/ALIVE mode, initial state is ALIVE/UNBLOCKED
Only when the ALIVE procedure fails, we mark a NS-VC as RECOVERING.

Change-Id: Ieb860827c2149306b135c0e6c8b3cd3bbb78851e
2021-03-24 01:04:21 +01:00
Harald Welte c962a2efc3 gprs_ns2: Add comments explaining the nsvc->sns_only field
Change-Id: I16009a1b03d8027de2be56b7d5013b755c9550fd
2021-03-24 00:30:23 +01:00
Harald Welte d164ef80f9 gprs_ns2_sns: Allow VTY configuration of default binds for IP-SNS
In the IP-SNS SGSN role, we need to inform the BSS of our local
IP endpoints.  For statically configured NSEs, those are explicitly
stated on a per-NSE level.

For dynamically created IP-SNS NSEs, we are adding a new VTY
command, using which the administrator can configure which binds
should be advertised as IP endpoints to such BSS.

Change-Id: Id01c29b07e9203c9305f2129361a4f5aaefa2c52
Related: OS#3373
2021-03-24 00:30:23 +01:00
Harald Welte fe0266e8d8 gprs_ns2: dynamic NS-VC + NSE creation for IP-SNS in SGSN role
Related: OS#3373
Change-Id: Ie10bb3531fae2e651da04f965d964de6eb1e7a97
2021-03-24 00:30:23 +01:00
Harald Welte 42e3646a98 gprs_ns2_vty: Permit VTY configuration of bind->accept_sns
Related: OS#3373
Change-Id: Ifb52cd245b10bf47d42d57d167d6d6c02b12ee12
2021-03-24 00:30:23 +01:00
Harald Welte 01fa6a3ef3 gprs_ns2_sns: Implement checks during processing of inbound SNS-SIZE
As per 3GPP TS 48.016 section 6.2.4.1, we need to perform some
consistency checks during the SNS-SIZE procedure.  Let's implement them.

Change-Id: I1638f04ba45fef3ba0b237948dff6022267141fb
Related: OS#3373
2021-03-24 00:30:23 +01:00
Harald Welte 24f4df5c46 gprs_ns2_sns: Assume the SGSN has a very large number of max. NSVC
It is the SGSN's job to ensure sufficient NS-VC capacity.  As the SGSN
doesn't tell the BSS, we should not make assumptions of only 4.

Change-Id: I41f493643cf51d7853959ab9c7bbc0ffae4e1f4b
2021-03-24 00:30:22 +01:00
Harald Welte 4e41acc1ad gprs_ns2_sns: SNS-SIZE contains the actual number of local endpoints
The SNS-SIZE sent from BSS to SGSN contains the actual number of local
IP endpoints on the BSS side, and not the maximum number of remote IP
endpoints supported.

Change-Id: I62a8bca4a3f7c47bcb9f292b045fa867d8877a09
2021-03-24 00:30:22 +01:00
Harald Welte a2c5af5547 gprs_ns2_sns: Verify mandatory IE presence in incoming SNS-SIZE
Change-Id: I40571e313c3332d8cead8fb4aa9768d0d083804d
2021-03-24 00:30:22 +01:00
Harald Welte 46eb7643c9 gprs_ns2_sns: Don't clear remote IP endpoints in SGSN role
In BSS role, we can clear local + remote endpoints when sending
SNS-CONFIG, as we are first.

In SGSN role, we must not clear remote endpoints when sending
SNS-CONFIG, as we are last, and the BSS has just previously told
us its IP endpoints in the BSS-originated SNS-CONFIG.

Change-Id: I58549707ac5a3a0aae5f9348ed76f16c09ad3e46
Related: OS#3373
2021-03-24 00:30:22 +01:00
Harald Welte 579699bc2d gprs_ns2_vty: Allow creating NSE in sgsn-role
Change-Id: I694fa6c80d04d13cb1afaae93a9ae43b6dfd2207
Related: OS#3373
2021-03-24 00:30:22 +01:00
Harald Welte 5b034fbab0 gprs_ns2: Introduce gprs_ns2_create_nse2() for SGSN side SNS
gprs_ns2_create_nse() doesn't allow the caller to specify if the
BSS or the SGSN role of IP-SNS shall be implemented.  Add
gprs_ns2_create_nse2() to fix that.

Change-Id: I6db8c36f7c69b592d7d0fbcf323804f7e9912be2
Related: OS#3373
2021-03-24 00:25:56 +01:00
Harald Welte 694dad502a gprs_ns2_sns: Rename BSS-side states to include 'bss' in name
Clearly separate those states that only occur on the BSS side from
those of the SGSN side (which already have a prefix)

Change-Id: Iebc97637063b2676abff4a7dce50272d9b4e336b
Related: OS#3373
2021-03-23 15:22:16 +01:00
Harald Welte f61a9150a9 gprs_ns2_sns: Add some more OSMO_ASSERT about BSS role
Some functions are only to be called when operating in BSS role,
let's enforce that by sprinkling some OSMO_ASSERT() around.

Related: OS#3373
Change-Id: I20d1bd8df62e0bb84696e291756e2d96acf49246
2021-03-23 11:57:16 +01:00
Harald Welte 4f1274614e gprs_ns2_sns: Support for SGSN-side IP-SNS
This adds the core functionality of implementing the SGSN-side of IP-SNS
inside a new FSM.  The SGSN-side FSM shares states, events, structures
and code with the BSS-side whenever possible.

Note that this commit does not yet use the SGSN-side FSM, that is part
of subsequent commits.

Closes: OS#3373
Change-Id: I780413ffacd9cb71f64cc38057aae781eeb59b2b
2021-03-23 11:57:16 +01:00
Harald Welte 9fb5d80007 osmo-aka-verify: Fix use case with OP and not OPc
Change-Id: Ic6b5da83276ce2618cd80c6d34d3322bad7b4c48
2021-03-22 11:53:23 +01:00
Vadim Yanitskiy c3c914a5df utils/osmo-aka-verify: fix swapped CK/IK arguments
The positions of arguments in the call to "milenage_check" do not
match the ordering of the parameters:

  * "ck" is passed to "ik"
  * "ik" is passed to "ck"

Let's simply reorder the arguments of milenage_check()
to match the ordering in milenage_f2345().

Change-Id: Ia003d3c9d88fb8f6740791583855a709b8639160
Fixes: CID#220324
2021-03-21 22:36:43 +01:00
Harald Welte 8602106224 utils: osmo-aka-verify to verify UMTS AKA (SIM side)
This new utility implements the UMTS AKA procedures of the SIM
side.  It can be used to manually verify the correctness of
authentication tuples received from the network.

Change-Id: I497747fbf09f633dcd7c592bd9af7fca9a820645
2021-03-20 11:00:27 +00:00
Oliver Smith a7eb735b8d Revert "stats: log error when missing stats values"
This reverts commit d290439b4a, 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-19 16:47:52 +01:00
Daniel Willmann 2fa0e9df68 tlv: Fix length returned by t{l16,16l}v_put
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-18 14:20:35 +01:00