Commit Graph

3885 Commits

Author SHA1 Message Date
Harald Welte c3aa8f903a ns2: Move to one common/shared ns2_bind_alloc()
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-02-01 09:39:29 +01:00
Harald Welte b40bf8ba3b ns2: Add a rate_ctr for each NS-UNBLOCK
We have one for BLOCK, so let's also add one for UNBLOCK.

Change-Id: I693109b7bc4d72b6803b40aae15327389aa37c69
2021-01-31 12:34:36 +01:00
Harald Welte 4c54f59aa5 ns2: Implement more rate counters
The counters had all been lost in the ns -> ns2 configuration,
let's try to implement some more of them: LOST_ALIVE, BLOCKED,
LOST_RESET.

Change-Id: I75d8637bd142722fdf9a162a2369aa9cdc980a57
2021-01-31 12:34:36 +01:00
Harald Welte f22ae5af5f ns2: count number of dropped packets / bytes on transmit
Differentiate between successfully transmitted packets/bytes,
and pacets/bytes that were dropped (i.e. overflow of net-device)

OsmoNSdummy# show ns nsvc 1001 stats
 NSVCI 01001: UNBLOCKED PERSIST data_weight=1 sig_weight=1 fr)netif: hdlc1 dlci: 1001
  NSVC Peer Statistics:
   Packets at NS Level  ( In):       36 (0/s 8/m 32/h 0/d)
   Packets at NS Level  (Out):    23344 (170/s 20556/m 13119/h 0/d)
   Dropped Packets      (Out):    30692 (230/s 27056/m 17221/h 0/d)
   Bytes at NS Level    ( In):      262 (0/s 24/m 250/h 0/d)
   Bytes at NS Level    (Out): 32741312 (238680/s 28849400/m 18391024/h 0/d)
   Dropped Bytes        (Out): 43014628 (322920/s 37986624/m 24101344/h 0/d)

Change-Id: If21906ff5379038f7be10cf48c68d1f756dd7c1e
2021-01-31 12:34:36 +01:00
Harald Welte 5e0ef6f958 ns2: Properly report packet drops in FR code
When the FR code decides to drop a packet (ENOBUFS from the AF_PACKET
socket for non-signaling packet), let's report that back via the
frame_relay code into the generic NS2 code.

This way the generic NS2 code always knows if a packet was actually
successfully  transmitted, or if it was dropped for some reason.

Change-Id: I4bb517fd04af69dbe6da628b132d57994ab3e5a4
2021-01-31 12:34:36 +01:00
Harald Welte e5f55f73bd ns2: Increment Rx and Tx byte / packet counters
Change-Id: If5e93f69cddbc8962cbbae38c07b504dd9b1ecd1
2021-01-31 12:34:36 +01:00
Harald Welte 5a5bf720a8 ns2: encapsulate calls to nsvc->bind->send_vc()
Don't call the function pointer of the underlying transport
directly, as we many still want to do some common processing,
such as statistics counting (see follow-up patches).

Change-Id: I8d14c7b8d3aacc2bed033072d7934dbd6aab41df
2021-01-31 12:34:36 +01:00
Harald Welte 3d5eaee726 ns2: Use named array initializers to avoid mistakes
It's always a bad idea to have an array of descriptions that's indexed
by an enum, without using named initializers.  It's too easy to get
inconsistencies.

Change-Id: Id0ebd2a202a465ca0298f4245f1fb5c495235fc8
2021-01-31 12:34:36 +01:00
Harald Welte d06128d17d ns2: Work around AF_PACKET socket ENOBUFS problems
AF_PACKET sockets cannot be written-to using select(), as they
will always return "writable" but then still fail with ENOBUFS.

This also means that we cannot use osmo_wqueue() as it assumes
that a writable socket can actually be written to.

As there's no way to figure out when exactly we can again perform
a successful write, we have no other option but to start a timer
and re-try at a later time.

We will scale that timer based on the estimated duration of transmission
for the just-failed PDU on the line rate of a 31TS E1 Line.

Furthermore, with this patch, we stop queueing anything but signaling
traffic (NS-BVCI=0) or Q.933 LMI.  User data (NS-BVCI != 0) will
instead be dropped in order to avoid buffer-bloat.

Change-Id: I4f79a246236c94175ceffa5f3f556c8931c6bc62
Closes: OS#4995
2021-01-31 12:34:36 +01:00
Harald Welte 0b7614b408 osmo-ns-dummy: Add simple NS traffic generator
This adds a simple NS traffic generator that can be used to perform
load testing on NS links, particularly those with limited bandwidth
such as frame-relay E1 lines.

Related: OS#4995
Change-Id: Iad3b694c85962dbbc6b4a27a0ed5bc841add464f
2021-01-30 22:13:03 +01:00
Harald Welte f0073d7045 ns2: Log ERROR if we cannot transmit a packet due to ENOBUFS
Related: OS#4995
Change-Id: I2ba64e96c60e23d2e6c8ecdcab0b52b3833f092c
2021-01-30 20:09:35 +01:00
Harald Welte 335c550fab ns2: Use proper return value from write_queue callback function
write_queue expects a -errno value on error, not '-1'.

Change-Id: I93c858facfe7e1c533df8dccc4502a574686bc8a
Related: OS#4995
2021-01-30 17:59:51 +01:00
Philipp Maier 4d40047c50 gprs_bssgp: agregate RIM related code in gprs_bssgp_rim.c
gprs_bssgp and gprs_bssgp_util.c also contains code related to send and
receive RIM PDUs via BSSGP and also code to encode and decode RAN
INFORMATION PDUs. Lets move this to gprs_bssgp_rim.c

Change-Id: Icda279452962b06e552cb1361d2a27b7dc8a6b04
Related: SYS#5103
2021-01-29 21:27:18 +00:00
Pau Espin 3e3f377749 gsm: bts_features: Introduce BTS_FEAT_CCN
This feature is used by BSC to gain knowledge on whether a given BTS
supports GPRS Cell Change Notification (CCN) related procedures on PDCH,
and as a result enable or not by default the CCN_ACTIVE bit in SI13 to
announce the support it is allowed to use the feature.

Related: SYS#4909
Change-Id: I61991266b95d0c13d51b47906cc07846e9cf1390
2021-01-29 18:01:14 +01:00
Pau Espin 5b6f1d7d7a gsm: Fix wrong length in SI13 GPRS Cell Options IE
Older commit adding the 2 bits for Rel-4 extension forgot to increase
the length field (see TS 44.060 Table 12.24.1)

Fixes: 946bb95af1
Change-Id: I20efb4403cdf6c5bc717502a7075630044142f17
2021-01-29 18:01:14 +01:00
Pau Espin 5f2b8e5edf cosmetic: fix typo in comment
Change-Id: I787cca5a032c57202a86dab18e1790ef3ad1509a
2021-01-29 17:04:14 +01:00
Pau Espin 377645d600 ctrl_connection: Initialize write_queue.bfd.fd to -1 during allocation
Otherwise fd is set to 0 by default, let's avoid accidentally closing
it if something goes wrong.

Change-Id: I98f744d2880fbb883719cdf1d3eb31f2b22a13b6
2021-01-29 11:21:09 +00:00
Daniel Willmann 9043205cd9 ns2: Fix assert when removing a bind listen
Change-Id: I3edd1e838f7516d9224045710047419039aa0ec0
Fixes: OS#4977
2021-01-29 11:37:41 +01:00
Alexander Couzens 260cd52bd0 gprs_ns2: correct vty config write
The vty configuration was wrong when any other node was
in between the vty configuration (e.g. gb or ss7).
The vty code doesn't have a relation between parent and child node.
It wasn't detected because this only happened in the sgsn.
The pcu doesn't have any binds defined.

Change-Id: I8a3d67d41baca36b4d1a951a574cd41e556355c5
2021-01-28 20:32:51 +01:00
Alexander Couzens e43b46e018 gprs_ns2: introduce gprs_ns2_vty_init_reduced() for the PCU
The gprs_ns2_vty_init_reduced() call initialized the ns2 vty without
configuration nodes (except timeout). The PCU can be only configured
by the BTS/BSC. It should not configured by vty.

Change-Id: I4437da74bd48ba64d3f16ea67afc26c45b6d3ac9
2021-01-28 13:54:32 +01:00
Alexander Couzens 2e1a3a982a gprs_ns2: remove api call gprs_ns2_dynamic_create_nse
The call was only introduced as workaround for the first implementation
of vty. There is no need for this anymore. The configuration can
just add "accept-ipaccess" to the bind to allow creation of dynamic
ipaccess NSE.

Change-Id: Ie924ead6da17657f3da334068c8ada82c8845495
2021-01-28 13:54:32 +01:00
Alexander Couzens da1bf8e835 gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty
Drop the vty(1) code and replace it with vty2. The vty(1) was only
used as intermediate to not develop a vty while developing a new
code base behind. Users of gprs_ns2_ has to use the new vty code.

API change which must be synchronized with osmo-pcu,
osmo-gbproxy, osmo-sgsn.

Change-Id: Ic2059e75d8ede8e5c29c4fef6be608ed79c8a97c
2021-01-28 13:54:24 +01:00
Pau Espin caf5317412 Revert "gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty"
This reverts commit b306094448.

It was merged too quickly and patches for projects using related
features are not yet prepared.

Change-Id: I8a2aaf74a47de8f4f0adb37d16426d199788e3fe
2021-01-28 13:38:23 +01:00
Alexander Couzens b306094448 gprs_ns2: drop gprs_ns2_vty, rename vty2 -> vty
Drop the vty(1) code and replace it with vty2. The vty(1) was only
used as intermediate to not develop a vty while developing a new
code base behind. Users of gprs_ns2_ has to use the new vty code.

API change which must be synchronized with osmo-pcu,
osmo-gbproxy, osmo-sgsn.

Change-Id: I8c3f2afecc74b78f7f914f7dce166cbcb63444eb
2021-01-28 11:56:37 +00:00
Alexander Couzens 138b96f21c gprs_ns2: refactor: ensure all enums have GPRS_NS2_
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-28 11:56:37 +00:00
Oliver Smith f2afb98c83 configure.ac: set -std=gnu11
Avoid using different dialects by accident (and resulting compiler
errors if compiler assumes a different dialect), like in
I72310886bef4db635078b75715c9d98ee45391cc.

Related: https://lists.osmocom.org/pipermail/openbsc/2019-September/013030.html
Related: https://lists.osmocom.org/pipermail/openbsc/2021-January/013360.html
Related: osmo-pcu Ia57ba101627e3cc0babeca82631e207a3e2e0960
Change-Id: Id79b13d3c498acb565f91eba650328fccb5a13ef
2021-01-27 13:42:12 +01:00
Philipp Maier 0fb33d2ed2 gprs_bssgp: log source and destination RIM routing information
Whenever a RIM PDU is received, log to which RIM routing information
(address) it is going to and where it is comming from.

Change-Id: Ia08d3b162a4f6257cccaa7f0764fa7ea498355ef
Related: SYS#5103
2021-01-26 16:36:53 +01:00
Philipp Maier 0a7e85ae81 gprs_bssgp_rim: cosmetic: connect routing identifier strings with "-"
The bssgp_rim_routing_info_discr_strs string list contains whitespaces,
when the whitespaces are replaced with a "-" the log output looks better

Change-Id: I26facd3dc160603da89dcd787cccf78b19a20f02
Related: SYS#5103
2021-01-26 16:36:53 +01:00
Philipp Maier c08a3fd30e gprs_bssgp_rim: add functions to convert a RIM-RI to a string
RIM routing formation structs can contain different variants of address
identifiers, so it is difficult for an API user to pick the _name()
function to generate a human readable string. Lets add
bssgp_rim_ri_name() and bssgp_rim_ri_name_buf() to make printing a
routing identifier easier.

Change-Id: Idca6bdccffe663aea71a0183ca3ea5bb5b59e702
Related: SYS#5103
2021-01-26 16:36:53 +01:00
Pau Espin 445a366c8a gprs_bssgp_prim.h: Add missing includes
Includes for struct gprs_ra_id and osmo_eutran_tai were missing.

Change-Id: I1c068b6841561003d4d7722daa6c2abb21363dda
2021-01-26 13:06:53 +01:00
Alexander Couzens f7e2cace2c gprs_ns2: drop the public prefix gprs_ from all static functions/structs/..
Change-Id: I6ba0599e5a6d6fabf93851dd3ec7716f2ef2d840
2021-01-25 16:18:21 +01:00
Alexander Couzens 8dfc24cb47 gprs_ns2: drop prefix of all internal exposed function
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-25 16:09:23 +01:00
Alexander Couzens ba5a9927b6 gprs_ns2: drop GPRS_ prefix of gprs_ns2_cs
gprs_ns2_cs is a privat enum while GPRS_ should only used
for public enums.

Change-Id: I79be92ca716366c2e07ea061c08d95bea817a8c7
2021-01-25 16:03:23 +01:00
Alexander Couzens 3f576ab486 gprs_ns2_vc_fsm: check NSVCI match the NSE
The NSVCI must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.

Change-Id: I0ebdd4f4135b03a7d44a93aff3846c8ec19f333b
2021-01-25 15:35:14 +01:00
Alexander Couzens 43771df63f gprs_ns2_vc_fsm: check NSEI match the NSE
The NSE must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.

Change-Id: I00bc04f3f46f5ae8ddd8b4b7d5479fb8e6463e1e
2021-01-25 15:35:14 +01:00
Alexander Couzens ba6345310f gprs_ns2: always pass a tp to gprs_ns2_vc_rx
In preparation of checking the NSEI/NSVCI in ns2_vc_rx. It
makes the function less error prone as the *tp is always defined.

Change-Id: I3cd6ed20cdc1390075669e1d0101154c51f3997f
2021-01-25 15:34:39 +01:00
Alexander Couzens 8f215c9fc9 tests: gprs_ns2: add unitdata unit test
test sending unitdata over a alive and blocked NSVC.

Change-Id: I2c44b711d004d2ca08e05d4f54519ad8dbd77c27
2021-01-25 15:28:47 +01:00
Philipp Maier cf11411ebb gprs_bssgp_rim: add value strings for enum bssgp_rim_routing_info_discr
Change-Id: Idd06d2e3df0d60409a89a474018a9d97f7772090
Related: SYS#5103
2021-01-22 19:59:31 +00:00
Philipp Maier 8b19d06643 gprs_bssgp_rim: add value strings for enum bssgp_ran_inf_app_id
Change-Id: I581d1176f82d6657d6136c32daa9c76dffb802a6
Related: SYS#5103
2021-01-22 19:59:31 +00:00
Philipp Maier 139c4ae003 gprs_bssgp_rim: add value strings for enum bssgp_nacc_cause
Change-Id: I3354699555569c2b0bd1b4313cffd32a0cbeffe9
Related: SYS#5103
2021-01-22 19:59:31 +00:00
Pau Espin d426ba6730 gsm: Introduce osmo_{rai,cgi_ps}_cmp() APIs
Similar to what we already have for other data types, such as
osmo_lai_cmp or osmo_cgi_cmp.

Change-Id: I00e329bc5be8674b30267dec238e7656ddfc21db
2021-01-22 20:32:45 +01:00
Pau Espin cc885fb0b6 gsm: Add missing osmo_*_cmp symbols to libosmogsm.map
Change-Id: I8ff677aa381118466d065abee7db20b15880352f
2021-01-22 17:44:04 +01:00
Oliver Smith 55934c4754 tests/*: fix control reaches end of non-void func
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-21 12:13:42 +00:00
Harald Welte b3d4778efb Revert "gprs_ns2_vc_fsm: check NSEI match the NSE"
This reverts commit 842599ca62.
Closes: OS#4965

Change-Id: I96882961e179bb63e3f4095571135244148dde20
2021-01-21 12:48:46 +01:00
Harald Welte 43cb90ff5d Revert "gprs_ns2_vc_fsm: check NSVCI match the NSE"
This reverts commit 9c1e04e580.
Related: OS#4965

Change-Id: Ic26e6ee8c225266dc31850e38976460cb0e81ebd
2021-01-21 12:46:59 +01:00
Harald Welte 2846ee2624 gprs_ns2_test: Fix compilation on Debian 8
[  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-21 10:23:20 +01:00
Harald Welte 8d6ca6933f logging_vty: Fix saving of "logging print file .. last"
Back in 2018 in I393907b3c9e0cc1145e102328adad0a83ee13a9f Neels
introduced "last" as an optional flag to log the file/line number at the
end of the line, rather than at the end of the header.  It seems nobody
has been usingi this feature, or at least never tried to save a related
config file, as there was no code whatsoever that would ever save this
optional "last" flag.

Change-Id: I7b6245256aecc425722242aaabc154ac58ba27a0
2021-01-21 10:23:19 +01:00
Alexander Couzens 9c1e04e580 gprs_ns2_vc_fsm: check NSVCI match the NSE
The NSVCI must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.

Change-Id: I8518bdb03e9e33b04b77a2a346d04c5d29544a6c
2021-01-20 17:50:55 +01:00
Alexander Couzens 842599ca62 gprs_ns2_vc_fsm: check NSEI match the NSE
The NSE must match the PDUs. The only exception is a RESET with
dialect ipaccess. However those will be handled later.

Change-Id: Ic8fc49d850490feb0ff69171a6b0881ae8696c0b
2021-01-20 17:47:10 +01:00
Harald Welte f294974e05 ns2: Unify logging context via log macros
Let's avoid open-coding the printing of log context and rather rely on
log macros to prefix each log line with the relevant context.  This
helps log readability, log post processing whether by grep or more
sophisticated tools.

Change-Id: I946c0e77686d91efc5afb62031e1ac1033a9a586
2021-01-20 16:42:33 +00:00