Commit graph

99 commits

Author SHA1 Message Date
Donald Sharp 0bc79f5e51 lib: nexthop code should use uint16_t for nexthop counting
It's possible to specify via the cli and configure how many
nexthops that are allowed on the system.  If you happen to
have > 255 then things are about to get interesting otherwise.

Let's allow up to 65k nexthops (ha!)

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-01 15:38:14 -04:00
Philippe Guibert e266c44345 lib: fix memory leak when disabling nexthop_hold contexts
A memory leak is detected when stopping the sharpd daemon
with a nexthop group configuration that includes nexthops.

The nexthop_hold structure and its attributes are not
freed. Fix it by adding the missing free function.

Fixes: 98cbbaea91 ("lib: Handle if up/down and vrf enable/disable events")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-01-04 17:12:36 +01:00
Philippe Guibert 66f08b3e15 lib: fix nexthop_group_nexthop_num_no_recurse() is static
No need to declare 'nexthop_group_nexthop_num_no_recurse()' as external.

Fixes: 98cda54a95 ("zebra: Add recursive functionality to NHE's")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-12-05 13:59:25 +01:00
Philippe Guibert 0c34fa2cc6 lib: fix nexthop node entry from nhg_list
When stopping a VRF, the linked list entries must be
removed too.

Fixes: 98cbbaea91 ("lib: Handle if up/down and vrf enable/disable events")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-11-30 14:25:08 +01:00
Philippe Guibert 2ff41dd690 lib: remove useless nexthop_group_active_nexthop_num_no_recurse()
The nexthop_group_active_nexthop_num_no_recurse() function is no more
used. Let us remove the function call.

Fixes: 148813c22a ("zebra: zebra_nhg check each nexthop for active, not just number")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-11-30 14:25:08 +01:00
Igor Ryzhov 7d67b9ff28 build: add -Wimplicit-fallthrough
Also:
- replace all /* fallthrough */ comments with portable fallthrough;
pseudo keyword to accomodate both gcc and clang
- add missing break; statements as required by older versions of gcc
- cleanup some code to remove unnecessary fallthrough

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-12 21:23:18 +03:00
G. Paul Ziemba 09262f1b72 pbrd: add nexthop drop type
Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2023-08-08 10:18:15 -07:00
Donald Sharp 8383d53e43
Merge pull request #12780 from opensourcerouting/spdx-license-id
*: convert to SPDX License identifiers
2023-02-17 09:43:05 -05:00
Stephen Worley 90aaed169f lib,sharpd: add ability for sharpd to install vni labels
Add the ability for sharpd to install vni labels for testing.

This patch is just for testing/dev work purposes with evpn.
It adds some code to vty for nexthop-groups so we can explicitly
add a label to nexthops and then let sharpd encode them to zebra.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
Stephen Worley 4645cb6bc2 lib,zebra,bgpd,staticd: use label code to store VNI info
Use the already existing mpls label code to store VNI
info for vxlan. VNI's are defined as labels just like mpls,
we should be using the same code for both.

This patch is the first part of that. Next we will need to
abstract the label code to not be so mpls specific. Currently
in this, we are just treating VXLAN as a label type and storing
it that way.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
Stephen Worley 78d106e1cb lib: add has_label function for nexthop groups
Add a function nexthop_group_has_label() for determining
if even a single nexthop in the group has a label on it.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:04 -05:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donald Sharp f3c6dd49f4 *: Add ability for daemons to notice resilience changes
This patch just introduces the callback mechanism for the
resilient nexthop changes so that upper level daemons
can take advantage of the change.  This does nothing
at this point but just call some code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:34:27 -04:00
Donald Sharp f0f618dcdb lib, vtysh: Add ability to specify resilient nhgs
Add the ability to specify a resilient nexthop group

nexthop-group A
 resilient buckets 32 idle_timer 100 unbalanced_timer 500
 nexthop 192.168.100.1 enp7s0
 nexthop 192.168.100.33 enp7s0
 nexthop 192.168.122.1 enp1s0

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:34:27 -04:00
Donald Sharp 569e141113 lib, zebra: Add ability to encode/decode resilient nhg's
Add ability to read the nexthop group resilient linux
kernel data as well as write it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04 13:29:36 -04:00
David Lamparter 89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
Donatas Abraitis 47e1288431 *: Replace sockunion2str => %pSU
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-21 13:34:56 +03:00
Donatas Abraitis 4e9a98636f *: Remove unused variables
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:41 +02:00
Donatas Abraitis e46a4ac958 lib: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 11:35:31 +02:00
Igor Ryzhov 5d8694aee7 lib: remove wrong setting of interface configured flag
The fact that the interface name is used in some nexthop config doesn't
mean that the interface is configured.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-15 03:42:52 +03:00
Igor Ryzhov 07679ad98a *: explicitly print "exit" at the end of every node config
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

For example, with the following config:
```
router ospf
 network 193.168.0.0/16 area 0
!
mpls ldp
 discovery hello interval 111
!
```
Line `mpls ldp` is processed as command `mpls ldp-sync` inside the
`router ospf` node. This leads to a complete loss of `mpls ldp` node
configuration.

To eliminate this issue and all possible similar issues, let's print an
explicit "exit" at the end of every node config.

This commit also changes indentation for a couple of existing exit
commands so that all existing commands are on the same level as their
corresponding node-entering commands.

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23 22:08:20 +03:00
David Lamparter 96244aca23 *: require semicolon after DEFINE_QOBJ & co.
Again, see previous commits.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:37 +01:00
David Lamparter bf8d3d6aca *: require semicolon after DEFINE_MTYPE & co
Back when I put this together in 2015, ISO C11 was still reasonably new
and we couldn't require it just yet.  Without ISO C11, there is no
"good" way (only bad hacks) to require a semicolon after a macro that
ends with a function definition.  And if you added one anyway, you'd get
"spurious semicolon" warnings on some compilers...

With C11, `_Static_assert()` at the end of a macro will make it so that
the semicolon is properly required, consumed, and not warned about.

Consistently requiring semicolons after "file-level" macros matches
Linux kernel coding style and helps some editors against mis-syntax'ing
these macros.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
Donatas Abraitis af3b34f690 lib: Convert inet_ntoa to %pI4
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 15:32:50 +03:00
Stephen Worley 7403e15561 lib: remove nexthop_same_firsthop() api
Remove the nexthop_same_firsthop() api and just call nexthop_same().
Not entirely sure why we were using this function in the first place,
but now we are just marking dupes with it so lets just call a
common function and avoid issues.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-10-02 17:25:36 -04:00
Stephen Worley cc6a0d7d80 Revert "lib,sharpd,pbrd: set installable nhg command"
This reverts commit 1844f45e30913b27cfd875036f865a0edadcf244.
2020-09-28 12:40:59 -04:00
Stephen Worley 0de1db8f3b lib,sharpd,pbrd: set installable nhg command
Add a command `set installable` that allows configured nexthop
groups to be treated as separate/installable objects in the RIB.

A callback needs to be implemented per daemon to handle installing
the NHG into the rib via zapi when this command is set. This
patch includes the implementation for sharpd.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Stephen Worley 54c6fa8e0a lib,doc: add onlink flag to nexthop group config
Add an `onlink` flag to nexthop group configuration.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-09-28 12:40:59 -04:00
Donald Sharp e7ff02539c lib: Note old ifindex on shutdown
If we have an interface configured in a daemon on shutdown
store the old ifindex value for retrieval on when it is
possibly recreated.

This is especially important for nexthop groups as that we
had at one point in time the ability to restore the
configuration but it was lost when we started deleting
all deleted interfaces.  We need the nexthop group subsystem
to also mark that it has configured an interface.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28 07:51:06 -04:00
Donald Sharp a251884bff lib: Allow nexthop simple display to take an alternate ifp name
The nexthop_group_write_nexthop_simple function outputs the
interface name, because we've stored the ifindex.  The problem
is that there are ephermeal interfaces in linux that can be
destroyed/recreated.  Allow us to keep that data and do something
a bit smarter to allow show run's and other show commands to continue
to work when the interface is deleted.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-28 07:51:06 -04:00
Stephen Worley 7992452008 lib: break up show nexthop API a bit for reuse
Not everything cares about the vrf and backup info. Break
up the API to add a simple version to just write gateway/interface
info.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-27 16:13:48 -04:00
Stephen Worley c40e980601 lib: fix crash in show nexthop when vrf deleted
Fix a crash where if we issue a show run after a vrf has been
deleted we would crash here due to not null checking.

Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2020-08-18 14:54:50 -04:00
Mark Stapp 28593bccc2 lib: support multiple backup nexthops in nexthop group cli
Revise the nexthop-group cli to support multiple backups for
a single primary nexthop.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17 13:12:33 -04:00
Mark Stapp 474aebd939 lib,sharpd,zebra: initial support for multiple backup nexthops
Initial changes to support a nexthop with multiple backups. Lib
changes to hold a small array in each primary, zapi message
changes to support sending multiple backups, and daemon
changes to show commands to support multiple backups. The config
input for multiple backup indices is not present here.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17 13:12:33 -04:00
Wesley Coakley 20953065ff pbrd, lib: remember to free alloc'd qobj on delete
Signed-off-by: Wesley Coakley <wcoakley@nvidia.com>
2020-07-01 13:10:53 -04:00
Wesley Coakley 3e81618d0c pbrd, lib, doc: fix new show json key semantics
Revise new `show pbr` keys to be consistent with existing
json in other daemons

target->nexthop
id->tableId (where relevant)
isValid->valid
isInstalled->installed

Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-27 10:28:02 -04:00
Wesley Coakley 81c0078ef4 pbrd, lib: verbosity++ for json show directives
Increased the verbosity of the json keys and flattened the returned
structure by removing superfluous keys.

Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-27 10:28:02 -04:00
Wesley Coakley 010dd8edcb pbrd, lib: opt. json for show pbr nexthop-group
Signed-off-by: Wesley Coakley <wcoakley@cumulusnetworks.com>
2020-05-27 10:28:02 -04:00
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