Donald Sharp [Wed, 7 Mar 2018 16:39:56 +0000 (11:39 -0500)]
*: Make code use a consisten definition of labels
Turns out we had 3 different ways to define labels
all of them overlapping with the same meanings.
Consolidate to 1. This one choosen is consistent
naming wise with what the *bsd and linux kernels
use.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Quentin Young [Tue, 6 Mar 2018 18:42:53 +0000 (13:42 -0500)]
ospfd: cancel SR thread at shutdown
Otherwise if it is scheduled the thread pointer will be accessed after
the shutdown task finishes accessing, having deleted the structure that
owns said pointer, which causes a heap UAF.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Quentin Young [Wed, 21 Feb 2018 17:01:34 +0000 (12:01 -0500)]
bgpd: fix incorrect keepalive timer evaluation
Incorrect check for sentinel value effectively caused peers to sometimes
use the keepalive timer value of other peers, which sometimes led to
hold timer expiry.
Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
Olivier Dugeon [Fri, 9 Feb 2018 11:13:07 +0000 (12:13 +0100)]
ospfd: Fix ospfd crash
- ospfd/ospf_opaque.c: Update issue #1652 by introducing a new
function 'free_opaque_info_owner()' to clean list of callback owner
and call this function in appropriate place where 'listdelete_and_null'
is not used.
- ospfd/ospf_packet.c: In case of crash, ospfd is not been able to
flush LSA. In case of self Opaque LSA, when restarting, ospfd crash
during the resynchronisation process with its neighbor due to an
empty list of LSA to flood. Just add a control on the list count
in 'ospf_ls_upd_queue_send()' to escape the function and avoid the
problem.
Olivier Dugeon [Fri, 9 Feb 2018 11:06:35 +0000 (12:06 +0100)]
ospfd: Add json output for Segment Routing
- To ease checking the Segment Routing conformity in topotest,
add json output to 'show ip ospf database segment-routing' CLI.
- Update ospfd user guide accordingly
- Update OSPF-SR documentation with supported features and interoperability
Olivier Dugeon [Mon, 19 Feb 2018 09:17:41 +0000 (10:17 +0100)]
OSPFD: Fix Segment Routing Lan Adjacency TLVs
- Lan Adjacency TLVs was incorrectly formatted due to an error in
TLV size computation. Add new macro to fix this issue
- Update SR link nexthop when it corresponds to an LAN Adj SID. The nexthop
is set to the router id in the TLVi (as per draft), but we need the neighbor
IP address to set the corresponding MPLS LFIB entry
Olivier Dugeon [Mon, 5 Feb 2018 19:24:17 +0000 (20:24 +0100)]
OSPFd: Fix Opaque LSA filtering in Segment Routing
Opaque LSA were incorrectly filtered. LSA Type 1 with a
router id set to 4.x.x.x or 7.x.x.x. or 8.x.x.x are not correctly
filtered and pass to Segment Routing as wrong Opaque LSA of type
Router Information, Extended Prefix respectively Extended Link.
- Add Opaque LSA check to the filter
The CLI command 'segment-routing prefix' didn't check if a same prefix
already exist in SRDB resulting to multiple entries in the SRDB for the
same prefix.
- Update prefix intead of adding a new one if already present in the SRDB
Olivier Dugeon [Sat, 3 Feb 2018 18:30:33 +0000 (19:30 +0100)]
OSPFd: Fix ospfd crash during CI
When preforming CI test, CLI command 'no router ospf' followed by a
'router ospf' is performed to clean up the previous configuration.
Ospfd crash when configuring 'netwoark area'.
This is due to opsf_opaque_term() introduce in previous commit that cause this
crash. It remove not only Opaque LSA but also the list through the call to
'list_delete_and_null()' function. Same take place in 'ospf_mpls_te_term()',
'ospf_router_info_term()' and 'ospf_ext_term()' function.
New set of 'ospf_XXX_finish()' has been introduced to solve this issue while
keeping the possiblity to terminate properly the Opaque LSA and remove MPLS
LFIB entries set by Segment Routing.
Donald Sharp [Sat, 3 Feb 2018 00:26:22 +0000 (19:26 -0500)]
bgpd: Add ability to see martian next-hop's for a vrf
We've run across an issue where the local connected
ip address is not being removed in some error condition.
During trackdown it was noticed that we cannot look
at this table for views/vrf's. While we don't have the
bug tracked down yet this will help us figure it out.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Renato Westphal [Fri, 2 Feb 2018 01:18:46 +0000 (23:18 -0200)]
lib: fix more warnings on *BSD
* zebra/kernel_socket.c: include "rt.h" to provide the prototypes of
kernel_init() and kernel_terminate();
* lib/prefix.h: remove the deprecation warning whenever ETHER_ADDR_LEN
is used. isisd uses the ETHER_HDR_LEN constant which is defined in
terms of ETHER_ADDR_LEN in the *BSD system headers. So, when building
FRR on *BSD, we were getting several warnings because we were using
ETHER_ADDR_LEN indirectly;
* lib/command_lex.l, lib/defun_lex.l: ignore other harmless warnings;
* lib/spf_backoff.c: cast 'tv->tv_usec' to 'long int' before printing.
Renato Westphal [Thu, 1 Feb 2018 23:04:03 +0000 (21:04 -0200)]
tests: fix warnings related to afi/safi constants
We were improperly mixing constants used to identify AFI/SAFI values
using the IANA and internal representations. Things happened to be
working because the IANA/internal values are the same in some cases
(e.g. AFI_IP and IANA_AFI_IPV4). This commit fixes a few warnings when
running "make check" on FreeBSD 11.1.
Renato Westphal [Thu, 1 Feb 2018 22:59:08 +0000 (20:59 -0200)]
tests: fix warnings by removing dead code
These variables being removed were made obsolete by commit 9cabb64b3. As
of now, the parse_test() function fetches the afi/safi values from
the parsed NLRIs. There's no need to have duplicate information in the
'test_segment' structure anymore.
This fixes several warnings of this kind when running "make check"
on FreeBSD: "implicit conversion from enumeration type 'iana_safi_t'
to different enumeration type 'safi_t'".
Olivier Dugeon [Thu, 1 Feb 2018 13:30:34 +0000 (14:30 +0100)]
OSPFd: Correct Extended Prefix LSA refresh
- When Extended Prefix LSA need to be refresh, paramaters may be
taken from the wrong interface i.e. Extended Link instead of Prefix
resulting in producing an empty LSA body. Then, ospfd crash due to the
assert on LSA length in ospf_lsa_different() function: code check that
the LSA size is larger than LSA header i.e. LSA is not empty.
Olivier Dugeon [Tue, 30 Jan 2018 15:17:54 +0000 (16:17 +0100)]
OSPFd: Clean up Segment Routing patch
- ospfd/ospf_te.c: Remove unregister function and call to
ospf_delete_opaque_functab() following the introduction of
ospf_opaque_term() function in ospfd.c for ospfd termination.
- ospfd/ospf_sr.c: Set initial index value for node-msd CLI to
avaoid crash when using this command
- ospfd/ospf_ext.c: Disable call to ospf_sr_update_prefix() if
Segment Routing, thus Extended Link/Prefix, is not enable
- ospfd/ospf_opaque.c: Correct scheduling of Opaque LSA flooding
Don Slice [Thu, 25 Jan 2018 16:06:27 +0000 (16:06 +0000)]
bgpd: fix output of show bgp vrf all neighbor x.x.x.x
Problem reported with output of the command "show bgp vrf all
neighbor x.x.x.x" not limiting the output to that peer in any vrf.
This fix corrects the logic to display by neighbor
(ipv4/ipv6/interface) in any vrf.
Ticket: CM-17377 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Donald Sharp [Mon, 29 Jan 2018 22:52:15 +0000 (17:52 -0500)]
zebra: Fix crash when dereferencing dest->selected_fib
When a rib_unlink() event is directly called for a
route_entry we need to see if the dest->selected_fib
is the same and just unset the dest->selected_fib.
This was happening for redistributed table 10 routes
into BGP.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp [Mon, 29 Jan 2018 21:20:41 +0000 (16:20 -0500)]
zebra: On shutdown actually delete rn's assoc w/ other_tables
Zebra stores routes coming from the kernel for non-default
tables. This information on shutdown was being leaked
because we never cleaned it up. Allow for this to happen
now.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Olivier Dugeon [Mon, 29 Jan 2018 16:58:53 +0000 (17:58 +0100)]
OSPFd: Update Segment Routing PR following review
Following various review, following files have been modfied:
- All: Change u_intXX_t typedef to standard uintXX_t types
- doc/OSPF-SR.rst: Update doc in particular the Linux Kernel configuration
section
- doc/ospfd.texi: Update CLI
- ospfd/ospf_dump.[c,h]: Add new 'debug ospf sr' when performing 'sh run'
- ospfd/ospf_ext.[c, h]: Various bug corrections notably to handle flooding of
Extended Prefix at startup. iFix TLVs size for LAN Adjacency.
Update Licence as per Community.md
- ospfd/ospf_opaque.c: Add proper termination function call to remove MPLS entries
- ospfd/ospf_ri.[c,h]: Bug corrections
- ospfd/ospf_sr.[c,h]: Various bug corrections, notably to determine the nexthop
SR Node. Add support to 'no-php-flag'.
Update Licence as per Community.md
- ospfd/ospfd.c: Add call to 'ospf_opaque_term()'
Donald Sharp [Sat, 27 Jan 2018 23:56:30 +0000 (18:56 -0500)]
zebra: Fix failure to parse src
If src happens to point at all 0's due to not initializing
it and if the address passed in is not a v6 address then
we would not set src in the AF_INET6 call and would
fail the (src.ipv4.s_addr && inet_pton(AF_INET...)
call. Thus causing us to return a NULL and make
the routemap code think there was an issue.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Don Slice [Thu, 25 Jan 2018 17:45:40 +0000 (17:45 +0000)]
bgpd: remove poorly located bestpath json output
The bestpath multipath-relax setting was added to the output of
"show ip bgp neighbor json" several months ago but this is not
the correct place to display that information and this fix removes
it from there. The multipath-relax setting was also added
to the output of "show ip bgp sum json" which is fine.
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
Donald Sharp [Thu, 25 Jan 2018 01:53:40 +0000 (20:53 -0500)]
zebra: Fix crash in ptm code
The code change to switch from stream_getX to STREAM_GETX added
a goto statement to be handled for a failure case. The failure
case was properly handled but the normal case was not tested
properly and there exists a situation where we would free
the out_ctxt 2 times. Prevent that from happening.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Quentin Young [Wed, 24 Jan 2018 16:07:27 +0000 (11:07 -0500)]
bgpd: update pthreads to use lib changes
Use the new threading facilities provided in lib/ to streamline the
threads used in bgpd. In particular, all of the lifecycle code has been
removed from the I/O thread and replaced with the default loop. Did not
do the same to the keepalives thread as it is much smaller (doesn't need
the event system).
Also cleaned up some comments to match the style guide.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Quentin Young [Mon, 22 Jan 2018 19:23:55 +0000 (14:23 -0500)]
lib: streamline frr_pthreads, add default loop
Some work on FRR's pthread wrapper.
* Provide a built-in way to synchronize thread startup
* Make utility functions take frr_pthread * instead of its integer ID
* Pass frr_pthread * as pthread start function argument
* Correct some comment styling
* Rename some variables to match naming conventions in the file
* Change parameter ordering in stop function prototype to follow the
convention in the other functions
* Default new frr_pthreads to using a vanilla event loop
For the last point, the original goal when designing the implementation
of pthreads into FRR was to be able to use the thread.c event based
system inside pthreads. This code essentially encapuslates all the
thread.c functionality into an easy to use pthread out of the box.
Creating a new frr_pthread with a null attributes field will cause the
created frr_pthread to run a thread.c event loop. The upshot of this is
that it is now possible to safely run existing functions in a pthread in
roughly 3 lines of code. It also serves as an example / starting point
for others.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Donald Sharp [Wed, 24 Jan 2018 13:22:57 +0000 (08:22 -0500)]
zebra: Modify southbound interface to pass `struct route_node`
The route_node that we are working on is going to be interesting
to the kernel_route_rib_pass_fail. So I am setting up the
code to allow me to pass it. This will be done in a subsuquent
commit.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
If a BGP message header fails validation we send a BGP NOTIFICATION from
the I/O thread. At this time we clear the output buffer, push a
NOTIFICATION and then call the manual write function for errors. But in
between the push and the write the main thread could have pushed some
other message. Thus we need to hold the lock for the duration of the
function. TOCTTOU.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Olivier Dugeon [Tue, 23 Jan 2018 15:15:58 +0000 (16:15 +0100)]
OSPFD: Solve Issue #1652
Issue 1652 was related to OSPF Crash on termination when ospf is
configured to flood self Opaque LSA e.g TE or RI Opaque LSA.
Analysis:
The problem resides in free_opaque_info_per_type() line 576 of
ospf_opaque.c. Once LSA flush, the function removes by calling
listnode_delete() function the opaque_info_per_type data structure.
However, this is also performed at the upper level function
ospf_opaque_type10lsa_term() which call list_delete_and_null() function.
This result into a double free pointer exception.
Solution:
Remove call to listnode_delete() calls in free_opaque_info_per_type()
function as it is done by list_delete_and_null(). Delete lines 592 - 615.
Remove also second call to ospf_opaque_type10lsa_term() in ospfd.c line 848.