Commit Graph

155 Commits

Author SHA1 Message Date
Vadim Yanitskiy 65d3c505b7 libosmo-sbcap: add -no-undefined to libosmo_sbcap_la_LDFLAGS
Make sure that there is no undefined references in shared libraries.

Change-Id: Id08bbd5ba35ef3f507f60f31a0634f921ec1db65
2022-08-05 11:47:44 +00:00
Pau Espin 13152304f7 cbsp: Store content of received Cell Id from Failed List
Change-Id: I10d2627cb5ef327fd57c22480a4e7d9a464930f0
2022-08-04 14:17:48 +02:00
Pau Espin 40a6158e41 cbsp: Log storing of CellId info received from peers
This is already done similarly in Sbc-AP.

Change-Id: I81ad8d40c5e2b9fbc011db795993fb7f00e99692
2022-08-04 14:07:45 +02:00
Pau Espin d78f13c89a sbcap: Add Concurrent-Warning-Message-Indicator IE to Write-Replace-Req
3GPP TS 23.041 9.3.32 states that the IE is always present for non-ETWS
messages and never present in ETWS messages.

Related: OS#4945
Change-Id: I4a5ac56b7e6eeb85aee07ae2ddf10fa2afbbf4ef
2022-08-02 17:58:10 +02:00
Pau Espin 28d3a53dc5 cbsp/sbcap: Fail if trying to Tx on non-connected (connecting) link
This way upper layers know right away that the message could not be
transmitted to that peer.

Change-Id: I1d2285d18ee064fd78191765e8cb833bf5ee08a4
2022-08-02 11:48:59 +02:00
Pau Espin caba7fc493 cbsp/sbcap: Set link fsm id with peer's name
Otherwise the id is left unset.

Change-Id: I8a6850293cbe01c66e4fb545d646d63743ddaecb
2022-08-02 11:48:59 +02:00
Pau Espin cb4e11f984 cbsp: Fix heap-use-after-free closing cli conn in connecting state
if conn is not in STREAM_CLI_STATE_CONNECTED state, it won't call disconnect_cb during
osmo_stream_cli_destroy(), hence the osmo-cbc pointers holding are not
nullified correctly.

"""
20220801174147247 DCBSP NOTICE ttcn3-bsc-server: Disconnected. (cbsp_link.c:101)
20220801174147247 DCBSP NOTICE ttcn3-bsc-server: Reconnecting... (cbsp_link.c:102)
20220801174147247 DLINP INFO [WAIT_RECONNECT] osmo_stream_cli_reconnect(): retrying in 5 seconds... (stream.c:287)
20220801174152235 DCBSP DEBUG CBSP-Link[0x612000002c20]{RESET_PENDING}: Timeout of T3 (fsm.c:317)
20220801174152236 DCBSP DEBUG CBSP-Link[0x612000002c20]{RESET_PENDING}: timer_cb requested termination (fsm.c:327)
20220801174152236 DCBSP DEBUG CBSP-Link[0x612000002c20]{RESET_PENDING}: Terminating (cause = OSMO_FSM_TERM_TIMEOUT) (fsm.c:332)
=================================================================
==17==ERROR: AddressSanitizer: heap-use-after-free on address 0x6180000024f0 at pc 0x7fbd28a05d01 bp 0x7ffe247352b0 sp 0x7ffe247352a8
READ of size 4 at 0x6180000024f0 thread T0
    #0 0x7fbd28a05d00 in osmo_stream_cli_close /tmp/libosmo-netif/src/stream.c:307
    #1 0x7fbd28a0a5b3 in osmo_stream_cli_destroy /tmp/libosmo-netif/src/stream.c:714
    #2 0x55c3534a0322 in cbc_cbsp_link_close /tmp/osmo-cbc/src/cbsp_link.c:356
    #3 0x55c3534a16e1 in cbsp_link_fsm_cleanup /tmp/osmo-cbc/src/cbsp_link_fsm.c:199
    #4 0x7fbd28bf5085 in _osmo_fsm_inst_term /tmp/libosmocore/src/fsm.c:947
    #5 0x7fbd28be6881 in fsm_tmr_cb /tmp/libosmocore/src/fsm.c:332
    #6 0x7fbd28bc70ab in osmo_timers_update /tmp/libosmocore/src/timer.c:269
    #7 0x7fbd28bcba5b in _osmo_select_main /tmp/libosmocore/src/select.c:394
    #8 0x7fbd28bcbb31 in osmo_select_main /tmp/libosmocore/src/select.c:438
    #9 0x55c35348bce8 in main /tmp/osmo-cbc/src/cbc_main.c:314
    #10 0x7fbd27a4cd09 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26d09)
    #11 0x55c353488ce9 in _start (/usr/local/bin/osmo-cbc+0x68ce9)
"""

Change-Id: Ic13578e958345207892465644b5e1f28537c032d
2022-08-01 20:36:49 +02:00
Pau Espin a76d15048d *_smscb_peer_fsm: Immediately NACK if Tx of msg failed
This makes the smscb_message_fsm receive immediate notice that this peer
failed to deliver the message, avoiding need to wait for 10 seconds
timeout.

Change-Id: I1f3911accb327f3378d65902d53d86fb298fd528
2022-08-01 10:55:21 +02:00
Pau Espin 20705a0877 cbsp/sbcap: Fix memleak in error condition (tx without link)
Change-Id: I95f6ab4e642529afc583b0747450b83af1e8f32e
2022-08-01 10:54:02 +02:00
Pau Espin 041ae3246d sbcap: Fix NULL pointer dereference
Related: Coverity CID#275347
Change-Id: I9ae1cad4ce4e3fe6cfd67ac6058fb7345a3dd49e
2022-08-01 10:49:12 +02:00
Pau Espin e86af042fd Propagate error to caller when tx cbsp/sbcap Write-Replace-Req fails
Change-Id: Ie40c8e41c297398bbec48f7bb2c60cfdc703fa5d
2022-07-29 17:55:33 +02:00
Pau Espin 0b8a08b698 cbc_main: Enable logging of fsm timeouts
Change-Id: I6ffbfbc8eddb3efff0b6401223b9b5563cf83b51
2022-07-29 17:55:33 +02:00
Pau Espin d24c3dfba0 Split smscb_peer_fsm into CBSP and SBcAP specific FSMs
This further simplifies tracking of events and simplifies and clears
code on each of the FSMs.

Change-Id: I0fd00b60cdc6bc6a088be1336d849548ca89c847
2022-07-29 14:54:26 +02:00
Pau Espin c190939f0c Split event list for smscb_message_fsm and smscb_peer_fsm
It really doesn't make sense to share the event list betwen those for
several reasons.
First, because ech of those FSM relate to different things:
* smscb_message_fsm: Handling/scheduling of 1 smscb towards all peers
* smscb_peer_fsm: Handling/scheduling of 1 smscb towards 1 peer.

The former has higher level interface used by the REST
API, plus some mid level interface used by smscb_peer_fsm.
The later has a mid level interface used by smscb_message_fsm to
interact, and a lower level interface used by the SBcAP/CBSP links to
talk to.

Furthermore, this makes it a lot easier understanding which events are
sent from one to another FSM.

Change-Id: I909474d1ff4ec7ed20aff0981da47074397df6cb
2022-07-29 14:49:30 +02:00
Pau Espin cb99991127 Introduce logging category smscb
The smscb_message_fsm is totally independent of CBSP.

Change-Id: I6e686747ddde9540ff3f765ef461bfca812615ba
2022-07-29 14:49:30 +02:00
Pau Espin e6e878a2fc sbcap: Improve handling of WriteReplaceWarnResponse
If cause != accepted, submit a NACK to the upper layers.
In that case, in the upper layers we don't want to parse the PDU IE
"Unknown Tracking Area List" since it shouldn't be there. 3GPP TS
29.168 4.3.4.3.6 states:
"""
This IE shall only be included if the Cause IE indicates Message accepted, which means the MME will proceed with the
request for Tracking Areas that are known to the MME. The Cause IE indicating Tracking area not valid is used when
all Tracking Areas in the Request are invalid.
"""

Change-Id: I0a4d5bdbb6c4fd3870a4f4ebf226668b70fea06a
2022-07-29 14:49:30 +02:00
Pau Espin d8a537aca8 sbcap: Store reported failed TAIs from WriteReplaceResponse in cbc_message_peer
Change-Id: I37b08aa374c1097d2871bf69a7bb7893f32bccd3
2022-07-29 14:49:30 +02:00
Pau Espin 4a9d22e5a0 sbcap: Request and handle Write Replace Warning Indication
Change-Id: I563e7d1c999f14b8197bb41e85b7bcf6262fe2a0
2022-07-29 14:49:30 +02:00
Pau Espin 1429377005 Move ASN1C enc/dec logging to its own category
ASN1C encoding/decoding can get really verbose. Furthermore, it should
only be enabled under really specific conditions, so it makes sense to
have it under its own category.

Change-Id: Ia4cbae2395532d9b5b7b9177a7d0f31bf777d751
2022-07-29 14:49:30 +02:00
Pau Espin bc21b3ae81 Move cbc_cell_id2str() and make it public
It will be used later on to log whenever new cell ids are added to a
message_peer.

Change-Id: I74ccbbc810a2fa76fb2999a7588b3f67d4d21e03
2022-07-29 14:49:30 +02:00
Pau Espin ab8b8402a4 sbcap: Log info about messages received and trasmitted
Change-Id: Ifd1eca79bf4fac63de8066cd6a18004138d51d04
2022-07-29 14:49:26 +02:00
Pau Espin e416069cf6 sbcap: Fix typo in comment
Change-Id: I6d519cb80a90e2a7e80e4608c713996f94043f21
2022-07-27 13:42:17 +02:00
Pau Espin e67faef4ec Move sbcap_as_find_ie() to libsbcap
This function is generic and can be (will be) used in more places.

Change-Id: Ib0c7fa12a8f6faa4271e4132ca5a5c656e717400
2022-07-27 13:42:17 +02:00
Pau Espin 745a2d6600 sbcap: Tx Error ind if Rx ProcedureCode is unknown
Change-Id: I3ee760b98d87f179917acbc369f56d72d0db571d
2022-07-27 13:42:17 +02:00
Pau Espin b093e6708d sbcap: Improve logging on non-implemented PWS Restart/Failure Ind
Change-Id: I0085ac40a7676d9c3626a9da38d02d3b1b2cf6b4
2022-07-27 13:42:17 +02:00
Pau Espin 66625de21c sbcap: Improve logging of rx Error Indication
Change-Id: I63871a57f219a98f8191e6ee4787fc33edb21528
2022-07-27 13:42:06 +02:00
Pau Espin 6db8c13fea sbcap: Drop unused events
Those events doesn't exist in SBc-AP.

Change-Id: Ie4843ed5debbd4282df487ada9596b4d75f4b46c
2022-07-26 14:33:47 +02:00
Pau Espin 3f9d78e2a3 sbcap: Send Error Indication if decoding rx msg fails
Change-Id: I444290f3d697e7485e04eaa38acd8fc3623e0eab
2022-07-26 14:33:47 +02:00
Pau Espin 692243baf5 sbcap: Fix typo in sbcap_cause_vals
Change-Id: I519a86e5292c39bf1ad502c587838e7b62a0e64f
2022-07-26 14:33:47 +02:00
Pau Espin 9ce5d4bad7 Rename functions generating CBSP/SBc-AP Write-Replace request
Previous naming is misleading, as it seems to indicate the function is
used to generate any kind of message, which is wrong.

Change-Id: Ib0228c64bbf104accdbbebb6076004a6a1f44c6f
2022-07-26 14:33:43 +02:00
Pau Espin 7beca6fda0 Rearrange cbc_message and cbsp message code
Move code from message_handling containing both code for generic
cbc_message and specific cbsp_message into thers files. The former are
moved to cbc_message.c and the later to cbsp_msg.c, similar to what's
already done for SBc-AP messages.

Change-Id: Ie4082e40f23170cfd6c573fbbb7beb8c6226b6e6
2022-07-26 10:01:05 +02:00
Pau Espin 4dd20eec56 vty: Fix typo in vty output
Change-Id: I601f9ebcf17c5129edbce5b3ac7f0fd8294dd572
2022-07-26 08:04:06 +02:00
Pau Espin 9144fd1fd8 sbcap_msg: Improve spec references for used IEs
Change-Id: I55749aa84415e0af240c3cc46f2b274e1d24e403
2022-07-26 08:03:33 +02:00
Pau Espin 3c804efcc6 vty: Print created and expired times for each message
This also allows differentiating between expired and active
messages.

Change-Id: I9ee49b99546a44be706700c3db94d45210c47e54
2022-07-26 08:03:33 +02:00
Pau Espin 5ae411980b vty: Add command to delete expired messages
Otherwise there's no way to remove expired messages, which keep filling
the expired list forever.

Change-Id: Ie7ed2d9ec8fc23cdc4cb007dce4150458085a6a3
2022-07-26 08:03:20 +02:00
Pau Espin 93a588ba60 vty: Fix 'show message' not finding expired messages
Change-Id: I23523876f1df167e8afd730b2164f133c2776085
2022-07-25 16:27:26 +02:00
Pau Espin 56d1ef3b52 cbc_vty: Fix missing indent char in dump_one_etws_msg
Change-Id: I8cdced4fa108dede8d5f5dba37dde9cb199198ab
2022-07-25 16:27:26 +02:00
Pau Espin 3ef5020007 Support CBSP/TCP and SBc-AP/SCTP client mode
This patch adds support to set up a CBSP link so that osmo-cbc connects
as a TCP client to the BSC, which runs as a TCP server.
Similary, support to set up a SBc-AP link so that osmo-cbc connects
as a SCTP client to the MME, which runs as SCTP server.

A new "mode (client|server|disabled)" VTY command is added to use one
mother or the other, and also to disable the link and hence the peer
until it is set again. This is useful if the peer is under manintenance
for instance.

client sockets are created automatically when the "peer" vty node is
exited if the link is not yet created, hence creating it at startup or
if moved back from "disabled" mode. If client socket dies, it will
keep attempting reconnect every 5 seconds.

Related: OS#4945
Change-Id: I3ec54b615b41b56f7a9c64298e3fcaac37f4b60e
2022-07-25 16:27:26 +02:00
Pau Espin 5044524f01 cosmetic: smscb_message_fsm.c: Fix typo in comment
Change-Id: I2eb15c2401efa9b07a51dbe71997da01aab30bba
2022-07-25 14:27:48 +02:00
Pau Espin 3468e90ab3 sbcap: Fix encoding of Warning-Type
Change-Id: I9f6a0779c20ba86962aaaebc9b40ad162d2f2f3e
2022-07-25 14:27:48 +02:00
Pau Espin a97e166ee7 Split cbsp/sbcap server socket creation from struct allocation
This will be needed when we add client support, since clients will
require the mgr structs to be available during VTY parsing.

Change-Id: I14e49d8d2e603925d7f06a7edb710c0eceb02ea3
2022-07-22 16:13:15 +02:00
Pau Espin 5661cef889 Move struct cbc bring up code to its own file and functions
This way it's clear and we have in one place all the related code that
neds to be run at a given time.t

Change-Id: I00fe755340664d4ca4a5cfdcae8d4cd33b2f40a1
2022-07-22 15:45:09 +02:00
Pau Espin d462e452e1 vty: Define peer proto during 'peer' node cmd
This way we lock the type (proto) of each peer at creation time.
Otherwise, having the possibility of changing the protocol of the peer
makes all the code too complex and there's no good way to prevent the
protocol from being changed at any time creating unexpected issues.
If the user wants to change the protocol, she can do so by removing the
peer and re-adding it through the VTY with the desired protocol.

Change-Id: I47756dddd8f9b8450ba14c914614fd2391d5486e
2022-07-22 14:16:10 +02:00
Pau Espin b05a9a6615 cbc_main: Fix setting default SBc-AP local address
The issue was not spotted until now because until recently
cbc_vty_go_parent was not called due to another bug.

Change-Id: I697597438d8c45f5956b12e2a6ea76413e945e5e
2022-07-22 14:16:10 +02:00
Pau Espin 54f50a4857 Fix cbc_vty_go_parent() not being called
Change-Id: I946c503f5a40eafbee6e7fa359781548b74e45a6
2022-07-21 21:50:04 +02:00
Pau Espin 7a8a388edf Make cbsp,sbcap mgr available in data model
Change-Id: I60c3ded80c38bcf50b831c6e9db719a8d2cba5b1
2022-07-21 20:39:23 +02:00
Vadim Yanitskiy bc606f8ea1 cbc_vty: use install_element[_ve](), not install_lib_element[_ve]()
As the naming suggests, install_lib_element[_ve]() should be used
for commands registered by libraries.  This API allows to enforce
some rules for command attribute letters and should not be used
by application specific commands.

Change-Id: I8c0c8ac66dfc4fc2b8bf9102fba0df2dd988e7c9
2022-07-21 20:33:42 +02:00
Pau Espin b4f7404b6c cbc_vty: write peer config nodes at the end
This way we end up with more "global" configs at the start of the file,
which are read/applied first, and later all the per-peer information,
which is a list of variable length.

Change-Id: I7623ea5874552e57764327e94a9c3a4de7b71d67
2022-07-21 20:33:42 +02:00
Pau Espin 678a9cb385 Refactor {cbsp,sbcap}_cbc_accept_cb
Delay allocating the structures until really needed.
First do checks agains the opened connection, and if an issue is
detected simply close the fd.
Next, fetch or allocate the related peer.
Finally, create the link from the fd.
This makes it easier to add early extra checks later when peers will
contain info on link_mode (client|server|disabled) later on.

Change-Id: Id4f83ec6b0b14e556b1caa9c80e7f68d062fec57
2022-07-21 20:33:38 +02:00
Pau Espin 85bc27d394 cbc_vty: print correct protocol when writing config
Change-Id: Id9fc0b42827f9a74ff1de4b35339de02aeeefee2
2022-07-20 21:02:53 +02:00