]> git.proxmox.com Git - mirror_frr.git/log
mirror_frr.git
4 years agopbrd: nexthop_group delete cb don't free pbr->nhg
Stephen Worley [Fri, 4 Oct 2019 17:54:39 +0000 (13:54 -0400)]
pbrd: nexthop_group delete cb don't free pbr->nhg

The pbr->nhg callback is used exclusively for individual nexthops
set through `set nexthop`. If an actuall "tracked" nexthop_group is
used, only the `pbrms->nhgrp_name` is set. Thus this delete does
nothing.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Use ng pointer in mpls_ftn_uninstall
Stephen Worley [Tue, 24 Sep 2019 22:40:09 +0000 (18:40 -0400)]
zebra: Use ng pointer in mpls_ftn_uninstall

With the new nexthop group shared memory framework, pointers
are being used in route_entry for the nexthop_group. Update
the use of this in `mpls_ftn_uninstall()` to reflect the change.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add DPLANE_NEIGH and DPLANE_VTEP to nhg cases
Stephen Worley [Tue, 24 Sep 2019 22:38:28 +0000 (18:38 -0400)]
zebra: Add DPLANE_NEIGH and DPLANE_VTEP to nhg cases

Add DPLANE_OP_NEIGH and DPLANE_OP_VTEP to nhg dplane
handler's switch statements.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agodoc: Add docs for new nexthop group commands
Stephen Worley [Mon, 9 Sep 2019 17:44:17 +0000 (13:44 -0400)]
doc: Add docs for new nexthop group commands

Add some doc information for the new nexthop group commands. Also
had to add some for ones that were missing, which we are adding
additional commands to.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Fallback to default ns if nhg vrf lookup fails
Stephen Worley [Fri, 6 Sep 2019 16:30:30 +0000 (12:30 -0400)]
zebra: Fallback to default ns if nhg vrf lookup fails

If the vrf lookup fails, use the default namespace
to find/delete the nexthop group from the kernel because it
should be there anyway.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Add common handler for nexthop_group_equal*()
Stephen Worley [Tue, 3 Sep 2019 20:59:57 +0000 (16:59 -0400)]
lib: Add common handler for nexthop_group_equal*()

Add a common handler function for the different nexthop_group_equal*()
comparison functions.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Add NULL check in nexthop_group_equal*() iter
Stephen Worley [Tue, 3 Sep 2019 20:43:42 +0000 (16:43 -0400)]
lib: Add NULL check in nexthop_group_equal*() iter

Add NULL checks in `nexthop_group_equal*()` iteration
before calling `nexthop_same()` to make Clang SA happy.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Zebra nexthop group re-work checkpatch fixes
Stephen Worley [Tue, 3 Sep 2019 20:12:06 +0000 (16:12 -0400)]
zebra: Zebra nexthop group re-work checkpatch fixes

Checkpatch fixes for the zebra nexthop group re-work.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Fix NULL check in zebra_nhg_rib_find()
Stephen Worley [Tue, 3 Sep 2019 19:10:21 +0000 (15:10 -0400)]
zebra: Fix NULL check in zebra_nhg_rib_find()

Check both the nhg and nexthop are not NULL before passing
them to be hashed. Clang SA caught this.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Fix nexthop_group_equal*() NULL check
Stephen Worley [Tue, 3 Sep 2019 18:46:14 +0000 (14:46 -0400)]
lib: Fix nexthop_group_equal*() NULL check

Logic error on the second null check for nexthop groups
passed to the `nexthop_group_equal*() functions. This fixes it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agotopotests: Expect shared nexthop memory
Stephen Worley [Tue, 3 Sep 2019 17:53:45 +0000 (13:53 -0400)]
topotests: Expect shared nexthop memory

A few topotests were failing since they were not aware
of shared nexthops and, therefore, matching on flags that
could be changed when another route sharing that nexthop is
installed.

Update routes that are not installed to not match their json output
on the nexthop flag information. The ones that are installed will
still retain their matches though since they can be sure the nexthop
should have those flags (they would be the route that set them).

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Update ip route show with nexthop_num API
Stephen Worley [Fri, 30 Aug 2019 20:18:07 +0000 (16:18 -0400)]
zebra: Update ip route show with nexthop_num API

Switch the nexthop_num dereferences to use the nexthop_group
API in `vty_show_ip_route()`.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add bsd nexthop install boilerplate
Stephen Worley [Thu, 29 Aug 2019 15:42:52 +0000 (11:42 -0400)]
zebra: Add bsd nexthop install boilerplate

Add some boilerplate for nexthop installation for bsd kernels.
They do not support nexthop objects for now so its just boilerplate.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Fix missed bsd nexthop group pointer
Stephen Worley [Thu, 29 Aug 2019 14:27:31 +0000 (10:27 -0400)]
zebra: Fix missed bsd nexthop group pointer

When moving the nexthop group in a route entry to be a pointer,
we missed one wrapped in a `ifndef` for when the kernel doesn't
have netlink.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Force off kernel nexthop group API for now
Stephen Worley [Wed, 28 Aug 2019 20:15:17 +0000 (16:15 -0400)]
zebra: Force off kernel nexthop group API for now

Force off kernel nexthop group API for now. Will re-enable
after suffient testing.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Only check nexthop status on route install/update
Stephen Worley [Wed, 28 Aug 2019 18:40:16 +0000 (14:40 -0400)]
zebra: Only check nexthop status on route install/update

We do not need to check that the nexthop is installed or queued
when sending a route deletion since we only need to the prefix for it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Only show route nexthop group ID when asked
Stephen Worley [Mon, 26 Aug 2019 22:20:45 +0000 (18:20 -0400)]
zebra: Only show route nexthop group ID when asked

In lieu of the fact that we probably shouldn't change show
command output too much, changing this to only give nhe_id
output when the user explicitly asks for it. Probably only
going to be used for debugging for now anyway.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Only use passed afi for blackhole/ifindex nexthops
Stephen Worley [Tue, 20 Aug 2019 19:08:01 +0000 (15:08 -0400)]
zebra: Only use passed afi for blackhole/ifindex nexthops

Only used the afi passed into `zebra_nhg_find()` for nexthops
that are blackhole/ifindex. Others should use the type actually declared
in the nexthop struct itself.

Basically, nexthop objects of type blackhole/ifindex in the kernel must
have an address family, they cannot be ambigious and be shared.

This is some requirement in the linux ip core code.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Handle out of order kernel nexthop groups
Stephen Worley [Tue, 13 Aug 2019 00:09:59 +0000 (20:09 -0400)]
zebra: Handle out of order kernel nexthop groups

Add a mechanism to requeue groups we receive from the
kernel if the IDs are in a weird order (Group ID is lower
than individual nexthop IDs for example).

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Free labels on nhg_ctx from kernel
Stephen Worley [Mon, 12 Aug 2019 22:13:30 +0000 (18:13 -0400)]
zebra: Free labels on nhg_ctx from kernel

If we get a nexthop group from the kernel with labels
and queue it as a context to process later, we have to
free the label stack we allocated.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add some getters for nhg_ctx
Stephen Worley [Mon, 12 Aug 2019 21:58:59 +0000 (17:58 -0400)]
zebra: Add some getters for nhg_ctx

Add some getters for the nhg_ctx struct. Probably unnecessary
at this point since they are all static but if they ever become
public it will be nice to have them.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Handle nhg_hash_entry encaps/more debugging
Stephen Worley [Mon, 12 Aug 2019 19:46:22 +0000 (15:46 -0400)]
zebra: Handle nhg_hash_entry encaps/more debugging

Add code for handling nexthop group hash entry encaps
and sending them to the kernel. Add some more debugging
information for the encaps and groups in general.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add common netlink mpls stack building path
Stephen Worley [Mon, 12 Aug 2019 16:35:58 +0000 (12:35 -0400)]
zebra: Add common netlink mpls stack building path

There was some code copypasta for mpls stack building in the
netlink install path. Reduced that to a common function.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Add nexthop quick hash api
Stephen Worley [Mon, 12 Aug 2019 15:27:09 +0000 (11:27 -0400)]
lib: Add nexthop quick hash api

Add a nexthop hashing api for only hashing on word-sized
attributes. Calling the jhash/jhash2 function is quite slow
in scaled envrionments but sometimes you do need a more granular hash.
The tradeoff here is that hashtable buckets using this hash
might be more full.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: NHE hash reduce calls to jhash
Stephen Worley [Mon, 12 Aug 2019 15:09:46 +0000 (11:09 -0400)]
zebra: NHE hash reduce calls to jhash

Reduce the two calls to jhash to one jhash_3words() call
to save some more hashing time.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Nexthop hash onlink and ifindex with one call
Stephen Worley [Mon, 12 Aug 2019 15:07:53 +0000 (11:07 -0400)]
lib: Nexthop hash onlink and ifindex with one call

In the nexthop hashing function, lets reduce the hash calls as
much as possible. So, reduce the onlink and infindex to one
call to jhash_2words().

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add nhe_id to show ip route detailed
Stephen Worley [Thu, 8 Aug 2019 20:03:39 +0000 (16:03 -0400)]
zebra: Add nhe_id to show ip route detailed

When querying for detailed route information, show the nexthop
group id for its nh_hash_entry in the output before listing the
nexthops.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add some more output to show nexthop-group
Stephen Worley [Thu, 8 Aug 2019 19:53:58 +0000 (15:53 -0400)]
zebra: Add some more output to show nexthop-group

Add some more detailed output to `show nexthop-group`.
It closely resembles the output of `show ip routes`.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Optimize the fib/notified nexthop matching
Stephen Worley [Wed, 7 Aug 2019 17:47:34 +0000 (13:47 -0400)]
zebra: Optimize the fib/notified nexthop matching

Optimize the fib and notified nexthop group comparison algorithm
to assume ordering. There were some pretty serious performance hits with
this on high ecmp routes.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: NHE use nexthop_group_equal_no_recurse()
Stephen Worley [Wed, 7 Aug 2019 18:06:22 +0000 (14:06 -0400)]
zebra: NHE use nexthop_group_equal_no_recurse()

Update nhg_hash_entry to use the non-recursive version of
nexthop_group_equal() since it doesn't really need to compare all
of those.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Separate nexthop_group_equal() into recursive
Stephen Worley [Wed, 7 Aug 2019 18:04:19 +0000 (14:04 -0400)]
lib: Separate nexthop_group_equal() into recursive

Separate nexthop_group_equal() into two versions. One
that compares verses recurisvely resolved nexthops and
one that doesn't.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib,zebra: Move nexthop dup marking into creation
Stephen Worley [Wed, 7 Aug 2019 15:33:01 +0000 (11:33 -0400)]
lib,zebra: Move nexthop dup marking into creation

We were waiting until install time to mark nexthops as duplicate.
Since they are immutable now and re-used, move this marking into
when they are actually created to save a bunch of cycles.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Call nexthop g_addr hashes together
Stephen Worley [Tue, 6 Aug 2019 21:30:16 +0000 (17:30 -0400)]
lib: Call nexthop g_addr hashes together

When hashing a nexthop, shove all the nexthop g_addr data together
and pass it as one call to jhash2() to optimize a bit better.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: nexthop_group_equal() assume ordered
Stephen Worley [Tue, 6 Aug 2019 17:40:19 +0000 (13:40 -0400)]
lib: nexthop_group_equal() assume ordered

Speed up nexthop_group_equal() by making it assume the
groups it has been passed are ordered. This should always
be the case.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Check active count first in nhg_hash_equal
Stephen Worley [Tue, 6 Aug 2019 17:16:07 +0000 (13:16 -0400)]
zebra: Check active count first in nhg_hash_equal

Before checking the equivalence of the whole group itself,
check to see if they contain the same number of non-recursive
active nexthops. This should shorten lookup time for the case of
non-resolved nexthop group creation.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Create depends after initial lookup
Stephen Worley [Mon, 26 Aug 2019 21:09:31 +0000 (17:09 -0400)]
zebra: Create depends after initial lookup

Create any depends only after the initial hash lookup
fails. Should reduce hashing cpu cycles significantly.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: TODO for hanlding blackhole attr exclusive
Stephen Worley [Mon, 26 Aug 2019 21:06:10 +0000 (17:06 -0400)]
zebra: TODO for hanlding blackhole attr exclusive

Add a TODO statement for handling the exclusiveness
of blackhole attributes.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Use nexthop object id on route delete
Stephen Worley [Thu, 1 Aug 2019 21:36:56 +0000 (17:36 -0400)]
zebra: Use nexthop object id on route delete

When we receive a route delete from the kernel and it
contains a nexthop object id, use that to match against
route gateways with instead of explicit nexthops.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Move the supports_nh bool to a better place
Stephen Worley [Thu, 1 Aug 2019 18:53:06 +0000 (14:53 -0400)]
zebra: Move the supports_nh bool to a better place

Move the supports_nh bool indicating whether the kernel we are
using supports nexthop objects into the netlink kernel interface
itself. Since only linux and netlink support nexthop object APIs
for now this is fine.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add handling for kernel del/update nexthop
Stephen Worley [Thu, 1 Aug 2019 18:24:35 +0000 (14:24 -0400)]
zebra: Add handling for kernel del/update nexthop

Add handling for delete/update nexthop object messages from the
kernel.

If someone deletes a nexthop object we are still using, send it back
down. If the someone updates a nexthop we are using, replace that nexthop
with ours. Routes are referencing this nexthop object ID and we resolved
it ourselves, so we should force the other `someone` to submit to our
will.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Sweep our nexthop objects out on restart
Stephen Worley [Thu, 1 Aug 2019 18:07:04 +0000 (14:07 -0400)]
zebra: Sweep our nexthop objects out on restart

On restart, if we failed to remove any nexthop objects due
to a kill -9 or such event, sweep them if we aren't using them.
Add a proto field to handle this and remove the is_kernel bool.

Add a dupicate flag that indicates this nexthop group is only
present in our ID hashtable. It is a dupicate nexthop we received
from the kernel, therefore we cannot hash on it.

Make the idcounter globally accessible so that kernel updates
increment it as soon as we receive them, not when we handle them.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Give installed nhe's the zebra proto
Stephen Worley [Thu, 25 Jul 2019 18:00:31 +0000 (14:00 -0400)]
zebra: Give installed nhe's the zebra proto

Give all nhg_hash_entrys we install into the kernel
as nexthop objects a defined proto matching the zebra
rib table one. This makes sense since nhe's are proto-independent
and determined exclusively in zebra.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Prevent duplication and overflow in nhe2grp
Stephen Worley [Thu, 25 Jul 2019 17:27:59 +0000 (13:27 -0400)]
zebra: Prevent duplication and overflow in nhe2grp

The kernel does not allow duplicate IDs in the same group, but
we are perfectly find with it internally if two different
nexthops resolve the the same nexthop (default route for instance).
So, we have to handle this when we get ready to install.

Further, pass the max group size in the arguments to ensure we
don't overflow. Don't actually think this is possible due to
multipath checking in nexthop_active_update() but better to be
safe.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: TODO for handling upper level nhe_id passing
Stephen Worley [Thu, 25 Jul 2019 17:26:29 +0000 (13:26 -0400)]
zebra: TODO for handling upper level nhe_id passing

We need to handle refcnt differently if we ever start making
upper level protocols aware of nhg_hash_entry IDs.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Mark nhe valid if installed
Stephen Worley [Thu, 25 Jul 2019 17:25:21 +0000 (13:25 -0400)]
zebra: Mark nhe valid if installed

If the nhe was successfully installed, make sure its marked
as valid. Not fully sure how/where the valid flag is going to
be used yet.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: A group isn't recursive if one depend is
Stephen Worley [Thu, 25 Jul 2019 17:18:27 +0000 (13:18 -0400)]
zebra: A group isn't recursive if one depend is

We were setting a group to be recursive if its first depend
was. This is not the case; individual depends of the group
might be recursive but the group itself is not.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Move resolve/add depend install into api
Stephen Worley [Thu, 25 Jul 2019 15:45:19 +0000 (11:45 -0400)]
zebra: Move resolve/add depend install into api

Move the resolving and installing of a single nhg_hash_entry
into the install function itself, rather than letting zebra_rib
handle it.

Further, ensure depends are installed/queued before installing
a group. The ordering should be find here since only one thread
will call this API.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Install the nhe along with the route
Stephen Worley [Thu, 25 Jul 2019 17:14:32 +0000 (13:14 -0400)]
zebra: Install the nhe along with the route

Move the installation of an nhe out of nexthop_active_update()
and into the rib install path. So, only install the nhe when
a route using it is being installed.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Install a route if the nhe is queued as well
Stephen Worley [Thu, 25 Jul 2019 15:58:25 +0000 (11:58 -0400)]
zebra: Install a route if the nhe is queued as well

Before we install a route, we verify that the nhg_hash_entry is installed.
Allow the nhe to be queued as well and still pass the route
install along.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Switch nhg_connected to use new RB tree
Stephen Worley [Wed, 24 Jul 2019 16:27:40 +0000 (12:27 -0400)]
zebra: Switch nhg_connected to use new RB tree

Switch the nhg_connected tree structures to use the new
RB tree API in `lib/typerb.h`. We were using the openbsd-tree
implementation before.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Remove some extraneous zebra_nhg logging
Stephen Worley [Wed, 17 Jul 2019 17:56:59 +0000 (13:56 -0400)]
zebra: Remove some extraneous zebra_nhg logging

Remove some extraneos zebra_nhg logging that was being
used during development.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Set recursive flag in rib_find() path
Stephen Worley [Wed, 24 Jul 2019 16:02:16 +0000 (12:02 -0400)]
zebra: Set recursive flag in rib_find() path

We were not setting the NEXTHOP_GROUP_RECURSIVE flag via
the rib find path. Adding a check and set after successful
creation of a new nhg_hash_entry.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: zebra_nhg_rib_find() handle recursive case
Stephen Worley [Wed, 17 Jul 2019 17:26:19 +0000 (13:26 -0400)]
zebra: zebra_nhg_rib_find() handle recursive case

When going through the zebra_nhg_rib_find(), we now handle the
case of if that nexthop has been recursively resolved. A depend
is created and passed along to zebra_nhg_find().

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add refcnt for depends when connected
Stephen Worley [Wed, 17 Jul 2019 17:22:23 +0000 (13:22 -0400)]
zebra: Add refcnt for depends when connected

Add a refcnt as soon as depend is connected to mark
that this is being referenced as part of a group or
resolving another one. If the one referencing it
is never used, decrement it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add some depends helper functions
Stephen Worley [Wed, 17 Jul 2019 17:19:56 +0000 (13:19 -0400)]
zebra: Add some depends helper functions

Add some helper functions for finding/creating nexthop
group hash entries and assigning them as a depends for
another one using them in a group or resolving to them.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add nhg refcnt connected helper functions
Stephen Worley [Wed, 17 Jul 2019 17:15:51 +0000 (13:15 -0400)]
zebra: Add nhg refcnt connected helper functions

Add some helper functions for ref incrementing and
decrementing the depends of a nexthop group hash entry.

This just abstracts the RB tree manipulation a bit more.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Remove nexthop group workqueue
Stephen Worley [Wed, 17 Jul 2019 17:10:20 +0000 (13:10 -0400)]
zebra: Remove nexthop group workqueue

We are using the rib workqueue to handle nexthop groups
from the kernel and no longer need this.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Hash nexthops on onlink flag
Stephen Worley [Wed, 10 Jul 2019 20:11:47 +0000 (20:11 +0000)]
lib: Hash nexthops on onlink flag

We should hash nexthops on the onlink flag since that is a
descriptor of the nexthop and not a status of it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Set resolved nhg in find path
Stephen Worley [Wed, 3 Jul 2019 16:09:20 +0000 (16:09 +0000)]
zebra: Set resolved nhg in find path

Set the resolved nhg during the find path, rather
than after it has been created. This make more sense
now that we are hashing on the resolved nexthop as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Refactor nexthop resolution in active funcs
Stephen Worley [Tue, 2 Jul 2019 05:37:17 +0000 (01:37 -0400)]
zebra: Refactor nexthop resolution in active funcs

Refactor/move around the code for nexthop resolution so
that it occurs only when the nexthop actually changes. Further,
provide a helper function to make the code more readable.

Also, remove the check for NEXTHOPS_CHANGED as this flag is used
specifcially for nexthop tracking and not an appropriate check
here.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Hash on resolved nexthops by default
Stephen Worley [Tue, 2 Jul 2019 05:34:57 +0000 (01:34 -0400)]
lib: Hash on resolved nexthops by default

Include resolved nexthops when hashing a nexthop
group but provide an API that allows you to non-recursively
hash as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Use nexthop/interface vrf, not the routes
Stephen Worley [Tue, 2 Jul 2019 05:16:48 +0000 (01:16 -0400)]
zebra: Use nexthop/interface vrf, not the routes

When hashing/creating the NHE, use the nexthops vrf as its
source of data. This is gotten directly from an interface
and should not come from a route.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Accept NULL value for updating route NHE
Stephen Worley [Tue, 2 Jul 2019 05:07:59 +0000 (01:07 -0400)]
zebra: Accept NULL value for updating route NHE

When updating a route's referenced NHE, accept a NULL value
as valid and clear out the pointer in the struct.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Resolved nh change, inc refcnt by rt refcnt
Stephen Worley [Tue, 2 Jul 2019 05:04:29 +0000 (01:04 -0400)]
zebra: Resolved nh change, inc refcnt by rt refcnt

When the resolved nexthop changes, we should increment the new
resolved NHE by the refcnt for the unresolved NHE being used
by the routes and decrement the old one by the same amount.

Before, we were simple incrementing by one, causing incorrect refcnts
to occur.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add cli show NHE by ID and interface groups
Stephen Worley [Thu, 16 May 2019 04:24:43 +0000 (21:24 -0700)]
zebra: Add cli show NHE by ID and interface groups

Add cli to show nhg_hash_entry's by ID.

Add cli to show nhg_hash_entry info for interfaces and remove
just listing ID's in `show interface *`

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: NHG checkpatch fixes
Stephen Worley [Wed, 15 May 2019 16:59:37 +0000 (09:59 -0700)]
zebra: NHG checkpatch fixes

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Ignore cleanup for now
Stephen Worley [Tue, 14 May 2019 23:12:53 +0000 (16:12 -0700)]
zebra: Ignore cleanup for now

Ignore the cleanup for now until we get the timing
figured out without using the kernel nexthop object API.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Remove uneeded is_valid NHE functons
Stephen Worley [Tue, 14 May 2019 23:11:00 +0000 (16:11 -0700)]
zebra: Remove uneeded is_valid NHE functons

Remove some unused is_valid checks for the nhg_hash_entry's.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Check group before setting NHE invalid
Stephen Worley [Tue, 14 May 2019 23:06:19 +0000 (16:06 -0700)]
zebra: Check group before setting NHE invalid

If the nhg_hash_entry is a group, check if its members
are valid before setting it invalid. If even one is valid,
then this group should still be considered valid.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Remove route only if NHE is installed check
Stephen Worley [Tue, 14 May 2019 22:58:02 +0000 (15:58 -0700)]
zebra: Remove route only if NHE is installed check

Only remove a route if the nexthop it is using is still installed.
If a nexthop object is removed from the kernel, all routes referencing
it will be removed from the kernel.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Create a new NHE if the mpls labels change
Stephen Worley [Tue, 14 May 2019 23:35:13 +0000 (16:35 -0700)]
zebra: Create a new NHE if the mpls labels change

We should create a new NHE if the mpls labels change
since we hash on them. This adds the functonality to do that
and decrement the refcnt on the old one.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Don't error on nexthop object support check
Stephen Worley [Tue, 14 May 2019 22:47:20 +0000 (15:47 -0700)]
zebra: Don't error on nexthop object support check

On startup when we are requesting all nexthop objects
from the kernel and it doesn't support that, we should not
produce an error message.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Return true if the NHE created, not found
Stephen Worley [Tue, 14 May 2019 23:33:04 +0000 (16:33 -0700)]
zebra: Return true if the NHE created, not found

In zebra_nhg_find(), if we created a nhg_hash_entry, return
true so we know rib-side.

Kernel-side, we don't care since it will always just enqueue
a context to process later.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Put NHE ref updating into a function
Stephen Worley [Tue, 14 May 2019 23:26:20 +0000 (16:26 -0700)]
zebra: Put NHE ref updating into a function

When the referenced NHE changes for a route_entry, use this function
to handle it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Error if the ifp lookup fails for an NHE
Stephen Worley [Tue, 14 May 2019 23:22:53 +0000 (16:22 -0700)]
zebra: Error if the ifp lookup fails for an NHE

If the lookup for an interface pointer fails when creating
the NHE, log an error message.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add recursive functionality to NHE's
Stephen Worley [Tue, 14 May 2019 22:27:40 +0000 (15:27 -0700)]
zebra: Add recursive functionality to NHE's

Add the ability to recursively resolve nexthop group hash entries
and resolve them when sending to the kernel.

When copying over nexthops into an NHE, copy resolved info as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Update snmp code to use nexthop pointer
Stephen Worley [Thu, 9 May 2019 16:48:24 +0000 (12:48 -0400)]
zebra: Update snmp code to use nexthop pointer

Update all nexthop_group struct's in zebra_snmp.c to use
a pointer to its nexthop.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Check for nh group support in dplane ctx
Stephen Worley [Tue, 23 Apr 2019 14:24:58 +0000 (10:24 -0400)]
zebra: Check for nh group support in dplane ctx

Only queue a nexthop object update if the dataplane
supports nexthop objects. Otherwise, mark it as a success
since we should only me sending them to the kernel
if we think they are valid anywyay.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Use NHE id on kernel route sends
Stephen Worley [Tue, 14 May 2019 23:42:39 +0000 (16:42 -0700)]
zebra: Use NHE id on kernel route sends

If the kernel supports nexthop objects, send the route
using an nhg_hash_entry ID instead.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Fix nhg ifindex setting and checking
Stephen Worley [Mon, 22 Apr 2019 19:42:10 +0000 (15:42 -0400)]
zebra: Fix nhg ifindex setting and checking

We were only setting and checking the ifindex if
the nexthop had an *_IFINDEX type. However, when nexthop
active checking is done, the non-*_IFINDEX types can also
obtain a nexthop with an ifindex and are thus valid too.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Use a nhe context dataplane and rib metaq
Stephen Worley [Tue, 14 May 2019 22:03:29 +0000 (15:03 -0700)]
zebra: Use a nhe context dataplane and rib metaq

We will use a nhe context for dataplane interaction with
nextho group hash entries.

New nhe's from the kernel will be put into a group array
if they are a group and queued on the rib metaq to be processed
later.

New nhe's sent to the kernel will be set on the dataplane context
with approprate ID's in the group array if needed.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Free the nhe dataplane ctx always
Stephen Worley [Tue, 14 May 2019 21:45:09 +0000 (14:45 -0700)]
zebra: Free the nhe dataplane ctx always

Free the nhe dataplane context no matter whether the operation
was successful or not.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Del from depends/dependents tree on release
Stephen Worley [Tue, 14 May 2019 21:42:50 +0000 (14:42 -0700)]
zebra: Del from depends/dependents tree on release

Upon release, call the approprate functions to remove itself
from depends/dependents trees it is in.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add depends/dependents release functions
Stephen Worley [Tue, 14 May 2019 21:40:27 +0000 (14:40 -0700)]
zebra: Add depends/dependents release functions

Add some functions to iterate over the depends/dependents
RB tree and remove themselves from the other's RB tree.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add NULL check before nhg_connected insert
Stephen Worley [Tue, 14 May 2019 21:36:48 +0000 (14:36 -0700)]
zebra: Add NULL check before nhg_connected insert

Add a check to make sure we allocated the nhg_connected
before inserting into the RB tree.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: RB_FIND then RB_REMOVE nhg_connected
Stephen Worley [Tue, 14 May 2019 21:31:17 +0000 (14:31 -0700)]
zebra: RB_FIND then RB_REMOVE nhg_connected

Can't RM_REMOVE directly with a key, you need to actually pass the
data to be removed. So, lookup with a key first to find the node,
then remove it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Check for nexthop group before free on fail
Stephen Worley [Wed, 17 Apr 2019 23:15:43 +0000 (19:15 -0400)]
zebra: Check for nexthop group before free on fail

Check to make sure the route entry has a nexthop
group before we try to free after a table lookup
failure.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Remove uneeded zebra_nhg_cmp() function
Stephen Worley [Thu, 11 Apr 2019 17:56:06 +0000 (13:56 -0400)]
zebra: Remove uneeded zebra_nhg_cmp() function

Removed a static function that did not need to be
there. The nhg_connected_cmp() function provides
all the needed functionality for comparing ID's
in the RB tree.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Update nhg_hash_equal to use nexthop_group_equal
Stephen Worley [Thu, 11 Apr 2019 17:51:15 +0000 (13:51 -0400)]
zebra: Update nhg_hash_equal to use nexthop_group_equal

Update the zebra_nhg_hash_equal() function to use
the nexthop_group_equal() function in lib/nexthop_group
instead of comparing their depends RB tree.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Add equals function for nexthop groups
Stephen Worley [Thu, 11 Apr 2019 17:36:41 +0000 (13:36 -0400)]
lib: Add equals function for nexthop groups

Add a function to check whether nexthop groups
are equivalent. It does not care about ordering.

Also, set any functions that it relies on to take
const vars as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Remove uneeded freeing helper function
Stephen Worley [Thu, 11 Apr 2019 16:47:03 +0000 (12:47 -0400)]
zebra: Remove uneeded freeing helper function

Removing this function since the new paradigm
of everything just being nhg_connected structs
makes it not make a lot of sense.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Put nhe ifp setting inside alloc
Stephen Worley [Thu, 11 Apr 2019 16:11:49 +0000 (12:11 -0400)]
zebra: Put nhe ifp setting inside alloc

Put the setting of the ifp on a nexthop group hash
entry into the zebra_nhg_alloc() function. It should
only be added if its not a group/recursive (it doesn't
have any depends) and its nexthop type has an ifindex.

This also provides functionality for proto-side ifp
setting.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: VRF ID should be null if a nexthop group
Stephen Worley [Thu, 11 Apr 2019 16:00:51 +0000 (12:00 -0400)]
zebra: VRF ID should be null if a nexthop group

A nexthop group should not have a VRF ID. Only individual
nexthops need to be using a VRF. Fixed this both kernel and
proto side.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Just uninstall NHE when refcnt hits zero
Stephen Worley [Tue, 14 May 2019 17:12:28 +0000 (10:12 -0700)]
zebra: Just uninstall NHE when refcnt hits zero

Just going to uninstall the NHE when refcnt hits zero
for now.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add interface down marking to NHE's
Stephen Worley [Tue, 14 May 2019 17:11:30 +0000 (10:11 -0700)]
zebra: Add interface down marking to NHE's

Add functionality to allow an interface down event to mark
any dependent NHE's as invalid.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Re-organize/expose nhg_connected
Stephen Worley [Tue, 14 May 2019 16:53:19 +0000 (09:53 -0700)]
zebra: Re-organize/expose nhg_connected

Re-organize and expose the nhg_connected functions so that
it can be used outside zebra_nhg.c. And then abstract those
into zebra_nhg_depends_* and zebra_nhg_depenents_* functons.

Switch the ifp struct to use an RB tree for its dependents,
making use of the nhg_connected functions.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Abstract the RB nodes/add dependents tree
Stephen Worley [Tue, 14 May 2019 01:13:02 +0000 (18:13 -0700)]
zebra: Abstract the RB nodes/add dependents tree

Create a nhg_depenents tree that will function as a way
to get back pointers for NHE's depending on it.

Abstract the RB nodes into nhg_connected for both depends and
dependents. This same struct is used for both.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra,lib: Refactor depends to RB tree
Stephen Worley [Tue, 14 May 2019 00:10:34 +0000 (17:10 -0700)]
zebra,lib: Refactor depends to RB tree

Refactor the depends to use an RB tree instead of a list.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Releasing/uninstalling re-work with groups
Stephen Worley [Tue, 14 May 2019 20:56:38 +0000 (13:56 -0700)]
zebra: Releasing/uninstalling re-work with groups

Re-work the code to release/uninstall after the addition
of groups.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Protocol side nhg_hash_entry afi fix
Stephen Worley [Mon, 1 Apr 2019 16:24:16 +0000 (12:24 -0400)]
zebra: Protocol side nhg_hash_entry afi fix

Default the afi of the nexthop to the route entry using it.
If it turns out to be a group, update the afi to AFI_UNSPEC.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>