Commit Graph

663 Commits

Author SHA1 Message Date
Vadim Yanitskiy 5277965190 e1line_dump_vty(): dump keepalive state and params
There is currently no obvious way to know if the keepalive is enabled
and which parameters are in use.  Executing 'show running-config'
command in the VTY would not always reveal the current configuration,
because it tends to omit parameters with default values.

Let's print the keepalive state and params in the output of the
'show e1_line' command.  Below is a few examples:

! keepalive is disabled
OsmoBSC# show e1_line
E1 Line Number 0, Name , Driver ipa
Keepalive: disabled
IPA Keepalive: disabled

! TCP Keepalive is enabled (default)
OsmoBSC# show e1_line
E1 Line Number 0, Name , Driver ipa
Keepalive: enabled
  Number of probes: (driver's default)
  Idle timeout: (driver's default)
  Probe interval: (driver's default)
IPA Keepalive: disabled

! TCP and IPA keepalive enabled (custom params)
OsmoBSC# show e1_line
E1 Line Number 0, Name , Driver ipa
Keepalive: enabled
  Number of probes: 2
  Idle timeout: 1s
  Probe interval: 3s
IPA Keepalive: enabled
  Interval: 2s
  Timeout: 10s

Note that in the case of TCP keepalive with default parameters
we cannot retrieve the actual defaults because that would be a
layering violation.  Thus we say "(driver's default)".

Change-Id: I17bd991850333ee794ab216f474b5e045fb01fa3
Related: OS#6375, SYS#6801
2024-03-18 17:19:53 +07:00
Vadim Yanitskiy d3d04f9edf input/ipaccess: fix regression in ipaccess_bts_handle_ccm()
As stated in a comment in this function, link->line might be NULL:

  /* line might not exist if != bsc||bts */
  struct e1inp_line *line = link->line;

so we cannot use LOGPIL, which dereferences it unconditionally.

Change-Id: Ic26181b580724a70c2af8a224155430902fe4101
Fixes: a87de3cd "input/ipaccess: Always log with context, if we have any"
Related: OS#6379
2024-02-28 16:23:07 +07:00
Harald Welte 12fae9aeeb Fix critical bug in default TCP keepalive user timeout
It turns out that our calculation of the TCP_USER_TIMEOUT value was
flawed in several ways:

* there should have been parenthesis around the + operator
  (line->keepalive_probe_interval + line->keepalive_idle_timeout) as the
  keepalive_idle_timeout is in seconds, not milli-seconds.

* in the default case, all those values are configured to -1
  (E1INP_USE_DEFAULT). This means we're using
	1000 * -1 * -1 + -1 = 999
  i.e. just below a second which clearly is not enough for a lossy
  satellite or wifi back-haul.

This fixes a regression introduced in Ia7659c209aea0d26eb37d31e771adc91b17ae668
(libosmo-abis >= 1.4.0) when TCP keepalive user timeouts became enabled
by default.

The initial support for TCP_USER_TIMEOUT was merged in
I5e7425958472aa5d758e09bfbefc7d7d37bf6f5f (libosmo-abis >= 0.7.0) but
since TCP keepalives were not yet enabled by default, only users with
explicit TCP keepalive configuration in their config files would be
affected - and then only of the second part of the bug (operator
precedence).

In addition, let's print the actually-used values to the log, helping to
spot unintended values.

Change-Id: Idca24d3e676a45d860d9eec60dc2097d8d87f3bf
Closes: OS#6375
Related: OS#5785, SYS#6801
Fixes: Ia7659c209aea0d26eb37d31e771adc91b17ae668
2024-02-27 08:08:02 +00:00
Harald Welte 361488f83f [cosmetic] input/ipaccess.c: We use tab indent, not spaces [wtf]
Change-Id: I6ba728ccf7f6d81dc42d1ff82a29b557752e80ba
2024-02-21 18:16:45 +01:00
Harald Welte ead2c4b651 input/ipa: Log error message also in unexpeted error paths
When calling ipa_msg_recv_buffered() we already had log statements
for -EPIPE, -ECONNRESET and zero-lengthe read (EOF), but not yet for any
other error causes.  Let's add a related 'else' clause.

Change-Id: Ib2134817f44026adf0111051ed9ec3c6b8fbe7c9
Related: SYS#6801
2024-02-21 18:15:16 +01:00
Harald Welte c14bf38732 [cosmetic] Don't break lines shorter than 120 chars
Change-Id: I0595ee899639d0eb798eb8d9372793db36f05b7a
2024-02-21 18:15:15 +01:00
Harald Welte 715653778c input/ipaccess: Makes sure to say "TCP keepalive"
We have TCP and IPA keepalive.  Reading a message like

"input/ipaccess.c:612 Keepalive is set: 0" is misleading, as one might
assume it relates to IPA.

Be explicit.

Related: SYS#6801
Change-Id: I01cbda27eb7826eb11f44e034d746b7c39b399a4
2024-02-21 18:14:07 +01:00
Harald Welte a87de3cd60 input/ipaccess: Always log with context, if we have any
Calling global LOGP/DEBUGP without giving any context (e.g. by using
LOGPIL, LOGPITS, ...) will leave the user wonder *which* line or
timeslot generated a certain log line.  We should know better than that.

Change-Id: I5cd84c2d69c0db3be296cb5d9a62720f7b2c827e
2024-02-21 18:13:45 +01:00
Harald Welte d67966b43e ipa_keepalive: Make FSM a bit less quiet
Let's make sure we log meaningful log messages whenever an IPA keepalive
FSM is started, stopped or if it times out.  This allows the user to
observe whether IPA keepalive is actually enabled (using what timeout),
and also to learn why exactly the connection was dropped.

Change-Id: Iad20b86f893c1036affaf14f978099fa858a0031
Related: SYS#6801
2024-02-21 18:12:44 +01:00
Harald Welte 1645a2a261 ipaccess: Log ERROR message if IPA keep-alive FSM allocation fails
This is a rather serious and unexpected event, it shouldn't go quiet.

Related: SYS#6801

Change-Id: Ic310b3544ae817e26247facf30ece617fefa82eb
2024-02-21 17:22:11 +01:00
Andreas Eversberg f5c799e903 Add support for sending and receiving Sa bits, as well as some line signals
The Sa bits are required for osmo-v5. V5.2 interface must alter and
detect Sa7 bit on time slot 0. 'Fastlink' multiplexers do not allow to
disable link check with Sa7, so that it must be supported by osmo-v5.

Requires: osmo-e1d Change-Id I2608af7bbb8092fddd68d4f3bb36b10a1100ce0f
Change-Id: Ie7643693c2daac99f5747591decd60e982b8052a
2024-02-12 18:06:25 +00:00
Vadim Yanitskiy d33d431a1d Bump version: 1.5.0.5-aa34 → 1.5.1
Change-Id: I88b987d714a88728b62f74a60c44d9c3532b5686
2024-01-28 18:04:12 +07:00
Vadim Yanitskiy aa3452cb80 build: include git-version-gen into the release tarball
Change-Id: I4100459461c04e57cbdfa072dcf1c771f0c0b798
2024-01-26 23:46:22 +07:00
Vadim Yanitskiy c4ea374e4a trau/osmo_ortp: support building without OrtpMemoryFunctions API
Recent ortp versions (v5.3.0+, maintained by linphone.org) no longer
have the memory allocator configuration API.  See the related commit:

9ba9db486a

A similar API is provided by bctoolbox, a dependency of ortp:

  void bctbx_set_memory_functions(BctoolboxMemoryFunctions *functions);

Let's support building against v5.3.0+ by checking (in ./configure)
if the old API is available.  Use talloc if possible;  otherwise
fall-back to whatever ortp uses by default (glibc's malloc).

Change-Id: I9fe6299fde81faeab86cd6645d67edd2f41e1873
2024-01-08 20:11:36 +07:00
Keith Whyte f0875079a3 DAHDI: Log hexdump of TX at level DEBUG, not ERROR
This fixes Change-Id I447a2360757fed97ed50f9db1e2efbf2f90e46a0 where
log messages received more context.  However, by accident, one log
statement got elevated from DEBUG to ERROR level.  Let's revert that
accident.

Change-Id: I29aa82c8586d846a861e62d90d376ff9cfaa9654
2024-01-07 08:54:53 +00:00
Harald Welte 247e52141f dahdi: Fix compilation with ancient DAHDI
We had an #ifndef DAHDI_SPECIFY clause which clearly wouldn't compile
as it used a wrong variable name.  Apparently nobody is building against
such ancient DAHDI for a long time...

Change-Id: Ib18343c0914ef25e673b930fa86b2dec6129065d
2023-09-17 12:32:54 +02:00
Harald Welte 56a73534c9 dahdi: Log context (e1inpt_ts name) when opening timeslot devices
This will provide us more context about what was attempted to open
at the time we print an error message.  Also, log a debug message
in the successful case.

Change-Id: Iaebe83e608a618264c42d57584089e92847d2448
2023-09-17 12:32:54 +02:00
Pau Espin e394d9dc58 Bump version: 1.4.0.54-9f17-dirty → 1.5.0
Change-Id: I3a850a19d842227577a6fb247b5681998d759c2c
2023-09-12 13:39:09 +02:00
Vadim Yanitskiy 9f1723d420 osmo_ortp: register a PayloadType for RTP_PT_CSDATA
Add a PayloadType definition for payload type 120 as per RFC 4040.

Change-Id: I48e91d2c4e9124ee1b7eb88e26af24603aa69f25
Related: OS#1572
2023-08-28 03:30:02 +07:00
Andreas Eversberg 23bac40d75 dahdi: Add msgb_free() to prevent memeory leaks
Change-Id: I862dfa80dc195639552f99ec0734ec94290a7bb5
2023-08-01 09:51:15 +02:00
Andreas Eversberg 7e5ab270b4 dahdi: Add missing msg->l2h
l2h is now set in all receive functions after putting received data to
the msgb.

Change-Id: Ieec5e2e6bacc4bce465c29b2148537e8b2218a00
2023-08-01 09:51:15 +02:00
Andreas Eversberg 9fe62b01a7 dahdi: Disable OSMO_FD_WRITE if HDLC/RAW write queue is empty
Not doing so will cause 100% CPU usage, because the write functions are
constantly called if their queue is empty.

Change-Id: I2c544594eb187110861ab2564323654a2dc6e85a
2023-08-01 09:51:15 +02:00
Philipp Maier de41b9a40b e1d: reconnect to osmo-e1d after connection loss
When osmo-e1d crashes while a line is in use the client process may
experience not only a lost connection, it may also hang up in an endless
loop that would also spam the logfile. The reason for this is that the
e1d driver in libosmo-abis lacks mechanisms to detect when the
connection to osmo-e1d gets lost.

When osmo-e1d goes down the effects should be similar to those of a
normal connection loss of an e1 line (cable pulled). So let's add an FSM
that takes care of the recovery of the connection when it is lost. Also
make sure that no havoc happens when the connection gets lost.

Related: OS#5983
Change-Id: Iaf4d42c2f009b1d7666e319fabdeb2598aa0b338
2023-07-04 14:49:02 +02:00
Harald Welte eb2c109dea trau_sync: Add sync pattern for FA protocol of 3GPP TS 43.045
The FA protocol is used to carry (modified) T.30 protocol (Fax G3)
information over synchronous CSD bearers in GSM.  It uses 64bit
framing with a well-known sync pattern.

Let's use the trau_sync infrastructure to synchronize to that framing.

Change-Id: Ie2206e120f456d10b4f98d8aeb34fd8a499cb22c
2023-06-13 08:58:10 +02:00
Philipp Maier a5afe23ab6 trau_pcu_ericsson: do not set unused D bits to 1
The er_gprs_trau_frame_encode already pre set all non T0 bits in the
TRAU frame to 1, there is no need to set unused bits explicitly.

Related: OS#6015
Change-Id: I003632a08cc80bc195b306bef5f907351b6fe94e
2023-06-11 19:24:30 +00:00
Philipp Maier 1e74d29937 e1d: get rid of strange file descriptor registered check
When the line update happens the list.next member of the file descriptor
is checked for NULL and != LLIST_POISON1. This directly tampers with the
llist API and might be problematic. Also we can tell by the file
descriptor number if the file descriptor is registered or not. An open
file descriptor is always registered.

Change-Id: I92c426271dc5455427471030fcf0749566e4c2ee
Related: OS#5983
2023-05-09 16:46:22 +02:00
Vadim Yanitskiy f6bde0f521 fix use-after-free in ipaccess_bts_keepalive_fsm_alloc()
In ipaccess_bts_keepalive_fsm_alloc() we allocate a keepalive FSM
instance as a child of the respective struct ipa_client_conn, and
store the pointer to the respective struct e1inp_ts.

  + struct e1inp_line
  |
  ---+ struct ipaccess_line (void *driver_data)
  |  |
  |  ---+ struct ipa_client_conn *ipa_cli[NUM_E1_TS]  // <-- parent
  |
  ---+ struct e1inp_ts ts[NUM_E1_TS]
  |  |
  |  ---+ .driver.ipaccess.ka_fsm  // <-- pointer

When an ipaccess connection (be it OML or RSL) goes down and then
up again, for instance if the BSC gets restarted, osmo-bts crashes.
The problem is that struct ipa_client_conn gets free()ed before the
associated FSM instance gets terminated:

* e1inp_ipa_bts_rsl_connect_n() is called
** calling e1inp_ipa_bts_rsl_close_n()
*** this function free()s struct ipa_client_conn
*** (!) as well as the struct osmo_fsm_inst (talloc child)
** calling ipaccess_bts_keepalive_fsm_alloc()
*** calling ipaccess_keepalive_fsm_cleanup()
**** accessing free()d e1i_ts->driver.ipaccess.ka_fsm
**** BOOOM!  segmentation fault

Fix this by calling ipaccess_keepalive_fsm_cleanup() before free()ing
the associated struct ipa_client_conn.

Note that ipaccess_bsc_keepalive_fsm_alloc() is not affected because
it's allocating keepalive FSMs using the global tall_ipa_ctx.

Change-Id: Ic56c4b5b7b24b63104908a0c24f2f645ba4c5c1b
Related: SYS#6438
2023-05-05 23:08:34 +07:00
Vadim Yanitskiy 0de8a853a6 cosmetic: e1inp_ipa_bts_rsl_close_n(): cache ipa_client_conn
Change-Id: I9bdb4b1778d702c97890149a9f98590ae8ec54be
2023-05-05 23:08:34 +07:00
Vadim Yanitskiy 4b1cac45f4 cosmetic: struct e1inp_ts: fix coding style
Change-Id: I64c30579f74391cefec6cdcba71e1f9e76ec9faa
2023-05-05 23:08:34 +07:00
Vadim Yanitskiy 36a075b06d .gitignore: add new trau_{pcu_ericsson,sync} tests
Change-Id: If7e5a91bc835fecb9c0540dceef4f31139c2146a
2023-05-05 23:08:34 +07:00
Philipp Maier 851a4e4cbd e1d: fix logic to detect if a timeslot is in use
When we check bfd->fd, we also treat 0 as "not in use". This is not
correct since 0 is a valid file descriptor (STDIN). Since we reliably
initialize the file descriptor numbers to -1 on startup we can fix this.
So let's treat all positive file descriptor numbers, including zero as
an open timeslot.

Change-Id: I67bc5ca25620ff96441391798f761144570c8306
Related: OS#5983
2023-05-02 15:00:19 +02:00
Philipp Maier 6542a1514f e1d: initialize file descriptor numbers to -1 on startup
The file descriptor numbers (bfd->fd) are not initialized, this means
they are set to 0 in the beginning. This technically also means that
the file descriptors point to STDIN, which is wrong. Let's use the
line_create callback of driver to initialize them to -1.

Change-Id: I2de8fccad56279748ed9cc035aebf4e2d3935172
Related: OS#5983
2023-05-02 15:00:19 +02:00
Philipp Maier 2b880d6474 e1_input: add new driver callback function: line_create
When a line is created using e1inp_line_create, then the line data
structures are initialized and the line is registered in the line list.

struct e1inp_line also contains driver specific sub structs that,
depending on the driver, might also need some initialization. At the
moment is no way. Let's add a line_create callback that, when
populated by the driver, is executed on line creation.

Related: OS#5983
Change-Id: I404fa23e9b8a952be84e9716889c0dbbbc665d22
2023-05-02 15:00:19 +02:00
Philipp Maier a7e7621690 e1d: do not set fd number to 0 after close
0 is reserved for STDIN, so lets not set the file descriptor to 0 after
we close it. Lets use -1 instead.

Change-Id: I72e4775135caf4e3727c4f0654a545478c73bb83
Related: OS#5983
2023-05-02 13:00:00 +00:00
Philipp Maier 2c0237a122 trau_pcu_ericsson: set uplink frame error bit correctly
At the moment we set the uplink frame error bit to 1 if ul_frame_err
is set to false. Unfortunately the er_gprs_trau_frame_encode pre set
all non T0 bits to 1 before calling the encoder function. This means
that with this logic the uplink frame error bit can never be set to 0.

Related: OS#6015
Change-Id: I74f56bc40ed074eb1588b202849870e2786ded24
2023-04-27 22:31:40 +02:00
Mychaela N. Falconia 2d70a93734 osmo_rtp2trau() for FR & EFR UL: set C13 & C14 correctly
Control bits C13 & C14 in TRAU-UL frames indicate SID classification
per section 6.1.1 of GSM 06.31 for FR or GSM 06.81 for EFR.
Previous commit 08d0c09902 implements correct setting of C16 in
TRAU-DL, but the case of generating TRAU-UL was left as a FIXME.
Now that we have osmo_{fr,efr}_sid_classify() functions in
libosmocodec, we can set C13 & C14 in TRAU-UL too.  Do it.

Change-Id: Ifcfc28ad7d77e561d456be546689995abfd8a6f5
2023-04-27 19:53:51 +00:00
Oliver Smith dbbc4a075f debian: set compat level to 10
Related: OS#5958
Change-Id: Icfdbea7cbe4681cd3b286471032fd6dd7226888f
2023-04-25 16:48:17 +02:00
Philipp Maier a551d3920e e1d: close fd when osmo_fd_setup fails
When osmo_fd_register() fails we just exit but the file descriptor stays
open. A file descriptor in this state does not work. Let's close the file
descriptor

Change-Id: I6b41e5ad8511f2d4e524979631a91ab23dc0b23f
2023-04-20 15:33:05 +02:00
Philipp Maier 239a7049b7 e1d: cosmetic: remove double whitespace
Change-Id: If29ace652b71b33c3240f4dcb5eceeffb513d970
2023-04-20 15:33:05 +02:00
Philipp Maier d741299f96 e1d: fix sourcecode formatting
Change-Id: I715e77849d771e05f8e7be82147c9168f9e8f86b
2023-04-18 11:45:39 +02:00
Philipp Maier dbb6cf4c7e e1d: maintain error log consistency in handle_ts_hdlc_read
The function handle_ts_hdlc_read() should log read errors in the same
way as the other functions do

Change-Id: I0af06d6adcbf61e0996d9888feb70b74f0c9c0ef
2023-04-18 11:45:39 +02:00
Philipp Maier d0c61dc1c2 e1d: clean up error logging in handle_ts_sign_read
The error logging in handle_ts_sign_read can be organized the same way
as in handle_ts_raw_read, then we do not need to check the return code
twice.

Change-Id: Ife3bb07fb4180dbd73d0efdc5acade8b20e8a5da
2023-04-18 11:45:39 +02:00
Philipp Maier d07528148e e1d: fix log output
When a read access to the osmo-e1d fd fails we just print the error to
LOGL_DEBUG but an error like this should be logged to LOGL_ERROR. Also
the line might print "read error 0 Success", which is a bit misleading,
so let's fix this as well.

Change-Id: I3a0500f083cbe8cc162826e2ec974875bafcaba9
2023-04-18 11:45:39 +02:00
Mychaela N. Falconia 08d0c09902 osmo_rtp2trau() for FR & EFR: set SP=0 in DL if the frame is a SID
The SP bit in TRAU DL frames is supposed to be 1 for regular
speech frames and 0 for SID frames.  The previous code always set
SP=1; the present change sets this flag per the spec (TS 48.060)
using osmo_{fr,efr}_check_sid() functions from libosmocodec.

The present change does not affect TRAU UL frame generation -
correct generation of SID bits in the TRAU UL frame is still missing
and would require further work if someone wishes to use Osmocom
software to implement a new T1/E1 BTS or some other entity that
needs to generate TRAU UL frames.

Change-Id: I371f8072c0afedbd1b065efecfed3734fb6d31ab
2023-04-17 17:14:10 +00:00
Mychaela N. Falconia 1d42fcd4ea osmo_rtp2trau() for FR & EFR: correctly handle the no-data case
3GPP TS 48.060 sections 6.5.2 and 6.5.3 prescribe the behavior of
TRAU frame emitters under conditions of not having any speech or SID
frame to send.  In the case of osmo_rtp2trau() this no-data condition
is indicated with a zero rtp_len argument to the function, but this
case was not handled correctly: a garbage speech frame (previous
buffer content for the D bits in struct osmo_trau_frame) was being
generated.  The present change implements the rules of TS 48.060
sections 6.5.2 and 6.5.3: standard FR/EFR speech frame with BFI=1
for UL, special idle speech frame pattern for DL.

Change-Id: I7f21e2210bba9ef87f1af515a001a0cfc1c0a1d8
2023-04-17 17:09:04 +00:00
Pau Espin 4680672d6d ipa: Call osmo_fd_unregister() before closing and changing bfd->fd
Change-Id: I8bfafe5de3cf194a71fb755c642121cec817aaa3
2023-03-14 11:43:31 +01:00
Andreas Eversberg e40939e432 e1d: Add support for HDLC type channels
Change-Id: I2f4b9f7ed6430804ca511c7f5283a16bc13bc2fc
2023-03-05 18:06:08 +00:00
Andreas Eversberg 1a4ff4fbfa e1d: Remove useless call of handle_ts_trau_write()
handle_ts_trau_write() is called inside handle_ts_trau_read(). There is
no need to call it when OSMO_FD_WRITE flag is set, because it is never
set.

Change-Id: Iccddcdb0975e8a043cc395c8908a157f5b376752
2023-03-05 18:06:08 +00:00
Andreas Eversberg df15c2976e Send raw data with e1d as it arrives from application
The application is responsible to send raw data in sync with the raw
data it receives. It also cares about sending data in advance, to
prevent underruns, if required. The length of data can vary.
(Now it is same procedure as with mISDN driver.)

OSMO_FD_WRITE flag must be disabled, if there is no message left
in the transmit queue.

Change-Id: I3e3ef623a02bffe75b168dc42514455b4df1007f
2023-03-05 18:06:08 +00:00
Philipp Maier 26f7a7474e trau_pcu_ericsson: add comment about uplink blocks
While testing each uplink block (CS1-C4, MCS1-MCS9) indvidually some
specific behaviour was observed.

Change-Id: I35b9a35c9b583378559daa400e105537338ee68a
Related: OS#5198
2023-02-27 10:54:56 +01:00