summaryrefslogtreecommitdiffstats
path: root/lib/command.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: remove null check before XFREEQuentin Young2020-02-041-2/+1
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: don't null after XFREE; XFREE does this itselfQuentin Young2020-02-031-2/+0
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: new defaults logicDavid Lamparter2019-12-061-14/+3
| | | | | | | Since we've been writing out "frr version" and "frr defaults" for about a year and a half now, we can now actually use them to manage defaults. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: make cmd_element & qobj_type constDavid Lamparter2019-11-301-9/+9
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* vtysh: Add an option to set banner motd from an inputDonatas Abraitis2019-10-311-5/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows to set motd from an input instead of creating a file. Example: root@exit2-debian-9:~/frr# telnet 127.0.0.1 2605 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Hello, this is bgpd User Access Verification Password: exit2-debian-9> enable exit2-debian-9# sh run Current configuration: ! frr version 7.3-dev-MyOwnFRRVersion frr defaults traditional ! hostname exit2-debian-9 password belekas log file /var/log/frr/labas.log log syslog informational banner motd line Hello, this is bgpd ! ! ! line vty ! end exit2-debian-9# Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* Merge pull request #5083 from zays26/feature/vtysh-masterQuentin Young2019-10-141-0/+4
|\ | | | | vtysh: fix searching commands in parent nodes
| * vtysh: fix searching commands in parent nodesPavel Ivashchenko2019-10-081-0/+4
| | | | | | | | | | | | Do not check parent command nodes in case of ambiguous and incomplete commands Signed-off-by: Pavel Ivashchenko <pivashchenko@nfware.com>
* | lib: avoid expensive operations when editing a candidate configRenato Westphal2019-10-121-0/+2
|/ | | | | | | | | | | | | | | | | nb_candidate_edit() was calling both the lyd_schema_sort() and lyd_validate() functions whenever a new node was added to the candidate configuration. This was done to ensure the candidate is always ready to be displayed correctly (libyang only creates default child nodes during the validation process, and data nodes aren't guaranteed to be ordered by default). The problem is that the two aforementioned functions are too expensive to be called in the northbound hot path. Instead, it makes more sense to call them only before displaying the configuration (in which case a recursive sort needs to be done). Introduce the nb_cli_show_config_prepare() to achieve that purpose. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* Revert "lib: introduce a read-write lock for northbound configurations"Renato Westphal2019-09-181-10/+6
| | | | | | | | | | | | | | | | | Adding a lock to protect the global running configuration doesn't help much since the FRR daemons are not prepared to process configuration changes in a pthread that is not the main one (a whole lot of new protections would be necessary to prevent race conditions). This means the lock added by commit 83981138 only adds more complexity for no benefit. Remove it now to simplify the code. All northbound clients, including the gRPC one, should either run in the main pthread or use synchronization primitives to process configuration transactions in the main pthread. This reverts commit 83981138fe8c1e0a40b8dede74eca65449dda5de.
* lib: optimize non-transactional cliRenato Westphal2019-09-061-2/+4
| | | | | | | | | | | | | Commit eaf6705d7a fixed a problem caused by configuration changes coming from the kernel. The fix consisted of regenerating the candidate configuration before every configuration command (when using the non-transactional CLI mode). There's no need, however, to regenerate the candidate when it's identical to the running configuration. Since the northbound keeps track of the version of each configuration, we can use that information to prevent regenerating the candidate configuration when that is not necessary. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* vtysh, lib: allow regexp in `find` commandQuentin Young2019-09-031-7/+59
| | | | | | ¯\_(ツ)_/¯ Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* bgpd/bmp: BMP implementationDavid Lamparter2019-08-301-0/+3
| | | | | | | | This implements BMP. There's no fine-grained history here, the non-BMP preparations are already split out from here so all that remains is BMP proper. Signed-off-by: David Lamparter <equinox@diac24.net>
* Merge pull request #4790 from opensourcerouting/ctype-castQuentin Young2019-08-061-5/+5
|\ | | | | *: fix ctype casts
| * *: fix ctype (isalpha & co.) castsDavid Lamparter2019-08-061-5/+5
| | | | | | | | | | | | | | | | | | The correct cast for these is (unsigned char), because "char" could be signed and thus have some negative value. isalpha & co. expect an int arg that is positive, i.e. 0-255. So we need to cast to (unsigned char) when calling any of these. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* | all: remove logical-router functionalityIgor Ryzhov2019-08-021-2/+0
|/ | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* lib: split off c-ares code from nhrpdDavid Lamparter2019-07-031-0/+1
| | | | | | This is useful in other places too, e.g. for BMP outbound connections. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: use MTYPE_STATICDavid Lamparter2019-06-211-1/+1
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge pull request #4300 from adharkar/frr-master-rmap_debugDonald Sharp2019-06-181-0/+1
|\ | | | | Lib: Debugs for route-map code in FRR
| * Lib: Debugs for route-map code in FRRAmeya Dharkar2019-06-121-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Added a CLI "debug route-map" to enble route-map debugs Added debugs for following triggers 1. Add/delete a route-map 2. Add/delete a sequence in route-map 3. Add/delete a match statement(dependency) 4. Update a dependency 5. Apply a route-map Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
* | lib: fix outdated candidate configuration issueRenato Westphal2019-06-121-3/+10
|/ | | | | | | | | | | | | | | | | | | | | | | Even when using the classic CLI mode (i.e. when --tcli is not used), the northbound code still uses vty->candidate_config to perform configuration changes. From the perspective of the user, the running configuration is being edited directly, but under the hood the northbound layer does a full configuration transaction for each command. When the running configuration is edited by a northbound client other than the CLI (e.g. kernel, gRPC), vty->candidate_config might become outdated, and this can lead to lots of weird problems. To fix this, always regenerate vty->candidate_config before each configuration command when using the classic CLI mode. When using the transactional CLI, the user needs to update the candidate manually using the "update" command, otherwise the "commit" command will fail with this error: "% Candidate configuration needs to be updated before commit". Fixes some problems reported by Don after moving an interface from one VRF to another one while zebra is running. Reported-by: Don Slice <dslice@cumulusnetworks.com> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* Merge pull request #4430 from lkrishnamoor/hostname_crashDonald Sharp2019-05-311-1/+9
|\ | | | | lib: crash when FRR hostname length > 80 chars
| * lib: crash when FRR hostname length > 80 charsLakshman Krishnamoorthy2019-05-311-1/+9
| | | | | | | | | | | | | | | | | | | | | | Although the RFC states hostname length should be < 255 chars, FRR allows infinite length technically. However, when you try to set a hostname > 80 chars, you would immediately notice a crash. RCA: Crash due to buffer overflow. Large buffer sprintf'd into smaller buffer. Usage of sprintf function instead of snprintf which is safer. Signed-off-by: Lakshman Krishnamoorthy <lkrishnamoor@vmware.com>
* | lib, vtysh: make debug memstats work in vtyshMark Stapp2019-05-301-2/+4
|/ | | | | | | Allow vtysh to send the 'debug memstats-on-exit' command to the running daemons. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* lib: remove some strcpy, strcatQuentin Young2019-05-291-4/+4
| | | | | | Replace with strlcpy, strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd, lib: style fixesQuentin Young2019-05-171-1/+1
| | | | | | | | | Fixup: * Blank lines after declarations * Trailing whitespace * Braces and parentheses Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vrrpd: add support for configuration writingQuentin Young2019-05-171-0/+1
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: hashing functions should take const argumentsQuentin Young2019-05-141-1/+1
| | | | | | | | | | It doesn't make much sense for a hash function to modify its argument, so const the hash input. BGP does it in a couple places, those cast away the const. Not great but not any worse than it was. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib, vtysh: Make archaic "terminal" optional in configure commandDinesh Dutt2019-05-081-1/+1
| | | | | | | The 'configure terminal' command is a bit redundant, so make the terminal portion optional. Signed-off-by: Dinesh Dutt <dd.ps4u@gmail.com>
* lib: introduce a read-write lock for northbound configurationsRenato Westphal2019-04-261-6/+10
| | | | | | | | | | | | The upcoming gRPC-based northbound plugin will run on a separate pthread, and it will need to have access to the running configuration global variable. Introduce a rw-lock to control concurrent access to the running configuration. Add the lock inside the "nb_config" structure so that it can be used to protect candidate configurations as well (this might be necessary depending on the threading scheme of future northbound plugins). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* *: remove null check before XFREEQuentin Young2019-02-261-30/+15
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: rename enum to avoid conflictRenato Westphal2019-02-121-1/+1
| | | | | | | | | Two different definitions of "enum filter_type" exist in libfrr: one in lib/filter.h and other in lib/command_match.h. Rename one of them to resolve a conflict that happens when both headers are included by the same file. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: don't disable "log file" on "log syslog"David Lamparter2019-01-241-2/+0
| | | | | | | | | FRR log targets are independent, so "log syslog" must not disable "log file" output. Fixes: #3551 Fixes: 0204baa87630b210c71d9ae0e2569cff0fb0539b Signed-off-by: David Lamparter <equinox@diac24.net>
* Treewide: use ANSI function definitionsRuben Kerkhof2019-01-241-1/+1
| | | | Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
* lib: simplify detection of when the user is leaving the CLI config modeRenato Westphal2019-01-191-55/+1
| | | | | | | | | | | | | We can make use of the vty->config variable to know when the CLI user is in the configuration mode or not. This is much simpler than obtaining this information from the vty node, and also a more robust solution (the three switch statements below, for example, were out of sync). Also, fix a bug where vty->config wasn't being unset in the vty_config_exit() function (bug introduced by commit f344c66ea3). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: reset the vty xpath index when entering the config modeRenato Westphal2019-01-191-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CLI code uses the vty->xpath[] array and the vty->xpath_index variables to keep track of where the user is in the configuration hierarchy. As such, we were resetting vty->xpath_index to zero whenever the user exited from the configuration mode in order to keep the index valid. We weren't doing this in the vty_stop_input() function however, which is called when the user types ^C in the terminal. This was leading to bugs like this: zebra> en zebra# conf t zebra(config)# interface eth0 zebra(config-if)# ^C zebra# conf t zebra(config)# interface eth0 % Configuration failed. Schema node not found. YANG path: /frr-interface:lib/interface[name='eth0'][vrf='default']/frr-interface:lib To fix this, do something more clever: instead of resetting the XPath index whenever the user exits from the configuration mode, do that when the user enters in the configuration mode. This way the XPath index needs to be reset in a single place only, not to mention it's a more robust solution. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* Merge pull request #3378 from opensourcerouting/remove-config-lockDonald Sharp2018-12-011-15/+3
|\ | | | | *: remove the configuration lock from all daemons
| * *: remove the configuration lock from all daemonsRenato Westphal2018-11-261-15/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A while ago all FRR configuration commands were converted to use the QOBJ infrastructure to keep track of configuration objects. This means the configuration lock isn't necessary anymore because the QOBJ code detects when someones tries to edit a configuration object that was deleted and react accordingly (log an error and abort the command). The possibility of accessing dangling pointers doesn't exist anymore since vty->index was removed. Summary of the changes: * remove the configuration lock and the vty_config_lockless() function. * rename vty_config_unlock() to vty_config_exit() since we need to clean up a few things when exiting from the configuration mode. * rename vty_config_lock() to vty_config_enter() to remove code duplication that existed between the three different "configuration" commands (terminal, private and exclusive). Configuration commands converted to the new northbound model don't need the configuration lock either since the northbound API also detects when someone tries to edit a configuration object that doesn't exist anymore. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | lib, ripd: rework API for converted CLI commandsRenato Westphal2018-11-261-1/+6
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When editing the candidate configuration, the northbound must ensure that either all changes made by a command are accepted or none are. This is done to prevent inconsistent states where only parts of a command are applied in the event any error happens. The previous API for converted commands, the nb_cli_cfg_change() function, required callers to pass an array containing all changes that needed to be applied in the candidate configuration. The problem with this API is that it was very inconvenient for complex commands, which change different configuration options depending on several factors. This required users to manipulate the array of configuration changes using low-level primitives, making it complicated to implement some commands. To solve this problem, introduce a new API based on the two following functions: - nb_cli_enqueue_change() - nb_cli_apply_changes() The first function is used to enqueue configuration changes, one at time. Then the nb_cli_apply_changes() function is used to apply all the enqueued configuration changes. To implement this, a static-sized array was allocated in the "vty" structure, along with a counter of enqueued changes. This eliminates the need to declare an array of configuration changes in every converted CLI command, simplifying things quite considerably. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: introduce new northbound APIRenato Westphal2018-10-271-3/+32
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: If command was successful don't store the command as an errorDonald Sharp2018-10-251-1/+3
| | | | | | | The CMD_SUCCESS_DAEMON case should be excluded from storing the command line that we think failed. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: Replace hash_cmp function return value to a boolDonald Sharp2018-10-191-1/+1
| | | | | | | | | The ->hash_cmp and linked list ->cmp functions were sometimes being used interchangeably and this really is not a good thing. So let's modify the hash_cmp function pointer to return a boolean and convert everything to use the new syntax. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib, vtysh: Allow notification across multiple lines of failureDonald Sharp2018-10-111-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | When reading in config files and we have failures on multiple lines actually note the actual failure lines and return them. This fixes an issue where we stopped counting errors after the first one and we got missleading line numbers that did not correspond to the actual problem. This is fixed: sharpd@donna ~/frr> sudo /usr/lib/frr/pimd --log=stdout -A 127.0.0.1 -f /etc/frr/pimd.conf 2018/10/11 09:41:01 PIM: VRF Created: default(0) 2018/10/11 09:41:01 PIM: pim_vrf_enable: for default 2018/10/11 09:41:01 PIM: zclient_lookup_sched_now: zclient lookup immediate connection scheduled 2018/10/11 09:41:01 PIM: zclient_lookup_new: zclient lookup socket initialized 2018/10/11 09:41:01 PIM: pimd 6.1-dev starting: vty@2611 2018/10/11 09:41:01 PIM: [EC 100663304] ERROR: No such command on config line 2: inteface lo 2018/10/11 09:41:01 PIM: [EC 100663304] ERROR: No such command on config line 3: ip igmp 2018/10/11 09:41:01 PIM: [EC 100663304] ERROR: No such command on config line 4: ip igmp join 224.1.1.1 13.13.13.2 ^C2018/10/11 09:45:09 PIM: Terminating on signal SIGINT 2018/10/11 09:45:09 PIM: VRF Deletion: default(0) Fixes: #3161 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: list_delete_and_null() -> list_delete()David Lamparter2018-10-021-4/+4
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* Merge pull request #3040 from pacovn/static_analysis__drop_const_1Quentin Young2018-09-171-2/+2
|\ | | | | bgpd isisd ldpd lib: const drop fixes (SA)
| * bgpd isisd ldpd lib: const drop fixes (SA)F. Aragon2018-09-171-2/+2
| | | | | | | | | | | | Can be detected with e.g. ./configure CFLAGS=-Wcast-qual CC=clang Signed-off-by: F. Aragon <paco@voltanet.io>
* | *: LIB_[ERR|WARN] -> EC_LIBQuentin Young2018-09-131-1/+1
|/ | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Merge pull request #2994 from opensourcerouting/sa-warningsDonald Sharp2018-09-091-0/+1
|\ | | | | fix remaining SA warnings
| * *: fix clang-6 SA warningsDavid Lamparter2018-09-081-0/+1
| | | | | | | | | | | | | | I don't see these in CI, but my local clang-6 does emit warnings for these. Signed-off-by: David Lamparter <equinox@diac24.net>
* | fabricd: add new daemon as build of isisdChristian Franke2018-09-051-0/+3
|/ | | | | | | fabricd is built using the sources of isisd. To allow differentiation in the code, -DFABRICD=1 is added to its preprocessor flags. Signed-off-by: Christian Franke <chris@opensourcerouting.org>
* *: rename ferr_zlog -> flog_err_sysQuentin Young2018-08-141-2/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>