Commit Graph

917 Commits

Author SHA1 Message Date
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
Pau Espin 5cf725b191 ss7: Refactor osmo_ss7_asp_find_or_create()
Move allocation code to its own function. Simplify
osmo_ss7_asp_find_or_create() code paths.

Change-Id: Ibbf20c63fc1d2b22a7c5d750002f94795ee31f26
2023-07-11 14:55:17 +02:00
Pau Espin c086a8ed42 sccp: Use tdef to implement osmo_sccp_timers
Related: OS#4372
Change-Id: I1dbe49a83a1bcddf074d5e638babd065834a0ebd
2023-07-11 14:55:14 +02:00
Harald Welte 1532791798 M3UA/SUA: Don't add empty routing context IE in DUNA/DAVA/DUPU
Before this patch, the code generating a DUNA or DAVA message would
potentially generate a ROUTE_CTX IE with zero-length content, rather
than skipping such an IE altogether if no routing context[s] are given.

Change-Id: I19d0382cd2d428a91ac716182b9d86dcdc2c2ebd
Related: SYS#6511
2023-07-10 08:36:40 +00:00
Pau Espin 7afbc23c2d xua_default_lm_fsm.c: Log rx ASP_UP timeout with NOTICE level
Some user run into this scenario recently and it was difficult to find
out why the SCTP links were being restarted. Add a new log line with
NOTICE level explicitly stating the reason to restart the ASP.

Related: SYS#6511
Change-Id: I5a388d2d96bcf1cbb76981c476abf37dbe213df0
2023-07-09 07:18:31 +00:00
Pau Espin a8aab23588 vty: Improve output of show cs7 instance <0-15> asp
Role and SCTP Role are now printed. Several formatting issues are fixed
or improved.

Related: SYS#6488
Change-Id: Id22bd4e74fb6f79950adba58862d379203d36760
2023-06-27 16:49:55 +02:00
Pau Espin 1470379c27 Set stream_cli/srv name to contain ASP + sockname
Upon connect/accept, update the name to contain both the ASP and the
sockname of the established socked. This allows easily identifying the
stream based on IP layer as well as upper xUA layer.

Example logs:
"""
stream.c:1193 SRV(m3ua,::1:2905) accept()ed new link from ::1 to port 2905
stream.c:1672 SRVCONN(asp-dyn-0,(r=::1:43568<->l=::1:2905)) connected read/write (what=0x1)
stream.c:1589 SRVCONN(asp-dyn-0,(r=::1:43568<->l=::1:2905)) message received
"""
"""
stream.c:521 CLICONN(asp0){CONNECTING} connection established
stream.c:552 CLICONN(asp0,(r=::1:2905<->l=::ffff:127.0.0.2:35911)){CONNECTED} connected read
stream.c:401 CLICONN(asp0,(r=::1:2905<->l=::ffff:127.0.0.2:35911)){CONNECTED} message received
"""

Depends: libosmo-netif.git I539a0d29d11348efe702f971965a55cf56db5c59
Change-Id: I05bc5f6c7795f62c1814c1c774287b41ee85a475
2023-06-20 19:52:46 +02:00
Pau Espin af768c716a Add osmo_ss7_asp getters for name and proto
Some apps such as osmo-bsc are accessing some of those fields, so better
add a getter API to make it easier to update the struct contents.

Change-Id: If9acfca1abc9ab7eb6d2388f548d7ee577b9c5ac
2023-06-20 14:11:46 +02:00
Pau Espin 5d30f648f4 Forbid partial VTY configurations of ASPs with name asp-clnt-*
A recent commit (83db938859) changed the
behavior of default "sctp-role" and "role" values of ASPs named
asp-clnt-* which are used by osmo_sccp_simple_client_on_ss7_id(), in
order to avoid having different default values when than function is
used, which is totally confusing for end users.

As it was already informed when submitting the mentioned commit, it
changes the behavior on that specific case, and that made some users
start having problems without a proper "your config is wrong!" error.

This commit addresses it by basically forbiding that exact use case,
that is, partially defining an asp-clnt-* ASP through VTY without
explicitly configuring a "role" and "sctp-role". With this patch,
function osmo_sccp_simple_client_on_ss7_id() will print a proper error
informing the user and will return NULL, potentially triggering an early
program exit which can then easily be fixed by using proper
configuration.

Related: SYS#6486
Change-Id: I65b5fad2ec06a9d9c521f1e3ce8aab633da95a47
2023-06-16 18:18:35 +02:00
Pau Espin 83db938859 osmo_sccp_simple_client_on_ss7_id(): Always follow VTY config of ASP if it was explicitly defined in VTY
The VTY config defaults are "role sg" and  "sctp-role server".
However, if not set explicitly in VTY,
osmo_sccp_simple_client_on_ss7_id() was replacing them to "role asp" and
"sctp-role client".
This is fine if the ASP is not defined/created at the VTY (aka
dynamically created with no config), but if the ASP is defined in the
VTY it becomes really confusing, since it's picking different defaults
than the usual ones.

Hence, follow always the same VTY defaults in
osmo_sccp_simple_client_on_ss7_id().

As a result of this change:
- Programs not defining the ASP over VTY keep the same behavior (ASP is
  created with role=asp and sctp-role=client)
- Programs defining ASP over VTY (eg. "asp asp-clnt-msc-0 5000 0 m3ua")
  explicitly setting "role" and "sctp-role": keep the same behavior
- Programs defining ASP over VTY but not explicitly setting "role" or
  "sctp-role", will get now the usual defaults instead.

So in summary, strange cases where osmo_sccp_simple_client_on_ss7_id()
is used (osmo-bsc, osmo-hnbgw, osmo-msc) and the dynamically created
ASP is created through VTY, then the config file must also explicitly
define the following lines:
role asp
sctp-role client

This patch also changes the "show running-config" VTY cmd to also always
show the configured role and sctp-role values, which are of vital
importance to understand a given setup.

Change-Id: Ie81987265118e48173211f88b27a006115dc62d4
2023-06-13 20:07:18 +02:00
Pau Espin 0aff5d101d osmo_sccp_simple_client_on_ss7_id(): Support ASP explicitly configured as sctp server
Right now, if a user configures an cs7 instance, as and asp (with
sctp-role server) in the VTY, then the function
osmo_sccp_simple_client_on_ss7_id() (used by osmo-bsc, osmo-msc,
osmo-hnbgw, etc.) will silently change the config to be SCTP client.
This is really confusing, since the user configured explicitly the ASP
as server but ends up running as client.
Instead, if the user explicitly configured the ASP as SCTP server,
allow it (after validating the user also properly configured a xUA
server through VTY).

Change-Id: I20de33edb8751a515d6719c49efadfc387dd85f8
2023-06-13 20:05:58 +02:00
Harald Welte 2a0ccafbf8 cosmetic: fix various typos in comments, log messages and VTY strings
Change-Id: I9a8afc07ae278100ffe34407db0e196f0c9ce8af
2023-06-13 17:24:27 +02:00
Pau Espin 8698f273d2 .gitignore: Ignore *.pyc
vty/config tests were added recently, which use python and end up
generating __pycache__/osmoappdesc.cpython-311.pyc when run.

Ignore those files as done in other projects such as osmo-bsc.

Change-Id: I8129a4a124457411c8163089ec2bac32f3e1c2b7
2023-06-08 13:57:01 +02:00
Oliver Smith 7e6bce7322 systemd: depend on networking-online.target
Related: SYS#6400
Change-Id: I7e88d7f48fb1f359fc9147acf3e69525c856d4e8
2023-05-26 14:10:12 +02:00
Vadim Yanitskiy 1f50d451a0 copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
Change-Id: Ibb6e904b3a2bb6e569bed76cad5e0c982e055612
2023-05-18 17:22:26 +07:00