Commit Graph

22 Commits

Author SHA1 Message Date
Neels Hofmeyr 9bea6eb78c tweak DEBUG log
Printing the debug log line a little later will include the MGCP verb
information.

Change-Id: Icb230cf4d623cdbc4ab52bd52d2a72525c0168c7
2024-02-06 03:17:50 +01:00
Neels Hofmeyr 43eed63b09 client: safely handle dealloc on event dispatch
See also the long in-code comment.

Related: OS#6302
Change-Id: I6f1c0f6a26f9cd6993dc1910a44070ec0438e636
2023-12-19 11:46:42 +00:00
Pau Espin 6225b5cecb mgcp-client: Introduce API osmo_mgcpc_ep_local_name()
Change-Id: I18d7bdf650c0ec87ae16ed4944aed9f495400137
2023-09-26 12:44:11 +02:00
Harald Welte 9befdeb673 Support building with -Werror=strict-prototypes / -Werror=old-style-definition
Unfortunately "-std=c99" is not sufficient to make gcc ignore code that
uses constructs of earlier C standards, which were abandoned in C99.

See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for
some related discussion.

Change-Id: I98a3c0d5cfda2c4b020652efb4f445f8288342b6
2022-11-03 12:53:20 +01:00
Harald Welte e0e5a772f4 Make osmo_mgcpc_ep_fsm_pre_term() static
This is a call-back for FSM pre-termination and it should not
be publicly exported.

Change-Id: Iaa44906baa201571f6bc3192bd3caacb272fec0b
2022-09-16 10:37:22 +00:00
Philipp Maier 3f4a4cb49c libosmo-mgcp-client: extend the mgcp_client for MGW pooling
At the moment the MGCP Client only supports one MGW per application.
Depending on the requirements of the application one MGW might not offer
the performance needed. Lets add support for an MGCP Client pool that is
backward compatible to existing applications.

Change-Id: Icaaba0e470e916eefddfee750b83f5f65291a6b0
Related: SYS#5091
2021-08-16 16:22:31 +02:00
Neels Hofmeyr 03fcc91aad mgcp_client_endpoint_fsm: on term, still let conns wait for DLCX OK
When the mgcp_client_endpoint_fsm terminates, do not directly pull each
conn FSM instance (mgcp_client_fsm) into oblivion as well. Those should
emit a DLCX and wait for the "OK" response before deallocating.

In programs using the mgcp client endpoint FSM (osmo-bsc, osmo-msc),
this gets rid of false LMGCP ERROR logging related to DLCX like this:

  Cannot find matching MGCP transaction for trans_id 71998

Related: SYS#5529
Change-Id: I8fbfec5533e9be9cc7ea550df1e6639a0a215973
2021-07-15 02:28:03 +02:00
Pau Espin 6a5e5ac2d4 Use DLMGCP instead of DLGLOBAL in log lines
Change-Id: I95e11e8b1803153315750840ecec01402becf819
2021-07-08 18:13:46 +02:00
Neels Hofmeyr 59e7cf4437 add osmo_mgcpc_ep_ci_get_remote_rtp_info()
So far an mgcp_client user can get the RTP address+port information that
the MGW has returned upon a CRCX. Add this function to return the other
RTP end, i.e. address+port that the MGW was told to send RTP to.

This will be used to fix the MGCP in osmo-bsc, which so far mixes up the
two RTP ends and compares the MSC's RTP address+port with the MGW's one
and hence fails to skip unnecessary MDCX.

Change-Id: Ibb488925827d9dc0ccb1f8d6d84728745d086793
2021-05-19 19:05:44 +02:00
Neels Hofmeyr fbf07f3f69 change timer T2427001 to X2427
libosmo-mgcp-client looks up this timer in a caller provided osmo_tdef
definition. So far, all of our libosmo-mgcp-client callers do not configure
such a timer, so that we always use the default timer value.

We have introduced X timers (negative numbers) to indicate Osmocom specific
timers, and reserve T timers for 3GPP specified ones. So now is still a good
chance to move this timer to the Osmocom X realm.

Remove a comment about this timer at an unrelated place. It is still described
at osmo_mgcpc_ep_alloc().

Change-Id: If097f52701fd81f29bcca1d252f4fb4fca8a04f7
2020-09-16 00:02:31 +02:00
Pau Espin 2741d6bb0e mgcp_client: copy back Connection Information from MDCX ACK
This is needed in case MGW changes the local IP address (for instance
because it initlaly offered an IPv4 address, and a client submitted a
remote IPv6 address, so MGW needs then to offer a local IPv6 address for
the RTP connection to be possible).

Change-Id: Ie964412b81fe6e10914790baaea724ca5f772adc
2020-09-07 15:55:30 +02:00
Pau Espin 729bf3e45a mgcp-client: Support IPv6 in osmo_mgcpc_ep_ci_get_crcx_info_to_sockaddr() implementation
Change-Id: Ibbfc1c2485636502dc0f3aef3922432cc7fd6170
2020-08-31 17:10:08 +02:00
Neels Hofmeyr ca2aec0235 fix use-after-free: require new fsm deferred dealloc, check for term
API doc: require osmo_fsm_set_dealloc_ctx().

mgcp_client during delete: do not reparent the FSM when it is already
terminating.

I have recently discovered a vulnerability: if an endpoint FSM deallocates
during event handling of a successful MGCP response, this causes a
use-after-free; and once that is fixed, a state change on the already
terminated FSM causes a pointer corruption by using already cleaned data
structures. osmo_fsm_set_dealloc_ctx() fixes the use-after-free, and
osmo_fsm_set_term_stops_actions() fixes the pointer corruption.

Related: Ib7fce7b7d54dfb87af97544796680919e5929a50 (osmo-bsc),
         I08c03946605aa12e0a5ce8b3c773704ef5327a7a (osmo-msc)
Depends: Ief4dba9ea587c9b4aea69993e965fbb20fb80e78 (libosmocore),
         I0adc13a1a998e953b6c850efa2761350dd07e03a (libosmocore)
Change-Id: I7df2e9202b04e7ca7366bb0a8ec53cf3bb14faf3
2019-11-01 17:37:59 +01:00
Neels Hofmeyr 923d60bb12 client: endp fsm: add osmo_mgcpc_ep_ci_ep()
If an API user only has access to the ci FSM (which is managed via an opaque
struct), provide this function to obtain the backpointer to the parent endpoint
FSM, mostly to be able to call osmo_mgcpc_ep_cancel_notify() on it.

osmo-msc's rtp_stream FSM will use this in
I351bb8e8fbc46eb629bcd599f6453e2c84c15015.

Change-Id: I14f7a46031327fb2b2047b998eae6ad0bb7324ad
2019-10-29 23:04:11 +01:00
Neels Hofmeyr f2bf8dc8c8 client: endp fsm: allow cancelling a notify event
There is a use-after-free problem if a 'notify' FSM as passed to
osmo_mgcpc_ep_ci_request() deallocates before the notify event has been
dispatched. To avoid that, add API to allow cancelling a notify.

Change-Id: I41687d7f3a808587ab7f7520f46dcc3c29cff92d
2019-10-29 23:04:01 +01:00
Neels Hofmeyr 055ded74de client: endp fsm: clear ci[] before dispatching DLCX success
In case the ep gets deallocated during event dispatch, move all ci[] cleanup to
*before* dispatching a DLCX OK event. Afterwards, it might become a
use-after-free.

Change-Id: Ib2032e5566e465c02a9a525ccd38f9dcc84fb669
2019-10-29 23:03:50 +01:00
Neels Hofmeyr 3ff71284fa client: endp fsm: add notify struct, prep for cancel-notify
Upcoming patches introduce copying notify information. Prepare by combining
notify info into a separate sub-struct.

Change-Id: I47c0dd112011b8cb4dc88e8efd010466d4ba6308
2019-10-29 23:03:36 +01:00
Neels Hofmeyr cc0b97e197 clear pending requests on MGCP failure
If an MGCP operation on one conn of an endpoint fails, no longer carry out
other pending requests for that endpoint. Only allow pending DLCX to be sent.

If the caller schedules two CRCX at the same time, the first CRCX is sent with
a wildcarded endpoint name like "rtpbridge/*@mgw". Only when the OK for that
returns an allocated endpoint, will the second CRCX be sent, using that actual
allocated endpoint name. But, if the first CRCX fails, then we should not send
another wildcard CRCX, but rather assume both as failed.

Since a failed MGCP message means that the endpoint becomes unusable /
undefined and typically deallocates directly, we can actually discard all other
pending requests except for DLCX.

Change-Id: Icb1d485224bb486b84eff6329f0bd95932e63246
2019-10-02 22:03:25 +02:00
Pau Espin 30907dc9d8 mgcp-cli: endpoint_fsm: Add API to retrieve Osmux CID from MGW
Change-Id: Ic80d47f8eedda1c6ac8c33f1cafeb55c65e74692
2019-05-14 11:36:33 +02:00
Pau Espin 182ca3bad4 mgcp-cli: Change osmo_mgcpc_ep_fsm name to avoid collision with old osmo-bsc
Recent commit moved mgw_endpoint_fsm from osmo-bsc.git here as
osmo_mgcpc_ep_fsm. Some API name changes were applied to avoid
collisions, but FSM was kept and it is registered during startup with
__attribute__((constructor)). As a result, with old osmo-bsc (+tests)
try to allocate its copy of mgw_endpoint_fsm, it fails because that name
is already registered.

Fixes: 538d2c53d9
Change-Id: I694ce58baa43f536b7e594b003edc891f029aa4a
2019-05-08 14:03:13 +02:00
Neels Hofmeyr c5479fe086 fix: multiple initial CRCX
The first CRCX responds with the actual MGW endpoint name that is assigned (at
least for rtpbridge/*@mgw requests).

If multiple CRCX are scheduled at the same time on a fresh MGW endpoint, both
get fired with a '*' and each creates a separate MGW endpoint.

Make mgcp_client_endpoint_fsm avoid this, and schedule only one CRCX at first,
and the rest once the MGW endpoint name is fixated. It is thus possible to
safely issue two osmo_mgcpc_ep_ci_request() at the same time.

Change-Id: I92a9944acc96398acd6649f9c3c5badec5dd6dcc
2019-04-30 02:25:05 +02:00
Neels Hofmeyr 538d2c53d9 move MGW endpoint FSM from osmo-bsc to here
Move mgw_endpoint_fsm from osmo-bsc here as osmo_mgcpc_ep_fsm. Apply various
renames for consistency. Use osmo_tdef from libosmocore instead of osmo-bsc's
(so far) local T_defs API.

Change T23042 to T2427001, which is a slightly less arbitrary number and
slightly more extendable in the future (2427 corresponds to the default MGCP
port at osmo-mgw, 001 is the first MGCP timer and so far the only one).

Change-Id: I9a3effd38e72841529df6c135c077116981dea36
2019-04-30 02:25:05 +02:00