summaryrefslogtreecommitdiffstats
path: root/vtysh/vtysh_config.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* vtysh: remove resync workaround when exiting to config nodeIgor Ryzhov2024-02-071-2/+0
| | | | | | | | | | | | | | When exiting from a level below the config node, like `router rip`, vtysh executes a resync by sending "end" and "conf term [file-lock]" commands to all the daemons. As statet in the description comment, it's done "in case one of the daemons is somewhere else". I don't think this actually ever happens, but even if it is, it is a bug in a daemon that needs to be fixed. This resync was okay before the introduction of mgmtd, but now it unlocks and locks back the datastores during the configuration reading process, which can lead to a failure which is explained in the previous commit. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* mgmtd, vtysh: fix possible conflict when reading the configIgor Ryzhov2024-02-071-1/+7
| | | | | | | | | | | | | | | | | | | | | | | When FRR starts, after mgmtd is initialized, backend clients connect to it and request their config. To supply the config, mgmtd creates a configuration transaction. At the same time, `vtysh -b` tries to read the startup config and configure mgmtd, which also creates a configuration transaction. If these two actions happen at the exact same time, there's a conflict between them, because only a single configuration translaction is allowed. Because of that, vtysh fails and the config is completely ignored. When starting the config reading, vtysh locks candidate and running datastores in mgmtd. This commit adds locking of running datastore when initializing the backend client. It allows to retry locking on the vtysh side and read the config only when the lock is aquired instead of failing. This change also prevents running datastore from being changed during initialization of backend clients. This could lead to a desynchronized state between mgmtd and backends. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bgpd: add support of rpki in vrf configure contextPhilippe Guibert2024-01-181-1/+10
| | | | | | | Add support of RPKI commands in the VRF configure context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
* lib: mgmtd: fix debug cli commands and memleaksChristian Hopps2023-11-111-0/+6
| | | | | | | | | | | - Cannot have 2 cmd_node's with same .node number. Install the mgmtd client library debug nodes (client frontend and client backend) using new unique node numbers. Fixes memleaks. - Fix "debug mgmt client backend" to generate correct config (and not for frontend). Signed-off-by: Christian Hopps <chopps@labn.net>
* vtysh: Print uniq lines when parsing `no service ...`Donatas Abraitis2023-08-111-8/+4
| | | | | | | | | | | | | | | Before this patch: ``` no service cputime-warning no service cputime-warning no ipv6 forwarding no service cputime-warning no service cputime-warning no service cputime-warning ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* vtysh: fix checking empty interface nodeIgor Ryzhov2023-08-041-3/+1
| | | | | | | vtysh is not supposed to show empty interface node in running config, however the corresponding check is broken and empty nodes are shown. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* vtysh: track and fix file-lock use in the workaround from 2004Christian Hopps2023-07-151-1/+3
| | | | | | | | | | | | There's a workaround in the code from a bug from back in 2004, it ends and re-enters config mode anytime an `exit` is done from a level below the top-level config node (e.g., from a `router isis` node). We need to re-enter config mode with or without a lock according to how we actually entered it to begin with. fixes #13920 Signed-off-by: Christian Hopps <chopps@labn.net>
* mgmtd: KISS the locking codeChristian Hopps2023-06-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* vtysh: Exit with first received error code when forkingDonald Sharp2023-03-281-3/+13
| | | | | | | vtysh -f forks. Gather the return codes and report the first failed return code. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* vtysh: use fork() workflow for -f tooQuentin Young2023-03-281-5/+94
| | | | | | | | | | 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>
* 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>
* | lib,yang,zebra: add affinity-map supportLouis Scalbert2023-02-091-8/+12
|/ | | | | | | | Add the affinity-map global command to zebra. The syntax is: > affinity-map NAME bit-position (0-1023) Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
* vtysh: Cleanup memory leakDonald Sharp2022-12-051-1/+5
| | | | | | | | When multiple daemons report a exit line for the same node, vtysh was just dropping the previous pointer. Ensure that we free it first. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib, vtysh: Add ability to specify resilient nhgsDonald Sharp2022-11-041-5/+17
| | | | | | | | | | | | Add the ability to specify a resilient nexthop group nexthop-group A resilient buckets 32 idle_timer 100 unbalanced_timer 500 nexthop 192.168.100.1 enp7s0 nexthop 192.168.100.33 enp7s0 nexthop 192.168.122.1 enp1s0 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* vtysh: Allow `service ...` lines to not repeatDonald Sharp2022-11-031-2/+2
| | | | | | | | When any `service ...` line is entered and there are multiple daemons running prevent this from being displayed multiple times. Fixes: #5475 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* vtysh: Ensure an empty string does not get printed for host/domainNico Berlee2022-10-251-5/+8
| | | | | | | | | | | | | | | | | | | vtysh show running-config is showing: frr version 8.3.1_git frr defaults traditional hostname test log file /etc/frr/frr.log informational log timestamp precision 3 domainname service integrated-vtysh-config domainname should not be printed in this case at all. If the host has no search/domainname configured, frr_reload.py crashes on invalid config from `vtysh show running-config` Basically the same change as commit a7141b8 Signed-off-by: Nico Berlee <nico.berlee@on2it.net>
* vtysh: Show allow-reserved-ranges once in configDonatas Abraitis2022-09-271-0/+2
| | | | | | | | | | | | | | | | | Before: ``` donatas-pc# sh run | include allow-reserved-ranges allow-reserved-ranges allow-reserved-ranges allow-reserved-ranges allow-reserved-ranges allow-reserved-ranges allow-reserved-ranges donatas-pc# ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* vtysh: Properly handle `service cputime-warning XX` in configDonald Sharp2022-09-271-1/+3
| | | | | | Prevent duplicate lines from each daemon in vtysh output. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* vtysh: Properly handle `[no] service cputime-stats` in configDonald Sharp2022-09-271-1/+5
| | | | | | | Prevent duplicate lines from each daemon in vtysh output. Fixes: #12022 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib, vtysh: Add `allow-reserved-ranges` global commandDonatas Abraitis2022-07-011-8/+12
| | | | | | | 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>
* vtysh: fix duplicated output of key chain configurationIgor Ryzhov2021-12-031-29/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When both ripd and eigrpd run at the same time, all key configuration in key chain node is duplicated. This change adds a concept of nested nodes into vtysh to fix the issue. Before: ``` key chain test key 1 key-string 1 exit key 1 key-string 1 exit exit ! ``` After: ``` key chain test key 1 key-string 1 exit exit ! ``` Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* vtysh: add missing rpki node when showing configIgor Ryzhov2021-11-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: ``` frr version 8.2-dev frr defaults traditional hostname frr rpki rpki polling_period 20 rpki cache 192.0.2.1 8080 preference 1 service integrated-vtysh-config ! ``` After: ``` frr version 8.2-dev frr defaults traditional hostname frr service integrated-vtysh-config ! rpki rpki polling_period 20 rpki cache 192.0.2.1 8080 preference 1 exit ! ``` Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* vtysh: remove sorting of vrf node commandsIgor Ryzhov2021-09-201-1/+0
| | | | | | | | | | A simple strcmp-based sorting done by `config_add_line_uniq` breaks the correct advanced sorting of static routes done by staticd. We don't actually need to check vrf node commands for uniqueness as all commands are daemon specific, so let's use simple `config_add_line` that doesn't sort commands. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* *: explicitly print "exit" at the end of every node configIgor Ryzhov2021-08-231-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a possibility that the same line can be matched as a command in some node and its parent node. In this case, when reading the config, this line is always executed as a command of the child node. For example, with the following config: ``` router ospf network 193.168.0.0/16 area 0 ! mpls ldp discovery hello interval 111 ! ``` Line `mpls ldp` is processed as command `mpls ldp-sync` inside the `router ospf` node. This leads to a complete loss of `mpls ldp` node configuration. To eliminate this issue and all possible similar issues, let's print an explicit "exit" at the end of every node config. This commit also changes indentation for a couple of existing exit commands so that all existing commands are on the same level as their corresponding node-entering commands. Fixes #9206. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* vtysh: add CLI timestamp '-t' flagChristian Hopps2021-06-301-0/+6
| | | | | | | | | | | | | | 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>
* *: new cli-nodes for SRv6 manager (step2)Hiroki Shirokura2021-06-021-0/+4
| | | | | | | | | | | | | This commit is a part of #5853 that add new cmd-node for SRv6 configuration. This commit just add cmd-node and moving node cli only, acutual SRv6 config command isn't added. (that is added later commit. of this branch) new cli nodes: * SRv6 * SRv6-locators * SRv6-locator Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
* bgpd: Create BGP alias names for community/large-communityDonatas Abraitis2021-05-051-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Show alias name instead of numerical value in `show bgp <prefix>. E.g.: ``` root@exit1-debian-9:~/frr# vtysh -c 'sh run' | grep 'bgp community alias' bgp community alias 65001:123 community-1 bgp community alias 65001:123:1 lcommunity-1 root@exit1-debian-9:~/frr# ``` ``` exit1-debian-9# sh ip bgp 172.16.16.1/32 BGP routing table entry for 172.16.16.1/32, version 21 Paths: (2 available, best #2, table default) Advertised to non peer-group peers: 65030 192.168.0.2 from home-spine1.donatas.net(192.168.0.2) (172.16.16.1) Origin incomplete, metric 0, valid, external, best (Neighbor IP) Community: 65001:12 65001:13 community-1 65001:65534 Large Community: lcommunity-1 65001:123:2 Last update: Fri Apr 16 12:51:27 2021 exit1-debian-9# ``` Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* lib, doc: add "route-map NAME optimization" commandIgor Ryzhov2021-04-091-0/+3
| | | | | | | | | | | | | | | | Currently we have a "route-map optimization" command which is entered from inside the route-map entry but actually applies to the whole route-map. In addition, this command is not shown in the running-config and not stored to the startup-config during "write". Let's add a new command on the config node level to control this setting and show it in the running-config to make possible to save it during "write". The old command is saved for the backward compatibility but hidden and marked as deprecated. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* *: require semicolon after DEFINE_<typesafe...>David Lamparter2021-03-171-2/+2
| | | | | | Again, see previous commits. Signed-off-by: David Lamparter <equinox@diac24.net>
* *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-171-3/+3
| | | | | | | | | | | | | | | | | Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
* vtysh: When dry-running no need to start/end configurationDonald Sharp2020-12-151-5/+7
| | | | | | | | When doing a dry run don't send start/end configuration commands. Ticket: CM-32665 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* lib, vtysh: Modify start/end configuration commands to be more hiddenDonald Sharp2020-12-151-2/+2
| | | | | | | | | There exists a world where some people have put `end` in their configuration. Then vtysh will command search for it and find it and then bad things happen. Ticket: CM-32665 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* vtysh: fix memory leakIgor Ryzhov2020-11-301-1/+3
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* lib, sharpd, vtysh: When reading a file in for config send start/end indicatorsDonald Sharp2020-11-191-0/+4
| | | | | | | When reading a file in for configuration, send start and end indicators to interested parties. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* vtysh: fix multiple "domainname" commands in running configIgor Ryzhov2020-10-021-2/+2
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* vtysh: Speed up output of configuration across daemonsDonald Sharp2020-08-041-19/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With a config that contains a large number of prefix-lists a 'show run' command was an expensive operation: sharpd@eva ~/frr_internal2 ((cl4.1.0))> time vtysh -c "show run" | grep ACTIVE | wc -l 32397 ________________________________________________________ Executed in 14.53 secs fish external usr time 14.45 secs 591.00 micros 14.45 secs sys time 0.03 secs 189.00 micros 0.03 secs sharpd@eva ~/frr_internal2 ((cl4.1.0))> Effectively we are keeping a linked list of data to store the configuration. When we received a new item we would look in the list to see if it already does, by doing a string search across each element in the list. Add to the master configuration a hash of items for O(1) lookup. Keep the list for order so we don't mangle that up. New time: sharpd@eva ~/frr_internal1 (dev)> time vtysh -c "show run" | grep ACTIVE | wc -l 32397 ________________________________________________________ Executed in 277.94 millis fish external usr time 237.46 millis 20.53 millis 216.93 millis sys time 14.31 millis 0.00 millis 14.31 millis Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Revert "Rpki Encapsulation"Quentin Young2020-07-141-12/+1
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Merge pull request #5015 from pguibert6WIND/rpki_vrf_encapsulationQuentin Young2020-07-141-1/+12
|\ | | | | Rpki Encapsulation
| * bgpd: duplicate config commands into rpki-vrf subnodePhilippe Guibert2020-07-021-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | rpki vrf subnode is instantiated under the vrf subnode. It it to be noted that this commit contains a change in vtysh. Actually, the output of bgp daemon from show running-config is extracted in vtysh, and reengineered ( hence the vtysh_config.c change done). This permits having a subnode under vrf sub node. Also, add vrf node support to bgpd, as rpki command can not be found under vrf node. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
| * lib, vtysh: bgp rpki constistent changes with rpki_nodePhilippe Guibert2020-07-021-0/+2
| | | | | | | | | | | | | | | | | | | | rpki_node is a node under configure terminal. as such, align with other nodes that are similar. Note that this change is important, since the location where show running-config from vtysh displays rpki configuration is changed in the middle of the configuration instead of at the top, before authentication. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* | vtysh: Improve lookup performanceDonald Sharp2020-06-301-1/+3
| | | | | | | | | | | | When we find the line we are interested in, stop looking. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* | vtysh: master is a non-sorted listDonald Sharp2020-06-301-11/+10
|/ | | | | | | | | | | | | | | | | | | | The commit: a798241265a5808083a06b14ce1637d1ddf6a45a attempted to use sorted master lists to do faster lookups by using a RB Tree. Unfortunately the original code was creating a list->cmp function *but* never using it. If you look at the commit, it clearly shows that the function listnode_add is used to insert but when you look at that function it is a tail push. Fixes: #6573 Namely now this ordering is preserved: bgp as-path access-list originate-only permit ^$ bgp as-path access-list originate-only deny .* Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: sprintf -> snprintfQuentin Young2020-04-211-1/+2
| | | | | | | | | | | | | Replace sprintf with snprintf where straightforward to do so. - sprintf's into local scope buffers of known size are replaced with the equivalent snprintf call - snprintf's into local scope buffers of known size that use the buffer size expression now use sizeof(buffer) - sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp buffer followed by strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: Remove parenthesis on return for constantsDonatas Abraitis2020-02-091-1/+1
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* vtysh: Ensure interface `ip mroute ...` commands are lastDonald Sharp2019-12-201-0/+2
| | | | | | | Ensure when displaying interface based ip mroute commands that they are last. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* vtysh: fix multiple "no ip/ipv6 prefix-list sequence-number" lines in ↵Igor Ryzhov2019-09-181-1/+3
| | | | | | running-config Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* all: remove logical-router functionality (#4774)David Lamparter2019-08-061-3/+0
|\ | | | | all: remove logical-router functionality
| * all: remove logical-router functionalityIgor Ryzhov2019-08-021-3/+0
| | | | | | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* | vtysh: Replace linked-list in vtysh_config with RB-treeJuergen Werner2019-08-021-17/+21
|/ | | | | | | ...for faster look-ups Fixes: 4673 Signed-off-by: Juergen Werner <juergen@opensourcerouting.org>