Quentin Young [Thu, 15 Jun 2017 19:10:57 +0000 (19:10 +0000)]
lib: make `show thread...` commands mt-aware
This patch fixes up show thread commands so that they know about
and operate on all extant thread_masters, since we can now have multiple
running in any given application.
This change also eliminates a heap use after free that appears when
using a single cpu_record shared among multiple threads. Since struct
thread's have pointers to bits of memory that are freed when the global
statistics hash table is freed, later accesses are invalid. By moving
the stats hash to be unique to each thread_master this problem is
sidestepped.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Quentin Young [Thu, 29 Jun 2017 23:05:36 +0000 (23:05 +0000)]
lib: always use 64-bit integers for json
json-c does not (yet) offer support for unsigned integer types, and
furthermore, the docs state that all integers are stored internally as
64-bit. So there's never a case in which we would want to limit,
implicitly or otherwise, the range of an integer when adding it to a
json object.
Among other things this fixes the display of ASN values greater than
(1/2) * (2^32 - 1)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Donald Sharp [Thu, 29 Jun 2017 13:09:23 +0000 (09:09 -0400)]
bgpd, lib, zebra: Fix if_update function to represent what it does
The if_update function was taking the interface name as
input and reapplying it, using strncpy to reapply the name.
This has several issues. strncpy should not be used
to copy memory in place. The second issue is that
the interface name is not actually changing when we
update interface to be in the new vrf.
Since every usage of if_update was just reapplying the same
name the interface actually had, just remove that part of
the function and rename it to if_update_to_new_vrf
to represent what it is actually doing.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
ospfd: Bring in some OSPF useful changes that were lost during Quagga fork
Several changes were made from the original patch to resolve conflicts
and also to fix various issues that were discovered during testing. Below
is the original commit message minus a few parts that correspond to code
that was dropped during bug fixing.
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
ospfd: Extend 'ip ospf area' to take address argument + rationalise ospf enable
* ospfd.c: (general) Clean up the whole running of OSPF on interfaces.
(add_ospf_interface) taking (struct interface *) arg is pointless here.
(ospf_is_ready) new helper.
(ospf_network_run_subnet) Put all the code for choosing whether to enable
OSPF on a subnet, and if so which area configuration to use, here. If a
subnet should not be enabled, ensure an existing oi is freed.
(ospf_network_run_interface) Just call run_subnet for all subnets on an
interface.
(ospf_network_run) Just call run_interface for all interfaces.
(ospf_if_update) Just call run_interface for the given interface.
(ospf_network_unset) Just call run_subnet for existing ois.
(ospf_update_interface_area) helper: update area on an oi, or create it.
(ospf_interface_set) renamed to ospf_interface_area_set for clarity.
Ensures OSPF is created, then into if_update.
(ospf_interface_unset) renamed to ospf_interface_area_unset and collapses
down to simple loop to call run_subnet for all ois.
* ospf_interface.h: add a more general OSPF_IF_PARAM_IS_SET, which does the
right thing and takes default config into account.
* doc/ospfd.texi: add 'ip ospf area' command.
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
This patch has been part of Quagga since October 2015
Orignial Author: Paul Jakma <paul@quagga.net>
Date: Thu Aug 27 16:51:42 2009 +0100
Don Slice [Wed, 28 Jun 2017 18:53:27 +0000 (14:53 -0400)]
lib/ospf/eigrp: enable ospf and eigrp to use more specific network statements
Issue reported that a configuration commonly used on other routing implementations
fails in frr. If under ospf, "network 172.16.1.1/32 area 0" or under eigrp, "network
172.16.1.1/32" is entered, the appropriate interfaces are not included in the routing
protocol. This was because the code was calling prefix_match, which did not match if
the network statement had a longer mask than the interface being matched. This fix
takes away that restriction by creating a "lib/prefix_match_network_statement" function
which doesn't care about the mask of the interface. Manual testing shows both ospf and
eigrp now can be defined with more specific network statements.
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Martin Winter [Wed, 28 Jun 2017 02:49:38 +0000 (19:49 -0700)]
redhat: On CentOS/RedHat 6, use python27-devel from iuscommunity.org
FRR requires now Python 2.7 development libraries, but CentOS 6
does not provide this (not in main and not in EPEL library)
This is only a build limitation.
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
Don Slice [Thu, 22 Jun 2017 16:17:24 +0000 (09:17 -0700)]
ospf6d: fix ifmtu settings when kernel changes values
Problem reported by customer that if an mtu value was set in the kernel,
quagga/frr would get very confused about what had been configured and
what had been learned. This caused peers to not be successfully established.
Resolved by keeping a configuration value separate than the operational value
and set the operational accordingly. If configured, it wins unless the config
defines a value that is higher than the kernel supports.
Ticket: CM-16876 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed By: CCR-6399
Testing Done: Manual testing successful, submitter tested, ospf-smoke completed
with no new failures.
Quentin Young [Tue, 20 Jun 2017 23:56:50 +0000 (23:56 +0000)]
*: simplify log message lookup
log.c provides functionality for associating a constant (typically a
protocol constant) with a string and finding the string given the
constant. However this is highly delicate code that is extremely prone
to stack overflows and off-by-one's due to requiring the developer to
always remember to update the array size constant and to do so correctly
which, as shown by example, is never a good idea.b
The original goal of this code was to try to implement lookups in O(1)
time without a linear search through the message array. Since this code
is used 99% of the time for debugs, it's worth the 5-6 additional cmp's
worst case if it means we avoid explitable bugs due to oversights...
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Quentin Young [Fri, 16 Jun 2017 22:43:56 +0000 (22:43 +0000)]
ospfd: fix route-map brokenness
ospf redefines the standard route map commands which causes ambiguity
issues in the CLI parser, it also uses a signed integer to hold an
unsigned quantity leading to weirdness when specifying metrics larger
than 2,147,483,647
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Donald Sharp [Fri, 16 Jun 2017 21:40:17 +0000 (17:40 -0400)]
lib: Fix ordering of RB Tree
So the *bsd implementations of RB Tree's for older
platforms use a macro implementation. New platforms
have converted to a function implementation that uses
a different calling parameter list. So when
we attempt to build FRR on older *bsd implementations
the macro's and functions do not interact too well.
As a workaround put the openbsd-tree.h #include
inside of zebra.h at a point before the particular
platforms version is included. Since we use
the same #if guard for the header we should be ok.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Quentin Young [Wed, 14 Jun 2017 17:06:10 +0000 (17:06 +0000)]
lib: tighten up exit semantics for thread_fetch()
* Account for the pipe poker in poll() by explicitly returning NULL when
we have no events, timers or file descriptors to work with
* Add a comment explaining exactly what we are doing and why
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Quentin Young [Fri, 9 Jun 2017 03:40:27 +0000 (03:40 +0000)]
lib: mt-safe cancel, round deux
* Update pollfds copy as well as the original
* Keep array count for copy in thread_master
* Remove last remnants of POLLHUP in .events field
* Remove unused snmpcount (lolwut)
* Improve docs
* Add missing do_thread_cancel() call in thread_cancel_event()
* Change thread_fetch() to always enter poll() to avoid starving i/o
* Remember to free up cancel_req when destroying thread_master
* Fix dereference of null pointer
* Fix dead store to timeval
* Fix missing condition for condition variable :-)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Quentin Young [Wed, 7 Jun 2017 20:34:09 +0000 (20:34 +0000)]
lib: add mt-safe thread_cancel
This patch implements an MT-safe version of thread_cancel() in
thread_cancel_async(). Behavior as follows:
* Cancellation requests are queued into a list
* Cancellation requests made from the same pthread as the thread_master
owner are serviced immediately (thread_cancel())
* Cancellation requests made from a separate pthread are queued and the
call blocks on a condition variable until the owning pthread services
the request, at which point the condition variable is signaled and
execution continues (thread_cancel_async())
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Quentin Young [Fri, 16 Jun 2017 18:03:34 +0000 (18:03 +0000)]
bgpd: fix misc cli ranges & config writes
* Ranges for some MED were 2^32 - 2 instead of 2^32 - 1
* Use correct printf specifiers for unsigned values
* Some drive-by CLI collapsing and simplification
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Renato Westphal [Mon, 12 Jun 2017 14:39:12 +0000 (11:39 -0300)]
ldpd: convert cli and get rid of the xml interface
The xml2cli.pl script was useful years ago when the vty code was very
rudimentary. This is not the case anymore, so convert all ldpd CLI
commands to use DEFUNs directly and get rid of the XML interface.
The benefits are:
* Consistency with the other daemons;
* One less build dependency (the LibXML perl module);
* Easier to add new commands.
Quentin Young [Wed, 14 Jun 2017 19:47:14 +0000 (19:47 +0000)]
lib: allow 'do' commands in ENABLE_NODE
'do' is syntax sugar that allows the user to execute a command under
ENABLE_NODE when in another CLI node. If the user is already in
ENABLE_NODE, use of 'do' was previously disallowed. This patch allows it
because it makes it easier for us to hack around certain instances of
the node synchronization problem with vtysh.
Also included is a fix for one of these problems.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Rafael Zalamena [Fri, 16 Jun 2017 13:44:31 +0000 (10:44 -0300)]
lib: improve the RB implementation
Switch the RB tree implementation completely to the new dlg@'s version
that uses pre-declared functions instead of macros for tree functions.
Original e-mail/diff:
https://marc.info/?l=openbsd-tech&m=147087487111068&w=2
Pros:
* Reduces the amount of code that the usage of those macros generate
* Allows the compiler to do a better compile-time check job
* Might have better i-cache utilization since the tree code is shared
Con:
* dlg@ benchmarks shows it has 'very slightly slower' insertions
* imported RB_* code must adapt the following calls:
RB_INIT(), RB_GENERATE(), RB_ROOT(), RB_EMPTY(), make compare
functions use 'const' (if not already) and maybe others.