Commit Graph

116 Commits

Author SHA1 Message Date
Pau Espin 3092167e4e server: Call osmo_fd_unregister() before closing and changing bfd->fd
Change-Id: I44405687dae79a13db5617867c669ee4840485ba
2023-03-14 11:50:02 +01:00
Daniel Willmann fa47880575 cosmetic: Remove trailing whitespace
Change-Id: I33c8747f1f9c1020232e91d5559f0a06a31857d8
2023-02-28 11:39:05 +01:00
Daniel Willmann 4e934bb546 osmo_{client,server}_main: Remove is_config_node in vty_app_info
This member is deprcated/unused so simply remove it:

> 'is_config_node' is deprecated: Implicit parent node tracking has
> replaced the use of this callback. This callback is no longer called,
> ever, and can be left NULL.

Change-Id: I34295950557d9009b0d8d3378deb3b1263476f82
2023-02-28 11:39:05 +01:00
Daniel Willmann 50cc638ac7 osmo_{client,server}_main: Remove tall_ctr_ctx and tall_msgb_ctx
tall_ctr_ctx is only used by the obsolete osmo_counters which are not
used anymore.
tall_msgb_ctx is now set through msgb_tallox_ctx_init().

Fixes undefined reference errors since libosmocore.map was introduced in
I13169c00a59fb59513dfc598de5a71d094492422:

```
osmo-pcap/src/osmo_client_main.c:226: undefined reference to `tall_msgb_ctx'
/usr/bin/ld: osmo-pcap/src/osmo_client_main.c:226: undefined reference to `tall_msgb_ctx'
/usr/bin/ld: osmo-pcap/src/osmo_client_main.c:227: undefined reference to `tall_ctr_ctx'
/usr/bin/ld: osmo-pcap/src/osmo_client_main.c:227: undefined reference to `tall_ctr_ctx'
```

Change-Id: Idcbb96fd070f5ad20d3091ce886dc6130968538f
2023-02-28 11:07:59 +01:00
arehbein 9d7556a73e Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: Icc57c68337d55c6594c1c36e9bf41624d11dab0a
2023-02-25 17:48:58 +01:00
Pau Espin a55253f438 client: Add 'wqueue max-length <0-4294967295>' VTY command
This allows setting a suitable write-queue max length per client. The
desired value can be different based on a lot of variables, like memory
availabilty, network and CPU load, input/output link state, etc.

Related: SYS#5921
Change-Id: I4e9d5d836ddda215f9e7a075aa8e10d2d3854dd2
2022-04-14 18:32:23 +02:00
Pau Espin 50dcc15a2e client: Log wqueue capacity when failing to enqueue
Related: SYS#5921
Change-Id: Ie5f39fe679906a15f74490cd8554b18b9d1e0664
2022-04-14 18:30:33 +02:00
Pau Espin 6bbda89308 client: Increase wqueue transmit length
Having a length of 10 packets is too low, it can be filled easily under
high load or really bursty traffic, where the input path could be polled
multiple times while the output path (write socket poll) is not called.

Related: SYS#5921
Change-Id: I72babfcc31e12624f30c16450dafd988192148be
2022-04-14 17:57:14 +02:00
Pau Espin b9be6767ab server: Add vty command file-permission-mask
Related: SYS#5792
Change-Id: I78e0b56b38de438ee5fb679ae41c65b02ea2e722
2022-01-12 17:44:38 +01:00
Pau Espin 30bc1885e4 Explicitly depend on required libosmogb
the spec.in files already stated so expicitly, since some files include
osmocom/gprs/*.h. Only some data types from there are used, so there's
no need in linking the lib. Even more, doing so makes the build fail
because there soft-linking symbols required to be implemented by
libosmogb are not implemented here.

Related: OS#5311
Change-Id: I9a8fa03cef1efc9fdaea65ee63ca9b3379993989
2021-11-16 13:36:14 +01:00
Pau Espin ef92a539e8 Use new stat item/ctr getter APIs
Generated with spatch:
"""
@@
expression E1, E2;
@@
- &E2->ctr[E1]
+ rate_ctr_group_get_ctr(E2, E1)
"""

Change-Id: Ic860db04489e9ee7312edb008497186116f30bfc
2021-06-04 18:01:06 +02:00
Harald Welte 8b73a2a530 vty: call telnet_init_dynif() after config file is read
In case the config file specifies a vty bind address, we must read
it before we start the telnet server.

Change-Id: I44561754d4beaad5c74cb66994ca4ef38960ea78
2021-04-24 16:09:09 +02:00
Harald Welte dd1389c3d3 use telnet_init_dynif() to allow VTY bind to non-loopack address
Prior to this patch, you could configure 'bind 1.2.3.4' in the
config file, but the telnet interface still binds to 127.0.0.1.

Change-Id: I9b86b2cf6949917c55ea15277619cfa2b745185d
2021-04-24 13:00:41 +02:00
Harald Welte 9148d49841 client: Ensure the "file" header is sent on connect
A non-blocking STREAM socket connect() will mark the socket as
write-able once the connection succeeds.  However, as we first
call osmo_fd_setup() and then osmo_sock_init2_ofd(), the latter
will force the 'when' to OSMO_FD_READ and hence the write callback
will not be called.

Change-Id: I44c484b48966a985a9b85fb16122a17df5666bc1
2021-04-23 14:02:11 +02:00
Harald Welte 831494ed34 use osmo_wqueue_enqueue_quiet() as we log anyway
There's no need in both libosmocore and osmo-pcap-client logging
the same queue overflow twice.

Change-Id: I43881f2bd0b0870a51f9ca5dad2d8cba40d1e54b
2021-04-23 13:27:11 +02:00
Harald Welte 8a119642ac update copyright statement; Holger worked on it until 2017
Change-Id: I7a39d4780d309f2dba99272c17bf1b9639760199
2021-04-18 14:26:07 +02:00
Harald Welte b0b2a2d542 add "--version" to osmo-pcap-client and -server
Change-Id: Ib82ee1a784a657f7274d78ba5f7a8afe6cfab395
2021-04-18 14:24:15 +02:00
Vadim Yanitskiy ff3f4b3bef vty_{client,server}_init(): remove unused argument
Change-Id: I65256c8602e91bcdbe5fe9e532b6ce7d347d3980
2021-04-16 20:30:18 +02:00
Vadim Yanitskiy d59783e601 vty: register commands for talloc context introspection
Change-Id: I3774cfd483102993340bd6e96f8512af61085679
2021-04-16 19:36:29 +02:00
Joachim Steiger 52f06fd54b manuals: generate VTY reference for osmo-pcap-{client,server}
Change-Id: I28353f51de798535a3bb6efdc6c2da443d96ddfb
Tweaked-By: Vadim Yanitskiy <vyanitskiy@sysmocom.de>
2021-04-16 19:29:31 +02:00
Harald Welte 611fd19fa3 vty: Add space after prompt, as customary
In all other programs, we have a space after the VTY prompt.

Change-Id: I7916c15cc34e41738a5716e4fefbb15e18f02fa7
2021-04-12 16:07:17 +02:00
Pau Espin 716a4db54c main: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Fixes: OS#4865
Change-Id: I39367aa480445fe961dcfa308789b3fc0cf759a1
2020-11-25 19:11:43 +01:00
Harald Welte 5899cb4fbf Use osmo_fd_*_{disable,enable}
Change-Id: I97e100b34e9d26cf5acaa57be12879787d4d2d2b
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-10-19 13:07:06 +02:00
Harald Welte a9600141b8 Use osmo_fd_setup() whenever applicable
Change-Id: I02097760e7c6a5694290f4b877013aee9d92fd0e
2020-10-19 13:06:44 +02:00
Harald Welte 20c6ba5a9e Use OSMO_FD_* instead of deprecated BSC_FD_*
Change-Id: I7d57919877520710b5dc1f54de1de89cae78093e
2020-10-18 22:39:39 +02:00
Pau Espin 210ed934bb Remove undefined param passed to {logging,osmo_stats}_vty_add_cmds
Since March 15th 2017, libosmocore API logging_vty_add_cmds() had its
parameter removed (c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7). However,
definition in C file doesn't contain "(void)", which means number of
parameters is undefined and thus compiler doesn't complain. Let's remove
parameters from all callers before enforcing "(void)" on it.
API osmo_stats_vty_add_cmds never had a param list but has seem problem
(no "void"), so some users decided to pass a parameter to it.

Change-Id: I2e1ab7005514f1a06cac03e967aa5c8ea472e671
Related: OS#4138
2019-08-05 16:28:11 +02:00
Harald Welte 407f7f9307 Fix compiler warning about deprecated _BSD_SOURCE
On (at least) Debian unstable I'm seeing the following compiler
warninig:

/usr/include/features.h:184:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"

Apparently this was deprecated in glibc 2.20 released in 2014 (!)

Change-Id: I826189dec4107e7c3e8cf4c013316ef3014b7857
2019-01-26 17:39:19 +01:00
Pau Espin a82aaef507 server: Add pcap snaplen VTY cmd
Change-Id: I8fdcdc1a58926ec66a1dc5dc7a5e57ed4dceb4b4
2018-10-08 20:20:43 +02:00
Pau Espin 868a501213 server: Improve verification of messages from client
Take the chance to define SERVER_MAX_DATA_SIZE as pcap payload, which we
can later match to configurable snaplen parameter.

Change-Id: I45d4c59026faf1108c0976eb6ad8c270e3577dbf
2018-10-08 20:20:43 +02:00
Pau Espin b799344ecd client_send_link: snaplen not needed during allocation
We don't send any pkt data, so no need to allocate snaplen bytes extra.

Change-Id: I8d6385f6ff265564492121812a7a9f2bcfea3d5f
2018-10-08 20:20:43 +02:00
Pau Espin f946fa21ee client: Add pcap snaplen VTY cmd
Change-Id: I84fda9f27b725e031c218187ab679392dfa7ec3d
2018-10-08 20:20:43 +02:00
Pau Espin 168949e119 client: Set snaplen to MAXIMUM_SNAPLEN
Despite this value not being exported publicly, the truth is that
tcpdump and wireshark nowadays avoid processing any file with snaplen
bigger than this value:
"tcpdump: pcap_loop: invalid packet capture length 861244, bigger than
snaplen of 262144"
It also fails to set snaplen to values bigger than that:
"tcpdump -s 262145" --> "tcpdump: invalid snaplen 262145"

pcapfix also warns about wrong packet length if bigger than same value
(defined as PCAP_MAX_SNAPLEN there).

MAXIMUM_SPANPLEN is defined in tcpdump's netdissect.h and libpcap's
pcap-int.h. It is also defined as WTAP_MAX_PACKET_SIZE in
wireshark/wiretap/wtap.h (this one being the only publicly available).

Change-Id: Ib7449d5aba9da342c150704ebd0e1f09e7f7276c
2018-10-08 20:20:43 +02:00
Pau Espin f10c57801a Replace '.' in counter names with ':'
The '.' is illegal character in counter names, as they are exported
via CTRL interface, where '.' has a special meaning that cannot be
used by strings comprising the variable name.

Change-Id: Icec5338d3242137980fa05d2c7ae2db940afb542
2018-10-08 20:20:43 +02:00
Pau Espin d475673b69 osmo_client_send_data: Fix wrong log format
According to pcap.h, type bpf_u_int32 can be 32 bits on some systems,
so better cast explicitly to size_t to make sure always correct size is
used by log function.

Fixes warning:
osmo-pcap/src/osmo_client_network.c:175:4: warning: format ‘%zu’ expects argument of type ‘size_t’, but argument 7 has type ‘bpf_u_int32’ {aka ‘unsigned int’} [-Wformat=]
    "Capture len too big %zu\n", in_hdr->caplen);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~

Change-Id: I98654da143218d3e57da4e57781252eb3d3f3d5b
2018-10-08 13:33:50 +02:00
Pau Espin dc27ca85aa Drop osmo_init_logging and use osmo_init_logging2
Change-Id: Ib1c38f6134b3c1988477caa0f2c281b1ef01d5e0
2018-10-08 13:29:52 +02:00
Pau Espin 5f3c30c40c server: Properly name main talloc ctx
Change-Id: I810417d84c6a6ebcbc4b75a9bc41607bb0637228
2018-10-08 13:29:52 +02:00
Pau Espin 2828690633 client: Properly name main talloc ctx
Change-Id: Ibaa7f0e0add5f5e61cc0bb82341ee3b6b5c0cf07
2018-10-08 13:29:52 +02:00
Pau Espin 6e9bf9aa15 vty: skip installing cmds now always installed by default
Fixes following compilation warning:
osmo-pcap/src/osmo_client_vty.c:511:2: warning: ‘install_default’ is deprecated: Now happens implicitly with install_node() [-Wdeprecated-declarations]

Depends: libosmocore I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I943f68dbafd7906313ad9e59f4adb289ae23cdec
2018-10-08 13:29:52 +02:00
Pau Espin 3dfdbc21dc cosmetic: client: rename forward_packet function
Function only checks if packet should be forwarded, it doesn't forward
any packet.

Change-Id: I87cd64290245db134b17bc0d6665c58f1cde17b6
2018-10-08 13:08:52 +02:00
Harald Welte f335e37ed5 Add support for generating IPIP to osmo-pcap-client
This allows the user to change the configuration between either using

a) the classic OsmoPCAP protocol (over TCP with or without TLS)
   which is used when you want to talk to an osmo-pcap-server

b) the (new) IPIP encapsulation, which will simply take the IP
   packet (without Ethernet or pcap header) and transmit it inside IPIP
   to the specified server IP address.  This is useful for gettin
   real-time streaming into wireshark.

Change-Id: I8056fc163ac2f15adcb964d867dd5e51df4e4710
2018-02-09 12:07:50 +01:00
Harald Welte 5f071cd2c6 client: Move to osmo_sock_init2_ofd()
We can simplify the code even further by using the osmo_fd version
of osmo_sock_init2() called osmo_sock_init2_ofd(), which takes care
of filling the osmo_fd.fd member and registering the socket in the
select loop.

Change-Id: Ibf1480e7dee287db77a19bb9f0254edddf7706ab
2017-07-21 18:25:15 +02:00
Harald Welte f266924bac Use libosmocore osmo_sock_init2() instead of local implementation
A related function for "create a socket, bind it locally and connect
remotely" has meanwhile been introduced in libosmocore, so the local
implementation can go.

Change-Id: Ieda77ad8b3f7b89faa09882c0037562ce4d0fc89
2017-07-21 18:20:36 +02:00
Harald Welte 2fe9cb937d Rename osmo_pcap_{client_server} executables to osmo-pcap-{client,server}
This naming is more in line with what all the other osmocom programs are
doing (e.g. osmo-pcu, osmo-bts-sysmo, osmo-bsc, ...).  We don't
generally use osmo_ anywhere else, so I suggest to change it for more
uniformity.

Change-Id: If1e3ce76f93266e0f01c801204769432b571fdb1
2017-07-21 15:21:01 +02:00
Harald Welte 2aea8704f3 Use TCP port numbers for VTY that don't overlap with other Osmocom Software
osmo-pcap for historical reasons uses the same port numbers as
OsmoPCU and OsmoBTS.  This leads to problems when wanting to run related
software together on one system.  Let's break the historical assumptions
and start with non-overlapping port numbers that are allocated/assigned
from https://osmocom.org/projects/cellular-infrastructure/wiki/Port_Numbers

Change-Id: I638ac0534517931d0987ce9f72f5db4f5b6c16b7
2017-07-21 15:18:02 +02:00
Harald Welte 604e071159 sock_src_init(): Don't freeaddrinfo() undefined src_result
src_result is only valid "if (src)", so we cannot unconditionally
free it:

(gdb) bt
    host=0x52 <error: Cannot access memory at address 0x52>, src=0x0)
    at /usr/src/debug/osmo-pcap/0.0.6+gitrAUTOINC+4776b2972e-r1d/git/src/osmo_client_network.c:165

Change-Id: I3b6778d9110583ecb1daec59ef2c86465d5818b9
2017-07-21 13:11:24 +02:00
Holger Hans Peter Freyther 40c1e85499 client: Allow to bind to a specific source_ip
Modify the osmo_sock_init (code clone to be integrated upstream)
to allow binding to a specific source ip and source port. Allow
the source ip to be configured but allow the kernel to pick a
random port for us.

This is necessary for systems with multiple interfaces where the
default route is not necessarily the right one to connect to the
pcap server.

Change-Id: I84e728b0752213d28f970fcbbfd6565c441ccfeb
2017-01-17 09:06:42 +01:00
Holger Hans Peter Freyther 36a183fd78 client: Tolerate an invalid pcap_handle
When not running as root the opening might fail and then we would
crash when sending the link information. Do not crash. This could
have crashed before the re-factoring but due the async connect it
seems more likely we hit it now.

Change-Id: I26a10c401a9a8998acc50a4bd4432d2ac7fceaeb
2016-11-09 01:46:35 +01:00
Holger Hans Peter Freyther 9294c40f14 client: disconnect before connecting the connection
With the VTY a user can write connect, connect, connect and this
would lead to leaking fds. Always close the connection.

Change-Id: Iab94dc2fd28496bf5fd8ceb5611f9e6505ccae1b
2016-11-09 01:04:04 +01:00
Holger Hans Peter Freyther 0a94e57b72 client: Allow to stop and remove a connection
Change-Id: I2118723345caf6a68f03de74a4182506e7bf105c
2016-11-09 01:04:04 +01:00
Holger Hans Peter Freyther d7ab53dc16 client: Do not connect default connection if no ip/port present
Ignore the default connection if no srv_port and has been specified.

Change-Id: I6a3a9a0af73a9183a6b233937af3357d15a07f25
2016-11-09 01:04:04 +01:00