]> git.proxmox.com Git - mirror_frr.git/log
mirror_frr.git
4 years agoMerge pull request #4941 from ton31337/fix/do_not_include_nexthop_dash_dash
Donald Sharp [Tue, 29 Oct 2019 13:37:04 +0000 (09:37 -0400)]
Merge pull request #4941 from ton31337/fix/do_not_include_nexthop_dash_dash

bgpd: Do not send next-hop as :: in MP_REACH_NLRI if no link-local ex…

4 years agoMerge pull request #5242 from FRRouting/feature/topotests-docker-libyang-from-repo
Donatas Abraitis [Tue, 29 Oct 2019 12:40:16 +0000 (14:40 +0200)]
Merge pull request #5242 from FRRouting/feature/topotests-docker-libyang-from-repo

topotests/Dockerfile: Install libyang from repository

4 years agotopotests/Dockerfile: Install libyang from repository
Christian Franke [Tue, 29 Oct 2019 09:08:19 +0000 (10:08 +0100)]
topotests/Dockerfile: Install libyang from repository

Instead of installing libyang from some old build, let's install
the current libyang from our Debian/Ubuntu repository.

Signed-off-by: Christian Franke <chris@opensourcerouting.org>
4 years agoMerge pull request #5234 from donaldsharp/fix_sa_or_else
Donatas Abraitis [Tue, 29 Oct 2019 06:58:51 +0000 (08:58 +0200)]
Merge pull request #5234 from donaldsharp/fix_sa_or_else

Fix sa or else

4 years agoMerge pull request #4897 from sworleys/zebra_nhg_add
Mark Stapp [Mon, 28 Oct 2019 12:07:23 +0000 (13:07 +0100)]
Merge pull request #4897 from sworleys/zebra_nhg_add

Zebra Nexthop Group Rework and Kernel Nexthop Object API Init

4 years agobgpd: write variable is never used in cli function
Donald Sharp [Sat, 26 Oct 2019 01:35:04 +0000 (21:35 -0400)]
bgpd: write variable is never used in cli function

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agobgpd: bgp_path_info_mpath_next only returns values
Donald Sharp [Sat, 26 Oct 2019 01:10:31 +0000 (21:10 -0400)]
bgpd: bgp_path_info_mpath_next only returns values

Since we don't set a value from the return of bgp_path_info_mpath_next
it is impossible for this function to do anything as such the if statement
is dead code as well.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agobgpd: Logically dead code
Donald Sharp [Sat, 26 Oct 2019 00:37:26 +0000 (20:37 -0400)]
bgpd: Logically dead code

SAFI_EVPN and SAFI_MPLSVPN have been excluded by previous
if statements.  This code is dead.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agobgpd: Remove dead code in rfapi
Donald Sharp [Sat, 26 Oct 2019 00:31:02 +0000 (20:31 -0400)]
bgpd: Remove dead code in rfapi

Coverity spotted some dead code in the rfapi code.  Removing.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agobfdd: VRF and Coverity
Donald Sharp [Sat, 26 Oct 2019 00:26:29 +0000 (20:26 -0400)]
bfdd: VRF and Coverity

Fixup a couple of Coverity issues surrounding pointers

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
4 years agoMerge pull request #5216 from ton31337/fix/override_peers_ttl_if_peer_group_configured
Donald Sharp [Fri, 25 Oct 2019 18:03:06 +0000 (14:03 -0400)]
Merge pull request #5216 from ton31337/fix/override_peers_ttl_if_peer_group_configured

bgpd: Override peer's TTL only if peer-group is configured with TTL

4 years agoMerge pull request #5225 from ton31337/fix/noip_nhrp_map
Donald Sharp [Fri, 25 Oct 2019 18:02:29 +0000 (14:02 -0400)]
Merge pull request #5225 from ton31337/fix/noip_nhrp_map

nhrp: Make sure `no ip nhrp map <something>` works as expected

4 years agoMerge pull request #5223 from donaldsharp/fix_it_it_it_it_it_it
Russ White [Fri, 25 Oct 2019 17:53:39 +0000 (13:53 -0400)]
Merge pull request #5223 from donaldsharp/fix_it_it_it_it_it_it

Fix it it it it it it

4 years agozebra: rt_netlink nexthop handling checkpatch
Stephen Worley [Fri, 25 Oct 2019 15:11:06 +0000 (11:11 -0400)]
zebra: rt_netlink nexthop handling checkpatch

Checkpatch was complaining because this code was extending
beyond 80 characters on a couple lines. Adjusted a conditional
tree to fix that.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Cleanup zebra_nhg APIs
Stephen Worley [Wed, 23 Oct 2019 22:28:10 +0000 (18:28 -0400)]
zebra: Cleanup zebra_nhg APIs

Add a private header file for functions that are internal/special
case like how we do it for `lib/nexthop_group_private.h`.

Remove a bunch of functions from the header file only being used
statically and add some comments for those remaining to indicate
better what their use is.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Re-work zebra_nhg_*_valid APIs
Stephen Worley [Wed, 23 Oct 2019 20:49:07 +0000 (16:49 -0400)]
zebra: Re-work zebra_nhg_*_valid APIs

Re-work the validity setting and checking APIs
for nhg_hash_entry's to make them clearer.

Further, they were originally only beings set
on ifdown and install. Extended their use into
releasing entries and to account for setting
the validity of a recursive dependent.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Improve commenting for group requeue case
Stephen Worley [Wed, 23 Oct 2019 19:07:22 +0000 (15:07 -0400)]
zebra: Improve commenting for group requeue case

The commenting for why we would need to requeue a
group from the kernel to be later processed was not
sufficient. Add a better explanation for the flow
and state of the system.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Change wording of duplicate kernel nhg flag
Stephen Worley [Wed, 23 Oct 2019 18:50:30 +0000 (14:50 -0400)]
zebra: Change wording of duplicate kernel nhg flag

Change the wording of the flag indicating we have received
a nexthop group from the kernel with a different ID but
is fundamentally identical to one we already have.

It was colliding with a flag of similar name in the nexthop struct.

Change it from NEXTHOP_GROUP_DUPLICATE -> NEXTHOP_GROUP_UNHASHABLE
since it is in fact unhashable.

Also change the wording of functions and comments referencing the same
problem.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib: Make nexthop_next* use const for nexthop
Stephen Worley [Wed, 23 Oct 2019 18:37:20 +0000 (14:37 -0400)]
lib: Make nexthop_next* use const for nexthop

Make nexthop_next() and nexthop_next_active_resolved() use
const for the nexthop argument. They should not be modifying so
it makes sense here.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Check depends for validity, not dependents
Stephen Worley [Wed, 23 Oct 2019 18:08:12 +0000 (14:08 -0400)]
zebra: Check depends for validity, not dependents

When determining whether to set the nhg_hash_entry as
invalid, we should have been checking the depends, not
the dependents. If its a group and at least one of its
depends is valid, the group is still valid.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Guard nexthop group overflow read
Stephen Worley [Wed, 23 Oct 2019 17:08:10 +0000 (13:08 -0400)]
zebra: Guard nexthop group overflow read

Guard against an overflow read when processing
nexthop groups from netlink. Add a check to ensure
we don't try to write passed the array size.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Adjust nhg handling for dataplane result off on shutdown
Stephen Worley [Fri, 4 Oct 2019 20:48:20 +0000 (16:48 -0400)]
zebra: Adjust nhg handling for dataplane result off on shutdown

Now with this patch we can't use shutdown for cleanup:

```
commit 2fc69f03d2f49fcf34948e82e865cd302ae08da0 (pr_5079)
Author: Mark Stapp <mjs@voltanet.io>
Date:   Fri Sep 27 12:15:34 2019 -0400

    zebra: during shutdown processing, drop dplane results

    Don't process dataplane results in zebra during shutdown (after
    sigint has been seen). The dplane continues to run in order to
    clean up, but zebra main just drops results.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
```

Adjusted nhg uninstall handling to clear data and other
cleanup before sending to the dataplane.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Set the nhe type in the appropriate place
Stephen Worley [Fri, 4 Oct 2019 20:12:19 +0000 (16:12 -0400)]
zebra: Set the nhe type in the appropriate place

We were setting the nhe type on uninstall when it should be on
the install.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Remove cleanup and nhg workqueue boilerplate
Stephen Worley [Fri, 4 Oct 2019 18:32:26 +0000 (14:32 -0400)]
zebra: Remove cleanup and nhg workqueue boilerplate

This code was from a strategies we elected not to use and
can safely be removed.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Comment to indicate where nhg hashtables live
Stephen Worley [Fri, 4 Oct 2019 18:28:33 +0000 (14:28 -0400)]
zebra: Comment to indicate where nhg hashtables live

Add a comment to the header of `zebra_nhg.c` to point the reader
to where the hashtables containing the nhg entries are held.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agolib,pbrd,zebra: Use one api to delete nexthops/group
Stephen Worley [Fri, 4 Oct 2019 18:04:43 +0000 (14:04 -0400)]
lib,pbrd,zebra: Use one api to delete nexthops/group

Reduce the api for deleting nexthops and the containing
group to just one call rather than having a special case
and handling it separately.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
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>