summaryrefslogtreecommitdiff
path: root/lib/vty.c
AgeCommit message (Collapse)Author
2023-09-28vty: fix working in file-lock modeIgor Ryzhov
When the configuration node is entered in file-lock mode, candidate and running datastores are locked. Any configuration change is followed by an implicit commit which leads to a crash of mgmtd, because double lock is prohibited by an assert. When working in file-lock mode, we shouldn't do implicit commits which is disabled by allowing pending configuration changes. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-24lib: assert for VTY_PASSFD expectationsDavid Lamparter
Coverity is complaining that vty->state could be VTY_PASSFD here. It can't, it really shouldn't, and if it actually is then something went seriously wrong somewhere earlier so assert()ing out is the best thing to do. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-20lib: random make-coverity-happy nitsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-07-14lib: mgmtd: only clear pending for the in-progress commandChristian Hopps
The lock/unlocks are being done short-circuit so they are never pending; however, the handling of the unlock notification was always resuming the command if pending was set. In all cases pending is set for another command. For example implicit commit locks then when notified its done unlocks which was clearing the set-config pending flag and resuming that command incorrectly. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-27mgmtd: consolidate getcfg and getdata msgs into "get"Christian Hopps
eliminates tons of copy and paste code. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-19mgmtd: KISS the locking codeChristian Hopps
Move away from things like "lock if not locked" type code, require the user has locked prior to geting to that point. For now we warn if we are taking a lock we already had; however, this should really be a failure point. New requirements: SETCFG - not implicit commit - requires user has locked candidate DS and they must unlock after implicit commit - requires user has locked candidate and running DS both locks will be unlocked on reply to the SETCFG COMMITCFG - requires user has locked candidate and running DS and they must unlock after rollback - this code now get both locks and then does an unlock and early return thing on the adapter side. It needs to be un-special cased in follow up work that would also include tests for this functionality. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-18lib: mgmtd: use short-circuit for lockingChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-13Merge pull request #13766 from LabNConsulting/chopps/mgmtd-cleanupIgor Ryzhov
mgmtd cleanup/simplify some code
2023-06-13lib: mgmtd: improvements in logging and commentaryChristian Hopps
- log names of datastores not numbers - improve logging for mgmt_msg_read - Rather than use a bool, instead store the pending const string name of the command being run that has postponed the CLI. This adds some nice information to the logging when enabled. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12lib: mgmtd: simplify implicit commit codeChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-12lib: mgmtd: avoid recursion with vty_close and add error logChristian Hopps
Avoid recursion into vty_close() when being notified of a session closure that happened inside vty_close(). If a vty is closed with outstanding config yet to be commited issue a warning that it is being lost. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-06lib: close config files after reading (coverity)Christian Hopps
fixes coverity CID# 1564375 Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-05mgmtd: rm unused/unneeded code add couple commentsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-06-04lib: mgmtd: remove obfuscating abstraction layer and other cleanupChristian Hopps
Remove an obfuscating abstraction layer whose existence was entirely based on using a uintptr_t rather than a pointer to an declared-only struct. As the code is no longer using a global FE "client context", and instead create client objects, rename the structure and it's uses to reflect this. Change init "params" structure into a single use callbacks one. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30mgmtd: address review commentsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30mgmtd: fix clang uninit warningChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30lib: mgmtd: fix memleaksChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30lib: mgmtd: add manual vty server start option and use itChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30lib: mgmtd: fixes for startup config file processingChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-30mgmtd: fix reading of config file[s]Christian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28lib: enable short circuit for FE client/adapter connectionChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28lib: dont be tricky with session_id just make it a session_idChristian Hopps
- Previously was substituting a pointer to local allocated session for the session_id returned from the FE adapter. This complexity isn't needed. - Get rid of "%llu" format and the casts that came with it, instead use PRIu64 and the actual (uint64_t) type. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-28lib: msg: refactor common connection code from mgmtdChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-05-04lib: log commands read from config fileChristian Hopps
When the user specifies `--command-log-always` in CLI arguments then also log commands executed from loading the config file. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-24lib: fix style warns and get rid of "!" for successChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-11mgmtd, lib: Cleanup zlog_err()Pushpasis Sarkar
Cleanup all zlog_err() that were meant for debug only. Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-04-01mgmtd: lib: read transitioned daemons split config files in mgmtdChristian Hopps
When daemons transition to mgmtd they should stop reading their split config files, and let mgmtd do that, otherwise things can get out of sync. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
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_XXX macros to EVENT_XXX macrosDonald 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 a bunch of thread_XX to event_XXDonald Sharp
Convert these functions: thread_getrusage thread_cmd_init thread_consumed_time thread_timer_to_hhmmss thread_is_scheduled thread_ignore_late_timer 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-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
This is a first in a series of commits, whose goal is to rename the thread system in FRR to an event system. There is a continual problem where people are confusing `struct thread` with a true pthread. In reality, our entire thread.c is an event system. In this commit rename the thread.[ch] files to event.[ch]. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-22lib: staticd: vtysh: apply frrbot style requirementsChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-03-22lib, mgmtd: Add few fixes for commit-check and rollbackPushpasis Sarkar
This commit contains fixes for the following issues found - 'mgmt commit check' issued through 'vtysh -f' was actually commtting the changeset. - On config validation failure backend, mgmtd was not passing the correct error-reason to frontend. - 'mgmt rollback ...' was reverting the change on backend, but config on mgmtd daemon remains intact Signed-off-by: Pushpasis Sarkar <pushpasis@gmail.com>
2023-03-21mgmtd: Add MGMT Frontend Interface FrameworkChristian Hopps
This commit introduces the Frontend Interface which can be used by front-end management clients like Netconf server, Restconf Server and CLI to interact with new FRR Management daemon (MGMTd) to access and sometimes modify FRR management data. This commit includes the following functionalities in the changeset: 1. Add new Frontend server for clients connect to. 2. Add a C-based Frontend client library which can be used by Frontend clients to communicate with MGMTd via the Frontend interface. 3. Maintain a frontend adapter for each connection from an appropriate Frontend client to facilitate client requests and track one or more client sessions across it. 4. Define the protobuf message format for messages to be exchanged between MGMTd Frontend module and the Frontend client. 5. This changeset also introduces an instance of MGMT Frontend client embedded within the lib/vty module that can be leveraged by any FRR daemon to connect to MGMTd's Frontend interface. The same has been integrated with and initialized within the MGMTd daemon's process context to implement a bunch of 'set-config', 'commit-apply', 'get-config' and 'get-data' commands via VTYSH Co-authored-by: Pushpasis Sarkar <pushpasis@gmail.com> Co-authored-by: Abhinay Ramesh <rabhinay@vmware.com> Co-authored-by: Ujwal P <ujwalp@vmware.com> Signed-off-by: Yash Ranjan <ranjany@vmware.com>
2023-02-24Merge pull request #12889 from LabNConsulting/chopps/fix-nb-context-argDonald Sharp
lib: fix init. use of nb_context to be by value not by reference
2023-02-24Merge pull request #12751 from Pdoijode/pdoijode/ospf-vrf-neighbor-detail-1Donatas Abraitis
ospfd: Added missing fields and option to query specific neighbor in VRF
2023-02-23lib: fix init. use of nb_context to be by value not by referenceChristian Hopps
Pass context argument by value on initialization to be clear that the value is used/saved but not a pointer to the value. Previously the northbound code was incorrectly holding a pointer to stack allocated context structs. However, the structure definition also had some musings (ifdef'd out code) and a comment that might be taken to imply that user data could follow the structure and thus be maintained by the code; it won't; so it can't; so get rid of the disabled misleading code/text from the structure definition. The common use case worked b/c the transaction which cached the pointer was created and freed inside a single function call (`nb_condidate_commit`) that executed below the stack allocation. All other use cases (grpc, confd, sysrepo, and -- coming soon -- mgmtd) were bugs. Signed-off-by: Christian Hopps <chopps@labn.net>
2023-02-17Merge pull request #12780 from opensourcerouting/spdx-license-idDonald Sharp
*: convert to SPDX License identifiers
2023-02-16lib: Fix non-use of optionDonald Sharp
Commit d7c6467ba2f55d1055babbb7fe82716ca3efdc7e added the ability to specify non pretty printing but unfortunately forgot to use the option variable to make the whole thing work. 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>
2023-02-07lib: Helper function to print empty JSONPooja Jagadeesh Doijode
Introduced a helper function to print empty JSON object. Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-02-07Merge pull request #12707 from donaldsharp/missed_enumsDonatas Abraitis
Missed enums
2023-02-02lib, bgpd: Add ability to specify that some json output should not be prettyDonald Sharp
Initial commit: 23b2a7ef524c9fe083b217c7f6ebaec0effc8f52 changed the json output of `show bgp <afi> <safi> json` to not have pretty print because when under a situation where there are a bunch of routes with a large scale ecmp show output was taking forever and this commit cut 2 minutes out of vtysh run time. Subusequent commit: f4ec52f7cc99f709756d9030623a20c98a086125 changed this back. When upgrading to latest version the long run time was noticed due to testing. Let's add back this functionality such that FRR can have reduced run times with vtysh when it's really needed. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31lib: Add missing enum's to switch statementDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-27*: no-warn pragmas for non-const format stringsDavid Lamparter
We do use non-constant/literal format strings in a few places for more or less valid reasons; put `ignored "-Wformat-nonliteral"` around those so we can have the warning enabled for everywhere else. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-11-26lib: Do not log `echo PING` commands from watchfrrDonald Sharp
Since the `echo PING` commands are from watchfrr and are sent a whole bunch when an operator has `log commands` on the amount of logging done is quite significant. Signed-off-by: Donald Sharp <sharpd@nvidia.com>