Quentin Young [Wed, 22 Aug 2018 20:05:04 +0000 (20:05 +0000)]
bgpd: fix rpki exit command
If a command returns a nonzero exit status and VTYSH has a corresponding
command, VTYSH will skip executing its own version. If this happens in a
command that changes CLI nodes we get node desynchronization.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Donald Sharp [Thu, 23 Aug 2018 00:59:46 +0000 (20:59 -0400)]
lib: Limit depth of unused thread list
The master->unused list was unbounded during normal operation.
A full BGP feed on my machine left 11k threads on the unused
list, taking up over 2mb of data. This seemed a bit excessive,
reduce to a limit of 10.
Also fix a crash that this exposed where we assumed that a thread
structure was not deleted.
Future committers can make this configurable? or modify
the value to something better for their system. I am
dubious of the value of this.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp [Thu, 16 Aug 2018 17:59:27 +0000 (13:59 -0400)]
lib: Remove default case statement from a enum driven switch
We are using a enum to drive a switch statement and we have
a default case statement that can never be entered because
we know all the enum states have been covered. Remove it
from the code as that it cannot happen.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp [Thu, 16 Aug 2018 17:51:13 +0000 (13:51 -0400)]
lib: Remove smux option for snmp
The smux.c code has not been able to compile for 2+ years
and no-one has noticed. Additionally net-snmp has marked
smux integration as deprecated for quite some time as well.
Since no-one has noticed and it's been broken and smux integration
is deprecated let's just remove this from the code base.
From looking at the code, it sure looks like SNMP could use
a decent cleanup.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp [Thu, 16 Aug 2018 16:21:25 +0000 (12:21 -0400)]
bgpd: convert zlog_warns to debugs or errors
Several zlog_warns were being used to tell the end
user that bgp had detected a bug. These all look like information
added during development that can be noted as debugs or logged
as an error situation.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp [Thu, 23 Aug 2018 01:05:29 +0000 (21:05 -0400)]
lib: Seperate out Poll data from thread memory statistics
We were storing Poll data for the read and write
memory information in MTYPE_THREAD, so a show run
would not be able to show actual amount of memory
associated with the `struct thread`.
Remove unnecessary NULL checks on malloc.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Chirag Shah [Fri, 17 Aug 2018 20:38:06 +0000 (13:38 -0700)]
zebra: mark router flag for remote neigh update
Handle Remote Neigh entry state change from Router to Host.
Remote MAC-IP update may not continue EVPN NA Extended community,
Zebra need to accomodate if router_flag change for existing neigh
and install with or without Router Flag (R-bit).
Testing:
Have locally run MAC/IP (neigh entry) with R-bit set,
Checke on remote VTEP 'show bgp evpn route ...mac ip' and
'show evpn arp-cache ...' contians router flag.
Change host to remove R-bit, which locally learnt entry removes
Router flag. This results in remote vtep to remove R-bit from
neigh entry.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Chirag Shah [Wed, 15 Aug 2018 20:32:03 +0000 (13:32 -0700)]
zebra: check router_flag change for neigh update
Neigh update can have router_flag change, from unset to set and
viceversa. This is the case where MAC, IP and VLAN are same but
entry's flag moved from R to not R bit and reverse case.
Router flag change needs to trigger bgpd to inform all evpn peers
to remove from the evpn route.
Testing Done:
Send GARP with and without R bit from host and validate neigh entry
and evpn neigh and mac-ip route entry in zebra and bgpd.
Check Peer VTEP evpn route entry where router flag is (un)set.
With R-bit
Route [2]:[0]:[0]:[48]:[00:1f:2f:db:45:a6]:[128]:[2006:33:33:2::10]
VNI 1001
Imported from
27.0.0.16:5:[2]:[0]:[0]:[48]:[00:1f:2f:db:45:a6]:[128]:[2006:33:33:2::10]
4435 5551
27.0.0.16 from MSP1(uplink-1) (27.0.0.9)
Origin IGP, valid, external, bestpath-from-AS 4435, best
Extended Community: RT:5551:1001 ET:8 ND:Router
Flag
AddPath ID: RX 0, TX 1261
Last update: Wed Aug 15 20:52:14 2018
Without R-bit
Route [2]:[0]:[0]:[48]:[00:1f:2f:db:45:a6]:[128]:[2006:33:33:2::10]
VNI 1001
Imported from
27.0.0.16:5:[2]:[0]:[0]:[48]:[00:1f:2f:db:45:a6]:[128]:[2006:33:33:2::10]
4435 5551
27.0.0.16 from MSP2(uplink-2) (27.0.0.10)
Origin IGP, valid, external, bestpath-from-AS 4435, best
Extended Community: RT:5551:1001 ET:8
AddPath ID: RX 0, TX 1263
Last update: Wed Aug 15 20:53:10 2018
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Chirag Shah [Tue, 14 Aug 2018 00:07:22 +0000 (17:07 -0700)]
zebra: mark router flag for neigh update
The neigh update can come prior to mac add update.
In this case, the mac will be auto created for the vni.
set router flag to local neigh update for mac with auto flag.
The neigh update will be informed to bgpd once local mac is learnt.
Unset router flag if the neigh update comes without the router flag
for an existing neigh entry.
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Chirag Shah [Wed, 1 Aug 2018 01:45:39 +0000 (18:45 -0700)]
bgpd: check existing l3vni for any l2vni creation
Scan all bgp vrf instances and respective L3VNI against the VNI which is being configured.
Ticket:CM-21859
Testing Done:
Configure l3vni,
try to configure same vni as l2vni under router bgp, address-family
l2vpn evpn.
The configuration is rejected.
show evpn vni
VNI Type VxLAN IF # MACs # ARPs # Remote VTEPs Tenant VRF
4001 L3 vx-4001 0 0 n/a vrf1
root [Wed, 22 Aug 2018 23:08:26 +0000 (16:08 -0700)]
bgpd: Fix memory leak show ip bgp json
Root Cause: In the function bgp_show_table(), we are creating a
json object and a json array with the same name as “json_paths”.
First it will create a json object variable "json_paths" pointing
to the memory allocated for the json object. Then it will create
a json array for each bap node rn (if rn->info is available) with
the same name as json_paths. Because of this, json_paths which was
pointing to the memory allocated for the json object earlier, now
will be overwritten with the memory allocated for the json array.
As per the existing code, at the end of each iteration loop of bgp
node, it will deallocate the memory used by the json array and
assigned NULL to the variable json_paths. Since we don’t have the
pointer pointing to the memory allocated for json object, will be
not able to de-allocate the memory, which is a memory leak here.
Fix: Removing this json object since it is never getting used in
this function.
Testing: Reproduced the memory leak with valgrind.
With the fix, memory leak gets resolved and checked with valgrind.
In some situations rtrlib does not release the locks for its internal
data structures before calling a callback. This can lead to deadlocks
when a lot of routes must be revalidated because the sync socket buffer
will fill up and block the rtrlib thread. The bgpd main thread then
waits for rtrlibs internal locks to be released indefinitely.
This is fixed by using nonblocking sockets instead of blocking ones and
setting a flag to revalidate everything, if it would block.
Donald Sharp [Wed, 22 Aug 2018 00:34:42 +0000 (20:34 -0400)]
lib: Convert stream_new to use one malloc
Modify stream.c to have stream_new call one malloc call
instead of two. Also change stream_resize_orig to
use stream_resize_inplace and to send an error
to the developer to switch over.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
root [Wed, 22 Aug 2018 07:00:32 +0000 (00:00 -0700)]
pimd: Fix pim_mroute_del crash while terminating pimd
When pimd is getting terminated, pim_upstream_del() gets called as
part of cleaning process. pim_upstream_del() deletes the route and
assigns NULL to the up->channel_oil. It also deletes each if_channel
by calling the function pim_ifchannel_delete().
pim_ifchannel_delete() internally calls the caller function pim_upstream_del(),
if it is the last ifchannel for that upstream. So pim_upstream_del
is getting called twice, which will access the up->channel_oil which
was already set to NULL before. This results in crash.
Fix:
pim_ifchannel_delete() should call pim_upstream_del (caller function)
only if the up->ref_count > 0. Added an assert(up->ref_count > 0) in
the function pim_upstream_del().
David Lamparter [Sat, 18 Aug 2018 02:47:27 +0000 (04:47 +0200)]
lib/bgpd: re-fix bgp_info_extra_free()
Make the wart slightly less bad... also there is still a possible write
after free here. This needs to be fixed again, properly, by some
structure changes.
Signed-off-by: David Lamparter <equinox@diac24.net>
David Lamparter [Sat, 18 Aug 2018 02:33:38 +0000 (04:33 +0200)]
*: fix gcc-8 format-overflow warnings
e.g.
pimd/pim_oil.c: In function ‘pim_channel_oil_dump’:
pimd/pim_oil.c:51:19: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Werror=format-overflow=]
Build on gcc-8.2.0 is warning-free after this patch.
Signed-off-by: David Lamparter <equinox@diac24.net>
Donald Sharp [Tue, 21 Aug 2018 12:40:51 +0000 (08:40 -0400)]
ospfd: Remove unused function
The ospf_external_route_lookup function was not
being used so let's just remove it.
Unfortunately the removal was not quite so simple as
that ospf_asbr.h was being used to generate a reference
for the `struct ospf_route` data structure, so we
need to fix up the compile by fixing up header
inclusions so that ospf_route.h is actually included
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
kssoman [Fri, 17 Aug 2018 15:53:28 +0000 (08:53 -0700)]
zebra : routemap "match ipv6 address prefix list" does not work
* Added code for "match ipv6 address prefix list" command
* Added common function route_match_address_prefix_list() to process
routemap for AFI_IP and AFI_IP6 address family
kssoman [Fri, 17 Aug 2018 15:47:48 +0000 (08:47 -0700)]
zebra : Zebra does not properly track which route-maps are changed (#2493)
* Check for the modified routemap in zebra_route_map_process_update_cb()
* Added zebra_rib_table_rm_update() for RIB routemap processing
* Added zebra_nht_rm_update() for NHT routemap processing
configure.ac: emit a config warning if sphinx-build is missing
If we don't have --disabled-doc and sphinx-build is not available
warn the user that sphinx-build is needed to build documentation
as shown in the last line of config summary example below
FRRouting configuration
------------------------------
FRR version : 5.1-dev
host operating system : linux-gnu
source code location : .
compiler : gcc -std=gnu11
compiler flags : -g -Os -fno-omit-frame-pointer -funwind-tables -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -pthread
make : make
linker flags : -rdynamic -ldl -lm -lcrypt -ljson-c -lrt -lreadline -ltermcap -lm
state file directory : /var/run
config file directory : /usr/local/etc
example directory : /usr/local/etc
module directory : /usr/local/lib/frr/modules
user to run as : frr
group to run as : frr
group for vty sockets :
config file mask : 0600
log file mask : 0600
zebra protobuf enabled : no
The above user and group must have read/write access to the state file
directory and to the config files in the config file directory.
configure: WARNING: sphinx-build is missing but required to build documentation
Donald Sharp [Thu, 16 Aug 2018 20:29:08 +0000 (16:29 -0400)]
zebra: When using BFD ensure that zebra thinks ptm is disabled
In order for connected routes to be installed the if_is_operative
function is called. This function checks the status of ptm
and decides to use ptm enabled/disabled on the interface.
The call to zebra_ptm_get_enable was returning true and causing
the interface subsystem to do the wrong thing. Modify the
internal bfd case to when checking for ptm enabled to say it
is not enabled.
Tested-by: Mark Stapp <mjs@voltanet.io> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Sarita Patra [Thu, 16 Aug 2018 13:41:01 +0000 (06:41 -0700)]
pimd: Fix memory leak pim nexthop creation
While terminating pim instance, the memory allocated for pim nexthop
should be released before deallocating the memory of pim nexthop cache(pnc).
This resolves the memory leak detected in pnc->nexthop creation.
Donald Sharp [Thu, 16 Aug 2018 00:44:31 +0000 (20:44 -0400)]
bgpd: zlog_warn to assert for code that must be executed first
In bgp_keepalives.c, it was noticed that we were
ensuring that we called an intialization function first,
but this is a development escape in that once this
was fixed we never see it. So if a developer moves
this assumption around, let's crash the program and
lead them to this spot instead of silently ignoring
the problem.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp [Wed, 15 Aug 2018 19:50:30 +0000 (15:50 -0400)]
lib: Update hash.h documentation
The hash_get function when called and the alloc_func returns
a NULL value, we do not create a backet nor do we insert
anything into the hash. As such backet->data must always
be non-NULL.
Modify the description in hash_get to inform of this.
Additionally indicate that hash_walk and hash_iterate
cannot have a NULL backet->data value.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Rafael Zalamena [Wed, 15 Aug 2018 19:04:13 +0000 (16:04 -0300)]
bfdd: improve docs
Improvements:
* Show command line as code, to avoid confusion about single dash (`-`)
and double dash;
* Tell the user where the BGP BFD commands can be found;
* Document OSPF/OSPF6/PIM BFD commands;
* Document JSON commands;
* Tell about session counters;
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>