summaryrefslogtreecommitdiffstats
path: root/lib/command.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #14498 from idryzhov/fix-conf-t-file-lockDonatas Abraitis2023-09-281-2/+2
|\ | | | | Fixes for `file-lock` mode of configuration node
| * vty: fix configure terminal argument descriptionsIgor Ryzhov2023-09-271-2/+2
| | | | | | | | | | | | "terminal" and "file-lock" description are mixed up. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* | lib: Drop deprecated enable-time-check, enable-cpu-time compile optionsDonatas Abraitis2023-09-241-17/+2
|/ | | | Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* vtysh: remove unused cmd_filter_typeIgor Ryzhov2023-08-041-10/+6
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* mgmtd: KISS the locking codeChristian Hopps2023-06-191-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lib: fix vtysh core when handling questionmarkYuan Yuan2023-05-311-2/+6
| | | | | | | | | | | | When issue vtysh command with ?, the initial buf size for the element is 16. Then it would loop through each element in the cmd output vector. If the required size for printing out the next element is larger than the current buf size, realloc the buf memory by doubling the current buf size regardless of the actual size that's needed. This would cause vtysh core when the doubled size is not enough for the next element. Signed-off-by: Yuan Yuan <yyuanam@amazon.com>
* mgmtd: fix reading of config file[s]Christian Hopps2023-05-301-0/+1
| | | | Signed-off-by: Christian Hopps <chopps@labn.net>
* lib: log commands read from config fileChristian Hopps2023-05-041-0/+8
| | | | | | | 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>
* mgmtd: fully implement debug flags for mgmtd and clientsChristian Hopps2023-05-011-0/+4
| | | | Signed-off-by: Christian Hopps <chopps@labn.net>
* *: Convert event.h to frrevent.hDonald Sharp2023-03-241-1/+1
| | | | | | | We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert a bunch of thread_XX to event_XXDonald Sharp2023-03-241-1/+1
| | | | | | | | | | | | | 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>
* *: Rename thread.[ch] to event.[ch]Donald Sharp2023-03-241-1/+1
| | | | | | | | | | | 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>
* *: Add a hash_clean_and_free() functionDonald Sharp2023-03-211-3/+1
| | | | | | | | | | Add a hash_clean_and_free() function as well as convert the code to use it. This function also takes a double pointer to the hash to set it NULL. Also it cleanly does nothing if the pointer is NULL( as a bunch of code tested for ). Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* Merge pull request #12248 from pguibert6WIND/bgpasdotRuss White2023-02-211-0/+1
|\ | | | | lib, bgp: add initial support for asdot format
| * lib, bgp: add initial support for asdot formatPhilippe Guibert2023-02-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AS number can be defined as an unsigned long number, or two uint16 values separated by a period (.). The possible valus are: - usual 32 bit values : [1;2^32 -1] - <1.65535>.<0.65535> for dot notation - <0.65535>.<0.65535> for dot+ notation. The 0.0 value is forbidden when configuring BGP instances or peer configurations. A new ASN type is added for parsing in the vty. The following commands use that new identifier: - router bgp .. - bgp confederation .. - neighbor <> remote-as <> - neighbor <> local-as <> - clear ip bgp <> - route-map / set as-path <> An asn library is available in lib/ and provides some services: - convert an as string into an as number. - parse an as path list string and extract a number. - convert an as number into a string. Also, the bgp tests forge an as_zero_path, and to do that, an API to relax the possibility to have a 0 as value is specifically called from the tests. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* | Merge pull request #12780 from opensourcerouting/spdx-license-idDonald Sharp2023-02-171-16/+1
|\ \ | | | | | | *: convert to SPDX License identifiers
| * | *: auto-convert to SPDX License IDsDavid Lamparter2023-02-091-16/+1
| |/ | | | | | | | | | | Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* / bgpd: Add BGP Software Version CapabilityDonatas Abraitis2023-02-151-0/+5
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement: https://datatracker.ietf.org/doc/html/draft-abraitis-bgp-version-capability Tested with GoBGP: ``` % ./gobgp neighbor 192.168.10.124 BGP neighbor is 192.168.10.124, remote AS 65001 BGP version 4, remote router ID 200.200.200.202 BGP state = ESTABLISHED, up for 00:01:49 BGP OutQ = 0, Flops = 0 Hold time is 3, keepalive interval is 1 seconds Configured hold time is 90, keepalive interval is 30 seconds Neighbor capabilities: multiprotocol: ipv4-unicast: advertised and received ipv6-unicast: advertised route-refresh: advertised and received extended-nexthop: advertised Local: nlri: ipv4-unicast, nexthop: ipv6 UnknownCapability(6): received UnknownCapability(9): received graceful-restart: advertised and received Local: restart time 10 sec ipv6-unicast ipv4-unicast Remote: restart time 120 sec, notification flag set ipv4-unicast, forward flag set 4-octet-as: advertised and received add-path: received Remote: ipv4-unicast: receive enhanced-route-refresh: received long-lived-graceful-restart: advertised and received Local: ipv6-unicast, restart time 10 sec ipv4-unicast, restart time 20 sec Remote: ipv4-unicast, restart time 0 sec, forward flag set fqdn: advertised and received Local: name: donatas-pc, domain: Remote: name: spine1-debian-11, domain: software-version: advertised and received Local: GoBGP/3.10.0 Remote: FRRouting/8.5-dev-MyOwnFRRVersion-gdc92f44a45-dirt cisco-route-refresh: received Message statistics: ``` FRR side: ``` root@spine1-debian-11:~# vtysh -c 'show bgp neighbor 192.168.10.17 json' | \ > jq '."192.168.10.17".neighborCapabilities.softwareVersion.receivedSoftwareVersion' "GoBGP/3.10.0" root@spine1-debian-11:~# ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* lib: Add missing enum's to switch statementDonald Sharp2023-01-311-1/+2
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib: fix display cputime-warning and walltime-warningDmitrii Turlupov2022-12-281-2/+2
| | | | | | | | | | | | | | | | | | | | Before patch: ``` # vtysh -c "c t" -c "service cputime-warning 1" -c "service walltime-warning 2" # vtysh -c "show run" | grep warn service cputime-warning 1000 service walltime-warning 2000 ``` After patch: ``` # vtysh -c "c t" -c "service cputime-warning 1" -c "service walltime-warning 2" # vtysh -c "show run" | grep warn service cputime-warning 1 service walltime-warning 2 ``` Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
* Merge pull request #12066 from opensourcerouting/cleanup-cli-xrefDonald Sharp2022-10-131-12/+8
|\ | | | | *: clean up various CLI-related bits
| * lib: make cmd_element->attr a bitmask & clarifyDavid Lamparter2022-10-061-12/+8
| | | | | | | | | | | | | | | | | | It already "looks" like a bitmask, but we currently can't flag a command both YANG and HIDDEN at the same time. It really should be a bitmask. Also clarify DEPRECATED behaviour (or the absence thereof.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* | *: Create and use infrastructure to show debugs in libDonald Sharp2022-10-071-0/+6
|/ | | | | | | | | There are lib debugs being set but never show up in `show debug` commands because there was no way to show that they were being used. Add a bit of infrastructure to allow this and then use it for `debug route-map` Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib, vtysh: Add `allow-reserved-ranges` global commandDonatas Abraitis2022-07-011-0/+26
| | | | | | | It will be used to allow/deny using IPv4 reserved ranges (Class E) for Zebra (configuring interface address) or BGP (allow next-hop to be from this range). Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* lib: Function `crypt` does not need to be declared mid functionDonald Sharp2022-06-161-1/+0
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: remove the checking returned value for hash_get()anlan_cs2022-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Firstly, *keep no change* for `hash_get()` with NULL `alloc_func`. Only focus on cases with non-NULL `alloc_func` of `hash_get()`. Since `hash_get()` with non-NULL `alloc_func` parameter shall not fail, just ignore the returned value of it. The returned value must not be NULL. So in this case, remove the unnecessary checking NULL or not for the returned value and add `void` in front of it. Importantly, also *keep no change* for the two cases with non-NULL `alloc_func` - 1) Use `assert(<returned_data> == <searching_data>)` to ensure it is a created node, not a found node. Refer to `isis_vertex_queue_insert()` of isisd, there are many examples of this case in isid. 2) Use `<returned_data> != <searching_data>` to judge it is a found node, then free <searching_data>. Refer to `aspath_intern()` of bgpd, there are many examples of this case in bgpd. Here, <returned_data> is the returned value from `hash_get()`, and <searching_data> is the data, which is to be put into hash table. Signed-off-by: anlan_cs <vic.lan@pica8.com>
* lib: Ensure an empty string does not get printed for host/domainDonald Sharp2022-04-211-4/+8
| | | | | | | | | | | | | | | | End operator is showing: ! frr version 8.0.1 frr defaults traditional hostname test.example.com domainname domainname should not be printed in this case at all. I do not see any mechanism in current code that this could happen, but what do I know? Put some extra stupid insurance in place to prevent bad config from being generated. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Add necessary new line for output of vty_out()anlan_cs2022-02-271-2/+2
| | | | Signed-off-by: anlan_cs <vic.lan@pica8.com>
* lib: Add more information to `show version`Donald Sharp2022-02-041-2/+25
| | | | | | | | Add to lib/command.c the ability to remember the release/version/system information and to allow `show version` to dump some of it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib: rework vty_check_node_for_xpath_decrementDavid Lamparter2021-11-161-32/+9
| | | | | | | ...by having a flag in struct cmd_node rather than hardcoding it in `lib/command.c`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* vtysh: defer CLI tree buildingDavid Lamparter2021-10-181-14/+61
| | | | | | We don't need the CLI tree until we actually enter the node. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge pull request #9497 from opensourcerouting/cli-better-noQuentin Young2021-09-091-0/+1
|\
| * lib: add `![...]` syntax for easy "no" formsDavid Lamparter2021-08-261-0/+1
| | | | | | | | | | | | | | | | | | | | This allows defining a CLI command like this: `[no] some setting ![VALUE]` with VALUE being optional for the "no" form, but required for the positive form. It's just a `[...]` where the empty branch can only be taken for commands starting with `no`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* | lib: make node_parent more genericIgor Ryzhov2021-08-261-86/+3
|/ | | | | | | Instead of adding a separate case clause for every node, just find the node structure in the global list and get its parent node from there. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* Merge pull request #8982 from dlqs/lua-func-stackQuentin Young2021-08-021-15/+17
|\
| * lib: Add function name to script commandDonald Lee2021-07-231-6/+5
| | | | | | | | Signed-off-by: Donald Lee <dlqs@gmx.com>
| * lib: Remove warning about script not foundDonald Lee2021-07-181-5/+4
| | | | | | | | Signed-off-by: Donald Lee <dlqs@gmx.com>
| * lib: Rename frrscript_unload to deleteDonald Lee2021-07-181-1/+1
| | | | | | | | | | | | | | frrscript_load now loads a function instead of a file, so frrscript_unload should be renamed since it does not unload a function. Signed-off-by: Donald Lee <dlqs@gmx.com>
| * test: Use frrscript_unloadDonald Lee2021-07-181-0/+2
| | | | | | | | Signed-off-by: Donald Lee <dlqs@gmx.com>
| * lib: Update Script command example to call functionDonald Lee2021-07-181-7/+9
| | | | | | | | Signed-off-by: Donald Lee <dlqs@gmx.com>
* | lib, zebra: fix exit from link-params nodeIgor Ryzhov2021-07-211-0/+3
|/ | | | | | | When exiting from link-params node, we must not decrement xpath_index because it is not incremented when entering the node. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* Merge pull request #8888 from dlqs/lua-callQuentin Young2021-07-051-2/+4
|\
| * lib: Update script SCRIPT commandDonald Lee2021-06-211-2/+4
| | | | | | | | | | | | Can now test out script by modifying a prefix Signed-off-by: Donald Lee <dlqs@gmx.com>
* | Merge pull request #8911 from donaldsharp/command_nodeDonatas Abraitis2021-06-291-2/+7
|\ \ | | | | | | lib: Add some hash name differentiation for Command Hash's
| * | lib: Add some hash name differentiation for Command Hash'sDonald Sharp2021-06-241-2/+7
| |/ | | | | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* / lib: make cputime checks runtime options (v2)David Lamparter2021-06-241-0/+30
|/ | | | | | | | | | ...really no reason to force this into a compile time decision. The only point is avoiding the getrusage() syscall, which can easily be a runtime decision. [v2: also split cputime & walltime limits] Signed-off-by: David Lamparter <equinox@diac24.net>
* Merge pull request #8593 from idryzhov/cmd-ambiguousQuentin Young2021-06-081-0/+3
|\ | | | | vtysh: fix searching commands in parent nodes
| * vtysh: fix searching commands in parent nodesPavel Ivashchenko2021-04-291-0/+3
| | | | | | | | | | | | Do not check parent command nodes in case of ambiguous and incomplete commands Signed-off-by: Pavel Ivashchenko <pivashchenko@nfware.com>
* | lib: fix address sanitizer crash on `find`Rafael Zalamena2021-06-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix the following address sanitizer crash when running the command `find`: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow WRITE of size 1 at 0x7fff4840fc1d thread T0 0 in print_cmd ../lib/command.c:1541 1 in cmd_find_cmds ../lib/command.c:2364 2 in find ../vtysh/vtysh.c:3732 3 in cmd_execute_command_real ../lib/command.c:995 4 in cmd_execute_command ../lib/command.c:1055 5 in cmd_execute ../lib/command.c:1219 6 in vtysh_execute_func ../vtysh/vtysh.c:486 7 in vtysh_execute ../vtysh/vtysh.c:671 8 in main ../vtysh/vtysh_main.c:721 9 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) 10 in _start (/usr/bin/vtysh+0x21f64d) Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* | Merge pull request #8781 from idryzhov/fix-list-findRafael Zalamena2021-06-071-10/+68
|\ \ | | | | | | lib: fix output of "list" and "find" commands