summaryrefslogtreecommitdiff
path: root/lib/command.c
AgeCommit message (Collapse)Author
2017-01-02lib/command.c: fix leak id'ed by valgrindLou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2016-12-20build: rename (1 of ?): configure.ac + preprocDavid Lamparter
This replaces Quagga -> FRR in most configure.ac settings as well as a handful of preprocessor macros in the source code. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-20bgpd, lib: fix a few scan-build catchesQuentin Young
Fixes a couple null pointer derefs and uninit'd values. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-18lib: Initialize ->allowrepeatQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-18lib: fix crash when tab-completing `do ...` commandsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-16lib: parser: fix SEGV when Tab hits non-WORD_TKNDavid Lamparter
If <Tab> processing finds that there is only 1 candidate, but that candidate is not a WORD_TKN that we can tab-complete on, the status would remain at CMD_COMPLETE_FULL_MATCH, but the resulting list of possible completions is empty. This then SEGVs in lib/vty.c where it tries to access the first element of the list, assuming FULL_MATCH always has 1 element there... Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Cc: Quentin Young <qlyoung@cumulusnetworks.com>
2016-12-08Merge branch 'fixes/command'David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-05*: fix up DEFUNs without install_element callsDavid Lamparter
These now generate warnings which will break the build with -Werror. Note this may have enabled commands that should be disabled, or the other way around... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-05Merge branch 'queue/osr/vtysh-generic'David Lamparter
WARNING: Merge contains nontrivial fixups in vrf_cmd handling. Conflicts: lib/if.c zebra/interface.c
2016-12-05lib: "write mem" should write to persistent configurationChristian Franke
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-12-05Merge branch 'stable/2.0'David Lamparter
Conflicts: bgpd/bgp_route.c lib/if.c ripd/rip_interface.c zebra/interface.c zebra/zebra_vty.c
2016-12-05Merge branch '-renato' into stable/2.0David Lamparter
This contains bgp memory leak fixes as well as cleanups to VRF/namespace handling and has been run through extended testing in Cumulus' testbed: Tested-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-12-01lib: remove misleading copy/del_cmd_elementDavid Lamparter
struct cmd_element items are static global variables, they are never allocated, copied or freed. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01lib: move command_parse_format prototypeDavid Lamparter
The function prototype for command_parse_format() is better left in command.h, so that the bison-generated header file doesn't need to be included for that. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01*: make DEFUN installations file-localDavid Lamparter
This moves all install_element calls into the file where the DEFUNs are located. This fixes several small related bugs: - ospf6d wasn't installing a "no interface FOO" command - zebra had a useless copy of "interface FOO" - pimd's copy of "interface FOO" was not setting qobj_index, which means "description LINE" commands would fail with an error The next commit will do the actual act of making "foo_cmd" static. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-29*: fix "uninitialized" warningsDavid Lamparter
reported by clang for: - cmd_complete_command() - show_ip_bgp_ipv4() Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-28zebra/lib: plug several memleaksRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-11-15build: fix -Wmaybe-uninitialized warningsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-12Merge branch 'cmaster-next' into vtysh-grammarQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Conflicts: lib/command.c lib/vty.c
2016-11-12lib, vtysh: Fix memory leaks, change cmd_element to constQuentin Young
Fix a few memory issues: * Not freeing tab-completions upon input match failure * Invalid write when null-terminating tab-completions * Not freeing argv[] itself in additinon to elements * Use XFREE() instead of free() as appropriate * Not freeing final token of an [option] during parsing Make a few minor changes to CLI internals: * Improve documentation on matching & completion functions * Only make one copy of cmd_token's when building argv, instead of three * Don't make a copy of the matching cmd_element Make one major(ish) change to CLI internals: * Change all pointers to struct cmd_element to const Code outside of the core CLI units should never have an occasion to modify the internal state of the command system. Doing so could easily amount to having a CLI interface that changes during runtime, and could conceivably lead to security issues. Explicitly disallowing this removes any chance of confusion. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-11-10lib: Update `list [permutations]`Quentin Young
Don't show hidden or deprecated commands. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-11-10lib: Implement hidden and deprecated commandsQuentin Young
Each token now knows whether it is part of a hidden or deprecated command. Command completion logic hides such tokens when generating completions. Command matching logic works as before and will still match on hidden and deprecated commands. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-11-10lib: add minimal no-config VTY modeDavid Lamparter
This silences the following warning from watchquagga: "Can't save to configuration file, using vtysh." which otherwise appears when doing a "write file" in vtysh when no integrated-config is in use. Also make "show memory" available in watchquagga. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-03lib: Remove node debug message on `list` outputQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-31lib: Fix segfault on erroneous commandQuentin Young
Command completion vector should only be copied if it is non-null. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-29lib: Various minor improvements & bugfixes to CLI backendQuentin Young
- Do not allow tab-completion on anything except words - Rewrite cmd_make_strvec to use strsep - Remove a few trailing whitespaces - Remove cmd_complete_command_lib Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-21Merge branch 'cmaster-next' into vtysh-grammarQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Conflicts: bgpd/bgp_encap.c bgpd/bgp_route.c lib/command.c lib/command.h ospf6d/ospf6d.c vtysh/vtysh.c
2016-10-20lib: Add helper function for working with argv, update bgpd to use itQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-20Merge branch 'cmaster-next' into vtysh-grammarQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Conflicts: isisd/isis_routemap.c zebra/rt_netlink.c
2016-10-19lib: keep hash of node's commands to detect duplicate installsPaul Jakma
* command.h: (struct cmd_node) Add a hash, so duplicate installs of a cmd_element to a command node can be detected. To help catch strays from the VIEW/ENABLE node consolidation particularly (installs to VIEW automatically install to ENABLE too now). * command.c: (cmd_hash_{key,cmp}) helpers for the hash - just directly on the pointer value is sufficient to catch the main problem. (install_node) setup the hash for the command node. (install_element) check for duplicate installs. The assert on the cmd_parse_format seems misplaced. (install_default_basic) separate the basic, VIEW, node default commands to here. (cmd_init) get rid of dupes, given consolidation. (cmd_terminate) clean up the node command hash. Not done: The (struct cmd_node)'s vector could be replaced with the cmd hash, however much of the command parser depends heavily on the vector and it's a lot of work to change. A vector_lookup_value could also work, particularly if vector could be backed by a hash. The duplicate check could be disabled in releases - but useful in development. It's a little extra overhead at startup. The command initialisation overhead is already something that bites in micro-benchmarks - makes it easy for other implementations to show how much faster they are with benchmarks where other load is low enough that startup time is a factor.
2016-10-18lib: add api method to read current config pathChristian Franke
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-10-17Merge branch 'cmaster-next' into vtysh-grammarQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com> Conflicts: bgpd/bgp_route.c bgpd/bgp_routemap.c bgpd/bgp_vty.c isisd/isis_redist.c isisd/isis_routemap.c isisd/isis_vty.c isisd/isisd.c lib/command.c lib/distribute.c lib/if.c lib/keychain.c lib/routemap.c lib/routemap.h ospf6d/ospf6_asbr.c ospf6d/ospf6_interface.c ospf6d/ospf6_neighbor.c ospf6d/ospf6_top.c ospf6d/ospf6_zebra.c ospf6d/ospf6d.c ospfd/ospf_routemap.c ospfd/ospf_vty.c ripd/rip_routemap.c ripngd/ripng_routemap.c vtysh/extract.pl.in vtysh/vtysh.c zebra/interface.c zebra/irdp_interface.c zebra/rt_netlink.c zebra/rtadv.c zebra/test_main.c zebra/zebra_routemap.c zebra/zebra_vty.c
2016-10-12lib/vtysh: fix duplicate installation of some vty commandsRenato Westphal
This is a followup to commits 735e62 and 0b1442, where we forgot to apply the same VIEW/ENABLE consolidation logic to vtysh. Also, we can't call install_default() for the ENABLE node because some of the vty commands installed by this function were already installed in the VIEW node before. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-10-07*: Consolidate all double VIEW_NODE and ENABLE_NODE'sDonald Sharp
If a command is put into the VIEW_NODE, it is going into the ENABLE_NODE as well. This is especially true for show commands. As such if a command is in both consolidate it down to VIEW_NODE. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07lib: Consolidate VIEW_NODE to be ENABLE_NODE as wellDonald Sharp
If you are in VIEW_NODE, the command should exist in ENABLE_NODE as well. This is being done to reduce chances of code being added to one but not the other NODE. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07bgpd, lib: Remove RESTRICTED_NODE from code baseDonald Sharp
The RESTRICTED_NODE command is not used, introduces code complexity and provides no additional levels of security. The only way to get into RESTRICTED_NODE is to add, under vty configuration the command 'anonymous restricted', and then telnet to a daemon, provide a password, then type 'enable' and fail to enter the password three times. Then the user can enter a very limited set of commands to monitor bgp and only bgp behavior. This commit removes both the RESTRICTED_NODE usage as well as the lib/* usage of the code Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-10-07lib: Remove `show commandtree`, add `list permutations`Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-07lib: Add naive deduplication checks when installing commandsQuentin Young
Since not all duplicate commands can be caught during graph construction, do a linear search over all commands before installing. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-07lib: add "qobj" object-ID infrastructureDavid Lamparter
This adds 64-bit random identifiers as "safe pointers" which are also type-tracked / can have type-specific extension methods. This will be used by both the CLI (to keep safe references while in config editing mode) as well as the Cap'n Proto code (to hand out pointers to the user in a safe way and add per-type handlers) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-06lib: Log invalid/unknown commands to log fileQuentin Young
Ticket: CM-6855 Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-06lib: Make <cr> appear first in completionsQuentin Young
When a command is complete and <cr> appears in tab- or ?-completions, make sure it appears first Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-05lib: Invalid commands are errors, fix msg formattingQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-04lib: Add logging for invalid commandsQuentin Young
Ticket: CM-6855 Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-04lib: fix password and enable password syntaxQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-03lib: Clean up completions code, fix segfault on no matchQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-03bgpd: add L3/L2VPN Virtual Network Control featureLou Berger
This feature adds an L3 & L2 VPN application that makes use of the VPN and Encap SAFIs. This code is currently used to support IETF NVO3 style operation. In NVO3 terminology it provides the Network Virtualization Authority (NVA) and the ability to import/export IP prefixes and MAC addresses from Network Virtualization Edges (NVEs). The code supports per-NVE tables. The NVE-NVA protocol used to communicate routing and Ethernet / Layer 2 (L2) forwarding information between NVAs and NVEs is referred to as the Remote Forwarder Protocol (RFP). OpenFlow is an example RFP. For general background on NVO3 and RFP concepts see [1]. For information on Openflow see [2]. RFPs are integrated with BGP via the RF API contained in the new "rfapi" BGP sub-directory. Currently, only a simple example RFP is included in Quagga. Developers may use this example as a starting point to integrate Quagga with an RFP of their choosing, e.g., OpenFlow. The RFAPI code also supports the ability import/export of routing information between VNC and customer edge routers (CEs) operating within a virtual network. Import/export may take place between BGP views or to the default zebera VRF. BGP, with IP VPNs and Tunnel Encapsulation, is used to distribute VPN information between NVAs. BGP based IP VPN support is defined in RFC4364, BGP/MPLS IP Virtual Private Networks (VPNs), and RFC4659, BGP-MPLS IP Virtual Private Network (VPN) Extension for IPv6 VPN . Use of both the Encapsulation Subsequent Address Family Identifier (SAFI) and the Tunnel Encapsulation Attribute, RFC5512, The BGP Encapsulation Subsequent Address Family Identifier (SAFI) and the BGP Tunnel Encapsulation Attribute, are supported. MAC address distribution does not follow any standard BGB encoding, although it was inspired by the early IETF EVPN concepts. The feature is conditionally compiled and disabled by default. Use the --enable-bgp-vnc configure option to enable. The majority of this code was authored by G. Paul Ziemba <paulz@labn.net>. [1] http://tools.ietf.org/html/draft-ietf-nvo3-nve-nva-cp-req [2] https://www.opennetworking.org/sdn-resources/technical-library Now includes changes needed to merge with cmaster-next.
2016-10-02lib: Null-terminate tab completions char*[]Quentin Young
vtysh expects the result of a tab completion to have a null pointer as the last element Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-01lib: Fix command execution npeQuentin Young
Caller may pass NULL if it does not care about what command was matched. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-30lib, vtysh: refactor vtysh.c, allow parser continuanceQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-30lib: initialize cmd_vector and add a root node to graphQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>