Commit Graph

266 Commits

Author SHA1 Message Date
Neels Hofmeyr cf70aa0c40 enable vty xml dumping to stdout
Allow dumping the VTY XML reference (for generating manuals) to a normal FILE*
stream instead of a vty output buffer.

We currently generate the VTY reference by starting the client program,
connecting to the VTY telnet and dumping the reference. That is weirdly
convoluted, especially since there has to be a valid config file that
successfully starts up a minimal set of external links before the reference can
be generated. IMO we should have dumped the XML reference to stdout from the
start, and never to a VTY session.

With this patch, it is trivial to generate the XML VTY reference by a
commandline switch. The client program will set up the entire VTY, and
immediately after parsing the cmdline options but before parsing a config file,
just dumps the reference and doesn't even start establishing local ports. That
would allow generating the XML reference on the fly during the build process of
the manuals, without the need of a docker container or somesuch.

A first implementation of such a commandline switch is `osmo-bsc -X`, added in
I316efedb2c1652791434ecf14a1e261367cd2fb7

This patch jumps through a bit of a hoop to still allow dumping to a VTY buffer
without code dup, to still allow dumping the XML reference through telnet VTY,
until all our programs have implemented an -X switch (TM).

Change-Id: Ic74bbdb6dc5ea05f03c791cc70184861e39cd492
2020-05-18 13:55:08 +02:00
Alexander Chemeris dfebf405e5 stats: Support regular stats flush
Reliable monitoring requires regular flush of all stat values, even
if they have not changed. Otherwise (1) the monitoring app has to
maintain state and (2) can go out of sync if it's restarted while
the app is still running.

Change-Id: I04f1e7bdf0d6f20e4f15571e94191de61c47ddad
2020-05-09 08:08:53 +00:00
Alexander Chemeris 161adeec84 stats: Move cfg_stats_interval_cmd() function.
cfg_stats_interval_cmd() function was (probably mistakenly)
inserted between cfg_stats_reporter_statsd_cmd() and
cfg_no_stats_reporter_statsd_cmd() function which makes no sense.
Move it below the cfg_no_stats_reporter_log_cmd() to follow the order
of the osmo_stats_vty_add_cmds() function calls.

Change-Id: I1ecec7025e95cf5ffc21ae3b1c75cf6da8c58de2
2020-05-09 08:08:53 +00:00
Vadim Yanitskiy df4f6085cd tdef_vty: do not enforce enum 'node_type' in osmo_tdef_vty_groups_init()
Some osmo-* applications may need to use their own VTY node as a
parent for the timer configuration commands. Therefore it makes
more sense to use 'unsigned int' instead of 'enum node_type'.

Let's also clarify that osmo_tdef_vty_groups_init() accepts parent
node for configuration commands only: 'parent_node' -> 'parent_cfg_node'.

Change-Id: Ifb4c406c85d76a25fc53fc235484599aa87dc77c
2020-02-06 01:06:14 +07:00
Pau Espin 57d1118c25 logging_vty.c: Avoid acquiring log tgt lock in logging level cmd when not needed
Change-Id: Ia6780221174070cee408625e24513f2c11cc9dfc
2020-01-03 22:16:08 +00:00
Pau Espin 2862f9082e Bump version: 1.2.0.108-c6a8-dirty → 1.3.0
Change-Id: I5698bfe45467a8b0e44549105aaf27b8da500de8
2020-01-02 18:42:30 +01:00
Vadim Yanitskiy 7a35b78648 libosmovty: simplify condition checking vty->fd in vty_close()
On POSIX systems, standard I/O streams - stdin, stdout, and stderr,
always have default file descriptors 0, 1, and 2 respectively.

Change-Id: Ied35d142af0ba0f5ad78975b8f22c35b32d6ff71
2019-11-30 18:49:33 +00:00
Vadim Yanitskiy 54df08e3fa libosmovty: properly initialize vty->fd in vty_new()
Since we're using talloc_zero(), vty->fd is initialized with 0,
which corresponds to stdin. Let's set an invalid value to prevent
potential bugs like the one fixed by the recent change [1].

[1] Icdeaea67a06da3a2f07b252e455629559ecc1829

Change-Id: Iec15649781317a23e13d2c2840a8f672050f76c1
2019-11-30 18:49:33 +00:00
Neels Hofmeyr d31de23758 vty: track parent nodes also for telnet sessions
Keep track of parent nodes and go back hierarchically, not only for .cfg file
reading, but also for telnet VTY sessions.

A long time ago cfg file parsing was made strictly hierarchical: node exits go
back to parent nodes exactly as they were entered. However, live telnet VTY
sessions still lacked this and depended on the go_parent_cb().

From this commit on, implementing a go_parent_cb() is completely optional. The
go_parent_cb() no longer has the task to determine the correct parent node,
neither for cfg files (as already the case before this patch) nor for telnet
VTY sessions (added by this patch). Instead, a go_parent_cb() implementation
can merely take actions it requires on node exits, for example applying some
config when leaving a specific node.

The node value that is returned by the go_parent_cb() and the vty->node and
vty->index values that might be set are completely ignored; instead the
implicit parent node tracking determines the parent and node object.

As a side effect, the is_config_node() callback is no longer needed, since the
VTY now always implicitly knows when to exit back to the CONFIG_NODE.

For example, osmo_ss7_is_config_node() could now be dropped, and the
osmo_ss7_vty_go_parent() could be shortened by five switch cases, does no
longer need to set vty->node nor vty->index and could thus be shortened to:

int osmo_ss7_vty_go_parent(struct vty *vty)
{
        struct osmo_ss7_asp *asp;
        struct osmo_xua_server *oxs;

        switch (vty->node) {
        case L_CS7_ASP_NODE:
                asp = vty->index;
                /* If no local addr was set */
                if (!asp->cfg.local.host_cnt) {
                        asp->cfg.local.host[0] = NULL;
                        asp->cfg.local.host_cnt = 1;
                }
                osmo_ss7_asp_restart(asp);
                break;
        case L_CS7_XUA_NODE:
                oxs = vty->index;
                /* If no local addr was set, or erased after _create(): */
                if (!oxs->cfg.local.host_cnt)
                        osmo_ss7_xua_server_set_local_host(oxs, NULL);
                if (osmo_ss7_xua_server_bind(oxs) < 0)
                        vty_out(vty, "%% Unable to bind xUA server to IP(s)%s", VTY_NEWLINE);
                break;
        }
        return 0;
}

Before parent tracking, every program was required to write a go_parent_cb()
which has to return every node's parent node, basically a switch() statement
that manually traces the way back out of child nodes. If the go_parent_cb() has
errors, we may wildly jump around the node tree: a common error is to jump
right out to the top config node with one exit, even though we were N levels
deep. This kind of error has been eliminated for cfg files long ago, but still
exists for telnet VTY sessions, which this patch fixes.

This came up when I was adding multi-level config nodes to osmo-hlr to support
Distributed GSM / remote MS lookup: the config file worked fine, while vty node
tests failed to exit to the correct nodes.

Change-Id: I2b32b4fe20732728db6e9cdac7e484d96ab86dc5
2019-11-24 19:59:35 +01:00
Vadim Yanitskiy 02f25ea77b logging/vty: fix: do not close stderr in vty_close()
Since Icdeaea67a06da3a2f07b252e455629559ecc1829, we use stderr for
printing warnings while parsing the VTY configuration files. Make
sure we do not close() stderr. Otherwise stderr logging gets broken.

Change-Id: I6ecc85555d102f5911d50ed5ac54933c766fa84d
Fixes: Icdeaea67a06da3a2f07b252e455629559ecc1829
2019-11-21 16:22:21 +07:00
Vadim Yanitskiy b639b4d4f7 logging/vty: fix vty_read_file(): do not write warnings to stdin
Setting vty->fd to 0 is a bad idea, which may cause the process
to write() warnings to its own _stdin_ (yes, it's possible).
For example, when a configuration file contains deprecated
logging commands. Let's use stderr by default.

Change-Id: Icdeaea67a06da3a2f07b252e455629559ecc1829
2019-11-21 10:48:30 +07:00
Vadim Yanitskiy 4abda9ea26 logging/vty: fix: actually ignore deprecated logging commands
We shall not prevent programs from starting if their configuration
files contain deprecated 'logging level ...' commands. Just print
a warning and return CMD_SUCCESS instead of CMD_WARNING.

While writing a unit test, another funny bug has been uncovered.
Parsing of a deprecated command indeed triggers a deprecation
warning, originated from libosmovty's log_deprecated_func().
This function simply calls vty_out(), but...

Since the invocation of the vty_out() happens _before_ the VTY
is initialized, the process is actually writing that warning
to its own stdin! Most likely, because we use talloc_zero()
to allocate a new instance of struct 'vty'.

As a side effect, the evil warning magically appears in the output
of 'make check', breaking the test statistics. Let's work around
this bug for now by redirecting stdin to /dev/null.

Change-Id: Ia934581410cd41594791d4e14ee74c16abe1009a
Fixes: Ic9c1b566ec4a459f03e6319cf369691903cf9d00
2019-11-21 10:48:02 +07:00
Vadim Yanitskiy 75c242e6a2 logging/vty: use LOG_LEVEL_ARGS in logging_vty_add_deprecated_subsys()
Change-Id: I862c3cce0147ee8cf4013501132584ea09c58b53
2019-11-21 00:07:08 +07:00
Vadim Yanitskiy 1581c49bdd logging/vty: do not print deprecated logging commands to stdout
Yes, we don't really need to poison stdout, as some osmo-* binaries
(like osmo-gapk) may want to use it for non-logging purposes.
This printf() call looks like a debugging leftover.

Change-Id: Ida35865b1c0bb3d3567918f8e89c6551c6b34103
2019-11-20 23:54:58 +07:00
Pau Espin a0c8195ad3 vty: Return error if cmd returns CMD_WARNING while reading cfg file
Otherwise bad configurations can easily sneak in and produce unexpected
behavior.

Change-Id: Ic9c1b566ec4a459f03e6319cf369691903cf9d00
2019-10-28 19:15:29 +00:00
Pau Espin 0fd0fe61fa vty: Fix go_parent_cb not called for indented nodes at end of cfg file
Without this patch, for instance in this cfg file below, go_parent_cb is
not called for nodes such as "listen" and "cs7":
"""
line vty
 no login
cs7 instance 0
 xua rkm routing-key-allocation dynamic-permitted
 listen m3ua 2905
  accept-asp-connections dynamic-permitted
  local-ip 127.0.0.1
"""

Related: OS#3608
Change-Id: Ia6d88c0e63d94ba99e950da6efbc4c1871070012
2019-10-11 14:13:02 +02:00
Pau Espin d12f698dbb logging: Introduce mutex API to manage log_target in multi-thread envs
log_enable_multithread() enables use of locks inside the
implementation. Lock use is disabled by default, this way only
multi-thread processes need to enable it and suffer related
complexity/performance penalties.

Locks are required around osmo_log_target_list and items inside it,
since targets can be used, modified and deleted by different threads
concurrently (for instance, user writing "logging disable" in VTY while
another thread is willing to write into that target).

Multithread apps and libraries aiming at being used in multithread apps
should update their code to use the locks introduced here when
containing code iterating over osmo_log_target_list explictly or
implicitly by obtaining a log_target (eg. osmo_log_vty2tgt()).

Related: OS#4088
Change-Id: Id7711893b34263baacac6caf4d489467053131bb
2019-10-09 14:19:52 +02:00
Pau Espin eda8b7b23d vty: Optionally Set/replace cfg file during cmd 'write file'
This way if the process is started with no file associated (eg. no -c
param and default cfg path doesn't exist), config can be later saved
into a file by passing the parameter. Otherwise, until now this message
was displayed:
Can't save to configuration file, using vtysh.

Related: OS#4024
Change-Id: I38edcf902a08b6bd0ebb9aa6fc1a7041421af525
2019-10-07 20:01:45 +00:00
Pau Espin 0cbe8f0100 tdef: Introduce min_val and max_val fields
This is useful for timers expected to have a range of valid or expected
values.

Validation is done at runtime when timer values are set by the app or by
the user through the VTY.

Related: OS#4190
Change-Id: I4661ac41c29a009a1d5fc57d87aaee6041c7d1b2
2019-10-07 13:14:14 +00:00
Ruben Undheim 766f77c3d9 MAXPATHLEN set if not defined
Change-Id: I1dce8ace228814b5a7246a00b31309ab9461d266
2019-09-02 09:12:27 +00:00
Neels Hofmeyr f8fe48e7fb fix: vty crash by logging during VTY_CLOSED event handling
When a VTY closes, dispatch the VTY_CLOSED signal before tearing down the VTY
buffer and fd.

In particular this fixes:

- a crash during telnet_close_client(), invoked by the VTY_CLOSED event, which
  logs to DLGLOBAL and uses vty->obuf that, so far, vty_close() had already
  unallocated earlier (OS#4164).

- the logging about closing a telnet session so far logged:
    DLGLOBAL INFO Closing telnet connection r=NULL<->l=NULL
  By dispatching the VTY_CLOSED event while the fd is still valid, we instead
  get the actual connection IP address and port being closed:
    DLGLOBAL INFO Closing telnet connection r=127.0.0.1:36708<->l=127.0.0.1:4258

Related: OS#4164
Change-Id: I1d235cbfbfb9aaf411316642c7bcfac12106df44
2019-08-30 00:38:01 +02:00
Pau Espin 0c2a46d8a6 vty: Register logp cmd next to logging commands
This way it's easier by osmo_verify_transcript_vty.py to skip and avoid
breaking existent test in osmo-hlr.

Fixes: d0b3b9edac
Change-Id: Iab9423661e4f4eefca2e3d02b60a43f913ed92a3
2019-08-20 10:39:07 +02:00
Neels Hofmeyr d0b3b9edac add vty logp command to echo on all log targets
When reading SUT logs resulting from TTCN3 runs, it can be hard to figure out
which log section corresponds to which test code. Add a 'logp' command on VIEW
and ENABLE nodes that simply echos an arbitrary message on log output, useful
to set markers / explanations from the TTCN3 code, which then appear in all log
outputs and can make it trivial to figure out which log section is interesting.

	logging_vty_test# logp lglobal notice This is the log message
	DLGLOBAL NOTICE This is the log message

From TTCN3, could be used like this, e.g. in BSC_Tests.ttcn:

	private function f_logp(charstring log_msg) runs on MSC_ConnHdlr
	{
		// log on TTCN3 log output
	        log(log_msg);
		// log in stderr log
	        f_vty_transceive(BSCVTY, "logp lglobal notice " & log_msg);
	}

	...

	f_logp("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");

Change-Id: Ife5dc8999174c74e0d133729284fe526d6eaf8d9
2019-08-13 15:35:02 +02:00
Pau Espin 922d276035 Bump version: 1.1.0.107-afce-dirty → 1.2.0
Change-Id: I05dd1f2725e05f856f1d27c9201a0005de101b8f
2019-08-06 18:02:02 +02:00
Pau Espin c21ba15b70 Get rid of osmo_str_tolower() use inside libosmocore code
There's no real good reason for using that function (static buffer)
instead of osmo_str_tolower_buf(local buffer), so let's use the later.
In any case, we get rid of TLS variables in those places, which is a
performance improvement.
It will also allow later shrinking of those buffers if we decide to
define maximum logging category and level name length.

Change-Id: I2e99de1142020e4d80ef0a094e4e751f7903f5f9
2019-08-02 20:35:15 +02:00
Vadim Yanitskiy 8c00f9d753 vty/vty.c: the command buffer can be accessed directly
Change-Id: Ic6d7d68e9a559a6fb5bd6eaf6eccceae51e7ed39
2019-07-30 17:17:15 +00:00
Vadim Yanitskiy 757dea8d4a vty/vty.c: fix vty_read(): prevent further heap-buffer overrun
After reading data from the socket, assigned to a given VTY, we
need to '\0'-terminate the received string. Otherwise, further
access to that string, stored in a heap buffer vty->buf, would
lead to a heap overrun.

== How to reproduce?

  $ python -c "print 'A' * 512" | telnet $HOST $PORT

  ==21264==ERROR: AddressSanitizer: heap-buffer-overflow on address
                                    0x6190000211e0 at pc 0x000000435d2f
				    bp 0x7ffc06c7add0 sp 0x7ffc06c7a578
  READ of size 1025 at 0x6190000211e0 thread T0
    #0 0x435d2e in __interceptor_strlen (/usr/local/bin/osmo-msc+0x435d2e)
    #1 0x7fb95bfa5624 in talloc_strdup (/usr/lib/x86_64-linux-gnu/libtalloc.so.2+0x6624)
    #2 0x7fb95c1be2bc in vty_hist_add /opt/osmocom/libosmocore/src/vty/vty.c:578
    #3 0x7fb95c1be2bc in vty_execute /opt/osmocom/libosmocore/src/vty/vty.c:703
    #4 0x7fb95c1be2bc in vty_read /opt/osmocom/libosmocore/src/vty/vty.c:1425
    #5 0x7fb95c1bfd78 in client_data /opt/osmocom/libosmocore/src/vty/telnet_interface.c:157
    #6 0x7fb95b90bd33 in osmo_fd_disp_fds /opt/osmocom/libosmocore/src/select.c:223
    #7 0x7fb95b90bd33 in osmo_select_main /opt/osmocom/libosmocore/src/select.c:263
    #8 0x5006cc in main /opt/osmocom/osmo-msc/src/osmo-msc/msc_main.c:723:3
    #9 0x7fb959935f44 in __libc_start_main /build/eglibc-xkFqqE/eglibc-2.19/csu/libc-start.c:287
    #10 0x4226fb in _start (/usr/local/bin/osmo-msc+0x4226fb)

== Why exactly 512?

Because the initial size of the heap buffer is 512 (see VTY_BUFSIZ).
Later on it can be realloc()ated, so X > 512 should also work.

Found using AddressSanitizer and Radamsa [1] fuzzer.

[1] https://gitlab.com/akihe/radamsa

Change-Id: I82f774ad18d0e555eb8f3590a519946d9c583c78
2019-07-30 17:17:15 +00:00
Vadim Yanitskiy 74b6ff074b vty/telnet_interface.c: log connection accept() / close() events
Unfortunately, osmo_sock_get_name_buf() fails in telnet_close_client():

  DLGLOBAL INFO telnet_interface.c:130 Closing telnet connection <error-in-getsockname>

because getsockname(), getpeername(), and even close() fail with:

  "Bad file descriptor".

This looks like a bug of the existing code.

Change-Id: I77b31abfa159d2f269deaa5a08d94b7bbba7d23c
2019-07-30 17:17:15 +00:00
Vadim Yanitskiy 5c4b9850c2 vty/logging_vty.c: fix writing of 'print category-hex'
Change-Id: I33837f0fac1afe83596fa600916abc05ecb8c356
2019-07-30 12:42:47 +00:00
Vadim Yanitskiy a9a8ea5347 vty/telnet_interface.c: avoid unneeded initialization
Unconditional initialization follows the structure definition,
so there is no need to do it twice. This prevents compiler
from warning about potential errors.

Change-Id: If9fd2826f132dfa203dda62940d93dbdfcfd92ac
2019-07-27 21:58:55 +07:00
Vadim Yanitskiy 0ba357343b vty/telnet_interface.c: use DLGLOBAL logging sub-system
Change-Id: I1564f4714a33d36792e4982deb8f19d1b740dc0c
2019-07-27 21:47:59 +07:00
Daniel Willmann 6f3bbd4b9f stats_vty: Add verb to sentence for show asciidoc counters
Change-Id: Ib444383d2074ddb89b3fe5bbf198bcbfabd7057f
2019-07-25 11:39:11 +02:00
Pau Espin e1e1ec31a3 vty: Simplify char escaping in asciidoc output
Change-Id: I7df6858bb98abffc1d5bf420f991ae5854b24638
2019-06-25 21:46:44 +00:00
Pau Espin 18e019e896 vty: Remove trailing whitespace in output from show asciidoc
Change-Id: Ifb3115c7488fbcf082cc9b92abc25cf7c46064e0
2019-06-19 14:26:23 +02:00
Pau Espin 32e6710487 vty: command.c: Fix: single-choice optional args are no longer passed incomplete to vty func
For instance, take command "single0 [one]":
If user executes "single0 on", VTY func will receive argv[0]="one"
instead of argv[0]="on".

Related: OS#4045
Change-Id: I5f4e2d16c62a2d22717989c6acc77450957168cb
2019-06-14 17:44:21 +02:00
Pau Espin 7e1b03f763 vty: command.c: Fix: multi-choice args are no longer passed incomplete to vty func
For instance, take command "multi0 (one|two|three)":
If user executes "multi0 tw", VTY func will receive argv[0]="two"
instead of argv[0]="tw".

Fixes: OS#4045
Change-Id: I91b6621ac3d87fda5412a9b415e7bfb4736c8a9a
2019-06-14 17:44:16 +02:00
Pau Espin 8930ace072 vty: command.c: Get rid of big indentation block
This block will become bigger in forthcoming commits.

Change-Id: Ibc1494014b1e77ce10950f7268a44d2d2091a6f2
2019-06-14 12:42:22 +02:00
Pau Espin c17c6d6ea5 command.c: Improve return check condition in cmd_execut_command_real()
Check against MAX argc is changed to == since it cannot be incremented
twice without passing the check.

Change-Id: Ia330e475989fda863bedcc3cbf94deaf8dd83037
2019-06-14 12:38:44 +02:00
Pau Espin 274ac4dcc3 vty: command.c: Get rid of huge indentation block
Huge conditional block inside for loop is negated in this patch
together with a "continue" keyword, similar to what was already done
recently in 4742526645.

Change-Id: I803c4ed38e9ab09bf929528c75a60e6f65da3928
2019-06-12 14:25:11 +00:00
Pau Espin de89099f68 cosmetic: vty: command.c: Use upper case for enum match_type value names
Makes code easier to follow because enum values no longer look like
variables.

Change-Id: Ib6e9592c5962d047869a280c10f9b557fae6f435
2019-06-12 14:25:11 +00:00
Pau Espin 6df2e44404 vty: command.c: Fix is_cmd_ambiguous() returning always 0
inner block defined variable "enum match_type ret" was being masking
outter block variable "int ret = 0". The ret variable was being given
non zero values only inside the inner block, so that change was done on
the inner variable and not the outer one, which is returned.

Fixes: 5314c513f2
Change-Id: Iec87d7db49a096d07e38ff8a060b923a52bfd6ba
2019-06-11 21:50:17 +02:00
Pau Espin 4742526645 vty: command.c: Get rid of huge indentation block
Huge conditional block inside foor loop is negated in this patch
together with a "continue" keyword.

Change-Id: I9715734ed276f002fdc8c3b9742531ad36b2ef9e
2019-06-11 21:04:11 +02:00
Vadim Yanitskiy f5781c9a88 vty/command.c: cosmetic: add missing curly brackets
Otherwise it's a bit hard to read the code.

Change-Id: I807ec71cfb67976251be844cdb2d2776b1837438
2019-06-01 02:27:16 +07:00
Harald Welte 581a34da60 tdef: Fix license: GPLv2+ instead of AGPLv3+
libosmo{core,gsm,vty} code is GPLv2+.  The tdef code originated in
osmo-msc.git and was moved here without changing the license. That
was a mistake, it always was meant to be under GPLv2-or-later after
moving to libosmocore.git.

Copyright is with sysmocom, so I as the managing director can
approve the license change.

Change-Id: Ie483ff6f6ea0a56c477649677b4b163c49df11d7
2019-05-27 23:26:45 +02:00
Pau Espin 1fcdd0d1b8 Bump version: 1.0.1.143-cc72c → 1.1.0
Change-Id: I351411ca5913c8b40f23287ec7c9ebfe11bd2bb0
2019-05-07 18:36:51 +02:00
Neels Hofmeyr 63053001d3 add vty_is_active()
For async callbacks it is useful to determine whether a given VTY pointer is still valid.

For example, in osmo-msc, a silent call can be triggered by VTY, which causes a
Paging. The paging_cb then writes to the VTY console that the silent call has
succeeded. Unless the telnet vty session has already ended, in which case
osmo-msc crashes; e.g. from an osmo_interact_vty.py command invocation. With
this function, osmo-msc can ask whether the vty pointer passed to the paging
callback is still active, and skip vty_out() if not.

Change-Id: I42cf2af47283dd42c101faae0fac293c3a68d599
2019-05-03 16:15:24 +02:00
Neels Hofmeyr d79ccc65f7 add osmo_str_startswith()
Move from a static implementation in tdef_vty.c to utils.c, I also want to use
this in osmo-msc.

The point is that the telnet VTY allows unambiguous partly matches of keyword
args. For example, if I have a command definition of:

    compare (apples|oranges)

then it is perfectly legal as for the vty parser to write only

    compare app

One could expect the VTY to then pass the unambiguous match of "apples" to the
parsing function, but that is not the case.

Hence a VTY function implementation is faced with parsing a keyword of "app"
instead of the expected "apples".

This is actually a very widespread bug in our VTY implementations, which assume
that exactly one full keyword will always be found. I am now writing new
commands in a way that are able to manage only the starts of keywords.

Arguably, strstr(a, b) == a does the same thing, but it searches the entire
string unnecessarily.

Change-Id: Ib2ffb0e9a870dd52e081c7e66d8818057d159513
2019-04-11 05:36:36 +00:00
Vadim Yanitskiy 3d81147dea vty/talloc_ctx_vty.c: use REG_NOSUB flag of regcomp()
We don't need to know position of matches: just yes or no.
This change would save some computation power.

Change-Id: Id55ffe64cc1a35dd83f61dbb0f9828aa676696f9
2019-04-11 00:24:55 +00:00
Vadim Yanitskiy bd6968a1ca vty/talloc_ctx_vty.c: allocate walk_cb_params on stack, not heap
There is no need to allocate struct 'walk_cb_params' dynamically.

Change-Id: I96f25f1ddb36b19b12055deaeeb6f58e59180e72
2019-04-11 00:24:55 +00:00
Harald Welte 1688699c3f select: Rename BSC_FD_* constants to OSMO_FD_*
The naming of these constants dates back to when the code was private
within OpenBSC.  Everything else was renamed (bsc_fd -> osmo_fd) at
the time, but somehow the BSC_FD_* defines have been missed at the
time.

Keep compatibility #defines around, but allow us to migrate the
applications to a less confusing naming meanwhile.

Change-Id: Ifae33ed61a7cf0ae54ad487399e7dd2489986436
2019-03-21 16:02:01 +00:00