Commit Graph

143 Commits

Author SHA1 Message Date
David Lamparter
6de469061b lib: rework vty_use_backup_config()
Like config_write(), this should use rename(), even though atomicity is
not a real issue here.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-10 15:04:40 +01:00
David Lamparter
148781210f lib: fix remaining coverity issues
Reported-by: Coverity
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-10 15:04:06 +01:00
David Lamparter
056cfe496e lib: use fsync() for config writes, plug fd leak
sync() has a HUGE impact on systems that perform actual I/O, i.e. real
servers...

Also, we were leaking a fd on each config write ever since
c5e69a0 "lib/vty: add separate output fd support to VTYs"
(by myself :( ...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-09 12:54:25 +01:00
David Lamparter
fa02c492fa Merge branch 'frr/pull/152' ("Lib fixes")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-02-07 15:48:46 +01:00
Donald Sharp
1a35e2e565 Merge remote-tracking branch 'origin/stable/2.0' 2017-02-02 10:42:51 -05:00
Donald Sharp
3d217741c3 lib: Properly Initialize code
was_stdio was never set up with a 'correct'
initial value, leading to cases where
we would choose what to do based upon
what was in the stack.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-02-01 19:49:48 -05:00
David Lamparter
dd03f8cae1 lib: move at_close call in vty_stdio to end
Since the at_close call for the stdio vty might exit() the process, move
it to the end of the function, after freeing all memory.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-31 15:28:39 +01:00
David Lamparter
66d29a54a1 lib: clean up tab-completion memory counting
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-31 15:28:19 +01:00
Martin Winter
38657f2ebd lib: Don't change uid/gid if we are already the correct uid/gid
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
2017-01-26 00:45:05 +07:00
Lou Berger
5ff06872e9 bgpd: add vrf-policy config using existing vnc code
add add/clear vrf prefix
      + Modified for FRR master parser

Signed-off-by: Lou Berger <lberger@labn.net>
2017-01-22 20:54:57 -05:00
Quentin Young
88e5a8cbe1 lib: additional patch for 496e83a
Fixes a couple off-by-ones introduced in previous commit.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
[cherry-picked from master d1e4a518e6]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-18 17:15:12 +01:00
Quentin Young
d1e4a518e6 lib: additional patch for 496e83a
Fixes a couple off-by-ones introduced in previous commit.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-01-18 06:12:08 +00:00
Donald Sharp
9aa7f43f7e Merge branch 'master' into cleanup 2017-01-13 14:48:16 -05:00
Quentin Young
78af6edc6c lib: limit size of vty buffer to 4096 bytes
This removes the automatic resizing of the vty input buffer and places a
hard size cap of 4096 bytes. It also fixes a potentially unsafe strcpy.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
[cherry-picked from master 2af38873d8]
2017-01-13 14:37:40 +01:00
Donald Sharp
56c1f7d852 frr: Remove HAVE_IPV6 from code base
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-13 08:05:50 -05:00
Quentin Young
2af38873d8 lib: limit size of vty buffer to 4096 bytes
This removes the automatic resizing of the vty input buffer and places a
hard size cap of 4096 bytes. It also fixes a potentially unsafe strcpy.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-01-10 23:33:50 +00:00
Donald Sharp
3b14d86eed Merge remote-tracking branch 'origin/stable/2.0' 2017-01-06 09:58:21 -05:00
Donald Sharp
9473e34052 watchfrr: Rename watchquagga -> watchfrr
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-01-03 20:13:02 -05:00
David Lamparter
0b84f29490 *: make DEFUN installations file-local
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-12-01 17:25:56 +01:00
David Lamparter
745e2754ef lib: temporary-catch a SEGV in command completion
Getting FULL_MATCH with matched[0] == NULL in tests/testcli.  Catch and
print error for now.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-28 18:41:34 +01:00
David Lamparter
82992fed8c Merge branch 'vtysh-grammar'
Conflicts:
	isisd/isisd.c
	lib/Makefile.am
	lib/thread.c

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-28 17:56:29 +01:00
David Lamparter
c5d9d3bb36 lib: replace strlcpy & strlcat with glibc versions
It seems these two were at some point copied in from rsync; replace with
more recent versions that will hopefully become available in glibc as
well.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-15 17:35:36 +09:00
Quentin Young
07321a065d Merge branch 'cmaster-next' into vtysh-grammar
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>

Conflicts:
	lib/command.c
	lib/vty.c
2016-11-12 05:17:37 +00:00
David Lamparter
95c4aff294 watchquagga: add "write integrated"
This new command - available for internal use by vtysh and explicit
usage by users - calls "vtysh -w" from watchquagga.  This ensures vtysh
is run with privileges to actually write the integrated-config file.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-09 14:29:39 +01:00
David Lamparter
2da59394ec lib: add and use set_cloexec()
watchquagga is already leaking an open file descriptor on its pid file
on fork+exec() invocations; next up is adding vtysh support with even
more fds.  Mark things CLOEXEC before going there.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-11-09 13:40:05 +01:00
Quentin Young
ebacb4edce lib: Various minor improvements & bugfixes to CLI backend
- 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-29 04:43:04 +00:00
Quentin Young
e52702f29d Merge branch 'cmaster-next' into vtysh-grammar
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-17 23:36:21 +00:00
Donald Sharp
0b1442e37b *: Consolidate all double VIEW_NODE and ENABLE_NODE's
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-07 21:05:06 -04:00
Donald Sharp
3c8ab49fd1 bgpd, lib: Remove RESTRICTED_NODE from code base
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-07 21:05:06 -04:00
David Lamparter
cc933ef9f6 lib, isisd: enable concurrent configuration editing
Finally, this disables the config editing lock for isisd.  It also
enables deprecation warnings for the lib/ and isisd/ to catch accidental
uses of vty->index.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-10-07 09:09:52 -04:00
Quentin Young
cbd7259d95 lib: Log invalid/unknown commands to log file
Ticket: CM-6855

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-06 18:39:31 +00:00
Lou Berger
65efcfce42 bgpd: add L3/L2VPN Virtual Network Control feature
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-03 08:17:02 -04:00
Daniel Walton
58749582a9 all: scrubbed some argc CHECK MEs
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-30 00:16:31 +00:00
Daniel Walton
abddf07563 all: scrubbed some argc CHECK MEs
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-29 19:51:56 +00:00
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
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
Renato Westphal
eac6e3f027 ldpd: adapt the code for Quagga
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-23 09:31:09 -04: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
aa1c90a487 lib: distribute.c, smux.c, vty.c grammar refactor
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-22 20:17:48 +00:00
Daniel Walton
bf2bfafd7e ospfd: argv update for all but ospf_vty.c
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2016-09-22 19:15:24 +00:00
Daniel Walton
7e347cbe16 Revert "lib: Fix vty.c to compile with new parser"
This reverts commit c1ad0838e8.
2016-09-22 18:23:14 +00:00
Donald Sharp
c1ad0838e8 lib: Fix vty.c to compile with new parser 2016-09-20 21:49:32 -04:00
Donald Sharp
460a768914 Merge remote-tracking branch 'origin/cmaster-next' into vtysh-grammar 2016-09-20 21:17:34 -04: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
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
Lou Berger
da688ecdde lib: change command logging to be off by default, and add 'log_commands' to enable it. 2016-06-09 11:04:21 -04:00
Lou Berger
1035065f2a lib: add facility to log all CLI commands
Signed-off-by: Lou Berger <lberger@labn.net>
(cherry picked from commit c7f7e49a4f68c92152384582ff70d64609858170)
2016-06-09 11:01:34 -04:00
Timo Teräs
40ee54a740 lib: allow caller to provide prefix storage in sockunion2hostprefix
Avoids a dynamic allocation which is usually freed immediate afterwards.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-06-09 08:21:40 -04:00