Commit Graph

733 Commits

Author SHA1 Message Date
Pau Espin 535e43268c xua: Avoid multiline log in xua_msg_dump()
In general we want to avoid multiline log messages since they make
parsing more difficult. Also output in VTY over telnet looks strange
(indentation incremented at each new line).

Change-Id: Id9084d0e0f976bb374186db93d6ff8062b99e238
2019-11-12 21:35:24 +00:00
Pau Espin 30275e13ef ss7: Set correct local addr and port during dynamic ASP creation
Change-Id: I54aada351d5fb74f5015fdfe691d0b237354743c
2019-11-12 14:18:39 +00:00
Pau Espin 6090d7e6b7 ss7: Improve log formatting during ASP restart
Since it may act sometimes as a server and sometimes as a client, let's
better use one more neutral (2-side arrow) connector, and mark which
address is the local and which is the remote. We already use same
formatting in other osmocom code.

Change-Id: I42feaa16790f02b98bcda65281de8cd9295ddcb6
2019-11-12 14:18:39 +00:00
Pau Espin 81d2f1e502 xua: ipa_asp_fsm: Allow receiving IPA ID ACK before IPA ID RESP
Since there's no official spec for IPA and some
implementations seem to like sending the IPA ID ACK before
the IPA ID RESP, let's catch it and feed it after we receive
the IPA ID RESP and we are in correct state. Otherwise the connection
would deadlock during the initial handshake.

That's the case with our TTCN3 IPA implementation running STP_Tests
suite.

Change-Id: I99f5346a3854ca07979020245897334197f3cd3b
2019-11-12 14:18:39 +00:00
Pau Espin 173dd627cd xua: ipa_asp_fsm: Allow moving ASP to inactive state
If AS is configured with Traffic Mode Override, then if a new ASP
becomes active, all previous ASPs are considered to be inactive and new
data is sent to the newly activated ASP.

Remark: It's still unclear which methodology/implementation will follow
when the last activated ASP becomes inactive/shutdown. Then probably
another one should be activated at that time, but that logic is not
there implemented as far as I know.

Change-Id: I4ff246b2f899aaa3cf63bbdb3f3d317dc89b3d15
2019-11-12 11:53:17 +00:00
Pau Espin b6140e4b43 xua: Don't send NOTIFY messages to IPA ASPs
Change-Id: Ice3d948e4d2f57a8f52cfb93792d5f4d23284b96
2019-11-08 15:16:03 +00:00
Pau Espin b92589a1a2 ss7: Set ASP default remote addr to 127.0.0.1 if none set in VTY
Similar to what we do with local address. Should fix creating the stream
when no remote address is provided on an ASP configured through VTY.

Related: OS#4260
Change-Id: I33672e76a51a5d5a483906749d30e4c4e08b66ce
2019-11-08 15:07:45 +01:00
Vadim Yanitskiy 7cc8c03088 tests/sccp/Makefile.am: use sccp.o from $(top_builddir)
This change suspends the warnings about option 'subdir-objects',
by using the existing object file from the build directory.

Change-Id: I4dc2abb19c58fce0a12cc9799019878194c667d1
2019-11-07 13:37:40 +00:00
Pau Espin fec3785156 xua: On new ASPAC, set and notify other ASPs as inactive
RFC4666 sec 4.3.4.3.  ASP Active Procedures:
"""
 In the case of an Override mode AS, receipt of an ASP Active message
   at an SGP causes the (re)direction of all traffic for the AS to the
   ASP that sent the ASP Active message.  Any previously active ASP in
   the AS is now considered to be in the state ASP-INACTIVE and SHOULD
   no longer receive traffic from the SGP within the AS.  The SGP or
   IPSP then MUST send a Notify message ("Alternate ASP_Active") to the
   previously active ASP in the AS and SHOULD stop traffic to/from that
   ASP.  The ASP receiving this Notify MUST consider itself now in the
   ASP-INACTIVE state, if it is not already aware of this via inter-ASP
   communication with the Overriding ASP.
"""

Change-Id: I474f5cc1f6cbab72d010d1f8ac7ed2285e4c1c45
2019-11-06 18:32:01 +01:00
Pau Espin 5695f25b3d xua: Select only active ASPs during tx in Override traffic mode
Change-Id: I7eb049011b81c5141fd3edf6f0ae0202ffb2c6c9
2019-11-06 17:58:36 +01:00
Vadim Yanitskiy ed6cc3e51e osmo_ss7.c: fix xua_accept_cb(): properly assign role
Most likely, we want all dynamically allocated ASPs to play the SG
role by default. Otherwise when using the following configuration:

  cs7 instance 0
   xua rkm routing-key-allocation dynamic-permitted
   listen m3ua 2905
    accept-asp-connections dynamic-permitted

both OsmoMSC and OsmoBSC fail to establish connections.

Change-Id: Ib904ecf0e5d192a1024863f6f0fdf79301055655
Fixes: I2df9cd9747ad5c9a05d567d9a71bab6184c53674
Related: OS#4247
2019-11-06 15:53:59 +00:00
Pau Espin c71fb71916 xua: Reset AS traffic mode set by peer during shutdown
This way the AS can be configured to use different traffic modes over
time as long as they don't overlap in time. That is in this case where
no specific traffic mode is specified in AS local configuration (VTY).

Some RFC4666 state similar behvor of deleting data set by ASPs during AS
shutdown. For instance:
"""
   Other ASPs may continue to be associated with the Application Server,
   in which case the Routing Key data SHOULD NOT be deleted.  If a
   Deregistration results in no more ASPs in an Application Server, an
   SG MAY delete the Routing Key data.
"""

This allows for tests to easily re-use same AS to test different traffic
modes as long as they wait for the recovery timeout (2 secs by default,
configurable via VTY).
Related: OS#4220
Change-Id: I370aa3b5ddfc456c1be5b2585f2f470d5aa8d289
2019-11-06 15:53:15 +00:00
Vadim Yanitskiy bd8dff2751 osmo_ss7.c: fix copy-paste error in xua_accept_cb()
Change-Id: I3d991849459378b35a5b4f248cc208f956e494be
2019-11-06 22:02:31 +07:00
Vadim Yanitskiy 348af264d2 osmo_ss7.c: cosmetic: fix typo in xua_accept_cb()
Change-Id: Id925d09b9232b5e0124b977fa482e8cdc3c8b835
2019-11-06 19:34:21 +07:00
Pau Espin 6c4fabc826 xua: loadshare: select ASP for tx only if active
Change-Id: I4f1d1aa9395698e5b6b930a5092a4b914dd15fb3
2019-11-06 04:55:37 +00:00
Pau Espin e924573490 xua: Fix private function name
The function clearly does stuff the other way as its name used to
describe.

Change-Id: Ib65a0f2706e2eefe2446d3c9a6bdd19cf9cb81f2
2019-11-06 04:52:34 +00:00
Harald Welte b521a2ed09 vty: Permit configuration of ASPs in SCTP client mode
The M3UA specification states that either of the two roles should
be the SCTP client and the other the server.  It also states that
the default for the SGP is to operate as server.  However, it permits
other configurations.  Let's allow this to be configured by the VTY.

We need to ensure that while in ASP role, we don't send any NOTIFY
messages to the peer SG.

Change-Id: I7452a862d45da35dcd58654ca17222eb52d26f1f
Closes: OS#2005
2019-11-05 20:51:04 +00:00
Harald Welte 1a822635f8 Allow ASP role to be configured
So far, we had a static role model:
* SCTP servers (listening, such as OsmoSTP) are role SGW
* SCTP clients (connecting, such as OsmoMSC) are role ASP

While this is customary, it is not actually required by the
specification.  The SGW can establish the SCTP connection to an ASP
but still remain "SG" role.

Let's make things more flexible by having the role configurable.

Related: OS#2005
Change-Id: I2df9cd9747ad5c9a05d567d9a71bab6184c53674
2019-11-05 20:50:51 +00:00
Harald Welte 79fb8a66f3 introduce public enum osmo_ss7_asp_role for ASP/SG/IPSP
This supersedes the library-internal enum xua_asp_role.

Change-Id: I28b0888b8f8206e9dd67ef64ce0f71ba9a7105ce
2019-11-05 20:50:37 +00:00
Harald Welte ebd2fc6046 M3UA: Reject ASP activation + RKM registration for incompatible traffic-mode
If the AS is e.g. configured as broadcast, then individual ASPs cannot
be activated in loadshare or override.  Everyone must agree.

Change-Id: Ic73410fbc88d50710202453f759fa132ce14db4c
2019-11-05 20:50:26 +00:00
Pau Espin 907121b85d xua: Allow traffic mode set by peer if not set by VTY
Change-Id: I8ca17439b4dd023625f8f22689c0432341986099
2019-11-05 20:41:56 +00:00
Harald Welte 02d0228a40 xua_asp_fsm: Don't send M3UA ERR and then send ASPAC_ACK
IF we cannot activate the ASP in response to an ASPAC, we should
return just the error and not an error + ASPACK_ACK.

Change-Id: I681021a13af9b91d8b2b849bd7149d6b1f783865
2019-11-05 18:41:49 +01:00
Pau Espin d70d82bdf3 ss7: Set Traffic mode and Route Ctx in ASPAC ACK msg if known
Change-Id: Ic99131489efaef87f882312a042f5feb6a60bb86
Related: OS#4220
2019-10-24 17:56:00 +02:00
Pau Espin 6e10736190 xua: Verify all route ctxs received in ASPAC msg
Change-Id: I16ad0847d671522c8942b441db7e4c460f4f142b
2019-10-24 17:42:57 +02:00
Pau Espin 2b139a65f0 ss7: Only override traffic mode from recv REG REQ if not set by VTY
RFC 4666 (SS7/MTP3/M3UA) states in isection 4.3.4.3 ASP Active Procedures:
"""
If the traffic handling mode of the Application Server is not already known via
configuration data, then the traffic handling mode indicated in the
first ASP Active message causing the transition of the Application
Server state to AS-ACTIVE MAY be used to set the mode.
"""

In section 3.6.1 Registration Request (REG REQ), no related information
is provided on how to handle it, but still makes sense to apply same
behavior as in 4.3.4.3.

Related: OS#4220
Change-Id: Iaebe3a93ad8d2d84ae01e41b02674f8ece9dfc95
2019-10-24 13:23:09 +02:00
Pau Espin b775d634f3 ss7: Set configured AS traffic mode when sending Routing Key Register msg
Otherwise default OSMO_SS7_AS_TMOD_OVERRIDE=0 value is always set
regardless of the VTY config "traffic-mode" under AS node.

Related: OS#4220
Change-Id: I5d24772f07e77cc3ba6edfa819bb9bc0266a1064
2019-10-24 13:23:09 +02:00
Pau Espin 3eae8ec9ef ss7: Implement AS traffic mode loadshare using round robin ASP selection
Related: OS#4220
Change-Id: I98144dde237672df2e78c7c92923e6f4cb77a271
2019-10-24 13:23:09 +02:00
Pau Espin c99724a9ec ss7: Set default traffic-mode to override
Change-Id: I8570ed6634eb20c0f9e4b712de6592b6c3b77227
2019-10-24 13:23:09 +02:00
Pau Espin 7240f56a70 vty: Print traffic mode during show cs7 instance as
Change-Id: Ief6b03f50751b8d8f4021e94d54f079681b64d51
2019-10-23 21:25:33 +00:00
Harald Welte f4f4e8c310 xua_rkm: Don't permit de-registration of rctx with ASP active
Change-Id: Ie47eb205b397f3d2ce94c4ec3531664ed290a819
Closes: OS#4238
2019-10-23 18:11:17 +00:00
Harald Welte 8a7c2eba43 xua_rkm: Print NOTICE log message if registration for wrong rctx
Change-Id: Ifb70940e9edfad8c99473ec724dc52f5885561de
2019-10-23 18:11:17 +00:00
Harald Welte d98960d189 Log correct protocol during xua_accept_cb()
This function is used for both actual SIGTRAN (M3UA, SUA over SCTP)
as well as for IPA/SCCPLITE (over TCP).  Having a static "SCTP"
string in the log lines is confusing.

Change-Id: Ic34ddbcd528cd871d9772665e1d0863896f33203
2019-10-23 18:11:17 +00:00
Pau Espin 1870752ca7 vty: ss7: Make sure ASP has at least INET_ANY addr set if not configured in VTY
Several parts of the code expect an operative ASP to always have at
least one local ip addr, be it INET_ANY (NULL, 0.0.0.0) or any specific
IP address.
This allows osmo_ss7_asp_find_by_socket_addr() matching incoming
connectiongs against ASPs defined through VTY "asp" node with no
"local-ip" cmd option specified. In that case, we assume the user wants
it to bind/match against INET_ANY.

Related: OS#3608
Fixes: 80b1355819
Change-Id: Id4da0c778890c90cf5bfcf0fd3a7ecf165f2a6df
2019-10-23 18:10:10 +00:00
Pau Espin f0a0a4cdd7 ss7: Fix finding asp by socket addr if it has no remote hosts configured
Fixes: 80b1355819
Change-Id: I14a0132a4667cea75fc212dfeeef76d8509b991d
2019-10-23 18:10:10 +00:00
Pau Espin 6168660986 ss7: Fix finding asp by socket addr if local ip addr is 0.0.0.0
Fixes: 80b1355819
Change-Id: I319e4983b35f63846ed7e8bfa8e8e3688c5d16e6
2019-10-23 18:10:10 +00:00
Pau Espin 51efa023c9 ss7: Fix osmo_ss7_asp_peer_snprintf() output if peer has zero IP addr assigned
If no IP addr is assigned yet, until know it'd print "(:3456". Let's
print ":34456" in that scenario.

Change-Id: Iae85d231093b6f3ce6b969324699858e525c14ea
2019-10-23 18:10:10 +00:00
Pau Espin 0e019528c9 cosmetic: Fix trailing whitespace
Change-Id: Ic5bae0b69dcf24da8069709692b5687ad76239dc
2019-10-23 16:47:33 +02:00
Pau Espin e21192dbb0 vty: Fix write-config of local-ip and remote-ip commands
Fixes: CID#205338
Fixes: CID#205337
Change-Id: I7b01e53aa4bfd714467cbd729cfcf4dc12a64bd4
2019-10-23 16:47:33 +02:00
Pau Espin b2ab192327 cosmetic: ss7: Fix trailing whitespace
Change-Id: Ifd947c51067842b83ea43ce25ba0d652baff259b
2019-10-22 19:38:53 +00:00
Pau Espin 2c3ff8c81b tests: Introduce test for multi-homing STP features
Config file sets omo-stp instance to bind on 2 IP addresses, and then
the test verfies through linux /proc/net/sctp/* that binding is done
correctly and that it can be reached from another remote address to one
of the configured addresses.

Change-Id: Ifa11b1fc882dff415405f62024e94bed67228866
2019-10-22 19:38:53 +00:00
Pau Espin dec38c1416 ss7: Log local and remote address set upon ASP restart
Change-Id: I35c2581923ed3e1f7aff6c137ddf356882bac621
2019-10-22 19:38:53 +00:00
Pau Espin 80b1355819 ss7: Support multiple addresses in SCTP connections
After this patch, Several "local-ip" and "remote-ip" lines are accepted
under "listen" and "asp" VTY nodes, allowing to configure an SCTP
connection with multiple connections, hence allowing control of SCTP
multi-homing features.
libosmo-sccp clients such as osmo-bsc and osmo-msc also gain support for
this feature with this commit.

Related: OS#3608
Depends: libosmocore.git Ic8681d9e093216c99c6bca4be81c31ef83688ed1
Depends: libosmo-netif.git I0fe62f518e195db4e34f3b0ad1762bb57ba9d92a
Change-Id: Ibd15de7a4e00dbec78ff2e2dd6a686b0f3af22de
2019-10-22 19:38:53 +00:00
Pau Espin 38ae954da5 Defer xua server binding until exit of VTY node
Commit 10d4815bb1 already fixed the issue
where binding was done during L_CS7_XUA_NODE (listen) done, meaning
local-ip inside it had no effect. In that comment, binding was moved to
happen during "local-ip" VTY cmd. Furthermore, that commit added a new
osmo_ss7_bind_all_instances() and related APIs to allow osmo-stp to have
all xua servers bound if no "local-ip" was provided.
These APIs have only been used so far by osmo-stp (which lays in the
same git repo that libosmo-sccp) since it's the only program using the
xua server features.

In the present commit, let's drop the APIs added by commit described
above, and instead let libosmo-sccp code to internally bind the xua
server upon exit of the VTY node. As a result, the previously introduced
APIs can be dropped (not used by anyone anymore) and it will provide
ways to support multiple "local-ip" commands in the future, hence
supporting SCTP multi-home features.

It's recommended to require libosmocore.git Ia6d88c0e63d94ba99e950da6efbc4c1871070012
since it fixes a bug where go_parent_cb was not called for nodes at the
end of the file.

Related: OS#3608
Change-Id: I2cff17b5e2e2fbfd4591e23a416e510e94e173d6
2019-10-22 19:38:53 +00:00
Pau Espin cb66698c8d m3ua: Log incorrect selected AS
Change-Id: Idfdf6279de1fed453b5f83a5329c50716a79aca9
2019-10-22 17:34:29 +02:00
Pau Espin 7504bd6f11 Fix typo in log message of recent commit
Change-Id: I53e6395ea564a7f6f5f8c9e1dd3372ba37bdfb39
2019-10-22 16:48:29 +02:00
Harald Welte 26a4c84ca7 cosmetic: Document why IPA uses hard-coded routing-context 0
Change-Id: Ibfae10a1e9385079db4b353e48a262bc8ab5230a
2019-10-20 18:56:05 +02:00
Harald Welte 89407619a3 Don't permit routing-context != 0 for IPA peers
The IPA protocol doesn't have the context of routing-keys. We are only
permitting routing key '0' (as the default routing key) when configuring
via VTY.

Change-Id: I3f166f44903d0b93963cc5d0cca73d277d2b7215
Fixes: OS#4234, OS#4233
2019-10-20 18:55:55 +02:00
Harald Welte ecb2cf1a31 ipa: VTY config option to explicitly enable/disable SCCP patching
When receiving SCCP messages from an IPA peer/ASP, osmo-stp so far
unconditionally inserted origin/destination point codes int the SCCP
called / calling party addresses.

This behaviro is now made optional with the introduction of the
following per-AS configuration:
	"point-code override patch-sccp (disabled|both)"

The default behavior is switched from 'both' to 'disabled' at the same
time.

Change-Id: I535e2170adadfe755d2bcbf5bbf4556bebb77737
Closes: OS#4219
2019-10-19 22:31:04 +02:00
Harald Welte d747573feb ipa: Fix crash when parsing of received IPA SCCP message fails
If an IPA ASP is sending us a SCCP message that cannot be parsed,
we shouldn't crash but handle this gracefully.

Change-Id: Ib7a8c2a36dd1b82ca8ed472760c1682ede50cb90
Fixes: OS#4236
2019-10-19 17:47:22 +02:00
Harald Welte 959c90492f ipa: Don't send non-SCCP data over IPA/SCCPlite
The IPA/SCCPlite stacking is - as the name implies - constrained to
the transport of SCCP messages. We have to reject any non-SCCP payload.

Change-Id: I5e5a2879013ee8cf08aa4199b4bee498dcb61446
Fixes: OS#4235
2019-10-19 12:24:55 +02:00