summaryrefslogtreecommitdiff
path: root/lib/vty.c
AgeCommit message (Collapse)Author
2018-06-06lib: fix output mangling with | includeQuentin Young
Sometimes output would be mangled when filtering with include as a result of the following bugs: * Filters were applied per each call to vty_out() instead of buffering until a line break and then applying * Long output would sometimes be cut due to using the wrong buffer pointer Also remove the trailing \n as it should no longer be necessary to ensure the vty prompt ends up on a new line. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06lib: initialize vty->ofQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06lib: add vector_compact(), use after str splitsQuentin Young
* Add function to move all data to the start of a vector by shifting over contiguous empty slots * Use this function to remove empty slots leftover after frrstr_filter_vec Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06lib: fix static analysis issues, use regfree()Quentin Young
* Fix potential NULL dereference * Fix use of uninitialized value * Fix leaking memory by not freeing regex_t * Fix extra \n when using empty regex filter * Clean up still-reachable hook memory * Handle nonexistent pager Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06*: style for | supportQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06vtysh: add | supportQuentin Young
* Rewrite pager implementation * Replace fprintf() with vty_out() * Modify vty_out() for better vtysh support * Remove static global outputfile var * Remove fp argument from many vtysh functions * Add some docs for stuff along the way Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-06-06lib: add cli preprocessor for `|` actionsQuentin Young
This patch adds a CLI preprocessor function that activates when `|` is found in the command. This is the start of adding support for some text processing utilities intended for inline use. The first one implemented here is `| include`, which provides grep-like filtering of command output. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-06pbrd: Add PBR to FRRDonald Sharp
This is an implementation of PBR for FRR. This implemenation uses a combination of rules and tables to determine how packets will flow. PBR introduces a new concept of 'nexthop-groups' to specify a group of nexthops that will be used for ecmp. Nexthop-groups are specified on the cli via: nexthop-group DONNA nexthop 192.168.208.1 nexthop 192.168.209.1 nexthop 192.168.210.1 ! PBR sees the nexthop-group and installs these as a default route with these nexthops starting at table 10000 robot# show pbr nexthop-groups Nexthop-Group: DONNA Table: 10001 Valid: 1 Installed: 1 Valid: 1 nexthop 192.168.209.1 Valid: 1 nexthop 192.168.210.1 Valid: 1 nexthop 192.168.208.1 I have also introduced the ability to specify a table in a 'show ip route table XXX' to see the specified tables. robot# show ip route table 10001 Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, F - PBR, > - selected route, * - FIB route F>* 0.0.0.0/0 [0/0] via 192.168.208.1, enp0s8, 00:14:25 * via 192.168.209.1, enp0s9, 00:14:25 * via 192.168.210.1, enp0s10, 00:14:25 PBR tracks PBR-MAPS via the pbr-map command: ! pbr-map EVA seq 10 match src-ip 4.3.4.0/24 set nexthop-group DONNA ! pbr-map EVA seq 20 match dst-ip 4.3.5.0/24 set nexthop-group DONNA ! pbr-maps can have 'match src-ip <prefix>' and 'match dst-ip <prefix>' to affect decisions about incoming packets. Additionally if you only have one nexthop to use for a pbr-map you do not need to setup a nexthop-group and can specify 'set nexthop XXXX'. To apply the pbr-map to an incoming interface you do this: interface enp0s10 pbr-policy EVA ! When a pbr-map is applied to interfaces it can be installed into the kernel as a rule: [sharpd@robot frr1]$ ip rule show 0: from all lookup local 309: from 4.3.4.0/24 iif enp0s10 lookup 10001 319: from all to 4.3.5.0/24 iif enp0s10 lookup 10001 1000: from all lookup [l3mdev-table] 32766: from all lookup main 32767: from all lookup default [sharpd@robot frr1]$ ip route show table 10001 default proto pbr metric 20 nexthop via 192.168.208.1 dev enp0s8 weight 1 nexthop via 192.168.209.1 dev enp0s9 weight 1 nexthop via 192.168.210.1 dev enp0s10 weight 1 The linux kernel now will use the rules and tables to properly apply these policies. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: Don Slice <dslice@cumulusnetworks.com> Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-30lib: remove MASC_NODEQuentin Young
Unused Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-06*: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger
Signed-off-by: Lou Berger <lberger@labn.net>
2018-01-30lib, pimd: Remove PIM_NODE as it is not neededDonald Sharp
The PIM_NODE command is only being used to display default vrf configuration. Move this into the vrf display and remove PIM_NODE. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-25lib: Fix non-integrated config error displayDonald Sharp
When using a non-integrated config and starting up of a protocol daemon, we were not properly handling all possible cases and as such when an user hit an actual error they were getting (null) listed for the message string. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-30*: fix styleQuentin Young
Fixes style nits introduced by recent pull requests. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-29Merge pull request #1056 from opensourcerouting/oldbits-0Donald Sharp
"pathspace" options, vtysh-suid-cleanups, "vty_frame()"
2017-08-29lib: add vty_frame() to get rid of unneeded configDavid Lamparter
vty_frame() can be used to reduce the amount of output produced by "show running-config" and "write ...". It buffers output in struct vty->frame (1024 bytes) and outputs it when vty_out is called. If vty_out isn't called, it can be removed with vty_endframe() later. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-28lib: new APIs for get/set system hostname/domainnameMitesh Kanjariya
1. Change hostname_get to cmd_hostname_get 2. Change domainname_get to cmd_domainname_get 3. New API to set domainname 3. Provide a CLI command to set domainname Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-24lib/bgpd: provide/use API to get hostname/domainnameMitesh Kanjariya
Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
2017-08-09Merge pull request #892 from opensourcerouting/watchfrr-simplifyDonald Sharp
simplify watchfrr, add --terminal, improve startup logging
2017-08-09zebra: add support for static pseudowiresRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-04lib: vty: fix config-write fd leakDavid Lamparter
Since we were only setting vty->wfd in config_write, vty->fd would remain 0 and vty_close() wouldn't close vty->wfd. Clean up the entire fd closing and make it more explicit. We were even trying to write to stdin... Reported-by: Jorge Boncompte <jbonor@gmail.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02lib: replace stderr with zlog in vty config loadDavid Lamparter
Now that the logging hole is plugged, we can just print config-loading errors to the log. This has 2 hidden advantages: - vty_read_config calls in SIGHUP don't print errors to /dev/null - errors are consistently printed to syslog on --enable-cumulus Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-08-02lib: vty_stdio signal handlingDavid Lamparter
- SIGTSTP appropriately suspends the foreground terminal - SIGINT causes the daemon to exit, regardless of -d - SIGQUIT causes the daemon to daemonize, regardless of -d Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-22Revert "*: reindent pt. 2"David Lamparter
This reverts commit c14777c6bfd0a446c85243d3a9835054a259c276. clang 5 is not widely available enough for people to indent with. This is particularly problematic when rebasing/adjusting branches. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindent pt. 2whitespace / reindent
w/ clang 5 * reflow comments * struct members go 1 per line * binpack algo was adjusted
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attrDonald Sharp
2017-07-14Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attrDonald Sharp
2017-07-14lib, vtysh: remove now-useless newline argDavid Lamparter
It's always \n now, hooray. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14Merge remote-tracking branch 'frr/master' into newline-reduxDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14Merge pull request #808 from qlyoung/vtysh-termcolsRuss White
lib, vtysh: pretty-print variable autocompletions
2017-07-14Merge remote-tracking branch 'frr/master' into newline-reduxDavid Lamparter
Lots of conflicts from CMD_WARNING_CONFIG_FAILED... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14*: remove VTYNL, part 4 of 6David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14*: remove VTYNL, part 3 of 6David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14*: remove VTYNL, part 2 of 6David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14*: remove VTYNL, part 1 of 6David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14*: ditch vty_outln(), part 2 of 2David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13vtysh: return non-zero for configuration failuresDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> This allows frr-reload.py (or anything else that scripts via vtysh) to know if the vtysh command worked or hit an error.
2017-07-13*: ditch vty_outln(), part 1 of 2David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13lib: move \n vs. \r\n handling into vty codeDavid Lamparter
Instead of having an ?: expression embedded in every single caller of vty_out, just expand \n to \r\n in the vty code if neccessary. (Deprecation warnings will be enabled in the next commits which will do the search-and-replace over the codebase.) [This reverts commit 4d5f445 "lib: add vty_outln()"] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-13lib, vtysh: pretty-print variable autocompletionsQuentin Young
Pretty-prints variable autocompletions by breaking them up into multiple lines, indenting them consistently and respecting the column width of the terminal. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-12bgpd: Additional configuration for EVPNvivek
Implement configuration options for EVPN. The configuration options include VNI configuration with RD and Import and Export Route Targets. Also, display the EVPN configuration. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-07-12lib: Change comment to reference watchfrrJafar Al-Gharaibeh
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2017-07-06lib: fix vty_out with >1024 bytes of outputDavid Lamparter
Consuming va_args modifies its internal bits, hence the need to copy it... but the copying wasn't quite right just yet. Fixes: 4d5f445 ("lib: add vty_outln()") Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-29*: vty_outln (vty, "") --> vty_out (vty, VTYNL)Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29*: s/VTY_NEWLINE/VTYNL/gQuentin Young
Should be able to fit more vty_out onto one line now Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29*: use vty_outlnQuentin Young
Saves 400 lines Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-29lib: add vty_outln()Quentin Young
Like *.println() in some other unspeakable languages Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-21lib: actually exit when asked to do soQuentin Young
When vtysh sends 'exit' to a daemon, we set the vty->status to VTY_CLOSE but never actually close the connection. Lovely. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-06-16ldpd: convert cli and get rid of the xml interfaceRenato Westphal
The xml2cli.pl script was useful years ago when the vty code was very rudimentary. This is not the case anymore, so convert all ldpd CLI commands to use DEFUNs directly and get rid of the XML interface. The benefits are: * Consistency with the other daemons; * One less build dependency (the LibXML perl module); * Easier to add new commands. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>