David Lamparter [Wed, 23 Nov 2016 08:02:08 +0000 (09:02 +0100)]
lib: parser: wrap state in struct parser_ctx
This encapsulates all parser state into a new "struct parser_ctx", which
is allocated on stack and passed around as pointer. The parser no
longer has any global variables with this.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter [Wed, 23 Nov 2016 07:42:27 +0000 (08:42 +0100)]
lib: move command_parse_format prototype
The function prototype for command_parse_format() is better left in
command.h, so that the bison-generated header file doesn't need to be
included for that.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter [Wed, 16 Nov 2016 06:00:52 +0000 (15:00 +0900)]
*: 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>
David Lamparter [Thu, 1 Dec 2016 16:18:57 +0000 (17:18 +0100)]
lib: replace MIT license with ISC
Since other parts (e.g. ldpd) use the ISC license, and the ISC license
is just a simplified form of the MIT license, just move things over and
reduce the number of different licenses we have in use here.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Renato Westphal [Mon, 28 Nov 2016 18:47:13 +0000 (16:47 -0200)]
bgpd: fix invalid memory access in peer_free()
We shoult not call bgp_unlock() before calling
bgp_delete_connected_nexthop() in the peer_free() function. Otherwise,
if bgp->lock reaches zero, bgp_free() is called and peer->bgp becomes
an invalid pointer in the bgp_delete_connected_nexthop() function.
To fix this, move the call to bgp_unlock() to the end of peer_free().
Bug exposed by commit 37d361e ("bgpd: plug several memleaks").
Signed-off-by: Renato Westphal <renato@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Donald Sharp [Thu, 1 Dec 2016 14:11:12 +0000 (09:11 -0500)]
bgpd: Fix crashes when no default bgp instance is configured.
The vnc code assumes that bgp must have a default instance.
This code change checks to make sure that we do before
proceeding. It makes no assurances that vnc will behave
correctly without a default instance.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Donald Sharp [Wed, 30 Nov 2016 13:23:12 +0000 (08:23 -0500)]
pimd: Fix large integer display of drpriority
When displaying drpriority you can enter unsigned
integer values from 1-2^32. The display was
turning the unsigned value into a signed value
and thus we were displaying the wrong value.
Ticket: CM-13787 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by: David Ahern <dsa@cumulusnetworks.com>
(cherry picked from commit db17265f1025e3ec578998ad537c33b49ed33cde) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Donald Sharp [Wed, 30 Nov 2016 13:23:11 +0000 (08:23 -0500)]
ospfd: Fix memory leak when not using json
When doing a show command under ospf, if
not using json we would have a small memory
leak in show_ip_ospf_common.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 50750712b1ac8364e290c67782eaf371025dc59e) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Daniel Walton [Tue, 29 Nov 2016 17:47:12 +0000 (12:47 -0500)]
bgpd: fix "show ip bgp" column alignment
The "Weight" column is off:
BGP table version is 0, local router ID is 10.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, =
multipath,
i internal, r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 4.1.1.2/32 9.9.9.2 0 32768 ?
*> 4.1.1.4/32 9.9.9.2 0 32768 ?
Displayed 2 out of 2 total prefixes
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
(cherry picked from commit 65c7395b07e8c592c847d4a1e22fc89ddf448341) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Ticket: CM-13712
(cherry picked from commit 367b138748e894bbfaae36d1cf7c90eafebfebc9) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter [Mon, 28 Nov 2016 17:40:25 +0000 (18:40 +0100)]
tests: update testcli reference output
These are expected changes in CLI behaviour. There's still a diff of
unexpected changes that need fixing (or are missing features, e.g.
keyword arguments).
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Renato Westphal [Thu, 24 Nov 2016 23:28:03 +0000 (21:28 -0200)]
isisd: fix loss of packets after circuit is brought up
The last parameter of THREAD_TIMER_ON() is the timeout, and we were
using circuit->fd for that. So, when a circuit was brought up, isisd
would miss all received packets on this circuit for quite a few seconds,
slowing down the convergence process.
To fix this, use the same logic we use in isis_receive() to calculate
this timeout.
This bug doesn't happen on Linux, which uses a different method to read
packets from the network.
Fixes the following ANVL tests on FreeBSD: ISIS-17.1, ISIS-18.6 (and
probably others too).
David Lamparter [Fri, 11 Nov 2016 06:23:02 +0000 (07:23 +0100)]
vtysh: fix some macro breakage
vtysh's extract.pl script doesn't cope with install_element(var, ) where
"var" is not one of the FOO_NODE constants. Also, the future defun_lex
tool doesn't deal well with preprocessor expansions in the same regard.
This tries simplifying out some of these. lib/distribute.c needs
further thinking.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter [Sat, 19 Nov 2016 09:42:52 +0000 (10:42 +0100)]
vtysh: initialise readline before binding key
when libreadline initialises itself, it also reads .inputrc, which may
result in keybindings being set up. This means the builtin help on the
'?' key can be overridden by that. Consistent availability of '?'
behaviour trumps .inputrc setup here, so let's initialise readline
first before binding that key (which means our keybinding wins).
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Quentin Young [Tue, 15 Nov 2016 22:15:18 +0000 (22:15 +0000)]
lib: Fix nondeterministic command matches in rare cases
When a user erroneously defines two commands which can
match the same input and at least one of the tokens defined
last in the command is a selector or option, the matcher
does not detect an ambiguous match and matches the command
installed first (leftmost in the graph).
Fix is to do a full walkthrough of the follow set when
matching the final token in a command to check that there
is exactly one possible match, and to throw an ambiguity
error otherwise.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
David Lamparter [Tue, 15 Nov 2016 02:18:43 +0000 (11:18 +0900)]
build: chop down complicated CFLAGS logic
Other packages don't have --with-cflags; we don't need it either. The
user can specify CFLAGS= in the environment or on ./configure and that
would work perfectly fine. If only it weren't for autoconf being an
idiot and adding its own "-g -O2" ... so we work around that.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Problem reported that in certain configs, when a router is initially
booted and the link is bounced, we can end up with a bogus static route
in the table. This was due to the assumption in zebra_rnh that a static
route would not be recursively resolved through another static route with
a different next-hop. This fix changes this assumption. Tested manually
and bgp-min, ospf-min, and vrf-min run with no new failures.
Ticket: CM-13328 Signed-off-by: Don Slice Reviewed-by: CCR-5338
Quentin Young [Sat, 12 Nov 2016 01:06:32 +0000 (01:06 +0000)]
lib, vtysh: Fix memory leaks, change cmd_element to const
Fix a few memory issues:
* Not freeing tab-completions upon input match failure
* Invalid write when null-terminating tab-completions
* Not freeing argv[] itself in additinon to elements
* Use XFREE() instead of free() as appropriate
* Not freeing final token of an [option] during parsing
Make a few minor changes to CLI internals:
* Improve documentation on matching & completion functions
* Only make one copy of cmd_token's when building argv,
instead of three
* Don't make a copy of the matching cmd_element
Make one major(ish) change to CLI internals:
* Change all pointers to struct cmd_element to const
Code outside of the core CLI units should never have an
occasion to modify the internal state of the command system.
Doing so could easily amount to having a CLI interface that
changes during runtime, and could conceivably lead to security
issues. Explicitly disallowing this removes any chance of
confusion.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Quentin Young [Thu, 10 Nov 2016 23:17:07 +0000 (23:17 +0000)]
lib: Implement hidden and deprecated commands
Each token now knows whether it is part of a hidden
or deprecated command. Command completion logic hides
such tokens when generating completions. Command
matching logic works as before and will still match on
hidden and deprecated commands.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>