Commit Graph

91 Commits

Author SHA1 Message Date
Pau Espin 70c03f5e44 Add Osmux IPv6 support
A new osmux bind-ip-v6 VTY command is added, similar to what's already
available for RTP. This way the user can decide whether to support IPv4,
IPv6 or both types of IP versions.

Both IP sockets are by default disabled, and must be explicitly enabled
by setting the bind-ip in the VTY configuration.

Change-Id: I446cd7da217e9f4a74995d7784ae55dcc60a29b7
2022-10-05 10:32:42 +02:00
Pau Espin e56ec4a146 osmux: Use available API to check if remote end is known
Since recently the port is guaranteed to be placed at
CRCX/MDCX in the sockaddr, hence we can check it using the API instead
of checking manually only for the address part.

In osmux_send_dummy() we actually fix a bug where an in_addr was being
compared against a struct sockaddr.

Change-Id: I736e7f4c51e577d8eb0b96bc776f984f928b6d27
2022-10-04 14:44:48 +02:00
Pau Espin 5ffd127384 Get rid of separate rtp_port field
Let's use the port part of the struct mgcp_rtp_end->addr field instead
of keeping it separate. This makes it easier passing around and
using/checking the RTP remote address + port, and avoids confusion
having to check stuff outside of the address, with its port part
potentially unset.

Change-Id: I294eb5d85fae79bf62d36eb9e818426e187d442c
2022-10-04 14:44:44 +02:00
Pau Espin e740665cab Fix regression in detection of legacy dummy packets
A commit refactored this code around one year ago, which broke osmux
detection of dummy messages. This commit partially reverts the earlier
commit and rearranges the existing code to make it more robust.

Fixes: b3d14eb552
Change-Id: Iedf085932c45af5d13e04e56a4cd1082de81d869
2022-10-04 12:16:15 +02:00
Pau Espin 2dd2b33030 osmux: Log remote address upon rx of osmux pkt
Change-Id: Ie2a375711c7c0989161ae651ea6f0695799e2670
2022-10-03 18:10:55 +02:00
Pau Espin 69f15e4e95 osmux: Fill in from_addr in struct osmo_rtp_msg_ctx
Change-Id: I9783978e295b964ca914f8d90d73effa8785f10d
2022-10-03 18:04:07 +02:00
Pau Espin b0ea7976bf osmux: Match remote address in osmux_conn_lookup()
Depends: libosmo-netif.git I95433b18802f73fa70e758f4aa02128eee940d88
Change-Id: Ia717efa5f68e9412b86ef44a4c42a0715ff0e469
2022-10-03 18:04:03 +02:00
Pau Espin 9d939b6d5d osmux: Unify rtp_conn osmux type into a single type
There's no need to separate between BSS and CN side nowadays, the
different types are used nowehere. This separation dates from
osmo-bsc-nat code days.

Change-Id: I65effeddf033eb1955553e8d659c593b4e67f7bc
2022-10-03 17:16:16 +02:00
Pau Espin de805b6772 osmux: cleanup misleading code calling rtp_bridge_cb
Documentation of rtp_bridge_cb was outdated, and caused confusion when
adding initial osmux support. Let's clear all the mess.

Change-Id: I42d1f2e2919eae3b1555ca4929e571855960792e
2022-10-03 17:16:16 +02:00
Pau Espin cb25a0aa48 osmux: Drop logging of osmux internal counters
This way we have no more access to internal osmux structures.
Moreover, we already have similar information in our rate_ctrs, so
there's no need to print those there.

Change-Id: I853e118f843070ea29b19e1b0fe56b52f267437a
2022-10-03 15:57:09 +02:00
Pau Espin 72eff2cf6a Allocate struct osmux_in_handle through new libosmo-netif APIs
Change-Id: I013c99d1f915279684ce278648e9c69e39b94266
Depends: libosmo-netif.git I752ab031f935f04731bb1a354333f1682a1aa5bd
2022-10-03 15:57:09 +02:00
Pau Espin 1c5fcb0791 osmux: Keep decoding osmux pkt if a batch contains an unknown CID
Receiving an unknown CID (for which we don't have an active conn) is
totally expected at the end of the call, were some messages from the
peer may be send for a while, specially if latency is high.
If this occurs, we simply drop that batch and keep decoding the osmux
message in order to keep delivering content to other circuits.

Related: SYS#5987
Change-Id: I315949853bdcc07bef15d2e8579029cc72c427cf
2022-09-29 16:02:10 +02:00
Pau Espin 48fb176fbc osmux: Lower log level when osmux batch received for unknown CID
This is actually quite common, since our peer may be sending some osmux
packets to us a while after we have closed the conn on our side,
specially if latency is high in the network (eg satellite links).

Related: SYS#5987
Change-Id: Idffd91b68d1f98ac906d78e7fbc0e6eaa1962f9e
2022-09-29 16:02:03 +02:00
Pau Espin 4d090d85f4 osmux: Drop unneeded comment block
Change-Id: Iae04a7c4b496492ce5b363a56fdd871b210012ed
2022-09-29 16:02:03 +02:00
Pau Espin 81c5847434 cosmetic: osmux: Drop extra empty line
Change-Id: I679a62c49290dfeb9e2c63890daa67002bfe3339
2022-09-27 13:45:07 +02:00
Pau Espin d48a811f6c osmux: Allocate rate counters during initialization of osmux conn
Let's not delay allocation of rate counters until the osmux conn is
fully enabled, since we may want to count stuff before that point in
time.

Fixes crash accessing null conn->osmux.ctrg in
MGCP_Test.TC_two_crcx_and_rtp_osmux_bidir.

Change-Id: Ic31d3567f4d24e628f8983d8362e5c7c2f66ec02
2022-09-27 13:45:04 +02:00
Pau Espin b7f52b414e osmux: Rename field s/init/initialized
Change-Id: Ic48de396b1d8a0774611b4a1c2248ba79bdaf044
2022-09-25 00:14:03 +02:00
Pau Espin ea7aaf2eca vty: show per-connection Osmux VTY stats
Related: SYS#5987
Change-Id: Ieab6dcbd195c8e01a73a2a832bce78ee015ae1c3
2022-09-25 00:06:00 +02:00
Pau Espin 432ee9d150 osmux: Improve per-conn tx rate counters
Change-Id: If030f5d921bdfcfcd00b015b4a9e48bb3b04e721
2022-09-25 00:06:00 +02:00
Pau Espin b4a59475d2 osmux: Fix incorrect rate_ctr_group used in mgcp_osmux.c
During development of the counters, they were first added to the same
RTP counter group and later on split, but some places still used the
RTP related functions to increment the counters.
Let's add a seaprate set of helpers to update the correct osmux counter
group.

Fixes: 582c2bf7b0

Change-Id: Ia2e5601c7d476b79afd95032dbc019517f8209af
2022-09-25 00:05:49 +02:00
Pau Espin 2177919edb osmux: Support local CID != remote CID
So far the implementation only allowed the remote CID being the same as
the one dynamically implemented internally.

Related: SYS#6138
Change-Id: I6b03eabc0305580c9788c529bec7dda9044a008f
2022-09-23 16:55:46 +02:00
Pau Espin 87f114a1d0 Use bool type instead of int in config field
Change-Id: Ie2624a6a6848c3c88deb39760317860d8074acb9
2022-09-23 15:48:43 +02:00
Pau Espin 928a20b540 osmux: Rename field osmux usage policy and define it with proper type
Change-Id: I7f41a443f488b75df792597ec3cec8f7e97a7411
2022-09-23 15:48:20 +02:00
Pau Espin b9022497d8 cosmetic: osmux: Fix formatting of if-else brackets
Change-Id: I748d41cd110841ef121f70560e70c07de56aa9da
2022-09-22 21:47:23 +02:00
Pau Espin 582c2bf7b0 osmux: Add connection and global rate counters
Change-Id: I200a4aa3908cac0ec729d980a66f3df7f55e4da7
2022-09-22 21:44:46 +02:00
Pau Espin 941e317c97 osmux: Get rid of static NULL talloc context
struct osmux_handle, which is shared by several rtp_conn, is
attached to the trunk object, since the socket also attaches to it.

Related: SYS#5987
Change-Id: If4980424cdb8e3dc26a23e9ee419c0a38912f38f
2022-09-22 21:21:11 +02:00
Pau Espin 3fbf035923 osmux: Clean up helper macro osmux_chunk_length()
Change-Id: I482d8c5be08610788c2ed98e3b87ae4184075e8d
2022-09-22 19:01:33 +02:00
Pau Espin 21bcf6abd8 osmux: Attach osmux to virtual trunk
It makes sense to handle one osmux socket per trunk. Since we only so
far operate one RTP/osmux trunk, let's stick to that only one for
simplicity.

Change-Id: I173266c4058d5db9479d773d7dec1304bc8f1f99
2022-09-22 18:23:05 +02:00
Pau Espin 4d1a52d463 osmux: Log sendto() error
Change-Id: Icd91b725ac6b5ef2b9307cc99d67d60efdfa32cb
2022-09-22 17:11:57 +02:00
Pau Espin c5bbb78ffe osmux: set log level of expected code path to INFO
Change-Id: I5caf850b7bb19c66716139512f16568d4f8459eb
2022-09-19 16:46:02 +02:00
Pau Espin e39ae87ea3 osmux: don't store conn ptr inside shared osmux_handle
The struct osmux_handle is a shared structure which goes together 1-1
with libosmo-netif's struct osmux_in_handle, which is common to all CIDs
to be muxed together. Hence, it makes no sense to store a specific conn
object to it, since it actually manages several of them. Hence, all the
conn specific stuff must be handled beforehand, not at osmux deliver
time.

Related: SYS#5987
Change-Id: Ie739b556e9eb7d3133e798831a09728c7cc87135
2022-09-09 18:13:45 +02:00
Pau Espin 8b0a614e43 osmux: Fix memleak on error code path
Change-Id: Ib84f78a53293799b925b645156513e129c32c705
2022-09-09 18:13:45 +02:00
Pau Espin c61664c2b2 osmux: Log refcounting of osmux_handle_list
Change-Id: Ia873e3021078976748762baaf406865149b2a090
2022-09-09 18:13:45 +02:00
Pau Espin 15e7e4f37d osmux: Use osmo_sockaddr wherever possible
This cleans up all the code, and makes it a lot easier to add IPv6 support
later on (mostly only a matter of adding an IPv6 bind address in VTY).
Similar changes were done to the Osmux code being added to osmo-bts.

Related: SYS#5987
Change-Id: I5a100fc654f88d29b2bcd85889a5a92aef3d576d
2022-09-09 18:13:40 +02:00
Pau Espin ab8371c6d7 osmux: Use better name for function which may allocate a new struct
Change-Id: I867e3f74775d97749a78c2f198452b1f2916492f
2022-09-09 16:40:57 +02:00
Pau Espin ec5e85b84e Add Osmux log category
Change-Id: Ia75de7965c39f3f84164a25584d901dbdd43f10f
2022-09-09 16:04:19 +02:00
Pau Espin a4f783b51b cosmetic: osmux: Fix wrong indentation
Change-Id: I7675d17bb3fc827e05c197104be29eadd8ddf3f2
2022-09-07 20:04:20 +02:00
Pau Espin 33639166a2 osmux: Use new osmux APIs to let libosmo-netif alloc struct osmux_out_handle
This way we don't need to worry about implementation details (struct
size) in the future in case they change (they will).

Related: OS#5987
Requires: libosmo-netif.git Change-Id Ie8df581f375c9a183a7af60b431561bda82f6e34
Change-Id: I2d0d8c152b8f1234ddfcd74d6cb04b1818b41510
2022-09-07 08:29:35 +00:00
Pau Espin f1f73b8e1d mgcp_osmux: Drop duplicated conn_osmux_release_cid() in code path
Change-Id: I65d9978ee93ef9b1a2e48a92617ae8de3e131a93
2022-08-12 14:06:50 +02:00
Eric Wild fbf78d13f1 endp: do not cache cfg pointer
There is no obvious reason why we would want to complicate the code by
caching pointers, since pointer traversal is probably not a performance
bottleneck, and if it is we should rather take a look at our dozens of
linked lists first..

Change-Id: I2456ba63598f76200d53e00223abf60bb36a49c0
2021-09-14 18:33:24 +02:00
Philipp Maier b3d14eb552 mgcp_network: refactor MGCP_DUMMY_LOAD
The constant MGCP_DUMMY_LOAD is used ambigously. Sometimes it is used as
initalizer for an array, sometimes it is used as a single byte. Also the
name is not very expressive. Lets refactor this.

Change-Id: I21d96cefeeb647958bfa1e22a0ea030884746fad
Related: OS#4005
2021-06-07 20:14:35 +00:00
Harald Welte 55a9229922 mgw: Add support for setting socket priority from VTY
This is useful for affecting the 802.1Q PCP value without any separate
external packet filter rules for classification.

Change-Id: I69136c6dd114c24b1dace034e75dba5157bac37e
Depends: libosmocore.git I89abffcd125e6d073338a5c6437b9433220e1823
2021-04-29 21:25:33 +02:00
Harald Welte 7802ccc8d6 switch from osmo_sock_set_dscp() to OSMO_SOCK_F_DSCP()
libosmocore If22988735fe05e51226c6b091a5348dcf1208cdf introduces
an even more convenient mechanism for specifying the DSCP of
an IP socket via OSMO_SOCK_F_DSCP()

Change-Id: If0b11dea08716ed3952a25b546b2a9bd013857bf
2021-04-28 20:27:37 +02:00
Harald Welte 5936a9c23e TOS bits != DSCP
We have VTY options that allow to set the DSCP value.  However, we
then call a function to set the TOS bits in the kernel.  This is
very wrong.  The DSCP is only the upper 6 bits of the 8-bit TOS
value, and hence we are mussing that translation.

As libosmocore now has a helper function osmo_sock_set_dscp(),
let's make use of it and don't care about the low-level details.

However, this means we need to finally remove the deprecated
alias for "rtp ip-tos <0-255>".

Closes: OS#5137
Change-Id: I9c18c90273be97aedd2ad212b82f650e35c32851
Depends: libosmocore.git Ia4ba389a5b7e3e9d5f17a742a900d6fd68c08e40
2021-04-28 20:27:11 +02:00
Harald Welte c2a8f59560 use osmo_fd_setup() whenever applicable
Change-Id: I1586e855d37670af2602fc26b5d1fc72a32d1929
2020-10-21 11:56:17 +00:00
Pau Espin de133113a0 mgw: osmux: Fix conn watchdog timeout not updated
It is currently done upon receival of RTP packets in rx_rtp for pure RTP
conns, but nothing similar is done for Osmux conns, which eventually
trigger a connection time out.

Change-Id: Id592d7db7b9399a497176e0d28cc826b3bce48c0
2020-09-08 17:51:45 +02:00
Pau Espin 2491401932 mgw: osmux: Avoid sending packets on recvonly connection
Change-Id: I87b1fb7d73cbbb2a5d4d8a40a9527a3e05d9947b
2020-09-08 12:57:35 +02:00
Pau Espin a790f0c082 mgw: Initial IPv6 support
This commit contains the bulky work of moving all address parsing to
support IPv6 together with IPv4.
Some specific patches required for full IPv6+IPv4 support requiring
behavioral changes come after this one.

Full Osmux IPv6 support is left out of the scope of this patch.

Depends: libosmocore.git Ie07a38b05b7888885dba4ae795e9f3d9a561543d (> 1.4.0)
Depends: libosmocore.git I59bf4b4b3ed14766a5a5285923d1ffa9fc8b2294 (> 1.4.0)
Change-Id: I504ca776d88fd852bbaef07060c125980db3fdd7
2020-09-07 18:12:59 +02:00
Philipp Maier 993ea6be7a get rid of mgcp_internal.h
The file mgcp_internal.h still contains mostly definitions and types
that are relevant for mgcp_network.c and mgcp_protocol.c. Lets give
the network and protocol module its own header files, also move stuff
that does not relate to protocol and network to the appropiate places.

Change-Id: I837eaad771ed7252304db4a81c37953b70766fff
2020-08-10 22:56:59 +02:00
Neels Hofmeyr 51b42ff2e1 refactor: use msgb to receive, pass and send RTP packets
Instead of numerous arguments (buf, len and context data), use a msgb, like
most other osmo programs do, with a msb->cb pointing at a context data struct.

This opens the future for adding/stripping IuUP header data from the msgb
easily.

(Checked to pass current ttcn3-mgw-tests.)

Change-Id: I3af40b63bc49f8636d4e7ea2f8f83bb67f6619ee
2020-07-21 16:13:23 +00:00