summaryrefslogtreecommitdiffstats
path: root/lib/vty.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* bgpd lib ospfd pimd ripngd: null chk (PVS-Studio)F. Aragon2018-07-031-7/+9
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* lib: Add ability to know if we have read anything inDonald Sharp2018-06-191-2/+8
| | | | | | | | When reading the config file add an ability to know if we have properly read in anything. So that a daemon can make fallback plans. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* lib: null dereference (Coverity 1469895)paco2018-06-111-3/+5
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* lib: fix output mangling with | includeQuentin Young2018-06-061-25/+59
| | | | | | | | | | | | | | | 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>
* lib: initialize vty->ofQuentin Young2018-06-061-0/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: add vector_compact(), use after str splitsQuentin Young2018-06-061-0/+1
| | | | | | | | | * 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>
* lib: fix static analysis issues, use regfree()Quentin Young2018-06-061-3/+21
| | | | | | | | | | | * 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>
* *: style for | supportQuentin Young2018-06-061-0/+1
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* vtysh: add | supportQuentin Young2018-06-061-70/+75
| | | | | | | | | | | * 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>
* lib: add cli preprocessor for `|` actionsQuentin Young2018-06-061-11/+51
| | | | | | | | | | 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>
* pbrd: Add PBR to FRRDonald Sharp2018-04-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* lib: remove MASC_NODEQuentin Young2018-03-301-2/+0
| | | | | | Unused Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: use C99 standard fixed-width integer typesQuentin Young2018-03-271-5/+5
| | | | | | | | | | | | | | | | | | | | | | 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>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-14/+17
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* lib, pimd: Remove PIM_NODE as it is not neededDonald Sharp2018-01-301-2/+0
| | | | | | | | 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>
* lib: Fix non-integrated config error displayDonald Sharp2017-10-261-0/+15
| | | | | | | | | | 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>
* *: fix styleQuentin Young2017-08-301-4/+2
| | | | | | Fixes style nits introduced by recent pull requests. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Merge pull request #1056 from opensourcerouting/oldbits-0Donald Sharp2017-08-291-0/+24
|\ | | | | "pathspace" options, vtysh-suid-cleanups, "vty_frame()"
| * lib: add vty_frame() to get rid of unneeded configDavid Lamparter2017-08-291-0/+24
| | | | | | | | | | | | | | | | | | 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>
* | lib: new APIs for get/set system hostname/domainnameMitesh Kanjariya2017-08-291-1/+1
| | | | | | | | | | | | | | | | | | 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>
* | lib/bgpd: provide/use API to get hostname/domainnameMitesh Kanjariya2017-08-251-9/+2
|/ | | | Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* Merge pull request #892 from opensourcerouting/watchfrr-simplifyDonald Sharp2017-08-091-53/+87
|\ | | | | simplify watchfrr, add --terminal, improve startup logging
| * lib: replace stderr with zlog in vty config loadDavid Lamparter2017-08-021-28/+20
| | | | | | | | | | | | | | | | | | | | 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>
| * lib: vty_stdio signal handlingDavid Lamparter2017-08-021-25/+67
| | | | | | | | | | | | | | | | - 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>
* | zebra: add support for static pseudowiresRenato Westphal2017-08-091-0/+2
| | | | | | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* | lib: vty: fix config-write fd leakDavid Lamparter2017-08-041-13/+20
|/ | | | | | | | | | | 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>
* Revert "*: reindent pt. 2"David Lamparter2017-07-221-3/+1
| | | | | | | | | 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>
* *: reindent pt. 2whitespace / reindent2017-07-171-1/+3
| | | | | | | | w/ clang 5 * reflow comments * struct members go 1 per line * binpack algo was adjusted
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-2415/+2228
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attrDonald Sharp2017-07-141-92/+73
|\
| * lib, vtysh: remove now-useless newline argDavid Lamparter2017-07-141-1/+1
| | | | | | | | | | | | It's always \n now, hooray. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * Merge remote-tracking branch 'frr/master' into newline-reduxDavid Lamparter2017-07-141-9/+5
| |\ | | | | | | | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * \ Merge remote-tracking branch 'frr/master' into newline-reduxDavid Lamparter2017-07-141-3/+3
| |\ \ | | | | | | | | | | | | | | | | | | | | Lots of conflicts from CMD_WARNING_CONFIG_FAILED... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * | | *: remove VTYNL, part 4 of 6David Lamparter2017-07-141-5/+5
| | | | | | | | | | | | | | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * | | *: remove VTYNL, part 3 of 6David Lamparter2017-07-141-3/+2
| | | | | | | | | | | | | | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * | | *: remove VTYNL, part 2 of 6David Lamparter2017-07-141-1/+1
| | | | | | | | | | | | | | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * | | *: remove VTYNL, part 1 of 6David Lamparter2017-07-141-10/+10
| | | | | | | | | | | | | | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * | | *: ditch vty_outln(), part 2 of 2David Lamparter2017-07-141-2/+2
| | | | | | | | | | | | | | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * | | *: ditch vty_outln(), part 1 of 2David Lamparter2017-07-131-35/+35
| | | | | | | | | | | | | | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
| * | | lib: move \n vs. \r\n handling into vty codeDavid Lamparter2017-07-131-37/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | | Merge remote-tracking branch 'origin/master' into evpn_plus_struct_attrDonald Sharp2017-07-141-12/+8
|\ \ \ \ | | |_|/ | |/| |
| * | | Merge pull request #808 from qlyoung/vtysh-termcolsRuss White2017-07-141-9/+5
| |\ \ \ | | |_|/ | |/| | lib, vtysh: pretty-print variable autocompletions
| | * | lib, vtysh: pretty-print variable autocompletionsQuentin Young2017-07-131-9/+5
| | |/ | | | | | | | | | | | | | | | | | | | | | 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>
| * | vtysh: return non-zero for configuration failuresDaniel Walton2017-07-131-2/+2
| | | | | | | | | | | | | | | | | | | | | 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.
| * | lib: Change comment to reference watchfrrJafar Al-Gharaibeh2017-07-121-1/+1
| |/ | | | | | | Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
* / bgpd: Additional configuration for EVPNvivek2017-07-121-0/+1
|/ | | | | | | | | 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>
* lib: fix vty_out with >1024 bytes of outputDavid Lamparter2017-07-061-2/+4
| | | | | | | | 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>
* *: vty_outln (vty, "") --> vty_out (vty, VTYNL)Quentin Young2017-06-291-10/+10
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: s/VTY_NEWLINE/VTYNL/gQuentin Young2017-06-291-8/+8
| | | | | | Should be able to fit more vty_out onto one line now Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: use vty_outlnQuentin Young2017-06-291-59/+56
| | | | | | Saves 400 lines Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>