Commit Graph

485 Commits

Author SHA1 Message Date
Stephen Worley
78fba41bd8 lib,zebra,bgpd: Remove nexthop_same_no_recurse()
The functions nexthop_same() does not check the resolved
nexthops so I don't think this function is even needed
anymore.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23 12:21:15 -04:00
Renato Westphal
81fddbe7ae *: rename new ForEach macros from the typesafe API
This is necessary to avoid a name collision with std::for_each
from C++.

Fixes the compilation of the gRPC northbound module.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-05-21 15:59:08 -03:00
Quentin Young
303b93cdee zebra: update zebra_rib for vrrp
VRRP doesn't install any routes, but should still have an array entry.
Also add a help string for VRRP to route_types.txt

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-17 00:27:08 +00:00
Russ White
1b072ce466
Merge pull request #4269 from donaldsharp/other_tables
zebra Other tables
2019-05-16 10:11:56 -04:00
Russ White
cc25952f2a
Merge pull request #4327 from sworleys/Move-Multipath-Num
zebra: Move multipath_num into zrouter
2019-05-16 10:04:14 -04:00
Donald Sharp
b3f2b59020 zebra: Move multipath_num into zrouter
The multipath_num variable is a property of zebra_router,
so move it there.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-14 14:15:18 -07:00
Mark Stapp
98124e2d6a
Merge pull request #4321 from sworleys/Ribsystem-Ribkernel
zebra: Make RIB_SYSTEM|KERNEL_ROUTE a property of rib.h
2019-05-14 09:29:08 -04:00
Donald Sharp
84340a15b4 zebra: Make RIB_SYSTEM|KERNEL_ROUTE a property of rib.h
These defines should be available from rib.h

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-13 13:11:49 -04:00
Donald Sharp
98572489ea zebra: Switch to using monotime(NULL) for re->uptime
The re->uptime usage of time(NULL) leaves it open to
timing changes from outside influence.  Switching
to monotime allows us to ensure that we have a timestamp
that is always increasing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-11 01:44:42 -04:00
Renato Westphal
773fc72b1f
Merge pull request #4242 from donaldsharp/zebra_diet
Zebra diet
2019-05-10 08:29:59 -03:00
Donald Sharp
d8612e6545 zebra: Track tables allocated by vrf and cleanup
For each table created by a vrf, keep track of it and
allow for proper cleanup on shutdown of that particular
table.  Cleanup client shutdown to only cleanup data
that the particular vrf owns.  Before we were cleaning
the same table 2 times.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-09 07:11:22 -04:00
Renato Westphal
95f092540e
Merge pull request #4256 from donaldsharp/zebra_table
doc, zebra: Remove "table X" command
2019-05-06 19:08:17 -03:00
Donald Sharp
c447ad08b2 doc, zebra: Remove "table X" command
This command is broken and has been broken since the introduction
of vrf's.  Since no-one has complained it is safe to assume that
there is no call for this specialized linux command.  Remove
from the system with extreme prejudice.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-06 13:42:23 -04:00
Donald Sharp
8dc7a75918 zebra: Add some extra safety for route_info
The route_info[X].meta_q_map *must* be less than MQ_SIZE
or we will do some strange stuff, so assert on it at startup.

The distance in route_info is a uint8_t so let's keep the data
structure the same.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-03 05:05:19 -04:00
Donald Sharp
4bb55bbecc zebra: ifp must be a real pointer sometimes
The ifp pointer must be pointing at a real location
in memory since right above us in this loop we
return if it is.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-03 05:05:19 -04:00
Donald Sharp
045207e27c zebra: Use built in list handler for route entries now
The route entry code was using a custom linked list to handle
route entries.  Remove and replace with the new lib link list
code.  This reduces the size of the route entry by a further
8 bytes.

Observant people will notice that the current linked list
implementation is singly linked, while the Route Entry
is doubly linked.  I am not terribly concerned about this
change as that 1) we do not see a large number of route
entries per prefix( say 2 maybe 3 items ) and route entries
do not come and go that often.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-02 17:41:35 -04:00
Donald Sharp
aa57abfbb5 zebra: Remove linked list and replace with new LIST
The `struct rib_dest_t` was being used to store the linked
list of rnh's associated with the node.  This was taking up
a bunch of memory.  Replace with new data structure supplied
by David and see the memory reductions associated with 1 million
routes in the zebra rib:

Old:
Memory statistics for zebra:
System allocator statistics:
  Total heap allocated:  675 MiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  567 MiB
  Free small blocks:     39 MiB
  Free ordinary blocks:  69 MiB
  Ordinary blocks:       0
  Small blocks:          0
  Holding blocks:        0

New:
Memory statistics for zebra:
System allocator statistics:
  Total heap allocated:  574 MiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  536 MiB
  Free small blocks:     33 MiB
  Free ordinary blocks:  4600 KiB
  Ordinary blocks:       0
  Small blocks:          0
  Holding blocks:        0

`struct rnh` was moved to rib.h because of the tangled web
of structure dependancies.  This data structure is used
in numerous places so it should be ok for the moment.
Future work might be needed to do a better job of splitting
up data structures and function definitions.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-02 16:21:38 -04:00
Lou Berger
e8b9ad5cdd
Revert "Zebra diet" 2019-05-02 06:54:59 -04:00
Donald Sharp
0a45d97472 zebra: Remove linked list and replace with new LIST
The `struct rib_dest_t` was being used to store the linked
list of rnh's associated with the node.  This was taking up
a bunch of memory.  Replace with new data structure supplied
by David and see the memory reductions associated with 1 million
routes in the zebra rib:

Old:
Memory statistics for zebra:
System allocator statistics:
  Total heap allocated:  675 MiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  567 MiB
  Free small blocks:     39 MiB
  Free ordinary blocks:  69 MiB
  Ordinary blocks:       0
  Small blocks:          0
  Holding blocks:        0

New:
Memory statistics for zebra:
System allocator statistics:
  Total heap allocated:  574 MiB
  Holding block headers: 0 bytes
  Used small blocks:     0 bytes
  Used ordinary blocks:  536 MiB
  Free small blocks:     33 MiB
  Free ordinary blocks:  4600 KiB
  Ordinary blocks:       0
  Small blocks:          0
  Holding blocks:        0

`struct rnh` was moved to rib.h because of the tangled web
of structure dependancies.  This data structure is used
in numerous places so it should be ok for the moment.
Future work might be needed to do a better job of splitting
up data structures and function definitions.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-01 20:28:57 -04:00
Stephen Worley
eaa2716dfb zebra: Check on startup route_info has all types
Add a function to check if the route_info array
has all types specified with data in it. Specifically,
test the 'key' attribute for non-zero data. Ignore
ZEBRA_ROUTE_SYSTEM as it should be zero key anyway.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-01 15:32:18 -04:00
Mark Stapp
88351c8f6d
Merge pull request #4226 from sworleys/PBR-BFD-OF-route_info
zebra: Add PBR, BFD, OpenFabric to route_info
2019-05-01 11:22:54 -04:00
Lou Berger
31e944a8a7
Merge pull request #3045 from opensourcerouting/atoms
READY: lists/skiplists/rb-trees new API & sequence lock & atomic lists
2019-04-30 10:26:35 -04:00
Stephen Worley
d6abd8b070 zebra: Comment to ensure types added to route_info
Add a comment to indicate that route types added to
Zebra, should also be present in the route_info array.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-04-30 10:07:45 -04:00
Stephen Worley
eab7b6e371 zebra: Add OpenFabric to route_info array
Add OpenFabric to the route_info array for handling processing
of the OpenFabric route type.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-04-29 19:28:15 -04:00
Stephen Worley
42d96b73cb zebra: Add BFD to route_info array
Add BFD to the route_info array for handling processing
of the BFD route type.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-04-29 19:26:11 -04:00
Stephen Worley
9815665214 zebra: Add PBR to route_info array
Add PBR to the route_info array for handling processing
of the PBR route type.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-04-29 19:24:26 -04:00
Don Slice
ade4a8868e zebra: resolve issue with protocol route-map not applied properly
Problem reported that route-maps applied to "ip protocol table bgp"
would not be invoked if the ip protocol table command was issued
after the bgp prefixes were installed.  Found that a recent change
improving how often nexthop_active_update runs missed causing this
filtering to be applied. This fix resolves that issue as well as
a couple of other places that were problematic with the recent
change.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-04-26 17:15:44 +00:00
Donald Sharp
df38b099ee zebra: Update flag output for route entry dump
Update the nexthop flag output for the route entry dump to
include all possible flag states be output.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18 14:57:54 -04:00
Donald Sharp
6883bf8d35 zebra: Run nexthop_active_check once
We currently run nexthop_active_check multiple times.  Make the
code run once and figure out state from that.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18 14:57:54 -04:00
Donald Sharp
80ad04184f zebra: Double check is not necessary in nexthop_active_update
The nexthop_active_update command looks at each individual
nexthop and decides if it has changed.  If any nexthop
has changed we will set the re->status to ROUTE_ENTRY_CHANGED
and ROUTE_ENTRY_NEXTHOPS_CHANGED.

Additionally the test for old_nh_num != curr_active
makes no sense because suppose we have several events
we are processing at the same time and a total ecmp
of 16 but 14 are active at the start and 14 are active
at the end but different interfaces are up or down.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18 14:57:54 -04:00
Donald Sharp
dd50eeb115 lib, zebra: Remove unused flag
The NEXTHOP_FLAG_FILTERED went away when we started treating
static routes like every other route in the system.  This was
a special case for handling static route code that just didn't
get finished cleaning up.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18 14:57:54 -04:00
Donald Sharp
99eabcec1a zebra: nexthop_active_update does not need set
We are effectively calling nexthop_active_update() on every
route entry being processed for installation at least 2 times.
This is a bit ridiculous.  We need to resolve the nexthops
when we know a route has changed in some manner, so do so.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18 14:57:54 -04:00
Renato Westphal
e412d3b8d9 lib: move zlog() prototype back to the public logging API
zlog() should be part of the public logging API as it's useful in
the cases where the logging priority isn't known at compile time
(i.e. it depends on a variable).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-04-18 13:15:13 -03:00
David Lamparter
7e3a1ec742 lib: ZEBRA_NUM_OF -> array_size
The latter is widely used, e.g. in the Linux kernel.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-04-18 12:44:29 +02:00
Mark Stapp
cf363e1bd8 zebra: dataplane notifications for system route changes
Add notifications from zebra to the dataplane subsystem when
kernel or connected routes change.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-10 16:07:01 -04:00
Mark Stapp
f4c6e2a815 zebra: remove unused VRF_RIB_SCHEDULED flag
We don't use th vrf-level VRF_RIB_SCHEDULED flag any longer;
remove it and collapse the zebra_vrf flags' values.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-05 08:46:28 -04:00
Donald Sharp
a1494c250c zebra: Modify lsp processing to be invoked as needed
LSP processing was a zvrf flag based upon a connected route
coming or going.  But this did not allow us to know
that we should do lsp processing other than after the meta-queue
processing was finished.

Eventually we moved meta-queue processing of do_nht_processing
to after the dataplane sent the main pthread some results.
This of course left us with a timing hole where if a connected
route came in and we received a data plane response *before*
the meta queue was processed we would not do the work as necessary.

Move the lsp processing to a flag off of the rib_dest_t. If it
is marked then we need to process lsps.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:22:22 -04:00
Donald Sharp
50872b0804 zebra: Add detailed debugging command for NHT tracking
Add a detailed debugging command for NHT tracking and add
the detailed output to the log about why we make some decisions
that we are.  I tried to model this like the rib processing
detailed debugs that we added a few months back.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:22:22 -04:00
Donald Sharp
699dae230d zebra: Modify NHT to occur when needed.
Currently nexthop tracking is performed for all nexthops that
are being tracked after a group of contexts are passed back
from the data plane for post install processing.

This is inefficient and leaves us sending nexthop tracking
changes at an accelerated pace, when we think we've changed
a route.  Additionally every route change will cause us
to relook at all nexthops we are tracking irrelevant if
they are possibly related to the route change or not.

Let's modify the code base to track the rnh's off of the rib
table's rn, `rib_dest_t`.  So after we process a node, install
it into the data plane, in rib_process_result we can
look at the `rib_dest_t` associated with the rn and see that
a nexthop depended on this route node.  If so, refigure it.

Additionally we will store rnh's that are not resolved on the
0.0.0.0/0 nexthop tracking list.  As such when a route node
changes we can quickly walk up the rib tree and notice that
it needs to be reprocessed as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:22:22 -04:00
Donald Sharp
c86ba6c283 zebra: Add a base node for the zebra vrf tables
Add a default route_node for our routing tables.  This will allow us
to know that we can hang data off the default route for processing.

We will be hanging the nexthop tracking data structures off the rib_dest_t
so that we can know which nexthops we need to handle.  Effectively
nexthops that we are tracking that are unresolved will be stored on the
default route.  When something changes in the rib tree we can
work up the rn->parent pointer checking for nexthops we need to re-evaluate.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -04:00
Donald Sharp
434434f704 zebra: Abstract the rib_dest_t creation
Abstract the creation of the rib_dest_t so that we can call it
from multiple places.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -04:00
Donald Sharp
3cdba47a82 zebra: Modify code so that dplane is responsible for indicating success/fail of install
We have several route types KERNEL and CONNECT that are handled via special
case in the code.  This was causing a lot of work keeping the two different
classes of route types as special(SYSTEM OR NOT).  Put the dplane
in charge of the code that sets the bits for signalling route install/failure.

This greatly simplifies the code calling path and makes all route types
be handled exactly the same.  Additionaly code that we want to run
post data plane install can just work as per normal then, instead
of having to know we need to run it when we have a special type
of route.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com.
2019-03-27 16:19:28 -04:00
Donald Sharp
7a230a9d0c zebra: On route install/update failure correctly indicate in rib
When we get a route install failure from the kernel, actually
indicate in the rib the status of the routes.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -04:00
Donald Sharp
9ef0c6ba87 zebra: Unset old_re as queued.
When switching routes from one route type to another actually
unset the old route as enqueued.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-27 16:19:28 -04:00
Quentin Young
73fb891892 Revert "Merge pull request #3982 from pacovn/Coverity_1479148_copy_paste"
This reverts commit 3a3704fe36, reversing
changes made to 5a3c6e736d.
2019-03-20 21:25:04 +00:00
F. Aragon
23fbacb455
zebra: copy-paste error (Coverity 1479148)
Signed-off-by: F. Aragon <paco@voltanet.io>
2019-03-20 16:45:32 +01:00
Donald Sharp
b900245adc zebra: System routes sometimes can not be properly selected
System Routes if received over the netlink bus in a
specific pattern that causes an update operation for that
route in zebra can leave the dest->selected_fib pointer NULL,
while having the ZEBRA_FLAG_SELECTED flag set. Specifically
one way to achieve this is to do this:

`ip addr del 4.5.6.7/32 dev swp1 ; ip addr add 4.5.6.7/32 dev swp1 metric 9`

Why is this a big deal?
Because nexthop tracking is looking at ZEBRA_FLAG_SELECTED to
know if we can use a route, while nexthop active checking uses
dest->selected_fib.

So imagine we have bgp registering a nexthop. nexthop tracking in
the above case will be able to choose the 4.5.6.7/32 route
if that is what the nexthop is, due to the ZEBRA_FLAG_SELECTED being
properly set. BGP then allows the peers connection to come up and we
install routes with a 4.5.6.7 nexthop. The rib processing for route
installation will then look at the 4.5.6.7 route see no
dest->selected_fib and then start walking up the tree to resolve
the route. In our case we could easily hit the default route and be
unable to resolve the route. Which then becomes inactive in the
rib so we never attempt to install it.

This commit fixes this problem because when the rib_process decides
that we need to update the fib( ie replace old w/ new ), the
replacement with new was not setting the `dest->selected_fib` pointer
to the new route_entry, when the route was a system route.

Ticket: CM-24203
Signed-off-by: Donald Sharp <sharpd@cumulusnetworkscom>
2019-03-15 10:02:11 -04:00
David Lamparter
d3b05897ed
Merge pull request #3869 from qlyoung/cocci-fixes
Assorted Coccinelle fixes
2019-03-06 15:54:44 +01:00
vivek
2b83602b24 *: Explicitly mark nexthop of EVPN-sourced routes as onlink
In the case of EVPN symmetric routing, the tenant VRF is associated with
a VNI that is used for routing and commonly referred to as the L3 VNI or
VRF VNI. Corresponding to this VNI is a VLAN and its associated L3 (IP)
interface (SVI). Overlay next hops (i.e., next hops for routes in the
tenant VRF) are reachable over this interface. Howver, in the model that
is supported in the implementation and commonly deployed, there is no
explicit Overlay IP address associated with the next hop in the tenant
VRF; the underlay IP is used if (since) the forwarding plane requires
a next hop IP. Therefore, the next hop has to be explicit flagged as
onlink to cause any next hop reachability checks in the forwarding plane
to be skipped.

https://tools.ietf.org/html/draft-ietf-bess-evpn-prefix-advertisement
section 4.4 provides additional description of the above constructs.

Use existing mechanism to specify the nexthops as onlink when installing
these routes from bgpd to zebra and get rid of a special flag that was
introduced for EVPN-sourced routes. Also, use the onlink flag during next
hop validation in zebra and eliminate other special checks.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-27 12:54:24 +00:00
Quentin Young
9f2d035447 *: remove useless return variables
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:16 +00:00