Commit Graph

818 Commits

Author SHA1 Message Date
Vadim Yanitskiy efcaff0b80 osmo-stp: register VTY commands for talloc context introspection
Change-Id: Id0789c4946929b783c54220de439958001f94992
2019-05-10 03:06:54 +07:00
Harald Welte d6cc1294e2 stp: Ensure telnet uses STP talloc context, not NULL context
Change-Id: I38a9538dc93cdcecbeb236f0eadc3d675cf20b5d
2019-05-09 10:34:23 +02:00
Holger Hans Peter Freyther 174d33681a udts/xudts: Attempt to implement unitdata service parsing
Use the new offset based parsing to extract GT and data from the
UDTS/XUDTS message as well. Test vectors are missing right now.

Change-Id: Id0a3a291d8bad3f8c9621e6c97d4ea0b8bbe6035
2019-05-02 00:12:16 +01:00
Holger Hans Peter Freyther 1646d9b827 xudt: Implement address and data extraction
The cellmgr-ng unfortunately looks at the data being sent and can't
handle the presence of XUDT at all. Add the structure definition
and refactor extraction code to work on offsets. Add a unit test.

Change-Id: I45a7447cc1be432fff34849e0e35abc0410cf153
2019-05-01 23:52:31 +01:00
Neels Hofmeyr 21ff9ae426 add osmo_sccp_addr_cmp(), osmo_sccp_addr_ri_cmp()
osmo-msc identifies its BSC and RNC peers by SCCP address, and compares those
by memcmp(), which is not really accurate. Rather provide a meaningful
osmo_sccp_addr_cmp() API to determine whether SCCP addresses are identical.

Go for a full cmp that would also allow sorting.

Change-Id: Ie9e2add7bbfae651c04e230d62e37cebeb91b0f5
2019-04-12 06:28:34 +02:00
Neels Hofmeyr ac729eb5a8 add caller-owns-msgb variant osmo_sccp_user_sap_down_nofree()
Add osmo_sccp_user_sap_down_nofree(), which is identical to
osmo_sccp_user_sap_down(), but doesn't imply a msgb_free().

To implement that, sccp_sclc_user_sap_down_nofree() with the same msgb
semantics is required.

Rationale:

Avoiding msgb leaks is easiest if the caller retains ownership of the msgb.
Take this hypothetical chain where leaks are obviously avoided:

  void send()
  {
  	msg = msgb_alloc();
	dispatch(msg);
	msgb_free(msg);
  }

  void dispatch(msg)
  {
  	osmo_fsm_inst_dispatch(fi, msg);
  }

  void fi_on_event(fi, data)
  {
	if (socket_is_ok)
		socket_write((struct msgb*)data);
  }

  void socket_write(msgb)
  {
  	if (!ok1)
		return;
	if (ok2) {
		if (!ok3)
			return;
		write(sock, msg->data);
	}
  }

However, if the caller passes ownership down to the msgb consumer, things
become nightmarishly complex:

  void send()
  {
  	msg = msgb_alloc();
	rc = dispatch(msg);
	/* dispatching event failed? */
	if (rc)
		msgb_free(msg);
  }

  int dispatch(msg)
  {
  	if (osmo_fsm_inst_dispatch(fi, msg))
		return -1;
	if (something_else())
		return -1; // <-- double free!
  }

  void fi_on_event(fi, data)
  {
	if (socket_is_ok) {
		socket_write((struct msgb*)data);
	else
		/* socket didn't consume? */
		msgb_free(data);
  }

  int socket_write(msgb)
  {
  	if (!ok1)
		return -1; // <-- leak!
	if (ok2) {
		if (!ok3)
			goto out;
		write(sock, msg->data);
	}
  out:
        msgb_free(msg);
	return -2;
  }

If any link in this call chain fails to be aware of the importance to return a
failed RC or to free a msgb if the chain is broken, or to not return a failed
RC if the msgb is consumed, we have a hidden msgb leak or double free.

This is the case with osmo_sccp_user_sap_down(). In new osmo-msc, passing data
through various FSM instances, there is high potential for leak/double-free
bugs. A very large brain is required to track down every msgb path.

osmo_sccp_user_sap_down_nofree() makes this problem trivial to solve even for
humans.

Change-Id: Ic818efa78b90f727e1a94c18b60d9a306644f340
2019-04-12 06:27:10 +02:00
Oliver Smith 49eea32ab4 sccp_scoc: conn_create{,_id}() user arg, not inst
Accept the osmo_sccp_user instead of calling conn_create() and setting
conn->user afterwards. Prepare for generating a local_ref inside
conn_create_id() in the future.

Related: OS#3871
Change-Id: I2fb47c8ba6c0ce7cd92c9ac31f15c67eb67fb66e
2019-04-04 08:33:58 +02:00
Oliver Smith ee0bcf2fca sccp_scoc: move sccp_find_user() up
Move it before sccp_scoc_rx_scrc_rout_fail(), so it can be used in
the latter function to figure out the local_ref from the user (follow
up commit).

Related: OS#3871
Change-Id: Ieabeda3126dcc0349a06c0fc7c9e468b900d7855
2019-04-03 15:06:10 +02:00
Oliver Smith 67b895e156 Cosmetic: sccp_scoc: fix local reference comments
Remove all comments, that claim conn_id is the local reference. This
is only a hack, and should not be something to rely on. A properly
separated local reference will be introduced shortly.

Related: OS#3871
Change-Id: I900124037da76caaaf5ecee323eb82e1c6d2e368
2019-04-03 15:06:02 +02:00
Harald Welte 3f2ff81831 sccp_scoc: Add more comments describing conn_id and local_ref members
Change-Id: I85cabc42621103de1a83282baf210fbc117b63db
2019-04-01 15:50:38 +02:00
Harald Welte 99beede80c Fix output of route destination in 'show ss7 instance <0-15> route'
We were printing the mask of the route, but not the point code itself.

Best would probably be to print both?

Closes: OS#3835
Change-Id: Ifa4fdbad953d40f222beb470a082eed8c20991ef
2019-03-15 17:26:01 +00:00
Harald Welte 005c3a6982 Store + show remote ip/port in dynamically created ASPs
"show cs7 instance 0 asp" before this patch would not display the
remote IP/port information about dynamically-added ASPs but instead:

                                                          Effect Primary

ASP Name      AS Name       State          Type  Rmt Port Remote IP Addr  SCTP
------------  ------------  -------------  ----  -------- --------------- ----------
asp-dyn-0     ?             ASP_ACTIVE     m3ua  0        (null)

With this patch it is now correctly displayed:
                                                          Effect Primary

ASP Name      AS Name       State          Type  Rmt Port Remote IP Addr  SCTP
------------  ------------  -------------  ----  -------- --------------- ----------
asp-dyn-0     ?             ASP_ACTIVE     m3ua  24905    127.0.0.1

Change-Id: I39a1c57bc72e8aff607f3a551811a2f6372adab4
Closes: OS#3836
2019-03-14 15:40:29 +00:00
Neels Hofmeyr bf7eded0fc improve logging for rejected AS in xua_rkm.c
Change a loglevel from NOTICE to ERROR, for when a routing key gets
re-purposed.

Add another error log for insufficient resources case.

Change-Id: Id22e3c6bab5f7b597df3514eedb162277ce0ef7d
2019-03-14 03:41:59 +00:00
Harald Welte 93940a2e35 vty: Ensure to properly save route pointcode and mask when writing
As osmo_ss7_route_print() returns a static buffer, we cannot use it
twice within a single log/print statement.  Rather, we must use
osmo_ss7_route_print2() for the second call, as it uses a separate
static buffer.

Change-Id: Ica32e83cbe8af2317cb07f8d8422a399fa537012
2019-03-13 21:20:12 +00:00
Neels Hofmeyr 03209f8eb6 debug log typo fix in sccp_scoc.c
Change-Id: Ic5637700122ef26a44932149994c01ccbfc18ffd
2019-03-06 07:19:36 +01:00
Max 5b5c1ed63c OsmoSTP: enable statsd support
Change-Id: I5309ae44e5b9eda1a5dd1bbf10db5ffdff1fa9cd
2019-02-18 13:33:28 +01:00
Max 8d712f0623 osmo_ss7.c: fix typo
Change-Id: Idd0945ef7fa5cc0caf2f35919f97e2e11691f3a3
2019-02-12 14:38:28 +01:00
Max 0a93a683f3 Don't use deprecated osmo_stream_cli_open2()
Using osmo_stream_cli_open() with explicit timeout set via
osmo_stream_cli_set_reconnect_timeout() will have the same
effect. Update comment explaining this as well as the code.

Change-Id: Iffe6ea48a170880faef071c7c4a1bc0605aa9855
2019-02-07 11:06:15 +01:00
Harald Welte 81c6a0a979 Bump version: 0.10.0.39-b723 → 1.0.0
Change-Id: I9b9d9331bdd1d9cdebdef5c3e0c49a1b18972abd
2019-01-20 15:19:07 +01:00
Harald Welte 2c880ba6f4 sccp.c: Fix gcc-8.2 -Werror=maybe-uninitialized
This fixes the following compiler warning when using -Werror on gcc-8.2:

sccp.c: In function ‘sccp_system_incoming_ctx’:
sccp.c:1039:10: error: ‘result.destination_local_reference’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
       && memcmp(&conn->source_local_reference,
          result.destination_local_reference,
          sizeof(conn->source_local_reference)) == 0
sccp.c:1030:27: note: ‘result.destination_local_reference’ was declared here
  struct sccp_parse_result result;
                           ^~~~~~

Change-Id: Ied41f7c8ddaa5f616dd6556079a54d8d70274490
2019-01-20 15:11:07 +01:00
Stefan Sperling 069b20dd6e fix ipa_asp_fsm down state transition
Properly transition into IPA_ASP_S_DOWN from IPA_ASP_S_ACTIVE
and fix the mask of legal out states from IPA_ASP_S_ACTIVE.

BSC-sccplite tests are still passing with this change.

Change-Id: Idb8e7bd1c74a4b47080fe32ebe0161c503ead571
Related: OS#3111
2018-12-20 16:23:19 +01:00
Oliver Smith 959290be11 contrib: fix makedistcheck with disabled systemd
EXTRA_DIST files need to be distributed, no matter if the systemd option
is configured or not.

Change-Id: Ib848aa5ce03f45d4f8182a4e77b0130ccb261635
2018-12-06 13:43:26 +01:00
Oliver Smith 397903fdb7 contrib/jenkins.sh: build and publish manuals
Add new environment variables WITH_MANUALS and PUBLISH to control if
the manuals should be built and uploaded. Describe all environment vars
on top of the file.

When WITH_MANUALS is set, install osmo-gsm-manuals like any other
dependency and add --enable-manuals to the configure flags (for "make"
and "make distcheck"). Add the bin subdir of the installed files to
PATH, so osmo-gsm-manuals-check-depends can be used by ./configure.

Related: OS#3385
Change-Id: I5904c86c7e38d36d23df213f5a2ae1986647a051
2018-12-05 13:08:57 +01:00
Oliver Smith c563197778 Fix DISTCHECK_CONFIGURE_FLAGS override
Set AM_DISTCHECK_CONFIGURE_FLAGS in Makefile.am instead of
DISTCHECK_CONFIGURE_FLAGS. This is the recommended way from the
automake manual, as otherwise the flag can't be changed by the user
anymore.

Related: OS#3718
Change-Id: Ib3f443e07f51df352357c5a90792bd946efcdf27
2018-12-04 15:39:31 +01:00
Oliver Smith b7237b139d build manuals moved here from osmo-gsm-manuals.git
Moved to doc/manuals/, with full commit history, in preceding merge commit.
Now incorporate in the build system.

Build with:

$ autoreconf -fi
$ ./configure --enable-manuals
$ make

Shared files from osmo-gsm-manuals.git are found automatically if
- the repository is checked out in ../osmo-gsm-manuals; or
- if it osmo-gsm-manuals was installed with "make install"; or
- OSMO_GSM_MANUALS_DIR is set.

Related: OS#3385
Change-Id: Ib5a22c2ea81fdde036bf9efb47d785a830b88c93
2018-11-27 18:46:32 +01:00
Neels Hofmeyr 2162f5d89e Merge history from osmo-gsm-manuals.git
Change-Id: Iabd0af069f00e7827a7793aabfc38a14fb7f1570
2018-11-27 18:46:19 +01:00
Neels Hofmeyr e6a0409d6e stp: update vty reference with added SCCP commands
After I66e97706de0c546db3c6ff77fb5e6ac6e32bff55 which adds the missing
sccp_vty_init(), update VTY reference with the new SCCP show / config commands.

Depends: I66e97706de0c546db3c6ff77fb5e6ac6e32bff55
Change-Id: Id941b8e31d3b4cfdb3f912beedc1e7af321a0113
2018-11-27 18:46:12 +01:00
Neels Hofmeyr 3508df2200 stp: update vty reference
Change-Id: Id5f1067760db7a11ec380a541bfe7357a21a3bb3
2018-11-27 18:46:12 +01:00
Harald Welte fcc95f960b vty-ref: Update URI of docbook 5.0 schema
... to match the /etc/xml/catalog file on debian (no "www" in hostname)

Change-Id: Id9f3579c7f2bc3af13fe30b5268f249b6f59ed0d
2018-11-27 18:46:12 +01:00
Neels Hofmeyr 5fab07911d OsmoSTP: update VTY reference
This is the first update since the libosmocore changes to the 'show
online-help' generated output. Hence the produced document now benefits from
the structural improvements:
- not repeating common commands for every node;
- using section names that match the VTY prompt.

Change-Id: I98cdfcb6c1c7db49ab106e775be92e4c6adeab17
2018-11-27 18:46:12 +01:00
Harald Welte 51ef55b6d4 STP: Update vty reference XML file
This ensures useful content in the STP vty reference manual

Change-Id: Ica4b1c0172255ec2328562fdd8fac190e3ad448d
2018-11-27 18:46:12 +01:00
Harald Welte 46c4b92926 First step towards an OsmoSTP manual
Change-Id: I450bfac7444ac9cb7f50c086d87cf7157c2e2a31
2018-11-27 18:46:12 +01:00
Neels Hofmeyr 7dd567979a Importing history from osmo-gsm-manuals.git
Change-Id: I17bfe64d98ca47cb4b3be81d2715bda047b79466
2018-11-27 18:46:00 +01:00
Max 5371a21293 SS7: safeguard against wrong number of pointcode component
Previously internal function get_pc_comp_shift() returned negative error
code when called with wrong component number despite unsigned return
value which wasn't checked for error anyway.

Fix this by using explicit assert in the error path. This should not
affect external users because this function always called with constant
component argument.

Change-Id: Ib24cdbcf614bad68f3cfa9776a451c5c1e45ae6e
2018-11-22 14:12:18 +00:00
Max c3824bca16 Log ip:port for created SS7 server
Change-Id: If2ae093175d64000490a2be31ecfea265ca3853d
2018-11-19 05:50:13 +00:00
Max 8d0343872e Make pointcode width function public
That's useful for external programs veryfying pointcode validity. For
example if used as part of BSS-related identity in GCR construction by
LCLS code we should be able to double.check that no significant bits off
pointcode are lost/ignored.

Change-Id: I5a9981dd2c1d78966c61a3f6b50c7c0d9b542caf
2018-11-19 05:50:13 +00:00
Neels Hofmeyr b5188f0169 osmo-stp: add SCCP related VTY commands
Call osmo_sccp_vty_init(), so far forgotten.

This adds the various 'show cs7 instance N sccp *' commands, as well as making
the SCCP timers configurable.

See Id941b8e31d3b4cfdb3f912beedc1e7af321a0113 for a diff of the VTY reference,
showing what commands are enabled by this patch.

Change-Id: I66e97706de0c546db3c6ff77fb5e6ac6e32bff55
2018-11-18 20:06:37 +00:00
Stefan Sperling 56ac82056a return error code from xua_srv_conn_cb() if conn is freed
Allow callers of xua_srv_conn_cb() to tell whether conn
was freed by returning error code EBADF, which is also
used elsewhere in osmocom programs for this purpose.

This is necessary because xua_srv_conn_cb() might be running
inside of a loop which checks for read and then write events
on the connection. If the connection is freed by xua_srv_conn_cb()
as part of processing a read event, callers should avoid further
processing of events. But if we don't return an error we are leaving
callers none the wiser and with a dangling conn pointer.

Change-Id: I7359667b2f25d6c45acc70049b2a4ee2f376a1df
Related: OS#3685
2018-11-09 15:43:30 +01:00
Stefan Sperling b59ebe9f22 skip simple-client default as/asp when saving VTY config
When saving the current VTY config to a configuration file,
do not write out AS/ASP configuration items which are generated
as a fallback by osmo_sccp_simple_client_on_ss7_id().

Since the user did not explicitly configure these configuration
items they should not be saved to the user's configuration file.

Change-Id: Id8a3afc6dee29ae1ee9c862cbe404a61fe979dba
Related: OS#3616
2018-10-29 19:25:34 +01:00
Neels Hofmeyr 6a973bab9c build: move include/{mtp,sccp} to include/osmocom/
Anywhere else in the Osmocom code base, we arrange headers in
include/osmocom/foo/ and pass -I ${root_srcdir}/include/.
This way including an osmocom header always has the format
  #include <osmocom/foo/bar.h>
whether we are including from the local source tree or from $prefix.

For some reason not clear to me, the mtp and sccp folders, even though they are
being installed to $prefix/include/osmocom/, were kept *next* to the osmocom/
dir, instead of inside it. Fix that weird situation.

The motivation is that I wanted to use a definition from sccp_types.h in a
public-API header. That is impossible if it requires
  #include <sccp/sccp_types.h>
in a local build, but
  #include <osmocom/sccp/sccp_types.h>
for any other source tree using libosmo-sccp. After this patch, both are
identical and including works without quirks. (The other patch that needed this
has changed in the meantime on and no longer needs this, but this still makes
sense for future hacking.)

The installed result does not change, since both mtp/*.h and sccp/*.h have
always been installed to $prefix/include/osmocom/{mtp,sccp}/. This merely
changes their position in the source tree.

The most curious situation before this is that any patch #including
<osmocom/sccp/sccp_types.h> might not get a notice that the header didn't
exist, but might instead include an older system-installed file.

Change-Id: I1209a4ecf9f692a8030b5c93cd281fc9dd58d105
2018-10-21 12:35:11 +00:00
Neels Hofmeyr bb6e4bb676 make SCCP timers configurable
The previous hardcoded SCCP timers may cause SCCP connection releases, if the
peer is configured with far lower timers than libosmo-sccp. Testing with a
specific SCCPlite MSC, I experienced an iar of just over three minutes, meaning
that calls would be cut off by the MSC, since the osmo-bsc failed to send an
Inactivity Timer message until seven minutes have passed.

With this patch, SCCP timers are configurable by the user.

Define constant global default timers, and variable user-configurable timers
with each osmo_sccp_instance.

Add VTY UI to configure the timers. Users must call osmo_sccp_vty_init() to get
the sccp-timer config nodes under the 'cs7' node. Show the new UI in
ss7_asp_test.vty.

Note that even though this function is not new at all, until recently, all of
our SCCP users (osmo-bsc, osmo-msc, osmo-sgsn, osmo-hnbgw) failed to call
osmo_sccp_vty_init(), and thus also missed out on the various 'show' commands
defined in sccp_vty.c. In other words, to benefit from the timer
configurability, the patches to call osmo_sccp_vty_init() must first be merged
to the corresponding master branches.

If a 'sccp-timer' config command occurs, the cs7 instance must allocate an SCCP
instance in order to store the timer config. Do that by calling the recently
added osmo_ss7_ensure_sccp() function.

Hence remove the limitation that the SCCP instance must not be populated from
the "simple" setup function. If we want to configure SCCP timers beforehand,
there must be an SCCP instance for that, and there is no hard reason to require
a NULL SCCP instance, besides the desire to prevent this function from being
invoked twice.

Change-Id: I28a7362aa838e648ecc9b26ee53dbcade81a9d65
2018-09-27 17:53:40 +02:00
Neels Hofmeyr eb2068d501 sccp_vty: fix doc strings for show ... ssn,connections
For 'show cs7 instance 0 ssn', fix doc string for 'ssn', and add missing one
for the SSN arg. This fixes depending builds that see VTY test failures due to
the missing doc string.

For 'show cs7 instance 0 connectsion', fix doc string for 'connections'.

Change-Id: I214ea51fc6bfa2a9a4dd7c34b43add0c77ffe22e
2018-09-27 16:08:10 +02:00
Neels Hofmeyr 6d867d1d08 cosmetic: allocate ss7->sccp in one common function
Instead of allocating ss7->sccp in various places, unify that in one common
function. We shouldn't spread the decision what to pass as priv pointer around
everywhere.  There is no functional difference.

This is preparation for a patch where the sccp_instance gets allocated from the
telnet VTY: I would prefer to hide all allocation details from that code; which
also makes sense for the other callers of osmo_sccp_instance_create().

Change-Id: Ie912898c66d31ce4ac8eeeea5a6ddc3f821c06f7
2018-09-27 14:44:30 +02:00
Neels Hofmeyr 00170f0ebf vty: install 'show cs7' for sccp addrs on _ve nodes
The 'show cs7 instance 0 sccp-addressbook' command should not be inside the
'cs7' node. That defies the point of naming the instance again, and it falls
out of place of all the other 'show cs7' commands on the VIEW and ENABLE nodes.

Drop the old command within the 'cs7' node without substitution or deprecation.

At the same time, drop dash from 'show cs7 i 0 sccp-addressbook'

There are various other show cs7 commands already defined in sccp_vty.c, which
have 'sccp' as a separate string. Conform to that.

Change-Id: I80e0bc0a91bcd3fb75372045db34592d2d663d41
2018-09-27 14:44:30 +02:00
Neels Hofmeyr 2bfe4a07ef vty: tweak two printed strings
Fix typo "to long".

Say 'cs7 instance' instead of 'ss7 instance': we are interacting with a user on
the telnet VTY, and that user is configuring a 'cs7 instance'. Especially a
lowercase 'ss7' is potentially confusing ("is there an 'ss7' node?").

Changes show in ss7_asp_test.vty.

Change-Id: Iebb976531576268d58338895a4baadbca6137b80
2018-09-27 14:44:30 +02:00
Neels Hofmeyr 8a9f92bbea sccp_vty: define SCCP_STR once
Define SCCP_STR in sccp_internal.h, because I know that I want to also use it
in osmo_ss7_vty.c.

Fix "Signaling" to "Signalling" upon copying the old string.

Change-Id: Ic93e4771147070a9222c73f80b5f7c29ae7eec35
2018-09-27 14:44:30 +02:00
Neels Hofmeyr 4a3e8f5b19 add tests/vty: VTY UI transcript testing
Add ss7_asp_vty_test, a shim test program with the sole purpose of exposing the
cs7 VTY nodes.

Add ss7_asp_test.vty, transcript for verifying VTY nodes using above program.

Add --enable-external-tests to configure.

Run jenkins.sh with --enable-external-tests.

Change-Id: I6a28684fa24d6e7de568623444297028eba2ab8c
2018-09-27 14:44:30 +02:00
Neels Hofmeyr 66f6ed06e1 allow less characters for SCCP address book entries
Allowing a whole line of characters as address book name would be a lot,
allowing 512 characters is completely ridiculous. That's more than this entire
commit log message! 32 is plenty.

All linking programs should automatically get the limitation in their VTY
parsing without any changes.

Configs with sccp-addr names > 31 chars will no longer work after this.

Change-Id: I3ecf83d620e46f7bf9857fc60a93d4e240ee3b8a
2018-09-27 14:44:30 +02:00
Neels Hofmeyr b8cd891148 vty: fix 'show asp' from within 'asp' node
When entering an 'cs7' / 'asp' node, and invoking 'do show cs7 i 0 asp', the
ASP's FSM instance is not yet allocated. Hence attempting to print its status
will result in a segfault.

Spotted this while writing VTY tests that will follow shortly in another patch
(I6a28684fa24d6e7de568623444297028eba2ab8c).

Change-Id: I3ebf498492c6ba69a5dd1c9f36acdabfd6fbdfe1
2018-09-27 12:39:59 +00:00
Neels Hofmeyr ee5f37e89f drop inaccurate comment from osmo_ss7_vty.c
Change-Id: I845f6661eaed361b5d4db88140efb8eb79b6b69d
2018-09-26 23:48:38 +02:00