]> git.proxmox.com Git - mirror_frr.git/log
mirror_frr.git
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>
4 years agozebra: Update rib_add_multipath with increment nhe
Stephen Worley [Mon, 1 Apr 2019 16:21:52 +0000 (12:21 -0400)]
zebra: Update rib_add_multipath with increment nhe

Update rib_add_multipath to use the reference count
increment function for nexthop group hash entries.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Recursively decrement refcnt on nhe's
Stephen Worley [Fri, 29 Mar 2019 22:16:27 +0000 (18:16 -0400)]
zebra: Recursively decrement refcnt on nhe's

Recursively decrement the refcnt on nhg_hash_entry's of
groups.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add function to increment nhg refcnt
Stephen Worley [Fri, 29 Mar 2019 22:14:20 +0000 (18:14 -0400)]
zebra: Add function to increment nhg refcnt

Add function to increment the route reference count for nhg_hash_entry's
and to do so recursively if its a group.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add equivalence function for nhg_depends
Stephen Worley [Fri, 29 Mar 2019 14:56:52 +0000 (10:56 -0400)]
zebra: Add equivalence function for nhg_depends

Add a helper function to allow us to check if two
nhg_hash_entry's dependency lists are equal.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add function to lookup ID in depends list
Stephen Worley [Fri, 29 Mar 2019 14:55:10 +0000 (10:55 -0400)]
zebra: Add function to lookup ID in depends list

Add helper function to allow us to lookup an ID inside
of a nhg_hash_entry's dependency list.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Fix hash key type in zebra_nhg
Stephen Worley [Fri, 29 Mar 2019 14:53:14 +0000 (10:53 -0400)]
zebra: Fix hash key type in zebra_nhg

We were declaring the hash key as an int rather then
uint32_t.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add function to find/create single nexthop
Stephen Worley [Fri, 29 Mar 2019 14:51:07 +0000 (10:51 -0400)]
zebra: Add function to find/create single nexthop

Add a function that allows us to take a single
nexthop struct and look that up or create a group and
nexthop hash entry with it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Pass is_kernel_nh to zebra_nhg_find()
Stephen Worley [Fri, 29 Mar 2019 14:46:50 +0000 (10:46 -0400)]
zebra: Pass is_kernel_nh to zebra_nhg_find()

Pass a boolean to zebra_nhg_find(), indicating whether the
nhg is being lookedup from the kernel side or not.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Move id counter into zebra_nhg_find()
Stephen Worley [Thu, 28 Mar 2019 19:20:29 +0000 (15:20 -0400)]
zebra: Move id counter into zebra_nhg_find()

Move the id counter further up into zebra_nhg_find() so that
it is still incremented if we receive a duplicate that never
would get allocated. The kernel will still use the dup, so we
have to account for that in our id counter.

Also, if we don't create a new entry, reset the id back to where
it was when zebra_nhg_find() was called.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Make kernel debug nexthop standardized
Stephen Worley [Thu, 28 Mar 2019 19:18:28 +0000 (15:18 -0400)]
zebra: Make kernel debug nexthop standardized

Make the the kernel debug zlog for nexthop messages from the
kernel more aligned with the route message kernel debug zlog.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Always copy nhg and depends on nhe alloc
Stephen Worley [Tue, 26 Mar 2019 23:40:23 +0000 (19:40 -0400)]
zebra: Always copy nhg and depends on nhe alloc

Changed our alloc function to just copy the nhg and
nhg_depends. This makes the zebra_nhg_find code a
little bit cleaner, hopefully preventing bugs.

The only issue with this is that it makes us have to loop
over the nexthops in a group an extra time for the copies.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Make wording for depend functions clearer
Stephen Worley [Tue, 26 Mar 2019 23:38:20 +0000 (19:38 -0400)]
zebra: Make wording for depend functions clearer

Fix a couple functions that were using depends (plural)
rather than depend(singular) in their wording.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add functionality to send groups to kernel
Stephen Worley [Tue, 26 Mar 2019 23:35:08 +0000 (19:35 -0400)]
zebra: Add functionality to send groups to kernel

Add functionality to allow us to send nexthop groups
to the kernel. It creates a nexthop_grp array based on
the dependency list in the nhg_hash_entry and then shoves
that into the netlink message.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Make nexthop ctx use nhg_depend_dup_list
Stephen Worley [Tue, 26 Mar 2019 23:32:15 +0000 (19:32 -0400)]
zebra: Make nexthop ctx use nhg_depend_dup_list

Update the dataplane nexthop ctx to use the nhg_depend_dup_list()
function for copying over the dependencies into its context.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add function to duplicate nhg dependencies
Stephen Worley [Tue, 26 Mar 2019 23:28:23 +0000 (19:28 -0400)]
zebra: Add function to duplicate nhg dependencies

Add a function to duplicate a nhg dependency linked
list. We will use this for duplicating the dependency
list rather than the linked list dup function in lib/linkedlist.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Make nexthop group vrf VRF_DEFAULT
Stephen Worley [Fri, 22 Mar 2019 18:00:25 +0000 (14:00 -0400)]
zebra: Make nexthop group vrf VRF_DEFAULT

Nexthop groups can have nexthops in different vrf's. So,
let's make the group vrf_id just be VRF_DEFAULT for hash
lookup purposes.

Set vrf_id to be VRF_DEFAULT for every message. If its a new
nextop, set the vrf to be the appropriate thing, otherwise
its a group and can just be left as default.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Refactor nexthop group creation code to use allocated memory
Stephen Worley [Fri, 22 Mar 2019 17:11:07 +0000 (13:11 -0400)]
zebra: Refactor nexthop group creation code to use allocated memory

Simplify the code for nexthop hash entry creation. I made nexthop
hash entry creation expect the nexthop group and depends to always
be allocated before lookup. Before, it was only allocated if it had
dependencies. I think it makes the code a bit more readable to go
ahead an allocate even for single nexthops as well.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add helper functions for freeing the members of nexthop group hash entries
Stephen Worley [Fri, 22 Mar 2019 17:07:22 +0000 (13:07 -0400)]
zebra: Add helper functions for freeing the members of nexthop group hash entries

Add some functions that can be called to free everything that should
have been allocated in a nexthop group hash entry.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Make show nexthop-group <null> list all nexthop hash entries
Stephen Worley [Thu, 21 Mar 2019 14:52:11 +0000 (10:52 -0400)]
zebra: Make show nexthop-group <null> list all nexthop hash entries

Add an option to not specify the afi in the show nexthop-group
command so that it shows all nexthops, including groups. This is
how iproute2 does it. If the afi is given, it will only show single
nexthops since groups are AF_UNSPEC.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Read in nexthop dependencies from the kernel
Stephen Worley [Thu, 21 Mar 2019 14:47:19 +0000 (10:47 -0400)]
zebra: Read in nexthop dependencies from the kernel

Add functionality to read in a group from the kernel,
create a hash entry for it, and add its nexthops to
its dependency list.

Further, we create its nhg struct separtely from this,
copying over any nexthops it should reference directly
into it.

Thus, we have two types for representation of the nexthop group:
nhe->nhg_depends->[nhe, nhe, nhe]

nhe->nhg->nexthop->nexthop->nexthop

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add dependency information for nexthop group hash entries
Stephen Worley [Thu, 21 Mar 2019 14:43:16 +0000 (10:43 -0400)]
zebra: Add dependency information for nexthop group hash entries

We treat "groups" from the kernel here as a dependency list.
Each hash entry, if its a group from the kernel, has
a list of any other nexthop hash entries that are in its
group. A non-group nexthop from the kernel will have its
dependency list set to NULL.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agoinclude: Add nexthop.h to the include automake file
Stephen Worley [Thu, 21 Mar 2019 14:33:42 +0000 (10:33 -0400)]
include: Add nexthop.h to the include automake file

Add linux header nexthop.h to the automake file under
include/.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Check if a nexthop was added to the nhg
Stephen Worley [Wed, 20 Mar 2019 17:09:15 +0000 (13:09 -0400)]
zebra: Check if a nexthop was added to the nhg

Before doing anything with our tables, less make sure
we even added anything to the group.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add afi value for all nexthops sent/received
Stephen Worley [Wed, 20 Mar 2019 17:03:22 +0000 (13:03 -0400)]
zebra: Add afi value for all nexthops sent/received

Since nexthops are always going to need to be address family
specific unless they are only a group, we have to address
this when we receive and send them.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agoRevert "zebra: Remove afi field in nexthop hash entry"
Stephen Worley [Tue, 19 Mar 2019 21:06:01 +0000 (17:06 -0400)]
Revert "zebra: Remove afi field in nexthop hash entry"

This reverts commit be73fe9393aac58c7f4bdb5c8a98c24c6cda6d5d.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Make bad address family log message more clear
Stephen Worley [Tue, 19 Mar 2019 20:43:27 +0000 (16:43 -0400)]
zebra: Make bad address family log message more clear

The message for an invalid address family on a nexthop gateway did
not specify that is what for the gateway specifically.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Give Nexthop Group Hash entries a defined memory type
Stephen Worley [Fri, 15 Mar 2019 16:23:51 +0000 (12:23 -0400)]
zebra: Give Nexthop Group Hash entries a defined memory type

The nexthop group hash entries were using the "TMP" memory
type. Declared one for them and updated to use it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Change wording in duplicate error message
Stephen Worley [Wed, 13 Mar 2019 14:26:30 +0000 (10:26 -0400)]
zebra: Change wording in duplicate error message

Changed to the wording in the duplicate error message
since its techincally possible we get could try to
create a dupe from somewhere else besides the kernel
in the future.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Fix where the flags are set for new nexthop entries
Stephen Worley [Wed, 13 Mar 2019 14:21:41 +0000 (10:21 -0400)]
zebra: Fix where the flags are set for new nexthop entries

We were setting the flags in a couple different places for
nexthop entries.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add ifp to zebra-side rib_add
Stephen Worley [Tue, 14 May 2019 20:46:05 +0000 (13:46 -0700)]
zebra: Add ifp to zebra-side rib_add

Add an interface pointer for an nexthop group hash entry
when we are getting a rib_add for a new route.

Also, add the interface index to the `show nexthop-group` command.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Make show nexthop-group command more readable
Stephen Worley [Mon, 11 Mar 2019 21:42:24 +0000 (17:42 -0400)]
zebra: Make show nexthop-group command more readable

Put some whitespace into the command output so that
we can read it a little bit easier.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add new nexthops to the interface nexthop hash entry list
Stephen Worley [Mon, 11 Mar 2019 20:31:44 +0000 (16:31 -0400)]
zebra: Add new nexthops to the interface nexthop hash entry list

When we get a new nexthop and find the interface associated
with it, add this nexthop to the interface's zebra interface
info nexthop hash entry list.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add nexthop hash entry list to zebra interface info
Stephen Worley [Mon, 11 Mar 2019 20:29:57 +0000 (16:29 -0400)]
zebra: Add nexthop hash entry list to zebra interface info

Add a nexthop hash entry list to the local zebra
interface info for each interface. This will allow
us to modify nexthops on link events.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Make route entry nexthop groups point to our hash entry
Stephen Worley [Mon, 11 Mar 2019 14:58:05 +0000 (10:58 -0400)]
zebra: Make route entry nexthop groups point to our hash entry

Make our route entry struct's re->ng nexthop group pointer
just point to the nhe->nhg nexthop hash entry nexthop group.
This will allow updates to the nexthop itself to propogate
to our routes immediately.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Update rib_add to take a nexthop ID
Stephen Worley [Mon, 11 Mar 2019 14:55:53 +0000 (10:55 -0400)]
zebra: Update rib_add to take a nexthop ID

Add a parameter to the rib_add function so that it takes
a nexthop ID from the kernel if one is passed along
with the route.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Put unicast nexthop parsing into its own function
Stephen Worley [Mon, 11 Mar 2019 14:52:33 +0000 (10:52 -0400)]
zebra: Put unicast nexthop parsing into its own function

Move the nexthop unicast parsing into its own function
to improve code readability. It was getting a bit too
indented.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Parse in nexthop ID information from new routes
Stephen Worley [Mon, 11 Mar 2019 14:46:25 +0000 (10:46 -0400)]
zebra: Parse in nexthop ID information from new routes

Add parsing code for nexthop object ID's when we get a
route. When we get a new route with the new kernel, it
will come with a nexthop ID and the nexthop full info.
We should just reference by ID if it exists and point
to the nexthop hash entry that matches it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Uninstall nexthops on shutdown
Stephen Worley [Fri, 8 Mar 2019 15:35:38 +0000 (10:35 -0500)]
zebra: Uninstall nexthops on shutdown

Add functionality to uninstall nexthops we created on shutdown.
To account for this, I added in a function for zebra_router
cleanup in a shutdown event.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Uninstall nexthop when ref count hits zero
Stephen Worley [Fri, 8 Mar 2019 15:29:43 +0000 (10:29 -0500)]
zebra: Uninstall nexthop when ref count hits zero

When nexthop entry reference counts hit zero and
we created them, uninstall them from the kernel.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add calls to the nexthop context process result function
Stephen Worley [Fri, 8 Mar 2019 15:26:33 +0000 (10:26 -0500)]
zebra: Add calls to the nexthop context process result function

Added in case statements to handle finished dataplane contexts
and then handle them with the nexthop process result function.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Set the INSTALLED flags on nexthop entries we receive
Stephen Worley [Fri, 8 Mar 2019 15:23:34 +0000 (10:23 -0500)]
zebra: Set the INSTALLED flags on nexthop entries we receive

Add SETs to the flags on nexthop entries to mark
 installed/uninstalled from the kernel.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Route entries use nexthop entry ID's instead of pointers
Stephen Worley [Fri, 8 Mar 2019 15:16:52 +0000 (10:16 -0500)]
zebra: Route entries use nexthop entry ID's instead of pointers

Switched the route entries to use ID's instead of pointers.
Perform lookups with the ID and then check if its null.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add dataplane process result function for nexthops
Stephen Worley [Thu, 7 Mar 2019 23:15:30 +0000 (18:15 -0500)]
zebra: Add dataplane process result function for nexthops

Add a function that can handle the results of a dataplane
ctx status, dpending on the operation performed.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add functions for installing/uninstalling nexthops
Stephen Worley [Thu, 7 Mar 2019 23:11:57 +0000 (18:11 -0500)]
zebra: Add functions for installing/uninstalling nexthops

Add functions for sending a nexthop to be queued on the dataplane
for install/uninstall into the kernel.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Force re-install nexthop if still referenced
Stephen Worley [Wed, 6 Mar 2019 20:04:23 +0000 (15:04 -0500)]
zebra: Force re-install nexthop if still referenced

Added functionality so that when we receive a RTM_DELNEXTHOP
for a nhg_hash_entry that is still being referenced by
a route, we immediately push it back to the kernel.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add function to install a nhe into the kernel
Stephen Worley [Wed, 6 Mar 2019 19:58:57 +0000 (14:58 -0500)]
zebra: Add function to install a nhe into the kernel

Add a function for installing Nexthop Group hash entires into
the kernel. It sends the entry to the dataplane and does any
post-processing immediately after that.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add a queued flag to nhg_hash_entry
Stephen Worley [Wed, 6 Mar 2019 19:56:04 +0000 (14:56 -0500)]
zebra: Add a queued flag to nhg_hash_entry

Added a NEXTHOP_GROUP_QUEUED flag to the nexthop
group hash entry struct. This indicates when we have
sent it to be installed to the kernel and are waiting
for the dataplane provider to process it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Return proper status result
Stephen Worley [Wed, 6 Mar 2019 19:10:08 +0000 (14:10 -0500)]
zebra: Return proper status result

We were ignoring the status result interger from
the netlink request and message parsing and just
returning 0. Fixed this to return the result of the last one.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add kernel condition check to see if it supports nexthops
Stephen Worley [Wed, 6 Mar 2019 19:08:13 +0000 (14:08 -0500)]
zebra: Add kernel condition check to see if it supports nexthops

Added a check on startup for determining if the kernel supports
nexthop objects. It sets an appropriate bool on the zebra namespace
struct.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Use the dest prefix for determining nexthop family
Stephen Worley [Wed, 6 Mar 2019 18:43:40 +0000 (13:43 -0500)]
zebra: Use the dest prefix for determining nexthop family

Device only nexthops still need an address family associated
with them. Decided to get this from the destination prefix on it.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add debug statement for nexthop netlink messages
Stephen Worley [Wed, 6 Mar 2019 18:42:05 +0000 (13:42 -0500)]
zebra: Add debug statement for nexthop netlink messages

Add the zebra kernel debug statement for nexthop messages
so we can see them via vtysh.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add namespace info to the nexthop dataplane ctx
Stephen Worley [Wed, 6 Mar 2019 18:35:31 +0000 (13:35 -0500)]
zebra: Add namespace info to the nexthop dataplane ctx

The nexthop dataplane context was not getting populated with
namespace info for its netlink messages. Fixed this to do
lookups the same way we do it with route contexts.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add kernel debugging function for netlink nexthop messages
Stephen Worley [Wed, 6 Mar 2019 16:13:43 +0000 (11:13 -0500)]
zebra: Add kernel debugging function for netlink nexthop messages

We needed a kernel debugging function for netlink nexthop
messages when people are debugging kernel zebra messages.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
4 years agozebra: Add base functionality for nexthop processing via the dataplane
Stephen Worley [Fri, 1 Mar 2019 22:17:00 +0000 (17:17 -0500)]
zebra: Add base functionality for nexthop processing via the dataplane

Add all the neccessary code to allow nexthops to be processed
in separate dataplane contexts with the netlink dataplane kernel
provider.

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