summaryrefslogtreecommitdiff
path: root/lib/command.c
AgeCommit message (Collapse)Author
2024-01-27build: homologize path handlingDavid Lamparter
Use consistent `e_somepath` names for expanded versions of `somepath`. Also remove all paths from `config.h` and put them into `lib/config_paths.h` - this is to make more obvious when someone is doing something probably not quite properly structured. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27lib: create `frr_daemon_state_{load,save}`David Lamparter
These functions load daemon-specific persistent state from `/var/lib/frr` and supersede open-coded variants of similar calls in ospfd, ospf6d and isisd to save GR state and/or sequence numbers. Unlike the open-coded variants, the save call correctly `fsync()`s the saved data to ensure disk contents are consistent. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-09*: zebra.h should not have fcntl.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>
2024-01-04lib: sys/utsname.h is not needed in zebra.hDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-28Merge pull request #14498 from idryzhov/fix-conf-t-file-lockDonatas Abraitis
Fixes for `file-lock` mode of configuration node
2023-09-27vty: fix configure terminal argument descriptionsIgor Ryzhov
"terminal" and "file-lock" description are mixed up. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-09-24lib: Drop deprecated enable-time-check, enable-cpu-time compile optionsDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-08-05vtysh: remove unused cmd_filter_typeIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
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-05-31lib: fix vtysh core when handling questionmarkYuan Yuan
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>
2023-05-30mgmtd: fix reading of config file[s]Christian 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-05-01mgmtd: fully implement debug flags for mgmtd and clientsChristian Hopps
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 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*: 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-21*: Add a hash_clean_and_free() functionDonald Sharp
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>
2023-02-21Merge pull request #12248 from pguibert6WIND/bgpasdotRuss White
lib, bgp: add initial support for asdot format
2023-02-17Merge pull request #12780 from opensourcerouting/spdx-license-idDonald Sharp
*: convert to SPDX License identifiers
2023-02-15bgpd: Add BGP Software Version CapabilityDonatas Abraitis
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>
2023-02-10lib, bgp: add initial support for asdot formatPhilippe Guibert
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>
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-01-31lib: Add missing enum's to switch statementDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-28lib: fix display cputime-warning and walltime-warningDmitrii Turlupov
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>
2022-10-13Merge pull request #12066 from opensourcerouting/cleanup-cli-xrefDonald Sharp
*: clean up various CLI-related bits
2022-10-07*: Create and use infrastructure to show debugs in libDonald Sharp
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>
2022-10-06lib: make cmd_element->attr a bitmask & clarifyDavid Lamparter
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>
2022-07-01lib, vtysh: Add `allow-reserved-ranges` global commandDonatas Abraitis
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>
2022-06-16lib: Function `crypt` does not need to be declared mid functionDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-03*: remove the checking returned value for hash_get()anlan_cs
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>
2022-04-21lib: Ensure an empty string does not get printed for host/domainDonald Sharp
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>
2022-02-27*: Add necessary new line for output of vty_out()anlan_cs
Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-02-04lib: Add more information to `show version`Donald Sharp
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>
2021-11-16lib: rework vty_check_node_for_xpath_decrementDavid Lamparter
...by having a flag in struct cmd_node rather than hardcoding it in `lib/command.c`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-18vtysh: defer CLI tree buildingDavid Lamparter
We don't need the CLI tree until we actually enter the node. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-09-09Merge pull request #9497 from opensourcerouting/cli-better-noQuentin Young
2021-08-26lib: add `![...]` syntax for easy "no" formsDavid Lamparter
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>
2021-08-26lib: make node_parent more genericIgor Ryzhov
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>
2021-08-02Merge pull request #8982 from dlqs/lua-func-stackQuentin Young
2021-07-24lib: Add function name to script commandDonald Lee
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-21lib, zebra: fix exit from link-params nodeIgor Ryzhov
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>
2021-07-18lib: Remove warning about script not foundDonald Lee
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18lib: Rename frrscript_unload to deleteDonald Lee
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>
2021-07-18test: Use frrscript_unloadDonald Lee
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-18lib: Update Script command example to call functionDonald Lee
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-07-05Merge pull request #8888 from dlqs/lua-callQuentin Young
2021-06-29Merge pull request #8911 from donaldsharp/command_nodeDonatas Abraitis
lib: Add some hash name differentiation for Command Hash's
2021-06-24lib: Add some hash name differentiation for Command Hash'sDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-24lib: make cputime checks runtime options (v2)David Lamparter
...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>