summaryrefslogtreecommitdiff
path: root/vtysh/vtysh_main.c
AgeCommit message (Collapse)Author
2025-04-08vtysh: clean up variable-shadow warningsMark Stapp
Clean up various variable-shadowing warnings from -Wshadow Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-10-15vtysh: fix SA warning, no need to call getenv() twiceJafar Al-Gharaibeh
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2024-07-31vtysh: de-conditionalize and reorder install_nodeDavid Lamparter
There is entirely no point to these being conditional. And pull them up so the upcoming pre-parse code can work on a clean slate. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-03-09vtysh: Include fnctl.h for vtysh_mainDonatas Abraitis
Fixing compilation for Alpine Linux: ``` 25 91.59 vtysh/vtysh_main.c: In function 'vtysh_flock_config': 25 91.59 vtysh/vtysh_main.c:276:20: warning: implicit declaration of function 'open'; did you mean 'popen'? [-Wimplicit-function-declaration] 25 91.59 276 | flock_fd = open(flock_file, O_RDONLY, 0644); 25 91.59 | ^~~~ 25 91.59 | popen 25 91.60 vtysh/vtysh_main.c:276:37: error: 'O_RDONLY' undeclared (first use in this function) 25 91.60 276 | flock_fd = open(flock_file, O_RDONLY, 0644); 25 91.60 | ^~~~~~~~ 25 91.60 vtysh/vtysh_main.c:276:37: note: each undeclared identifier is reported only once for each function it appears in 25 91.60 CC zebra/if_netlink.o 25 91.61 vtysh/vtysh_main.c: In function 'main': 25 91.61 vtysh/vtysh_main.c:637:49: error: 'O_CREAT' undeclared (first use in this function) 25 91.61 637 | fp = open(history_file, O_CREAT | O_EXCL, 25 91.61 | ^~~~~~~ 25 91.62 vtysh/vtysh_main.c:637:59: error: 'O_EXCL' undeclared (first use in this function) 25 91.62 637 | fp = open(history_file, O_CREAT | O_EXCL, 25 91.62 | ^~~~~~ ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-27*: rename `frr_vtydir` to `frr_runstatedir`David Lamparter
Also remove frr_init_vtydir(), just initialize to default. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-09lib: zebra.h is not using signal.hDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09*: remove sys/stat.h from zebra.hDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-10-11lib: Suppress HOB/STARVATION warnings when running in vtyshDonatas Abraitis
Running ping/traceroute/etc. (any kind of commands that use execute_command() suffer with this kind of warnings. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-25vtysh: Fix typo in warning message for `-b -f ...`Donatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-28vtysh: use fork() workflow for -f tooQuentin Young
It was being used for -b only; we should be able to use it for -f as well. This also merges the codepaths for -b and -f since they have no real functional difference. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2023-03-28vtysh: use daemon type and handle multi-instance typesMark Stapp
To handle multi-instance daemons (ospf, e.g.), each forked vtysh handles all of the instances of a daemon type. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2023-03-28vtysh, doc: add doc & help text for -t/--timestampQuentin Young
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2023-03-28vtysh: fork() on bootQuentin Young
When using -b flag to apply config to all running daemons, fork a copy of vtysh for each daemon we need to configure instead of doing them one at a time. This is about N times faster when you have N daemons. Signed-off-by: Quentin Young <qlyoung@nvidia.com> mergeme
2023-03-24*: Convert `struct event_master` to `struct event_loop`Donald Sharp
Let's find a better name for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_master_XXX functions to event_master_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert struct thread_master to struct event_master and it's ilkDonald Sharp
Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_fetch and thread_call to event_fetch and event_callDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_add_XXX functions to event_add_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
Effectively a massive search and replace of `struct thread` to `struct event`. Using the term `thread` gives people the thought that this event system is a pthread when it is not Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-12-21vtysh: Remove double retrieve of env VTYSH_HISTFILEDonald Sharp
The code is double checking the VTYSH_HISTFILE env variable, additionally clang-15 when running SA over it doesn't fully understand the code pattern. Reduce the double check to one check to reduce program run-time (ha!) and make SA happy. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05vtysh: free memory given to us by readlineDonald Sharp
The rl_callback_handler_install function manual says this: Set up the terminal for Readline I/O and display the initial expanded value of prompt. Save the value of lhandler to use as a handler function to call when a complete line of input has been entered. The handler function receives the text of the line as an argument. As with readline(), the handler function should free the line when it is finished with it. Adding a free removes this memory leak that I am seeing with address sanitizer enabled; SUMMARY: AddressSanitizer: 99 byte(s) leaked in 5 allocation(s).: 2022-12-05 07:50:57,231 INFO: topolog.r7: vtysh result: Hello, this is FRRouting (version 8.5-dev). Copyright 1996-2005 Kunihiro Ishiguro, et al. r7# clear log cmdline-targets r7# conf t r7(config)# log file staticd.log debug r7(config)# log commands r7(config)# log timestamp precision 3 r7(config)# ================================================================= ==976989==ERROR: LeakSanitizer: detected memory leaks Direct leak of 99 byte(s) in 5 object(s) allocated from: #0 0x49cadd in malloc (/usr/bin/vtysh+0x49cadd) #1 0x7fc57135d8e8 in xmalloc build/shlib/./xmalloc.c:59:10 SUMMARY: AddressSanitizer: 99 byte(s) leaked in 5 allocation(s). Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10vtysh: Handle SIGTSTP (C-z) without exiting the vty shellDonatas Abraitis
After 4c92dd90d3d15cff640de063ff14eec950402d25 switching to poll-based I/O, vtysh prompt exits on C-z signal. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-02-28vtysh: use poll/callback-driven readline interfaceDavid Lamparter
Create a thread_master and funnel readline terminal I/O through it. This allows processing other input in parallel, e.g. log messages. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-02-14vtysh: Fix spelling mistakesDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02build: ignore prototype warnings from readlineDavid Lamparter
Readline contains some truly ancient cruft. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-06-30vtysh: add CLI timestamp '-t' flagChristian Hopps
Example output: flk# show version % 2021/06/29 00:25:01.562 FRRouting 8.1-dev-my-manual-build (flk). Copyright 1996-2005 Kunihiro Ishiguro, et al. ... Signed-off-by: Christian Hopps <chopps@labn.net>
2021-04-12vtysh: Set history file on demandDonatas Abraitis
It's sometimes needed to disable logging all FRR commands at all. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-12-15vtysh: When dry-running no need to start/end configurationDonald Sharp
When doing a dry run don't send start/end configuration commands. Ticket: CM-32665 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-03vtysh: Have help dump the how FRR was builtDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-12-03vtysh: Display version w/ vtysh --helpDonald Sharp
Add a bit of useful data to know what version of FRR we are playing with in this vtysh instance. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-07-14*: un-split strings across linesDavid Lamparter
Remove mid-string line breaks, cf. workflow doc: .. [#tool_style_conflicts] For example, lines over 80 characters are allowed for text strings to make it possible to search the code for them: please see `Linux kernel style (breaking long lines and strings) <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_ and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-08*: Replace `sizeof something` to sizeof(something)Donatas Abraitis
Satisfy checkpatch.pl requirements (check for sizeof without parenthesis) Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05*: use gmtime_r, localtime_r exclusivelyMark Stapp
Stop using gmtime() or localtime() everywhere. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-09*: Remove parenthesis on return for constantsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-12-06lib: rename memory_vty.c to lib_vty.cDavid Lamparter
And memory_init() to lib_cmd_init(). Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-07vtysh: be helpful and kind to unprivileged usersQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-07-29vtysh: only show error codes onceQuentin Young
When using `show error` commands, show errors shared between multiple daemons only once. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-04*: Convert over to all -N namespace to change DAEMON_VTY_DIRDonald Sharp
When the user specifies -N namespace allow it to influence the frr_vtydir(DAEMON_VTY_DIR) to have namespace in it's path like so: $frrstate_dir/<namespace> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-12-06vtysh: rework/straighten pager handlingDavid Lamparter
- no longer try to special-case a custom terminal length; the OS has procedures for that (SIGWINCH & TIOCGWINSZ) - only use a pager if requested by CLI command or VTYSH_PAGER. The behaviour with VTYSH_PAGER set should be compatible to previous versions. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-12lib vtysh zebra: variable shadowing fixesF. Aragon
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-08vtysh: Add code to isolate append_historyDonald Sharp
The append_history function in lib readline appears to not be universally available across all of the esoteric platforms we may want to compile on. As such provide a way to gracefully do nothing. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-13vtysh: Fix missing tailing / in --config_dir option parsingMartin Winter
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2018-06-12vtysh: in user mode, don't show 'enable not allowed', also block writeconfigLou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2018-06-07bgpd, lib, ospf6d, vtysh: fix possible snprintf possible truncationDonald Sharp
With a new version of clang 6.0, the compiler is detecting more issues where we may be possibly be truncating the output string. Fix by increasing the size of the output string to make the compiler happy. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-05-22vtysh: rewrap commentsQuentin Young
fixup comments for vtysh Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-12vtysh: Extending vtysh to allow question-mark cmdsRodny Molina
Currently, "vtysh -c" interface does not provide a logic to parse commands ending with '?' character. In consequence, the following behavior is observed: $ vtysh -c "show bgp ?" % Unknown command. With these changes, i'm extending FRR's parser to be able to handle these commands, which allow a more friendly interaction with users that rely on "vtysh -c" interface. The typical use-case here is for scenarios in which the final users relie on external/their-own CLI and require a friendly interface to FRR's vtysh cli. $ vtysh -c "show bgp ?" <cr> A.B.C.D Network in the BGP routing table to display A.B.C.D/M IPv4 prefix X:X::X:X Network in the BGP routing table to display X:X::X:X/M IPv6 prefix attribute-info List all bgp attribute information cidr-only Display only routes with non-natural netmasks community Display routes matching the communities community-info List all bgp community information ... Signed-off-by: Rodny Molina <rmolina@linkedin.com>
2018-04-11vtysh: fix pathspec option -NChristian Franke
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2018-03-28vtysh: move user_mode to header file, keep checkpatch happyLou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-28vtysh: add -u/--user flag to run commands without enableLou Berger
Signed-off-by: Lou Berger <lberger@labn.net>