Commit Graph

931 Commits

Author SHA1 Message Date
Andreas Eversberg 6d78c5308a wip reconnect notify 2024-02-19 15:43:13 +01:00
Harald Welte 17586d41fa xua + ipa: Add support for I/O in OSMO_IO mode
This switches osmo_stream_{cli,srv} over to using the OSMO_IO
mode instead of the classic OSMO_FD mode.  The difference is that
we no longer read/write directly to a file descriptor, but we pass
message buffers to/from the library.

This in turn allows the library to use more efficient I/O mechanisms
as osmo_io backend, for example the Linux kernel io_uring.

Change-Id: I7d02037990f4af405839309510dc6c04e36c3369
Depends: libosmo-netif.git I6cf5bad5f618e71c80017960c38009b089dbd6a1
Depends: libosmocore.git I89eb519b22d21011d61a7855b2364bc3c295df82
Closes: OS#5752
2024-02-09 09:26:30 +01:00
Vadim Yanitskiy 02d664b1e4 build: include README.md into the release tarball
Change-Id: I4ffd3738b3230d7b2cb4f8ebfa5d59f9e6dca27f
2024-01-26 23:27:59 +07:00
Pau Espin 5744469021 ipa: Use ASP name as ipa_unit_name on dynamic ASPs
A recent patch fixed a long problem where the ASP name (instead of
expected AS name) was used as ipa_unit_name in IPA based ASPs.
For server side it doesn't matter much, sense anyway the ipa_unit_name
is actually restored on the struct with what's received in IPA GET_RESP
message (see ipa_asp_fsm_wait_id_resp()). So the fix was actually for
the client side in the scenario where a non-dynamic ASP with an assigned
AS was configured in the VTY.

However, dynamic ASPs usually have no assigned AS (because in general it
is really not created/configured, as the ASP is created on the flight).
As a result, the recent patch (see "Fixes" below), broke dynamic ASPs
case because from then one ipa_asp_fsm_start() would fail and terminate
the FSM because ipa_find_as_for_asp() was returning NULL.

So improve the recent patch by applying the previous logic for dynamic
ASPs:
* On the server side, it really doesn't matter since as mentioned, the
  field will be repopulated later on, but allows the code to avoid
  terminating the FSM and hence be brought up and be ready to receive
  clients.
* On the client case, this is how dynamic IPA ASPs were ment to be used
  when they were introduced anyway (use ASP as ipa_unit_id, meaning
  "AS name" == "ASP name").

Furthermore, on the client side, the non-dynamic IPA ASPs need their
bring up be delayed until assigned to an AS, because the AS name is sent
in ipa_unit_name field in Tx IPA ID RESP.
This usually happens at a later point than ASP (FSM) creation, because
first the ASP object is created (through VTY or API) and then assigned
to an AS through osmo_ss7_as_add_asp() usually from a later "asp" vty
command in the "as" node.

Fixes: 65741dca05
Change-Id: I0a741449450c998253b1e44a76a3b7fc224e0903
Related: SYS#5914
2023-12-12 19:18:27 +01:00
Pau Espin 59bab0187c cosmetic: Fix typo in function doc
Change-Id: I1c4fe7d1b3a5cdd4c2c9c942e292a7135467d9e2
2023-12-12 16:57:50 +01:00
Pau Espin 00ec53c057 vty: Introduce show cs7 instance asp-assoc-status
Change-Id: I96ef4c0500991c9b86ab5991fb338ea20a18ff33
Depends: libosmocore.git Change-Id I3e1c84526b006baff435bbbca49dc6cf7d201cf5
Depends: libosmo-netif.git Change-Id I78a0bd8279a04f4011c7273e0f542981308e482f
Related: SYS#6636
2023-12-12 16:07:46 +01:00
Pau Espin c86bdae6f5 vty: Introduce show cs7 instance asp-remaddr
Depends: libosmocore.git Change-Id I3e1c84526b006baff435bbbca49dc6cf7d201cf5
Depends: libosmo-netif.git Change-Id I78a0bd8279a04f4011c7273e0f542981308e482f
Related: SYS#6636
Change-Id: Ie5ac1d0ee74d2b977b1f5319cd88566df7994fd0
2023-12-12 16:07:46 +01:00
Pau Espin 483894bfd1 vty: Introduce cmd 'show cs7 instance asp name ASP_NAME'
Allow printing only a specific asp by name. Useful when user is only
interested in a uniqe ASP and there's lots of them configured.

Related: SYS#6636
Change-Id: I08426272069ce5f3c8403b08dcaf686547bee336
2023-12-12 16:07:45 +01:00
Pau Espin a431b9230b vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
Until now, we were in general printing the list of remote addresses that
were stored in config, because we didn't have an easy way to retrieve
the addresses from the socket. Since recently some libosmocore APIs make
that easy, so use them now.
If the socket is not yet created, then log the addrress list from the config.

Furthermore, take the chance to print now both local and remote
addresses.

Related: SYS#6636
Change-Id: I607e4c2dd37f07bf1c07c88681918184e92202ea
2023-12-12 16:07:17 +01:00
Pau Espin bbecd572a0 vty: show cs7 instance asp: Swap columns SCTP Role and Remote Address list
The Remote Address is by far the potentially largest column, as well as
the one with more variable length, so move it to the end for better formatting.

Change-Id: I4854219f8898266ae47b9117ef79dbad30a5b0fd
2023-12-12 15:54:19 +01:00
Pau Espin 6ad714de98 vty: Retrieve IP addr set from sk when dumping xUA server
Until now we simply printed back the configured set of IP addresses, not
the one retrieved from the socket at the time, because we didn't have
any easy means to retrieve multiple addresses from a socket.
This is possible since recently using libosmocore APIs. Use them.

Depends: libosmo-netif.git Change-Id I1bd3f790d93af74c150938a59108b882ad2820f3
Depends: libosmocore.git Change-Id I18a0e1a652a3e8ef3e97154355eb1d07a14ef0bd
Related: SYS#6636
Change-Id: I331b6e2fe11cd97e286b7ba684d4a17b8055f9d4
2023-12-12 15:54:13 +01:00
Pau Espin 65741dca05 ipa: Fix client setting unit_id with ASP name instead of AS
This was broken since ever. The client was submitting the ASP name
 in the unit_id field during IPA handshake, and the server was
expecting it to contain the AS, so it failed with message:
"Cannot find any definition for IPA Unit Name '%s'" in
ipa_asp_fsm_wait_id_resp().

Fixes: 5f0a8df34c
Change-Id: I249964e171f578726439c40e01ae85aa447afada
2023-12-07 19:36:57 +01:00
Harald Welte 04ca01eaeb port from osmo_stream_*_get_ofd() to osmo_stream_srv_get_fd()
The existing/old osmo_stream_{srv,cli}_get_ofd() API functions are
only compatible with OSMO_FD mode of libosmo-netif/stream.  In the
OSMO_IO mode, there is no osmo_fd involved, and hence those functions
are illegal to call.

Let's instead migrate over to the new osmo_stream_{srv,cli}_get_fd()
which directly return the file descriptor integer value.

Change-Id: I12c66badfb4bdfdfe71f1716de960d353d3548b1
Related: OS#5752
2023-11-25 17:28:59 +01:00
Pau Espin 42ed1bf15d sccp_scoc: Fix remote PC not assigned preventing RSLD to be sent in st WAIT_CONN_CONF
Scenario: RUA Connect triggers SCCP CR towards peer, and we move to
CONN_PEND_OUT state where we expect to receive CC.
However, if some timer (like X31) times out before we receive CC (eg
because CC takes a long time to come), we end up in state
WAIT_CONN_CONF.

In that state, according to Figure C.2/Q.714 (sheet 2 of 7), among other
possibilite we wait for CC, and if it arrives, we send an RLSD to the
peer to inform him that we released the conn, and wait
for the peer to ack the RLSD, then release all state.

Given the scenario above, scoc_fsm_wait_conn_conf() was not assigning
the received OPC from the CC to the conn->remote_pc (unlike
scoc_fsm_conn_pend_out() which does it properly). As a result, when
trying to send teh RLSD it would fail and never transmit RLSD, taking
then a long time to release through T(rel) (10-20 seconds), and probably
longer in the peer (T(iar) or similar?).

Rua Connect triggers tx of SCCP CC:
Received SCCP User Primitive (N-CONNECT.request)
XUA_AS(as-clnt-msc-0)[0x55f11c7df980]{AS_ACTIVE}: Received Event AS-TRANSFER.req //Tx CC
SCCP-SCOC(929)[0x55f11c909c90]{IDLE}: State change to CONN_PEND_OUT (no timeout)
...
X31 timeout triggers state change:
map_sccp(...-SCCP-929)[0x55f11c909820]{wait_cc}: Timeout of X31
SCCP-SCOC(929)[0x55f11c909c90]{CONN_PEND_OUT}: Received Event N-DISCONNECT.req
SCCP-SCOC(929)[0x55f11c909c90]{CONN_PEND_OUT}: State change to WAIT_CONN_CONF (no timeout)
...
CC arrives, but conn_remote_pc is not properly assigned and tx of RLSD fails:
SCCP-SCOC(929)[0x55f11c909c90]{WAIT_CONN_CONF}: Received Event RCOC-CONNECT_CONFIRM.ind
MTP-TRANSFER.req from SCCP without DPC?!? called=RI=0 // PROBLEM HERE!!!!
SCCP-SCOC(929)[0x55f11c909c90]{WAIT_CONN_CONF}: State change to DISCONN_PEND (no timeout)
...
SCCP-SCOC(929)[0x55f11c909c90]{DISCONN_PEND}: Received Event T(rel)_expired

Related: SYS#6616
Change-Id: I9f9f78c92dd95f38af7b03037e60a1c993d7e5b0
2023-10-31 15:51:50 +00:00
Max 427c462484 cosmetic: add spec reference
Related: OS#5579
Change-Id: I4d6bf9d0e681db779770b2fb815f7f9c5e608b15
2023-10-31 09:37:32 +00:00
Pau Espin 87ed6e7b53 sccp_demo_user: Allow initiating conns from vty in server mode
This allows starting SCCP conns from within sccp_demo_user, which in
turn allows testing more scenarios in osmo-ttcn3-hacks.git
SCCP_RAW_Tests testsuite.

Related: SYS#6616
Change-Id: I7d5b3534c496dca8a3f3e66025af554bbe860c04
2023-10-30 19:06:57 +01:00
Harald Welte b24cdce2d9 Fix counting received IPA packets in server mode
When operating an IPA ASP in server mode, we were not counting the
packets using the related stat item:

For example:

OsmoSTP# show stats
Ungrouped counters:
SIGTRAN Application Server Process (6)('asp-dyn-5'):
 Total number of packets received:        0 (0/s 0/m 0/h 0/d)
 Total number of packets transmitted: 235370503 (129/s 7682/m 442447/h 11342653/d)

This patch adds the missing counter increment.

Change-Id: I75881d115b5c2c2567c4731bcf2cabe11f367117
Closes: SYS#6600
2023-10-17 13:03:01 +02:00
Pau Espin 08001775c6 xua_server: asp: Support removing local addresses
The socket is reconfigured (and hence reopened) upon VTY node exit if
changes were stored in the address list of the xua_server
(osmo_stream_srv_link).

Related: OS#4607
Change-Id: I942edff7695efeea7753f22e31c2098c201290ff
2023-10-04 11:21:05 +00:00
Pau Espin c5a4b772b1 asp: Support removing local & remote addresses
The local address is removed dynamically from the socket if it is
already created. For remote addresses, it doesn't make any sense (and
there's no API to do so) because the remote address list passed to it is
only used at connect() time, when the socket is created. During the
initial hanshake, the remote provides its own list of remote addresses.

Related: OS#6077
Related: OS#4607
Depends: libosmocore.git Change-Id Ifc6e7d643c2a0c53f479bfd0d5c36d08c0c01953

Change-Id: I554aee92285bd72eb90c6daf47b37055cb3067aa
2023-10-04 11:21:05 +00:00
Pau Espin 613e25305b sccp: Drop unused local variable
Change-Id: I7f829f1c285d01faeaad317262ddd51f39e42886
2023-10-04 11:20:52 +00:00
Pau Espin f8aaa75852 asp: Support adding new local addresses after the ASP was started
Related: OS#6077
Depends: libosmocore.git Change-Id Ifc6e7d643c2a0c53f479bfd0d5c36d08c0c01953
Change-Id: I8318d2693f3a9c479b18ab1d660431c1ec77c004
2023-10-02 13:15:51 +02:00
Pau Espin 44cf7c8231 asp: Apply SCTP peer primary address changes after the ASP was started
Related: OS#6077
Change-Id: I088b9a59ebfd85f3ce4a26f28bf41472d9b9da60
2023-09-29 18:24:01 +02:00
Pau Espin 3ed3b2c2ed asp: Apply SCTP primary address changes after the ASP was started
Related: OS#6077
Change-Id: I2beb597b2e98d8983177fb21882a461219b3aa58
2023-09-29 18:23:39 +02:00
Pau Espin 4a744e2234 Split osmo_ss7_as functionalities to its own file
Change-Id: I6e39dcb594ffe918ba117fce08cae7b5a6fd2dcc
2023-09-29 17:36:32 +02:00
Pau Espin e39a104727 Factor our osmo_ss7_as allocation to its own function
This makes it easier to find out where the AS struct is allocated, plus
also split between inst code looking up + checking + allocating and the
code doing the allocation and initialization of the AS.

Change-Id: Ie237ec8ac4b2e15b76fce3b3a56f47a59fdcc76e
2023-09-29 17:36:32 +02:00
Pau Espin adbf243e1b Split osmo_ss7_asp_peer functionalities to its own file
Change-Id: I4fe457dc0ee1e904e05423557cfba2505b315a75
2023-09-29 17:36:21 +02:00
Pau Espin 07e788fc94 asp: Factor out helper function to match host in asp_peer
Change-Id: I6f13b285be09982ec83107ff96ade4dabf843815
2023-09-29 16:50:02 +02:00
Pau Espin 785d160da8 cosmetic: src/Makefile: reformat to one item per line
Change-Id: I9efb883d2a56723300a66b7e13c7aa079f2e4600
2023-09-29 16:34:11 +02:00
Harald Welte 743deba334 sccp: Introduce initial support for SCCP LUDT + LUDTS messages
* LUDT/LUDTS is now properly received and passed along to the app.
* LUDT/LUDTS is now used if the data to transmit spans more than 255
  bytes.

Related: SYS#6566
Change-Id: Ic91abfc921f5e4f36045bfa325333112cddd9fa6
2023-09-21 16:35:40 +02:00
Pau Espin 033072fc2d cosmetic: sccp_types.h: Fix typo in comment
Change-Id: Ia75502874e3a07dbd6b685a6721adaedb429e904
2023-09-21 12:59:12 +02:00
Pau Espin 945b252a48 sccp2sua: Produce smaller output if msg contains no optional section
Change-Id: I5c8fcb30b76ac7bafd4a99bc3004049644e7e3f9
2023-09-21 10:32:10 +02:00
Pau Espin 1dab088701 sscp2sua: Constify several more parameters
Change-Id: I0d0997a137f65bccdf8eeda70d95f3f908d2d91a
2023-09-20 18:39:25 +02:00
Pau Espin 88de6d403b sccp2sua: remove unused msg param from sccp_{addr,data}_to_sua_ptr
Change-Id: If4a8283614639d456d2bdf2b31873e28c68f59bc
2023-09-20 18:32:14 +02:00
Pau Espin 0d7f99fd59 xua_msg: Implement xua_msg_dump() using OSMO_STRBUF
This fixes a buffer overflow when a big message (eg containing long
unitada, LUDT) is passed.

Change-Id: I3f91586a96df2d683865715dabb4d6bc042fb33f
2023-09-20 18:17:42 +02:00
Pau Espin c4c444ec7e sccp2sua: constify params of sccp_ptr_part_consistent()
Change-Id: I8011e5cf26d535120829c3925693a2bb3efdb864
2023-09-20 14:43:21 +02:00
Pau Espin 15efbbdba4 Bump version: 1.7.0.56-abf26-dirty → 1.8.0
Change-Id: I563bba2eaca7f569a5216fb8268122c0f55ef48b
2023-09-12 14:03:25 +02:00
Pau Espin abf26ce1ad Allow configuring per-ASP SCTP INIT parameters
Related: SYS#6558
Depends: libosmo-netif.git Change-Id I5343c7659881b29e0201e72badbc2d07e1ef2dca
Change-Id: I4c104f0313b549efab7fae2e81a163474e9bcd4b
2023-09-08 18:14:52 +02:00
Pau Espin 13a341e813 asp,xua_srv: Use new osmo_stream API to request sockopt SCTP AUTH/ASCONF SUPPORTED
Support to enable AUTH/ASCONF in the SCTP socket was added recently in
libosmocore and libosmo-netif, in order to support the Peer Primary
Address features used by the libosmo-sccp code.
The code to request the AUTH/ASCONF support through setsockopt() was
internally applied transparently by lisbosmo-netif's osmo_stream. This
is not 100% disarable since other users of the library may not need/want
that behavior.
As a result, libosmo-netif's osmo_stream no longer enables the SCTP
AUTH/ASCONF support by default, but it must be enabled through
the new osmo_stream_{cli,srv_link}_set_param() API.

This change in behavior of the API/implementation can be done because
all these new features are pretty new and no release of
libosmocore/libosmo-netif/libosmo-sccp has been released yet.

Related: SYS#6501
Related: SYS#6558
Depends: libosmo-netif.git Change-Id I2607c1c926a625986cd851adc65dd8b4de83d6ab
Change-Id: I16c97fc148792aa3e39b7414899660990c39dfff
2023-09-08 18:14:37 +02:00
Pau Espin 0937875983 ss7: Split asp and xua_server into their own files
This allows having a clearer picture of the several entities involved,
as well as simplifying the files.

In the future, we can do the same for AS, route, etc. and leave osmo_ss7
for the "instance" object.

Change-Id: I3d43268459d61b0b9f9bec34bf31dc0851fa5e48
2023-09-07 13:14:51 +02:00
Pau Espin 08cb70e158 ss7: Drop unneeded else branch after early return
Change-Id: I845be6bfbf36ec8a38697ca92420483a9d41aa6c
2023-09-07 12:59:44 +02:00
Pau Espin d01c45918d ss7: Rename internal APIs to avoid exporting them in so file
Change-Id: Ibb22c1dc1ec73fc574cc3d38664874114f681c37
2023-09-07 12:48:52 +02:00
Harald Welte 4c1751ddca m3ua: Add some TODO comments on where we fall short of our potential
Change-Id: I75d7b8f3fb6a06f6941b6dff4072287fdbb1d33e
2023-09-01 10:39:20 +02:00
Harald Welte b93e1d0120 ipa: use LSBs of file descriptor as SLS in IPA->M3UA direction
when IPA/SCCPlite traffic traverses the osmo_ss7 stack, so far the
SLS of the MTP3 label was always set to 0 (default initialization).

However, in order to achieve a better distribution of signaling traffic
in SS7 networks that actually utilize the SLS to select any links (or
ASPs), it makes sense to use non-zero values.

Instead of introducing some kind of new, configurable attribute for
each ASP (IPA client connection), let's simply use the lower 4 bits of
the file descriptor integer.  Those file descriptors should have a
roughly equal distribution, resulting in traffic (from multiple IPA
clients) to be spread across the 4-bit SLS number space.

Also, this mechanism ensures that traffic from one IPA client will
always get the same SLS and hence routed the same way in any underlying
CS7/SS7 network.

Change-Id: Ice7bab997b84cfed00c7d6d780c70f4e9fac6002
Related: SYS#6543
2023-09-01 10:28:14 +02:00
Pau Espin 1edd02bb3b asp: Monitor SCTP_PEER_ADDR_CHANGE events to re-apply configured Primary Address
The kernel doesn't store state about a "always-preferred" Primary
address, it simply applies the requested one at the time the request is
done. If afterwards the remote address becomes unavailable, the kernel
will end up giving up on it and selecting anoter one as primary address.

If the VTY-configured Primary Address become available after a while
(signaled by the kernel in the SCTP_PEER_ADDR_CHANGE), make sure to
apply it again.

Similary, if the peer sends us an ASCONF changing our Primary Address,
we should discard that and apply/overwrite *iff* the user explicitly
VTY-configured one (kernel announces the change through
SCTP_ADDR_MADE_PRIM in this scenario).

Related: OS#6076
Change-Id: I2e54e6f9e424350474db6dec6ab604b33a03f88b
2023-08-21 13:01:47 +02:00
Pau Espin 8b8458d153 asp: Allow setting IP address as SCTP primary upon conn establishment
This is an initial implementation to set the local SCTP Primary address
as well as the peer's Primary Address (through SCTP ASCONF messages).
The Primary address is only set upon conn establishment (after connect()
 for clients, or accept() for severs), which means no logic is
introduced to make sure that primary address is kept during the entire
operation of the SCTP association (for instance if the Primary address
becomes unavailable and the stack changes the primary, and later on that
address becomes available again, the primary addres won't be set back to
the initially configured one).

Related: OS#6076
Change-Id: I4a9fc1a4ad82ed20ece328bc53fca58299d744ca
2023-08-21 12:23:52 +02:00
Pau Espin 58fd289443 ss7: Use libosmo-netif's osmo_stream_{cli,srv}_recv() APIs
Since libosmo-netif.git Change-Id
I4cb94d264109f1b763cccd44c6ba049cc7509319, we receive SCTP notifications
in both client and srv, so there's no real need to use sctp_recvmsg()
directly.

Change-Id: If3d78b636e8e224aa9c8597d0b242e29d3e3c84e
2023-08-07 19:58:14 +02:00
Pau Espin f9852ae077 ss7: Log addr and event state for SCTP_PEER_ADDR_CHANGE
Change-Id: I989f0180dab25cd6fb1a0c0a49c04a03be118ba3
2023-08-07 17:11:49 +02:00
Pau Espin e798ebdf6d tests/vty: test multiple local/remote IP addresses
Change-Id: I9e8c6499b26edea271ee8d8c4ab86506e765e000
2023-08-03 17:37:53 +02:00
Pau Espin a18f907aaf cosmetic: Fix pointer location format
Caught by linter:
ERROR:POINTER_LOCATION: "foo* const* bar" should be "foo * const*bar"

Change-Id: Icb3adff115e77fca273fdbfda6c7de1ddf1b61cd
2023-08-03 17:14:08 +02:00
Pau Espin 4ddaee9362 asp: Make ASP default LM timers VTY configurable
Related: SYS#6511
Change-Id: Ib62e19f2e528e8b2792cbb51a5900dc3463ebd06
2023-07-11 14:56:26 +02:00