Commit Graph

133 Commits

Author SHA1 Message Date
Daniel Walton
67656e9b65 all: added CHECK ME for DEFUNs that look at argc
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-29 17:48:57 +00:00
Daniel Walton
199d90a10e Expand #defines in command strings
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-25 16:49:39 +00:00
Daniel Walton
3ce54f7812 Expand #defines in command strings
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
Reviewed-by:   Sam Tannous <stannous@cumulusnetworks.com>

Ticket:
2016-09-25 14:22:48 +00:00
Daniel Walton
9ccf14f739 Expand #defines in command strings
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-25 14:10:48 +00:00
Quentin Young
d862bffbda lib: lib compiles
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-23 21:34:33 +00:00
Daniel Walton
c349116d7c lib: add 'int idx_foo' argv index variables
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 20:17:29 +00:00
Quentin Young
f667a580b7 lib: Implement removed ALIAS into DEFUN
N.B.: some of these are de-facto ALIAS resurrections
that are necessary due to some parser limitations; these
are marked with ALIAS_FIXME so I can go back and add
capability to the parser to handle these special cases.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-23 20:08:47 +00:00
Daniel Walton
6147e2c694 convert <1-255> to (1-255), ()s to <>s, etc
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 13:47:20 +00:00
Daniel Walton
f412b39a33 ALIAS removal for bgp, ospf, pim, isis, rip, ripng, lib and zebra
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-23 03:55:26 +00:00
Quentin Young
97e5b7c0b3 lib: argv fixes, XFREE -> free, rm decl in matcher
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-22 20:26:07 +00:00
Daniel Walton
e4123a9bb5 Revert "lib: Fixup more files"
This reverts commit f68cec764a.
2016-09-22 18:22:50 +00:00
Donald Sharp
f68cec764a lib: Fixup more files 2016-09-20 22:26:30 -04:00
Quentin Young
9547b5d072 lib: Update copyright headers
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-21 23:55:29 +00:00
Donald Sharp
460a768914 Merge remote-tracking branch 'origin/cmaster-next' into vtysh-grammar 2016-09-20 21:17:34 -04:00
Quentin Young
844ec28cee Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	lib/.gitignore
	lib/command.c
	lib/command.h
2016-09-21 22:11:53 +00:00
Quentin Young
d0bfb22c22 lib: Initial refactor pass on CLI backend
Shotgun commit:
* Remove shim sources from Makefile.am
* Move new types to command.c / command.h
* Rewrite command.c / command.h
* Refactor shim types to real types in matcher
  and parser
* Initial refactor pass on vty.c

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-19 23:46:51 +00:00
David Lamparter
4a1ab8e405 *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEs
This is a rather large mechanical commit that splits up the memory types
defined in lib/memtypes.c and distributes them into *_memory.[ch] files
in the individual daemons.

The zebra change is slightly annoying because there is no nice place to
put the #include "zebra_memory.h" statement.

bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the
library for its own use.  This is bad practice and would break when the
memtype are made static.

Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
[CF: rebased for cmaster-next]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-09-19 16:31:04 -04:00
Quentin Young
039dc61292 lib: Fix tab completions memleak, memory stats corruption
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-09 21:58:33 +00:00
Feng Lu
13460c44a2 lib, vtysh: support multiple VRFs by using linux netns
We realize VRFs with linux netns by default. The main job is
to associate a VRF with a netns. Currently this is done by
the configuration:

  [no] vrf N netns <netns-name>

This command is also available in vtysh and goes to only
zebra, because presently only zebra supports multiple VRF.

A file descriptor is added to "struct vrf". This is for the
associated netns file. Once the command "vrf N netns NAME"
is executed, the specified file is opened and the file
descriptor is stored in the VRF N. In this way the
association is formed.

In vrf_socket(), we first switch to the specified VRF by
using the stored file descriptor, and then can allocate
a socket which is working in the associated netns.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
(cherry picked from commit 55cfa2f190620f7c711944637659bc208970324d)
2016-09-09 12:15:14 -04:00
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
Olivier Dugeon
16f1b9ee29 Update Traffic Engineering Support for OSPFD
NOTE: I am squashing several commits together because they
do not independently compile and we need this ability to
do any type of sane testing on the patches.  Since this
series builds together I am doing this. -DBS

This new structure is the basis to get new link parameters for
Traffic Engineering from Zebra/interface layer to OSPFD and ISISD
for the support of Traffic Engineering

* lib/if.[c,h]: link parameters struture and get/set functions
* lib/command.[c,h]: creation of a new link-node
* lib/zclient.[c,h]: modification to the ZBUS message to convey the
link parameters structure
* lib/zebra.h: New ZBUS message

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add support for IEEE 754 format

* lib/stream.[c,h]: Add stream_get{f,d} and stream_put{f,d}) demux and muxers to
  safely convert between big-endian IEEE-754 single and double binary
  format, as used in IETF RFCs, and C99.  Implementation depends on host
  using __STDC_IEC_559__, which should be everything we care about.  Should
  correctly error out otherwise.
* lib/network.[c,h]: Add ntohf and htonf converter
* lib/memtypes.c: Add new memeory type for Traffic Engineering support

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add link parameters support to Zebra

* zebra/interface.c:
   - Add new link-params CLI commands
   - Add new functions to set/get link parameters for interface
* zebra/redistribute.[c,h]: Add new function to propagate link parameters
to routing daemon (essentially OSPFD and ISISD) for Traffic Engineering.
* zebra/redistribute_null.c: Add new function
zebra_interface_parameters_update()
* zebra/zserv.[c,h]: Add new functions to send link parameters

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Add support of new link-params CLI to vtysh

In vtysh_config.c/vtysh_config_parse_line(), it is not possible to continue
to use the ordered version for adding line i.e. config_add_line_uniq() to print
Interface CLI commands as it completely break the new LINK_PARAMS_NODE.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

Update Traffic Engineering support for OSPFD

These patches update original code to RFC3630 (OSPF-TE) and add support of
RFC5392 (Inter-AS v2) & RFC7471 (TE metric extensions) and partial support
of RFC6827 (ASON - GMPLS).

* ospfd/ospf_dump.[c,h]: Add new dump functions for Traffic Engineering
* ospfd/ospf_opaque.[c,h]: Add new TLV code points for RFC5392
* ospfd/ospf_packet.c: Update checking of OSPF_OPTION
* ospfd/ospf_vty.[c,h]: Update ospf_str2area_id
* ospfd/ospf_zebra.c: Add new function ospf_interface_link_params() to get
Link Parameters information from the interface to populate Traffic Engineering
metrics
* ospfd/ospfd.[c,h]: Update OSPF_OPTION flags (T -> MT and new DN)
* ospfd/ospf_te.[c,h]: Major modifications to update the code to new
link parameters structure and new RFCs

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>

tmp
2016-09-03 11:05:50 -04:00
Sid Khot
c05795b16b Fix for CM-12450 Ensure quagga logs at startup are sent to syslog (until log configuration is processed)
Ticket: CM-12450
Reviewed By: CCR-5112
Testing Done: Manual
2016-08-17 19:36:54 -07: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
Donald Sharp
daa2bc7068 lib: 'show commandtree' is not a CLI command
The 'show commandtree' command was added to the CONFIG_NODE.

We have a basic assumption that CONFIG_NODE commands actually
change state.  'show commandtree' doesn't meet this requirement.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-07-28 14:02:52 -04:00
David Lamparter
fbfa889168 Revert "lib: Rewrite ipv4 address and prefix validator"
This reverts commit d4dc41b6a2.

The rewritten parser fails to recognise "1.2." as partial input for an
IPv4 address, which causes "make check" to fail.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-07-24 03:47:04 -04:00
Don Slice
c9a42b3d91 lib: Free memory correctly when braces used in parser
When braces (optional parameters) are used in the quagga parser, there
was a small leak on every iteration.  Since this construct is primarily
used in the configuation process rather than show commands, it was not
readily apparent.  With the addition of the "show ip bgp {json}" form of
the commands, each time one was run, memory was leaked.

Ticket: CM-11435
Signed-off-by: Don Slice
Reviewed By: Donald Sharp
Testing Done: Manual testing, bgp-min and bgp-smoke successful
2016-07-26 12:32:53 -07:00
Donald Sharp
1ee08155da lib: Modify 'banner motd file <X>'
Modify the banner motd file X command to do these things
differently:

1)  Only allow the file <X> to be in SYSCONFDIR
2)  Only allow the user to use a file that exists.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
2016-07-22 19:50:51 -04: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