David Lamparter [Thu, 26 Jan 2017 04:59:50 +0000 (05:59 +0100)]
lib: graph: fix vector_remove()
vector_remove would corrupt the data in the following sequence:
1. assume vector v = [a, b], active = 2
2. vector_unset(v, 0) => v = [NULL, b], active = 2
3. vector_remove(v, 1)
vector_remove calls vector_unset(v, 1), vector_unset notices index #0 is
also NULL and thus sets active to 0.
The equality test in vector_remove() now fails, leading it to decrement
v->active *again*, leading to an underflow that will likely crash the
daemon (and might even be exploitable).
This call sequence does not happen in existing code since vector_unset()
is not used on graph from/to lists. Nonetheless this is a buried land
mine in the code at best.
Rewrite the function - while we're at it, there's no reason to move the
entire array around, just fill the hole with the last element.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Cc: Quentin Young <qlyoung@cumulusnetworks.com>
David Lamparter [Wed, 25 Jan 2017 03:13:14 +0000 (04:13 +0100)]
lib: graph: fix deletions
Iterating over an array while deleting items needs to consider
interactions between the iteration position and deletion. The previous
code completely ignored that problem, leading to memleaks (graph_delete
skipping half of the nodes) and dangling pointers (if parallel edges
exist in graph_remove_edge).
Iterating backwards is safe and reduces "move to fill hole" overhead in
deletion.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Cc: Quentin Young <qlyoung@cumulusnetworks.com>
David Lamparter [Wed, 25 Jan 2017 21:33:29 +0000 (22:33 +0100)]
bgpd: lcommunity: fix minor issues
- route_set_lcommunity would do nothing (and leak memory) if attr->extra
wasn't up yet
- an if() arch in bgp_show_table() was duplicated (with no effect)
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Donald Sharp [Wed, 25 Jan 2017 13:26:21 +0000 (08:26 -0500)]
bgpd: Add ability to clean lcommunity hash
Ensure that we don't leak any memory on shutdown.
Since the bgp_lcommunity.c file mirrors bgp_ecommunity.c
Add the same code for shutdown that ecommunity has.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
... which means that there are 2 distinct MTYPE_CMD_TOKENS.
(The description text being different does not matter, even with the
same text it'd be 2 distinct types.)
command_match.c allocates token->arg in command_match_r() while
command.c frees it in del_cmd_token(). Therefore with each command
being executed, the allocation count goes up on one, down on the other.
=> clean up parser allocation counting. Also, use separate MTYPEs for
the different fields in struct cmd_token.
Fixes: #108 / ee9216cf ("lib, ripngd: clean up merge leftovers") Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Cc: Quentin Young <qlyoung@cumulusnetworks.com>
David Lamparter [Sat, 17 Dec 2016 06:32:58 +0000 (07:32 +0100)]
lib: parser: add error location reporting
flex+bison have nice capabilities to track the location that is
currently being processed; let's enable these and get better warnings
for broken CLI specs.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter [Sat, 17 Dec 2016 04:25:36 +0000 (05:25 +0100)]
lib: parser: unify subgraphs & simplify even more
This cuts a large piece of complexity from the parser by making the
sequences between | the same, no matter whether it's <> () or [].
This causes some changes in behaviour:
- [foo|bar] is now accepted
- <foo|[bar]> is now accepted (yes it's stupid)
- {a|b} is now means "at least one of these, in any order"; to allow
zero use [{a|b}] instead.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter [Sat, 17 Dec 2016 04:14:49 +0000 (05:14 +0100)]
lib: parser: keep subgraph pointers on stack
There's no need to malloc() these, we can just keep them on the stack.
The entire struct will get copied around, but replacing a 2-pointer copy
with a 1-pointer copy + malloc + free overhead is not quite efficient.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Donald Sharp [Fri, 20 Jan 2017 15:43:08 +0000 (10:43 -0500)]
bgpd: Fix cli for large-communities
The original commit for large communities broke
'show ip bgp' and 'show bgp ipv4 unicast' and
their ilk. This commit fixes this as well
as some vtysh parse errors identified.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Quentin Young [Thu, 19 Jan 2017 17:07:39 +0000 (17:07 +0000)]
lib: guard strict cli completions
Completions are checked for token and docstring equality before
deduplicating. Put an ifdef guard around checking docstrings because
many of them are inconsistent and may confuse users in a release build.
It is a good idea to enable VTYSH_DEBUG when adding new CLI in the
future to help check docstrings.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Donald Sharp [Thu, 19 Jan 2017 14:58:53 +0000 (09:58 -0500)]
pimd: PIM_MRT is a linux specific piece of code.
The PIM_MRT and registration for WRVIFWHOLECACHE
is a bit of linux specific code. Until such
time that this gets implemented we will have
issues being able to work within the context
of PIM-SM.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Job Snijders [Tue, 15 Nov 2016 10:00:39 +0000 (19:00 +0900)]
Support for BGP Large Communities
BGP Large Communities are a novel way to signal information between
networks. An example of a Large Community is: "2914:65400:38016". Large
BGP Communities are composed of three 4-byte integers, separated by a
colon. This is easy to remember and accommodates advanced routing
policies in relation to 4-Byte ASNs.
This feature was developed by:
Keyur Patel <keyur@arrcus.com> (Arrcus, Inc.),
Job Snijders <job@ntt.net> (NTT Communications),
David Lamparter <equinox@opensourcerouting.org>
and Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Job Snijders <job@ntt.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
David Lamparter [Wed, 18 Jan 2017 17:01:53 +0000 (18:01 +0100)]
build: include copy of pkg.m4, fix invocation
pkg.m4 will be missing on systems that don't have pkg-config installed;
this renders the point of the configure check moot which is to find
pkg-config...
Also, PKG_PROG_PKG_CONFIG should be invoked unconditionally as described
in https://autotools.io/pkgconfig/pkg_check_modules.html
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Philippe Guibert [Wed, 18 Jan 2017 11:27:52 +0000 (12:27 +0100)]
bgpd: add define of compilation for vpn commands
Use KEEP_OLD_VPN_COMMANDS define to brace some vty commands used by bgp
to configure or show vpnvx contexts using old method, that is to say
using vty keyword vpnv4 or vpnv6 command.
In addition to this, the commit adds two new commands under route-map
with new format:
[no] set ipv4|ipv6 vpn nexthop <IPv4 Address> | <IPv6 Address>
It also add following command in old format:
[no] set vpnv6 nexthop <IPv6 Address>
Note that the commit does not take into account the availability of old
commands that are not available in new format.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com
This configure applies for BGP and keeps old for vpnv4/vpnv6
configuration and exploitation commands.
If not used, this old style vty commands will not be included.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Donald Sharp [Wed, 18 Jan 2017 03:01:36 +0000 (22:01 -0500)]
zebra: Allow the collection of sg stats on more platforms.
The code to collect the sg stats was written for linux.
Abstract the call to allow it to work on all platforms.
I have not implemented the call for non-linux systems.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
vivek [Fri, 11 Nov 2016 02:49:43 +0000 (18:49 -0800)]
zebra: Perform safe walk of RIB entries in rib_process()
There is a scenario where a RIB entry is unlinked and freed during RIB
processing. However, the walk of the entries is not being performed in
a safe manner. Fix the code to do this correctly.
Donald Sharp [Thu, 10 Nov 2016 18:58:40 +0000 (13:58 -0500)]
lib: Slight Optimization of thread handling.
This commit does these things:
1) Make thread_add_unuse own the setting of THREAD_UNUSED.
2) Move thread->hist finding to to thread_get.
We are storing the thread->hist even when the thread
is on the unused. This means that we check to see
if the funcname or func have changed and we get new
history. Else we've probably just retrieved the last
unused which has the same func/funcanme. This is
a common practice to do THREAD_OFF/THREAD_ON in
quick succession.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.