Commit Graph

61 Commits

Author SHA1 Message Date
David Lamparter
f4b8291fcb *: move CLI node names to cmd_node->name
And again for the name.  Why on earth would we centralize this, just so
people can forget to update it?

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:59 +02:00
David Lamparter
243895805a *: move CLI parent data to cmd_node->parent_node
Same as before, instead of shoving this into a big central list we can
just put the parent node in cmd_node.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
612c2c15d8 *: remove second parameter on install_node()
There is really no reason to not put this in the cmd_node.

And while we're add it, rename from pointless ".func" to ".config_write".

[v2: fix forgotten ldpd config_write]

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
249a771b63 *: remove cmd_node->vtysh
The only nodes that have this as 0 don't have a "->func" anyway, so the
entire thing is really just pointless.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter
62b346eefa *: clean up cmd_node initializers
... and use named assignments everywhere (so I can change the struct.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
Mark Stapp
4fda105e44 lib: support replacement in the nexthop-group cli
Use more limited matching logic so that nexthops within a
nexthop-group are unique based only on vrf, type, and gateway.
Treat configuration of a nexthop that matches an existing
nexthop as a replace operation.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-07 09:31:32 -04:00
Mark Stapp
0a8881b4b5 lib: support backup nexthops in nexthop-groups and zapi
Add vty support for backup nexthops in nexthop groups. Capture
backup nexthop info in zapi route messages.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:39:14 -04:00
Mark Stapp
e4a1ec7454 zebra,lib: use const in more apis
Use const with some args to ipaddr, zebra vxlan, mpls
lsp, and nexthop apis; add some extra checks to some
nexthop-related apis.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27 09:37:02 -04:00
Mark Stapp
c13bfa7435 lib: use const in nexthop_group copy api
Add some const to the nhg copy api.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-25 08:26:38 -05:00
Mark Stapp
d26e2d9be4
Merge pull request #5600 from sworleys/NHG-Depend-Crash
zebra: can't improve efficiency for recursive depends
2020-01-15 16:31:55 -05:00
Stephen Worley
89ca64c90a lib: assert if someone adds to nexthop list to nhg
If someone tries to add a nexthop with a list of nexthops
already attached to it, let's just assert. This standardizes
the API to say we assume this is an individual nexthop
you are appending to a group.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-01-15 13:35:29 -05:00
Stephen Worley
77bf9504bf lib,zebra: tighten up the nexthop_copy/nexthop_dup APIs
Make the nexthop_copy/nexthop_dup APIs more consistent by
adding a secondary, non-recursive, version of them. Before,
it was inconsistent whether the APIs were expected to copy
recursive info or not. Make it clear now that the default is
recursive info is copied unless the _no_recurse() version is
called. These APIs are not heavily used so it is fine to
change them for now.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-01-15 13:35:04 -05:00
Donald Sharp
04dd9e420e
Merge pull request #5535 from opensourcerouting/santa-elf
*: cleanup elves were here
2019-12-16 07:42:47 -05:00
Donald Sharp
f4d7bc0820
Merge pull request #5452 from mjstapp/fix_notify_nhg
zebra: align dplane notify processing with nhg work
2019-12-13 14:11:34 -05:00
David Lamparter
1b3e9a21dd lib: make some variables static
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-13 06:22:34 +01:00
Mark Stapp
e1f3a8eb19 lib,zebra: add api to enforce nexthop sort order when copying
Add an api that creates a copy of a list of nexthops and
enforces the canonical sort ordering; consolidate some nhg
code to avoid copy-and-paste. The zebra dplane uses
that api when a plugin sets up a list of nexthops, ensuring
that the plugin's list is ordered when it's processed in
zebra.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-09 16:25:53 -05:00
Donald Sharp
597371a615 lib: Add weight to nexthop for nexthop-group nexthops
Add the ability to read in the weight of a nexthop and store/handle
it appropriately

nexthop-group BLUE
  nexthop 192.168.201.44 weight 33
  nexthop 192.168.201.45 weight 66
  nexthop 192.168.201.46 weight 99

Is appropriately read in and handled as appropriate.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-09 13:39:59 -05:00
Renato Westphal
6f0af4c069
Merge pull request #5439 from mjstapp/nhg_add_labels
lib: support labelled nexthops in nexthop_groups
2019-12-06 11:17:10 -03:00
Mark Stapp
0eb97b860d lib,zebra: use nhg_hash_entry pointer in route_entry
Replace the existing list of nexthops (via a nexthop_group
struct) in the route_entry with a direct pointer to zebra's
new shared group (from zebra_nhg.h). This allows more
direct access to that shared group and the info it carries.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-04 08:13:52 -05:00
Mark Stapp
db2fede990 lib: support labelled nexthops in nexthop_groups
Add support for labelled nexthops in nexthop-group
vtysh configuration. Also update the PBR doc where
the cli is described.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-03 16:54:35 -05:00
Stephen Worley
d3a3513811 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>
2019-10-25 11:13:43 -04:00
Stephen Worley
f17f2c5d6c 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>
2019-10-25 11:13:43 -04:00
Stephen Worley
dd9546e196 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>
2019-10-25 11:13:43 -04:00
Stephen Worley
9c387098eb 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>
2019-10-25 11:13:43 -04:00
Stephen Worley
2171b19c5a 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>
2019-10-25 11:13:42 -04:00
Stephen Worley
9ef49038d5 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>
2019-10-25 11:13:42 -04:00
Stephen Worley
12ec584da8 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>
2019-10-25 11:13:42 -04:00
Stephen Worley
2f00094498 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>
2019-10-25 11:13:40 -04:00
Stephen Worley
98cda54a95 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>
2019-10-25 11:13:40 -04:00
Stephen Worley
8f8d9845c6 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>
2019-10-25 11:13:39 -04:00
Stephen Worley
0c8215cbab 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>
2019-10-25 11:13:39 -04:00
Igor Ryzhov
e429a2a0cc *: fix missing VRF autocompletions
Current autocompletion works only for simple "vrf NAME" case.

This commit expands it also for the following cases:
- "nexthop-vrf NAME" in staticd
- usage of $varname in many daemons

All daemons are updated to use single varname "$vrf_name".

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-09-24 19:51:46 +03:00
Stephen Worley
8c15fa95a8 lib: Add tail check before nexthop insertion
Add a tail check to see if we can just put the nexthop
at the end of the already sorted list before iteration.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-08-19 13:55:50 -04:00
Stephen Worley
50d8965075 lib: Private api for nexthop_group manipulation
Add a file that exposes functions which modify nexthop groups.
Nexthop groups are techincally immutable but there are a
few special cases where we need direct access to add/remove
nexthops after the group has been made. This file provides a
way to expose those functions in a way that makes it clear
this is a private/hidden api.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25 22:58:48 -04:00
Stephen Worley
504d0a4096 lib: Add a nexthop_dup() that allocates and copies
Add a nexthop_dup() api that both allocates and copies
a new nexthop from an old one. Still retain the old exposed
function nexthop_copy() so we can copy without allocation.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25 22:58:47 -04:00
Stephen Worley
e7addf02a1 lib: Put single nexthop copy into its own function
Put the code to copy a single nexthop into a function
of its own.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25 22:58:47 -04:00
Donald Sharp
6c8b51e172 lib: Add a couple functions to nexthop_group.c
Add nexthop_group_copy and nexthop_group_add_sorted functions.

nexthop_group_copy -> Copy src nexthop_group into dst nexthop_group
nexthop_group_add_sorted -> Adds a new nexthop to the nexthop group
in a sorted manner.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-25 22:58:47 -04:00
Donald Sharp
868ee86cec lib, pbrd, sharpd, vtysh: Add autocompletion for 'nexthop-group'
Add some auto-completion for the nexthop-group command

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-05 06:33:00 -04:00
Donald Sharp
454192f46f lib: Add a counter for number of nexthops
Add a ability to count the number of nexthops in a nexthop_group.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-18 14:17:44 -04:00
Stephen Worley
1b1fe1c409 lib: Add hash function for nexthop groups
Add a hash function to turn a nexthop group into a
32 bit unsigned hash key with jhash. We do not care to
hash any recursively resolved nexthops, just the group.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-04-05 14:19:44 -04:00
Mark Stapp
deff170e8b libs: use const in copy_nexthops api
Use const for the source arg to copy_nexthops().

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-04 10:54:10 -04:00
Quentin Young
c17faa4b10 lib: reduce exported var symbols
Don't need these in our DSO tables

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-03 20:34:18 +00:00
Donald Sharp
8d39ebf675
Merge pull request #3776 from opensourcerouting/pbrd-interface-nexthops
pbrd: add support for interface nexthops
2019-03-22 03:45:48 -04:00
Quentin Young
0a22ddfbb1 *: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:46 +00:00
Renato Westphal
7dce96f0e4 lib, pbrd: fix indentation of a few commands
When displaying the running configuration, we should use a single
space to indent commands when necessary (and not two spaces).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14 22:57:39 -02:00
Renato Westphal
1c869b6418 lib: add support for interface nexthops on nexthop groups
This patch adds support to nexthops of type NEXTHOP_TYPE_IFINDEX to
nexthop-groups. This should be especially useful when dealing with
p2p interfaces like tunnels that don't have IP addresses assigned
to them.

NOTE: nh->addr can be NULL now, so we should always perform a null
check before dereferencing this pointer.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14 22:57:39 -02:00
Renato Westphal
b43bb64f82 lib: change how nexthop groups store nexthop addresses
Use a pointer to a sockunion instead of a full sockunion in the
nexthop_hold structure. This prepares the ground for the next commit,
which will make nexthop addresses optional (in this commit we assume
nh->addr will never be NULL, but this will change).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14 20:01:30 -02:00
Renato Westphal
e5a501c2ed lib: consolidate nexthop-group deletion in a single place
Reuse the nhgl_delete() function to avoid code duplication.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-14 20:00:14 -02:00
David Lamparter
6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02:00
Donald Sharp
b51016ebb9 lib: Fix SA warning
The addr value will never be null because of the way we do the
cli, but the SA system doesn't understand this.  Add an assert
to make it happy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-04-23 22:09:33 -04:00