Commit Graph

108 Commits

Author SHA1 Message Date
Quentin Young
1eb5e8dcd1 lib: Continue matching system refactor
Most things back to working, all CLI units refactored
to use improved graph implementation.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-07 04:05:07 +00:00
Quentin Young
9b887497e8 lib: Remove debug fprintf for cmd_element copy
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-10 19:11:31 +00:00
Quentin Young
de9d7e4f3c lib: Cleanup some memory issues in CLI
Various memory leaks have been fixed and the quagga
memory macros are in use. Also consolidated the argv
and matching code into one graph traversal.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-29 15:54:03 +00:00
Quentin Young
9d0662e009 lib: Break up functions, begin matcher
Moved test hook out of command.c into vtysh.c,
renamed graph modules, added matching code

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-19 21:14:27 +00:00
Quentin Young
04e6406218 lib: Cleanup cmd_execute_command
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-12 15:05:05 +00:00
Quentin Young
51e156b303 Add grammar sandbox framework 2016-07-12 15:05:05 +00:00
Quentin Young
d4dc41b6a2 lib: Rewrite ipv4 address and prefix validator
Simplify ipv4 prefix and address matcher / validator to use standard
Linux networking functions instead of a state machine.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-07-12 13:41:27 +00:00
Quentin Young
4d91343a45 lib: Disallow % in IPv6 addresses and prefixes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-12 13:37:34 +00:00
Quentin Young
4c58c70dcb lib: Rewrite ipv6 prefix matcher
Simplify ipv6 prefix matcher / validator to use standard Linux
networking functions instead of a state machine.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-07-12 13:33:56 +00:00
Quentin Young
490b281c00 lib: Add documentation to internal command format parser functions
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-06-23 20:00:17 +00:00
Quentin Young
c4ae17398c lib: Clean command.c
Removed dead code paths and fixed a typo.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-06-16 11:59:16 -04:00
Lou Berger
8b1fb8be22 bgpd, lib, vtysh: hook up bgp ENCAP CLI node
Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit a3fda886cdd48b6d8c421ebb1401142fa9ee93b0)

Conflicts:
	bgpd/bgp_vty.c
	bgpd/bgpd.c
	vtysh/vtysh_config.c
2016-06-11 15:52:05 -07:00
David Lamparter
c5e69a025f lib/vty: add separate output fd support to VTYs
to be used with stdin/stdout terminals, this adds support for writing to
a different FD than we're reading from.  Also fixes error messages from
config load being written to stdin.

[v2: fixed config write]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

(cherry picked from commit 4715a53b4d390e72a06c864a6a505971841e3dc9)
2016-06-08 15:08:05 -04:00
David Lamparter
dc1b72dca3 lib: assert(0) still needs a return
assert(0) is not guaranteed to not return since assert() in general can
be optimised out when building without debug / with optimisation.  This
breaks the build in clang, which warns/errors about the missing return.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit f1fc327c7eb00634d2c2b08c2a6f6e44a626ef04)
2016-06-08 15:03:13 -04:00
David Lamparter
27e7f29029 lib: fix "reduce strcmp in CLI" fallout (10bac801)
In "lib/cli: reduce strcmp in CLI hot paths", I failed to notice that
CMD_VARIABLE as a boolean test covers a superset of the other types of
variables.  Thus, the patch broke processing of IP/IPv6/Integer range
parameters in the CLI.

Fix by some reordering and introducing TERMINAL_RECORD macro (which
marks whether a given terminal type is a parameter) to be used in places
where the check is really for all kinds of variables.

Reported-by: Timo Teräs <timo.teras@iki.fi>
Tested-by: Martin Winter <mwinter@netdef.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-06-08 14:58:36 -04:00
David Lamparter
c117e02796 lib/cli: reduce strcmp in CLI hot paths
Er, no idea how anyone could ever have thought that it would be a good
idea to have a zillion of strcmp() calls in the CLI's active paths, just
to compare against things like "A.B.C.D".

Reduces 40k prefix list load time from 1.65s to 1.23s (1.34:1).

Acked-by: Paul Jakma <paul@jakma.org>
[v2: killed CMDS_* macros]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>

(cherry picked from commit 10bac80195cf5a781da6e4415e6580fd7080f734)
2016-06-08 14:35:38 -04:00
David Lamparter
c5e0075f8b *: add/cleanup initialisers
There were some (inconsequential) warnings about uninitialised use of
variables.  Also, in one case, sub-structs were mixed in initialisation,
which doesn't quite work as intended.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-06-07 08:51:46 -04:00
vivek
8ecd326693 bgpd, lib, vtysh: hook up bgp VPNv6 CLI node
Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 13c378d96a57017f5995b2e0df46cfc31123f0e8)

Conflicts:
	bgpd/bgp_vty.c
	bgpd/bgpd.c
	vtysh/vtysh_config.c
2016-06-06 19:29:05 -07:00
Lou Berger
bcd9fa7ff2 lib: add "show commandtree" CLI command
Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit f9ec4190f1eaf2dba355a9808bca8d7148bc8a55)
2016-06-06 14:57:00 -07:00
Lou Berger
cde9f10117 lib: fix bookkeeping for libreadline malloc()s
When libreadline is used, we mistakenly mix in strdup() done in
libreadline with Quagga's lib/memory bookkeeping/counting, leading to
counter underflows on MTYPE_TMP.

Signed-off-by: Lou Berger <lberger@labn.net>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 672900382d47137638086bd8351b2678f589a546)

Conflicts:
	lib/command.c
2016-06-06 14:34:42 -07:00
Donald Sharp
b06fd12526 Quagga: Fix code to use srandom/random
Quagga was using a mix of srand/rand and srandom/random.
Consolidate to use srandom/random which are the POSIX
versions of random number generators

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-05-29 20:24:55 -04:00
David Lamparter
80db5ac178 build: track config args
Record the ./configure arguments used and make them user-visible.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Acked-by: Paul Jakma <paul@jakma.org>
2016-06-03 15:53:42 -04:00
David Lamparter
12e41d03bd pimd: merge pimd as of 2015-01-19
Welcome pimd to the Quagga daemon zoo!

This is a merge of commit 77ae369 ("pimd: Log ifindex found for an
interface when zebra lib reports a new connected address."), with
the intermediate "reconnect" changes removed (c9adf00...d274381).
d274381 is replaced with b162ab7, which includes some changes.  In
addition, 4 reconnect-related changes and 1 cosmetic one have been
bumped out.

The rebase command used to produce the branch that is merged here is:
  git rebase --onto b162ab7 c9adf00 77ae369

Note that 3 patches had their author rewritten from
    "Anonymous SR#108542 <>" (which is not a valid git author ID)
to: "Savannah SR#108542 <nbahr@atcorp.com>" (which is the e-mail address
                               listed in the associated Savannah ticket)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-25 20:38:32 -04:00
Donald Sharp
1db63918b2 lib, vtysh: Return actual problem further up
When we encounter a problem loading a config file
quantify to the end user what has gone wrong,
with a combination of err output as well as
return codes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by: Dave Olson <olson@cumulusnetworks.com>
2016-04-06 20:07:27 -04:00
Donald Sharp
73d2dad0bd lib: Fix assert in node_parent()
With this sequence of commands in a conf file:
router bgp X
address-family ipv4
exit
address-family ipv6
exit

When the bgp AS # is currently configured as !X and the
'vtysh -b -f <conf file above>' command run, vtysh will
crash with an assert.

This commit fixes that issue.

Ticket: CM-9852
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-03-17 16:12:55 -04:00
Daniel Walton
abaaab4e2d vtysh: make HIDDEN commands work
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-9646
2016-03-02 19:55:32 +00:00
Donald Sharp
4d833e556a lib, vtysh: Fix 'banner motd file' command
the File to specify was inadvertently a optional parameter.
Dissallow this.

Ticket: CM-9431
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-03-01 13:12:36 -05:00
Donald Sharp
7cfc61d32e lib, vtysh: Rehook the motd command back into vtysh
Code was already in place to read and display a motd, but
no cli was present to make it happen.  Add the cli
back to vtysh.conf.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
2016-02-18 10:23:45 -05:00
Daniel Walton
41d9cc6a65 quagga: remove babel
Ticket: CM-9274
Reviewed By: sharpd@cumulusnetworks.com
Testing Done:

<DETAILED DESCRIPTION (REPLACE)>
2016-02-11 08:55:24 -08:00
Donald Sharp
19dc275e1f lib, vtysh, zebra: Better VRF debug handling
Fixup the debug handling of vrf's to be a bit
more explicit how we create a vrf internally.

Add code to turn on/off debugging of vrf's.

Ticket: CM-9063
Testing: Manual

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-03 09:00:25 -05:00
Donald Sharp
f93e3f696c lib: Allow vrf under the cli
Add the infrastructure to allow the vrf keyword.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-02-01 09:38:33 -08:00
Daniel Walton
fd715b78d9 quagga errors parsing a valid config
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2015-10-16 20:51:38 +00:00
Donald Sharp
bed578b8b9 vtysh: Fix Quagga.conf file read in.
There exists a sequence of cli commands that are successfully read in by bgpd.conf, but
not by a consolidated Quagga.conf.

This issue stems from the fact that the consolidated config file attempts to match the
current node + 1 node up the tree, while the individual config file searches for matches
all the way up the tree.

Quagga.conf read-in relies on vtysh_cmd.c command parsing which puts all nodes
at CONFIG_NODE and if a match is found CMD_SUCCESS_DAEMON is returned.  This signals to
the parser to call the appropriate daemon with the comamnd.

bgp as an example has three levels of config node's.  If you are reading in a config node
at the 3rd level(say address-family ipv6) then transition to another node under bgp it will
not work in Quagga.conf because the code only looked up one node and was at CONFIG_BGP when it failed
to find a match.

Ticket: CM-7625
Reviewed by: CCR-3591
Testing: See Bug

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
2015-09-28 13:17:36 -07:00
Steve Hill
13fbc82d86 lib: Improve error reporting from broken config files
* command.h: (config_from_file) Add variable to interface for line
      number reporting.
    * command.c: (config_from_file) Set & increment 'line_num' while parsing.
    * vty.c: (vty_read_file) Report parse errors in the correct order to
      stderr, with added line numbers.

Conflicts:
	lib/command.c
	lib/vty.c

Integrated in changes made to continue loading code even after failure
to read a line in properly as part of this cherry-pick
2015-09-01 12:44:10 -07:00
Donald Sharp
16cf945a50 Fix optional arguments with description interactions
Ticket: CM-6659
Reviewed by: CCR-3203
Testing: See bug

If you have a cli like this:
"neighbor WORD interface {v6only}"

When in the cli you hit ? after entering v6only you get this:

tor-11(config-router)# neighbor swp1 interface v6only
% There is no matched command.
tor-11(config-router)# neighbor swp1 interface v6only

With this fix we now see:
tor-22(config-router)# neighbor swp1 interface v6only
<cr>
tor-22(config-router)# neighbor swp1 interface v6only

This behavior is now consistent with non-optional last
arguments.
2015-08-26 09:01:31 -07:00
Daniel Walton
5689fe5fef Quagga processes should not die if they read an unrecognized line in
their config file

Ticket: CM-6738
Reviewed By: Donald and Dinesh
Testing Done:

<DETAILED DESCRIPTION (REPLACE)>
2015-07-27 20:30:22 -07:00
Donald Sharp
e442116524 vtysh-integrated-fix.patch
Lost config when switching back and forth between 'service integrated-vtysh-config'.
Also it was possible to have config files not be read in if they were not generated.

Ticket: CM-6011, CM-6033
Reviewed By: Daniel Walton <dwalton@cumulusnetworks.com>
Testing Done: See bugs
2015-05-20 16:55:57 -07:00
Donald Sharp
c0e8c16f84 vtysh: vtysh-warnings.patch
Remove compile warnings for the vtysh directory
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:
2015-05-19 18:29:15 -07:00
Donald Sharp
24873f0c06 lib: lib-warnings.patch
Remove compile warnings for the lib directory
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:
2015-05-19 18:04:26 -07:00
Donald Sharp
f702c39f46 "set metric -10" is not accepted by the parser on 64-bit x86 platforms 2015-05-19 17:58:11 -07:00
David Lamparter
6b0655a251 *: nuke ^L (page feed)
Quagga sources have inherited a slew of Page Feed (^L, \xC) characters
from ancient history.  Among other things, these break patchwork's
XML-RPC API because \xC is not a valid character in XML documents.

Nuke them from high orbit.

Patches can be adapted simply by:
	sed -e 's%^L%%' -i filename.patch
(you can type page feeds in some environments with Ctrl-V Ctrl-L)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-06-04 06:58:02 +02:00
Christian Franke
cd40b329a2 lib/command.c: rewrite command matching/parsing
Add support for keyword commands.

Includes new documentation for DEFUN() in lib/command.h, for preexisting
features as well as new keyword specification.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2014-04-01 20:21:41 +02:00
David Lamparter
0be793e674 build: include git info
If enabled with --with-pkg-gitversion on ./configure, this will append
git version strings and branch information at the following places:
 - overall version number: 0.99.21-g0123456
 - login motd and show version: tag information + git id + branches

Sample output:
  Hello, this is Quagga (version 0.99.21-g14b49ad-dirty).
  Copyright 1996-2005 Kunihiro Ishiguro, et al.

  This is a git build of quagga_0_99_21_release-106-g14b49ad-dirty
  Associated branch(es):
	local:master

[v2]: fix build without gitinfo (add "else" branch)
[v2]: fix for repos without any tags (different git describe output)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-12-12 15:34:37 +01:00
David Lamparter
aa5cf24b9d lib: make IPv6 prefix parser slightly more strict
This makes it possible to have both "show babel route A.B.C.D/M"
and "show babel route X:X::X:X/M" commands at the same time without
the parser complaining about ambiguity.

* lib/command.c: only accept STATE_DOT after : was seen.

Reported-by: Juliusz Chroboczek <jch@pps.jussieu.fr>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-07-19 16:15:50 +02:00
Roman Hoog Antink
7c9c6aebe8 lib: drop heuristic IPv6 address recognition
* command.c: (cmd_ipv6_match) Drop IPv6 address recognition
  heuristics and solely rely on inet_pton, because strings
  like "abcd" were mistaken for IPv6 addresses.
  This affects e.g. the command "neighbour WORD peer-group",
  which won't work with words consisting of up to 4 characters
  between 'a' and 'f' and digits.

From: Roman Hoog Antink <rha@open.ch>
[full delete instead of #if 0]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2012-05-21 15:41:14 +02:00
Paul Jakma
5734509c05 babeld: Initial import, for Babel routing protocol.
* Initial import of the Babel routing protocol, ported to Quagga.
* LICENCE: Update the original LICENCE file to include all known potentially
  applicable copyright claims.  Ask that any future contributors to babeld/
  grant MIT/X11 licence to their work.
* *.{c,h}: Add GPL headers, in according with the SFLC guidance on
  dealing with potentially mixed GPL/other licensed work, at:

  https://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
2012-03-25 17:06:51 +01:00
Denis Ovsienko
b82cdeb18f delete CVS keywords 2011-09-27 21:34:26 +04:00
Christian Hammers
fc95186c30 lib: fix more format warnings (#637)
The following patch was also neccessary to compile.

* command.c: (config_logmsg_cmd) use "%s" format spec
* if.c: (connected_log) ditto
2011-03-23 13:07:55 +03:00
Paul Jakma
e276eb8282 lib: Add a command to clear the thread CPU history data
* (general) this can be useful when investigating thread latency problems,
  when you don't want to have to restart a daemon between tests.
* thread.c: (cpu_record_(hash_)clear) wipe the stored thread cpu history
  data, according to the filter, similar to the vty print code.
  (clear_thread_cpu_cmd) new command to clear data.
* thread.h: export new command
* command.c: install it
2010-12-08 16:53:09 +00:00
Stephen Hemminger
2d362d1099 lib: make some structures constant
* isisd/isis_pdu.c
  * maskbit: this pre-initialized array is not modified
* lib/prefix.c
  * maskbit: idem
* lib/command.c
  * facility_map: idem
  * itoa64: idem
  * default_motd: make local var static
  * facility_name(): update local var accordingly
  * facility_match(): idem
2009-12-21 13:03:51 +03:00