Commit Graph

3025 Commits

Author SHA1 Message Date
Neels Hofmeyr 04cb09cbf1 make osmo_sockaddr_str_is_set() NULL-safe
Obviously a NULL pointer should return false instead of segfaulting.

Change-Id: Iac025cf4d556cbed99f3924cd9ca05a05881cd9a
2019-04-11 05:36:36 +00:00
Neels Hofmeyr d28aa0c2f1 fsm_dealloc_test: no need for ST_DESTROYING
A separate ST_DESTROYING state originally helped with certain deallocation
scenarios. But now that fsm.c avoids re-entering osmo_fsm_inst_term() twice and
gracefully handles FSM instance deallocations for termination cascades, it is
actually just as safe without a separate ST_DESTROYING state. ST_DESTROYING was
used to flag deallocation and prevent entering osmo_fsm_inst_term() twice,
which works only in a very limited range of scenarios.

Remove ST_DESTROYING from fsm_dealloc_test.c to show that all tested scenarios
still clean up gracefully.

Change-Id: I05354e6cad9b82ba474fa50ffd41d481b3c697b4
2019-04-11 05:36:36 +00:00
Neels Hofmeyr 1f9cc01861 fsm: support graceful osmo_fsm_inst_term() cascades
Add global flag osmo_fsm_term_safely() -- if set to true, enable the following
behavior:

Detect osmo_fsm_inst_term() occuring within osmo_fsm_inst_term():
- collect deallocations until the outermost osmo_fsm_inst_term() is done.
- call osmo_fsm_inst_free() *after* dispatching the parent event.

If a struct osmo_fsm_inst enters osmo_fsm_inst_term() while another is already
within osmo_fsm_inst_term(), do not directly deallocate it, but talloc-reparent
it to a separate talloc context, to be deallocated with the outermost FSM inst.

The effect is that all osmo_fsm_inst freed within an osmo_fsm_inst_term()
cascade will stay allocated until all osmo_fsm_inst_term() are complete and all
of them will be deallocated at the same time.

Mark the deferred deallocation state as __thread in an attempt to make cascaded
deallocation handling threadsafe.  Keep the enable/disable flag separate, so
that it is global and not per-thread.

The feature is showcased by fsm_dealloc_test.c: with this feature, all of those
wild deallocation scenarios succeed.

Make fsm_dealloc_test a normal regression test in testsuite.at.

Rationale:

It is difficult to gracefully handle deallocations of groups of FSM instances
that reference each other. As soon as one child dispatching a cleanup event
causes its parent to deallocate before fsm.c was ready for it, deallocation
will hit a use-after-free. Before this patch, by using parent_term events and
distinct "terminating" FSM states, parent/child FSMs can be taught to wait for
all children to deallocate before deallocating the parent. But as soon as a
non-child / non-parent FSM instance is involved, or actually any other
cleanup() action that triggers parent FSMs or parent talloc contexts to become
unused, it is near impossible to think of all possible deallocation events
ricocheting, and to avoid running into freeing FSM instances that were still in
the middle of osmo_fsm_inst_term(), or FSM instances to enter
osmo_fsm_inst_term() more than once. This patch makes deallocation of "all
possible" setups of complex cross referencing FSM instances easy to handle
correctly, without running into use-after-free or double free situations, and,
notably, without changing calling code.

Change-Id: I8eda67540a1cd444491beb7856b9fcd0a3143b18
2019-04-11 05:36:36 +00:00
Neels Hofmeyr 3b414a4adc fsm: add flag to ensure osmo_fsm_inst_term() happens only once
To prevent re-entering osmo_fsm_inst_term() twice for the same osmo_fsm_inst,
add flag osmo_fsm_inst.proc.terminating. osmo_fsm_inst_term() sets this to
true, or exits if it already is true.

Update fsm_dealloc_test.err for illustration. It is not relevant for unit
testing yet, just showing the difference.

Change-Id: I0c02d76a86f90c49e0eae2f85db64704c96a7674
2019-04-11 05:36:36 +00:00
Neels Hofmeyr 223d66a414 add fsm_dealloc_test.c
Despite efforts to properly handle "GONE" events and entering a ST_DESTROYING
only once, so far this test runs straight into a heap use-after-free. With
current fsm.c, it is hard to resolve the situation with the objects named
"other" also causing deallocations besides the FSM instance parent/child
relations.

For illustration, add an "expected" test output file fsm_dealloc_test.err,
making this pass will follow in a subsequent patch.

Change-Id: If801907c541bca9f524c9e5fd22ac280ca16979a
2019-04-11 05:36:36 +00:00
Vadim Yanitskiy ed8e263096 gsm_utils.c: fix Doxygen description for gsm_get_octet_len()
Change-Id: Id6fd2cd33be1cb7cd7ff6a43bfcfb1f368304522
2019-04-11 00:24:55 +00:00
Vadim Yanitskiy 3d81147dea vty/talloc_ctx_vty.c: use REG_NOSUB flag of regcomp()
We don't need to know position of matches: just yes or no.
This change would save some computation power.

Change-Id: Id55ffe64cc1a35dd83f61dbb0f9828aa676696f9
2019-04-11 00:24:55 +00:00
Vadim Yanitskiy bd6968a1ca vty/talloc_ctx_vty.c: allocate walk_cb_params on stack, not heap
There is no need to allocate struct 'walk_cb_params' dynamically.

Change-Id: I96f25f1ddb36b19b12055deaeeb6f58e59180e72
2019-04-11 00:24:55 +00:00
Harald Welte 179f35702e Add _c versions of functions that otherwise return static buffers
We have a habit of returning static buffers from some functions,
particularly when generating some kind of string values.  This is
convenient in terms of memory management, but it comes at the expense
of not being thread-safe, and not allowing for two calls of the
related function within one printf() statement.

Let's introduce _c suffix versions of those functions where the
caller passes in a talloc context from which the output buffer shall
be allocated.

Change-Id: I8481c19b68ff67cfa22abb93c405ebcfcb0ab19b
2019-04-10 22:42:32 +00:00
Vadim Yanitskiy d08e9866a5 gsm_03_40.h: define max SM-TP-UDL (User-Data-Length) values
As per 3GPP TS 03.40, section 9.2.3.16 "TP-User-Data-Length (TP-UDL)"
field may contain up to 140 octets (or 140 * 8 / 7 = 160 septets).

Change-Id: I54f88d2908ac47228813fb8c049f4264e5145241
2019-04-09 15:14:18 +07:00
Neels Hofmeyr 0e8df1c7e4 add osmo_use_count API
Provide a common implementation of use counting that supports naming each user
as well as counting more than just one use per user, depending on the rules the
caller implies.

In osmo-msc, we were originally using a simple int counter to see whether a
connection is still in use or should be discarded. For clarity, we later added
names to each user in the form of a bitmask of flags, to figure out exactly
which users are still active: for logging and to debug double get / double put
bugs. This however is still not adequate, since there may be more than one CM
Service Request pending. Also, it is a specialized implementation that is not
re-usable.

With this generalized implementation, we can:

- fix the problem of inadequate counting of multiple concurrent CM Service
  Requests (more than one use count per user category),
- directly use arbitrary names for uses like __func__ or "foo" (no need to
  define enums and value_string[]s),
- re-use the same code for e.g. vlr_subscr and get fairly detailed VLR
  susbscriber usage logging for free.

Change-Id: Ife31e6798b4e728a23913179e346552a7dd338c0
2019-04-08 13:47:17 +00:00
Neels Hofmeyr 0c7826e9bd add osmo_sockaddr_str API
For handling RTP IP addresses and ports, osmo-mgw, osmo-bsc and osmo-msc
so far have their own separate shims and code duplication around
inet_ntoa(), htons(), sockaddr conversions etc. Unify and standardize
with this common API.

In the MGW endpoint FSM that was introduced in osmo-bsc and which I
would like to re-use for osmo-msc (upcoming patch moving that to
osmo-mgw), it has turned out that using char* IP address and uint16_t
port number types are a convenient common denominator for logging,
MGCP message composition and GSM48. Ongoing osmo-msc work also uses this
for MNCC.

This is of course potentially useful for any other IP+port combinations
besides RTP stream handling.

Needless to say that most current implementations will probably stay
with their current own conversion code for a long time; for current
osmo-{bsc,msc,mgw} work (MGW endpoint FSM) though, I would like to move
to this API here.

Change-Id: Id617265337f09dfb6ddfe111ef5e578cd3dc9f63
2019-04-08 13:47:17 +00:00
Philipp Maier e8461e486e gsm_utils: fix use buf_len instead of sizeof in osmo_dump_gsmtime_buf
The function osmo_dump_gsmtime_buf gets a pointer *buf and a parameter
buf_len. The pointer *buf is a string buffer and the function places an
\0 at the end of the buffer before it exists. However it uses
sizeof(buf) as part of the index calculation, which is incorrect. Lets
correct this by using buf_len instead.

Change-Id: Id24263aa7c9a53544f1639b6ceb09ce5615d5114
2019-04-08 12:16:03 +02:00
Harald Welte 4a62eda225 Add _buf() functions to bypass static string buffers
We have a number of static buffers in use in libosmo*.  This means
the related functions are not usable in a thread-safe way.  While
we so far don't have many multi-threaded programs in the osmocom
universe, the static buffers also prevent us from calling the same
e.g. string-ify function twice within a single printf() call.

Let's make sure there's an alternative function in all those cases,
where the user can pass in a caller-allocated buffer + size, and make
the 'classic' function with the static buffer a wrapper around that
_buf() variant.

Change-Id: Ibf85f79e93244f53b2684ff6f1095c5b41203e05
2019-04-03 18:03:14 +02:00
Harald Welte 98ed3393cd osmo_escape_str_buf: Always copy, don't return input string pointer
osmo_escape_str_buf() used to have the somewhat odd semantics that
if no escaping was needed, it would return the original pointer without
making any copy to the output buffer.  While this seems like an elegant
optimization, it is a very strange behavior and it works differently
than all of our other *_buf() functions.  Let's unify the API and
turn osmo_escape_str_buf() into a strlcpy() if no escaping is needed.

Change-Id: I3a02bdb27008a73101c2db41ac04248960ed4064
2019-03-29 16:42:25 +00:00
Pau Espin 3cb68518fc ipa: Fix ipa_ccm_id_resp_parse on big endian systems
Change-Id: Iedc46ab53a4f76bbd98741c065fad3d9042a34a4
2019-03-28 12:22:36 +00:00
Pau Espin deeab473a0 ipa: Document ipa_ccm_idtag_parse_off and fix ipa_ccm_idtag_parse
ipa_ccm_idtag_parse_off is broken, and can only be used with
len_offset=1 on ID Request messages, otherwise won't work correctly.
Modify ipa_ccm_idtag_parse to at least parse those correctly, and
document the limitations.

Those two functions are already deprecated and only used in openbsc by 3
callers:
* ipa_ccm_idtag_parse in ussd_read_cb(): Broken, that function can only
work for Requests and it's used to parse a Response.
* ipa_ccm_idtag_parse_off in forward_sccp_to_msc (NAT): Broken, it can
only be used to parse Requests and it's used to parse a Response.
Furthermore, len_offset=2 is passed which makes no sense and most
probably it fails always, or can even make the program crash.
* ipa_ccm_idtag_parse_off in (answer_challenge): This one is fine and
could actually be replaced with ipa_ccm_id_get_parse after this commit
is merged.

Change-Id: I6efc852dfc041192f554e41a58290a0f63298021
2019-03-28 12:22:36 +00:00
Vadim Yanitskiy b9baf02c12 src/gsmtap_util.c: fix possible memleak in gsmtap_source_init()
In gsmtap_source_init() we dynamically allocate a gsmtap_inst struct,
but don't free it if the subsequent call to osmo_fd_register() fails.

Change-Id: I970b493f3a64fbe9c3f68fcfba5097ee3ff72960
2019-03-28 10:07:59 +00:00
Max 548caef269 BSSGP: use variable for NSEI
Handle NSEI the same way as BVCI is handled: assign it to variable
instead of repetitive calls to msgb_nsei() - this simplifies log update
in follow-up patches and makes code slightly easier to read.

Change-Id: I919a717ca22646849d6ec7f62c677c536db0ed31
2019-03-28 09:00:20 +00:00
Vadim Yanitskiy ccf7c7c887 logging_gsmtap.c: document all params of log_target_create_gsmtap()
Change-Id: Id7bd6b4fb4be571af351f77aa4a59b9e1076434f
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy bc29b2660f Doxygen: fix documentation of osmo_timer_setup()
This change fixes the following Doxygen warnings:

  timer.c:69: warning: argument 'callback' of command @param is not
              found in the argument list of
              osmo_timer_setup(struct osmo_timer_list *timer,
                               void(*cb)(void *data), void *data)
  timer.c:69: warning: argument 'pointer' of command @param is not
              found in the argument list of
              osmo_timer_setup(struct osmo_timer_list *timer,
                               void(*cb)(void *data), void *data)
  core/timer.h:70: warning: The following parameters of
                   osmo_timer_setup(struct osmo_timer_list *timer,
                   void(*cb)(void *data), void *data)
                   are not documented:
                     parameter 'cb'
                     parameter 'data'

Change-Id: If5668f40a7bfde2f4f22329a071c8c6eff23b99e
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy ed3a3c6f1d src/rate_ctr.c: drop some incorrect \ref references
rate_ctr.c:411: warning: unable to resolve reference
                  to `handle_group' for \ref command
  rate_ctr.c:208: warning: unable to resolve reference
                  to `talloc' for \ref command

Change-Id: I24a80ff6cf11ce0455529515d1ecb9900f0271a8
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy c761044ecb Doxygen: fix documentation of rate_ctr_for_each_counter()
Doxygen was confused by duplicated documentation for both
definition and declaration of rate_ctr_for_each_counter().
Moreover, both variants contained some mistakes.

Let's avoid this duplication and keep the only (corrected) one.

Change-Id: Icca2d4a95bd5f96ae85a86909ec90fb8677cacf3
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy 914a8ec5b3 core/msgb.h: fix incorrect Doxygen parameter description
core/msgb.h:414: warning: argument 'msgb' of command @param is not
                   found in the argument list of
                   msgb_pull_to_l2(struct msgb *msg)
  core/msgb.h:399: warning: argument 'msgb' of command @param is not
                   found in the argument list of
                   msgb_pull_to_l3(struct msgb *msg)

  core/msgb.h:351: warning: argument 'msgb' of command @param is not
                   found in the argument list of
                   msgb_push_u16(struct msgb *msg, uint16_t word)
  core/msgb.h:361: warning: argument 'msgb' of command @param is not
                   found in the argument list of
                   msgb_push_u32(struct msgb *msg, uint32_t word)
  core/msgb.h:341: warning: argument 'msgb' of command @param is not
                   found in the argument list of
                   msgb_push_u8(struct msgb *msg, uint8_t word)

Change-Id: I5d660933ecfa89c631319eccf9e3d5c1986ec8ff
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy b8d06fb6b3 src/msgb.c: fix Doxygen documentation for msgb_printf()
This change fixes the following Doxygen warnings:

  src/msgb.c:479: warning: argument 'msg' of command @param is not
                  found in the argument list of
                  msgb_printf(struct msgb *msgb, const char *format,...)
  core/msgb.h:708: warning: The following parameters of
                   msgb_printf(struct msgb *msgb, const char *format,...)
                   are not documented:
                     parameter 'msgb'
                     parameter 'format'

As a bonus, it dot-terminates all sentences.

Change-Id: Ib708664336eef06f748d408ae02a13c754b6647a
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy ba426e3b0c core/msgb.h: drop meaningless parameter of msgb_eq_* helpers
Thanks to the following Doxygen warning:

  msgb.h:XXX: warning: The following parameters of
              msgb_eq_l2(msg1, msgb2, len) are not documented:
                parameter 'msgb2'
                parameter 'len'

it was discovered that parameter 'len' is not required at all.
It basically doesn't make any sense to pass any length value,
because it can be calculated using msgb_length().

Let's drop this parameter. Given that this part of the API was
broken so far (see I1079d629abdb8770eef6be7341e586a933cd9cca),
it should be more or less safe to do this.

Change-Id: Icd9b72eb6bfa9628ff1ed2f948b57058551a4328
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy 115a2ccae5 core/msgb.h: fix dead msgb2 reference in msgb_eq_* helpers
Neither Doxygen documentation of the msgb data comparison helpers,
nor their actual definitions does refer msgb2. Instead, 'msg2' is
referenced in both cases. This was discovered while investigating
the following Doxygen warnings:

  msgb.h:XXX: warning: argument 'msg2' of command @param is not
              found in the argument list of
              msgb_eq(msg1, msgb2, len)

  msgb.h:XXX: warning: The following parameters of
              msgb_eq_l2(msg1, msgb2, len) are not documented:
                parameter 'msgb2'
                parameter 'len'

Due to this bug it was impossible to use the affected macros,
because 'msg2' was not listed in their parameters. Having the
unit test coverage would spot this bug at the beginning!

Change-Id: I1079d629abdb8770eef6be7341e586a933cd9cca
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy 73e66b3eef src/logging.c: fix syntax errors in Doxygen documentation
This change should fix the following warnings:

  logging.c:956: warning: unable to resolve reference to `talloc'
                 for \ref command
  logging.c:203: warning: argument 'in' of command @param is not
                 found in the argument list of
                 log_level_str(unsigned int lvl)
  logging.c:194: warning: argument 'in' of command @param is not
                 found in the argument list of
                 log_parse_level(const char *lvl)
  logging.c:708: warning: argument 'print_catname' of command
                 @param is not found in the argument list of
                 log_set_print_category(struct log_target *target,
                                        int print_category)
  logging.c:687: warning: argument 'print_filename' of command
                 @param is not found in the argument list of
                 log_set_print_filename2(struct log_target *target,
                                         enum log_filename_type lft)
  logging.c:729: warning: argument 'print_catname' of command
                 @param is not found in the argument list of
                 log_set_print_level(struct log_target *target,
                                     int print_level)
  logging.c:893: warning: argument 'in' of command @param is not
                 found in the argument list of
                 log_target_destroy(struct log_target *target)

Change-Id: I85f6c70216b7574b49b90bb1469869a47f721713
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy 095a39616c core/linuxlist.h: fix white-space and inconsistent alignment
- fix trailing white-space;
  - properly align parameters of functions;
  - use tabs instead of 8 spaces where possible.

Change-Id: Iaf616592a6bd72a1e7e94d8c55475710868beef0
2019-03-27 08:56:21 +01:00
Vadim Yanitskiy 72ea919a48 core/linuxlist.h: fix and unify Doxygen documentation
- drop incorrect \ref and \a references;
  - add missing documentation to LLIST_HEAD_INIT;
  - document parameter 'member' of llist_entry();
  - turn @argument naming into a valid \param format;
  - fix 'type *' vs llist_head loop counter confusion;
  - capitalize and dot-terminate all sentences.

Change-Id: Iac67bdb9d5fbf7c222d04858967337f2428d6a94
2019-03-27 08:56:21 +01:00
Neels Hofmeyr c0fcedc968 gsm_utils.h: remove unused include of gsm_08_08.h
Change-Id: Ied4cb2bd06147785540a53ef118e9268406da702
2019-03-27 07:42:24 +00:00
Oliver Smith 27f7b0da6f Revert "ipa_ccm_idtag_parse*: Fix reported length value"
This reverts commit 1261db1505.

The patch broke openbsc's external tests, and currently it is unclear
whether it is just an error in the test or if openbsc makes wrong
assumptions about the length value. Let's revert the patch to unblock
the master-openbsc jenkins job.

Related: OS#3851
Change-Id: I9adea35ff6de36c1611c7f85dde1b15bc1c0e786
2019-03-25 14:43:52 +00:00
Vadim Yanitskiy 2f65bb1b01 Doxygen: fix incorrect / missing parameter description
Change-Id: Ibc63a5d4442a192efab8b5b30e0beb3545642ecc
2019-03-25 15:57:09 +07:00
Oliver Smith 9f2814283e Revert "signal.c: Make non-exported tall_sigh_ctx static"
This reverts commit cff2242e68.

The patch broke openbsc:
../../src/libcommon/libcommon.a(talloc_ctx.o): In function `talloc_ctx_init':
/build/openbsc/src/libcommon/talloc_ctx.c:50: undefined reference to `tall_sigh_ctx'

See also:
https://lists.osmocom.org/pipermail/openbsc/2019-March/012843.html

Change-Id: Ib4cb31427a1cad063bc9f1a10b9c3182b314a9f2
2019-03-22 13:25:01 +01:00
Harald Welte cff2242e68 signal.c: Make non-exported tall_sigh_ctx static
As indicated in the commitlog of
Id58ca18eb826b8f4183a7cf0dbb2b38cba702a09,
the symbol was never exported in a header file, so it should be safe
to mark it as static.

Change-Id: I7132ffe9a7efcab226cc639d1b2357f7115bcadf
2019-03-21 16:02:39 +00:00
Harald Welte 8c58af139d signal.c: Fix osmo_signal_talloc_ctx_init()
This function is broken ever since it was added back in 2018 in commit
Id58ca18eb826b8f4183a7cf0dbb2b38cba702a09

Rather than allocating from the user-supplied 'root_ctx', it is
allocating from the context that it's trying to create (which is
NULL at that time, rendering the entire operation more or less
a no-op.  For sure you will not see osmo_signal structures never in
any talloc report.

Change-Id: I922d26815a3baa5be74bd3ee89d498555882d62f
2019-03-21 16:02:31 +00:00
Harald Welte 1688699c3f select: Rename BSC_FD_* constants to OSMO_FD_*
The naming of these constants dates back to when the code was private
within OpenBSC.  Everything else was renamed (bsc_fd -> osmo_fd) at
the time, but somehow the BSC_FD_* defines have been missed at the
time.

Keep compatibility #defines around, but allow us to migrate the
applications to a less confusing naming meanwhile.

Change-Id: Ifae33ed61a7cf0ae54ad487399e7dd2489986436
2019-03-21 16:02:01 +00:00
Vadim Yanitskiy a3226f7b9d src/signal.c: cosmetic: use talloc_zero()
Change-Id: I55c6249b0c4c82d5a181001e945ff2eca6e9ca36
2019-03-20 20:42:06 +07:00
Harald Welte fa90cfd8d2 gprs_ns_sns: Properly initialize sockaddr_in in gprs_nsvc_create_ip4()
When putting together a sockaddr_in, we must not only set the IP
address and port, but also set the address family to AF_INET.  And
while at it, let's zero-initialize the entire 'struct sockdadr_in'.

Change-Id: I1c8d8fe7f79a2ec737baa7800247269c3271983e
2019-03-20 08:32:30 +01:00
Harald Welte c0dfc9d885 socket: osmo_sock_get_name() Use "const void *" as talloc context
Change-Id: Ie6877277cddb0a9e049449c260afe3314ba65050
2019-03-19 14:04:00 +00:00
Vadim Yanitskiy 54f5f4da59 vty/tdef_vty.c: drop redundant comparison
The amount of arguments is already being checked a few lines before:

  /* If any arguments are missing, redirect to 'show' */
  if (argc < 3)
    return show_timer(self, vty, argc, argv);

so we cannot reach the expression NULL inside this statement:

  group_arg = argc > 0 ? argv[0] : NULL;

Change-Id: Ice59d1a46c2080cd02060e3410706c502db4ce0b
Fixes: CID#190873 Logically dead code (DEADCODE)
2019-03-19 13:44:58 +00:00
Harald Welte 1261db1505 ipa_ccm_idtag_parse*: Fix reported length value
IPA CCM is using a somewhat weird TLV encoding scheme:
* 16bit length (of tag and value)
* 8bit tag
* value

Our existing code mapping the CCM to 'struct tlv_parse' used the plain
length value without accounting for the one-byte tag.

This patch ensures we only report the length of the "value" part,
excluding the tag.

Change-Id: I435aaa33605bd48635715a2c81aa2d231c1abf51
2019-03-19 13:41:49 +00:00
Max fb6f43ee0c rate_ctr_group_free(): guard against empty or NULL input
Change-Id: I859a91ee4400b3685c05971f8c66bceca6758724
2019-03-19 12:57:10 +00:00
Harald Welte d488c7256f tests: use -no-install libtool flag to avoid ./lt-* scripts
This ensures that the rpath of the generated binaries is set to
use only the just-compiled libosmo{core,gsm,vty}.so and not any
system-wide installed libraries while avoiding the ugly shell script
wrapper.

Change-Id: I9b9ae0ed277ba71519661a66a70b7f86971e4511
2019-03-19 00:06:35 +01:00
Harald Welte 24e67f86dd gprs_ns_sns: Use "correct" remote IP address for local IP endpoint
we cannot use "nsi->nsip.remote_ip", as this address is not set
when SNS is in use.  We can only have a valid nsi->nsip.remote_ip
if there's only a single NS-VC inside the NS Instance, as this would
connect() the UDP socket to the remote IP/port, breaking any possibility
to have multiple NS-VCs to different SGNS-side IP addresses.

Closes: OS#3845
Change-Id: Ic094621eb01d7458063f531289d5eeadf52bf330
2019-03-16 18:34:58 +01:00
Harald Welte 94c9b449cf gprs_ns: Don't use initial IP/port for anything but SNS
Section 6.2.1 of 3GPP TS 48.016 states:
> A pre-configured endpoint shall not be used for NSE data or signalling
> traffic (with the exception of Size and Configuration procedures) unless
> it is configured by the SGSN using the auto-configuration procedures.

However, in the current SNS implementation, the initial IP/Port over
which we perform the SNS-SIZE + SNS-CONFIG are treated as one of the
normal NS-VCs. Specifically, we also perform the NS-ALIVE procedure on
it, which is clearly wrong.

Let's explicitly create the "initial" NS-VC with data and signalling
weight of 0, and ensure we never start the alive timer or send any
non-SNS PDUs on this connection as long as SNS was not used to change
either of the two weights to non-zero.

While at it, also safeguard against processing any incoming non-SNS
messages on such a all-zero-weight connection.

Change-Id: I16a91a07e5914d123b2ea2f8413b94e7cd518628
Closes: OS#3844
2019-03-16 18:34:52 +01:00
Harald Welte 1e072cca4e gprs_ns.c: Update comment: IP SNS has recently been implemented
Change-Id: I8b98621a582a23d0483a5340b4aca7e0bc096e6d
2019-03-16 13:00:44 +01:00
Neels Hofmeyr 9e6f5f10bd osmo_gsm48_classmark_a5_name(): fix 'no-cm3' label
Change-Id: Id84021858dfb2f7d6a7cf81ae73bd94cd47f6776
2019-03-14 03:43:10 +00:00
Karl Koscher 76f025eae8 Fix build on non-glibc systems
Change-Id: Id5d577522a4889e152158f7e93ee1c99d3a21003
2019-03-11 13:19:46 -07:00
Philipp Maier 94d79fdeef gsm0808_utils: fix gsm48 multirate to S-bit converter
The function gsm0808_sc_cfg_from_gsm48_mr_cfg() is used to convert a
gsm48 multirate struct into a set of S-bits (S0 to S15). However, the
conversion function currently does not take into account that bit S1
actually stands for four rates at once (Config-NB-Code = 1). Lets make
sure that S1 is only set when the multirate configuration permits all
four required rates.

Change-Id: I6ad531d4e70c2252e32e2bbaca8e14a7ec6d9840
Related: SYS#4470
2019-03-11 09:08:31 +01:00