Commit Graph

5964 Commits

Author SHA1 Message Date
Donald Sharp
e0437aba6d zebra: Add more vrf name to debugs
Trying to debug some cross vrf stuff in zebra and frankly
it's hard to grep the file for the routes you are interested
in.  Let's clean this up some and get a bit better
information for us developers

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-11 15:30:43 -04:00
Russ White
add56c61dd
Merge pull request #15259 from dmytroshytyi-6WIND/nexthop_resolution
zebra: add LSP entry to nexthop via recursive (part 2)
2024-09-10 10:04:08 -04:00
Donald Sharp
98b11de9f6 zebra: Modify show zebra dplane providers to give more data
The show zebra dplane provider command was ommitting
the input and output queues to the dplane itself.
It would be nice to have this insight as well.

New output:
r1# show zebra dplane providers
dataplane Incoming Queue from Zebra: 100
Zebra dataplane providers:
  Kernel (1): in: 6, q: 0, q_max: 3, out: 6, q: 14, q_max: 3
  dplane_fpm_nl (2): in: 6, q: 10, q_max: 3, out: 6, q: 0, q_max: 3
dataplane Outgoing Queue to Zebra: 43
r1#

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-05 15:52:05 -04:00
Donald Sharp
8926ac1984 zebra: Limit queue depth in dplane_fpm_nl
The dplane providers have a concept of input queues
and output queues.  These queues are chained together
during normal operation.  The code in zebra also has
a feedback mechanism where the MetaQ will not run when
the first input queue is backed up.  Having the dplane_fpm_nl
code grab all contexts when it is backed up prevents
this system from behaving appropriately.

Modify the code to not add to the dplane_fpm_nl's internal
queue when it is already full.  This will allow the backpressure
to work appropriately in zebra proper.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-05 15:52:05 -04:00
Donald Sharp
3af381b502 zebra: Modify dplane loop to allow backpressure to filter up
Currently when the dplane_thread_loop is run, it moves contexts
from the dg_update_list and puts the contexts on the input queue
of the first provider.  This provider is given a chance to run
and then the items on the output queue are pulled off and placed
on the input queue of the next provider.  Rinse/Repeat down through
the entire list of providers.  Now imagine that we have a list
of multiple providers and the last provider is getting backed up.
Contexts will end up sticking in the input Queue of the `slow`
provider.  This can grow without bounds.  This is a real problem
when you have a situation where an interface is flapping and an
upper level protocol is sending a continous stream of route
updates to reflect the change in ecmp.  You can end up with
a very very large backlog of contexts.  This is bad because
zebra can easily grow to a very very large memory size and on
restricted systems you can run out of memory.  Fortunately
for us, the MetaQ already participates with this process
by not doing more route processing until the dg_update_list
goes below the working limit of dg_updates_per_cycle.  Thus
if FRR modifies the behavior of this loop to not move more
contexts onto the input queue if either the input queue
or output queue of the next provider has reached this limit.
FRR will naturaly start auto handling backpressure for the dplane
context system and memory will not go out of control.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-05 15:44:34 -04:00
Donald Sharp
34670c476a zebra: Use the ctx queue counters
The ctx queue data structures already have a counter
associated with them.  Let's just use them instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-05 15:44:34 -04:00
Donald Sharp
d97c535c1e *: Create termtable specific temp memory
When trying to track down a MTYPE_TMP memory leak
it's harder to search for it when you happen to
have some usage of ttable_dump.  Let's just give
it it's own memory type so that we can avoid
confusion in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-01 13:07:46 -04:00
Donald Sharp
0c72a78930 zebra: Allow for initial deny of installation of nhe's
Currently the FRR code will receive both kernel and
connected routes that do not actually have an underlying
nexthop group at all.  Zebra turns around and creates
a `matching` nexthop hash entry and installs it.
For connected routes, this will create 2 singleton
nexthops in the dplane per interface (v4 and v6).
For kernel routes it would just create 1 singleton
nexthop that might be used or not.

This is bad because the dplane has a limited amount
of space available for nexthop entries and if you
happen to have a large number of interfaces then
all of a sudden you have 2x(# of interfaces) singleton
nexthops.

Let's modify the code to delay creation of these singleton
nexthops until they have been used by something else in the
system.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-30 08:23:48 -04:00
Jafar Al-Gharaibeh
90787a57fd
Merge pull request #16689 from donaldsharp/blackhole_and_afi
Blackhole and afi
2024-08-29 22:13:03 -04:00
Donald Sharp
8ad5643abe zebra: Convince SA that the ng will always be valid
There is a code path that could theoretically get you
to a point where the ng->nexthop is a NULL value.
Let's just make sure the SA system believes that
cannot happen anymore.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-29 18:10:30 -04:00
Donald Sharp
f90989d52a zebra: Allow blackhole singleton nexthops to be v6
A blackhole nexthop, according to the linux kernel,
can be v4 or v6.  A v4 blackhole nexthop cannot be
used on a v6 route, but a v6 blackhole nexthop can
be used with a v4 route.  Convert all blackhole
singleton nexthops to v6 and just use that.
Possibly reducing the number of active nexthops by 1.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-29 15:06:31 -04:00
Donald Sharp
c10cdcd79a zebra: Display afi of the nexthop hash entry
Let's display the afi of the nexthop hash entry.  Right
now it is impossible to tell the difference between v4 or
v6 nexthops, especially since it is important for the kernel.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-29 14:49:36 -04:00
Jafar Al-Gharaibeh
ffaa365cc4
Merge pull request #16681 from donaldsharp/zebra_re_after_rn
zebra: Move prefix lookup to outside re loop
2024-08-28 23:43:40 -04:00
Mark Stapp
8b23abf36e
Merge pull request #16300 from donaldsharp/local_connected
Local connected
2024-08-28 14:10:14 -04:00
Donald Sharp
184dccca60 zebra: Move prefix lookup to outside re loop
Move the prefix lookup/comparison to outside the re loop
and into the rn loop, since that is where the code should
actually be.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-28 13:18:00 -04:00
Russ White
5a6cb0bf75
Merge pull request #16103 from mjstapp/fix_5549_nhg_type
zebra: be consistent about v6 nexthops for v4 routes
2024-08-27 09:46:53 -04:00
Donald Sharp
9bc0cd8241 zebra: Prevent accidental re memory leak in odd case
There exists a path in rib_add_multipath where if a decision
is made to not use the passed in re, we just drop the memory
instead of freeing it.  Let's free it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-27 06:25:34 -04:00
Donald Sharp
d528c02a20 zebra: Handle kernel routes appropriately
Current code intentionally ignores kernel routes.  Modify
zebra to allow these routes to be read in on linux.  Also
modify zebra to look to see if a route should be treated
as a connected and mark it as such.

Additionally this should properly handle some of the issues
being seen with NOPREFIXROUTE.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-27 06:25:34 -04:00
Donald Sharp
bdfccf69fa zebra: Expose rib_update_handle_vrf_all
This function will be used on interface down
events to allow for kernel routes to be cleaned
up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-27 06:25:34 -04:00
Donald Sharp
f450e1cda4 zebra: Make p and src_p const for rib_delete
The prefix'es p and src_p are not const.  Let's make
them so.  Useful to signal that we will not change this
data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-27 06:25:34 -04:00
Mark Stapp
b4dae97381
Merge pull request #16609 from donaldsharp/singleton_no_weight
Reduce the number of Singleton objects when using weight for NHG's
2024-08-23 16:19:29 -04:00
Khem Raj
0ef71391f0
zebra: Mimic GNU basename() API for non-glibc library e.g. musl
musl only provides POSIX version of basename and it has also removed
providing it via string.h header [1] which now results in compile errors
with newer compilers e.g. clang-18

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2024-08-22 14:50:41 -07:00
Donald Sharp
c20fa972d6 zebra: Create Singleton nhg's without weights
Currently FRR when it has two nexthop groups:
A
  nexthop 1 weight 5
  nexthop 2 weight 6
  nexthop 3 weight 7
B
  nexthop 1 weight 3
  nexthop 2 weight 4
  nexthop 3 weight 5

We end up with 5 singleton nexthops and two groups:

ID: 181818168 (sharp)
     RefCnt: 1
     Uptime: 00:04:52
     VRF: default
     Valid, Installed
     Depends: (69) (70) (71)
           via 192.168.119.1, enp13s0 (vrf default), weight 182
           via 192.168.119.2, enp13s0 (vrf default), weight 218
           via 192.168.119.3, enp13s0 (vrf default), weight 255
ID: 181818169 (sharp)
     RefCnt: 1
     Uptime: 00:02:08
     VRF: default
     Valid, Installed
     Depends: (71) (127) (128)
           via 192.168.119.1, enp13s0 (vrf default), weight 127
           via 192.168.119.2, enp13s0 (vrf default), weight 170
           via 192.168.119.3, enp13s0 (vrf default), weight 255

id 69 via 192.168.119.1 dev enp13s0 scope link proto 194
id 70 via 192.168.119.2 dev enp13s0 scope link proto 194
id 71 via 192.168.119.3 dev enp13s0 scope link proto 194
id 127 via 192.168.119.1 dev enp13s0 scope link proto 194
id 128 via 192.168.119.2 dev enp13s0 scope link proto 194
id 181818168 group 69,182/70,218/71,255 proto 194
id 181818169 group 71,255/127,127/128,170 proto 194

This is not a desirable state to be in.  If you have a
link flapping in the network and weights are changing
rapidly you end up with a large number of singleton
nexthops that are being used by the nexthop groups.
This fills up asic space and clutters the table.
Additionally singleton nexthops cannot have any weight
and the fact that you attempt to create a singleton
nexthop with different weights means nothing to the
linux kernel( or any asic dplane ).  Let's modify
the code to always create the singleton nexthops
without a weight and then just creating the
NHG's that use the singletons with the appropriate
weight.

ID: 181818168 (sharp)
     RefCnt: 1
     Uptime: 00:00:32
     VRF: default
     Valid, Installed
     Depends: (22) (24) (28)
           via 192.168.119.1, enp13s0 (vrf default), weight 182
           via 192.168.119.2, enp13s0 (vrf default), weight 218
           via 192.168.119.3, enp13s0 (vrf default), weight 255
ID: 181818169 (sharp)
     RefCnt: 1
     Uptime: 00:00:14
     VRF: default
     Valid, Installed
     Depends: (22) (24) (28)
           via 192.168.119.1, enp13s0 (vrf default), weight 153
           via 192.168.119.2, enp13s0 (vrf default), weight 204
           via 192.168.119.3, enp13s0 (vrf default), weight 255

id 22 via 192.168.119.1 dev enp13s0 scope link proto 194
id 24 via 192.168.119.2 dev enp13s0 scope link proto 194
id 28 via 192.168.119.3 dev enp13s0 scope link proto 194
id 181818168 group 22,182/24,218/28,255 proto 194
id 181818169 group 22,153/24,204/28,255 proto 194

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-22 13:22:06 -04:00
Donald Sharp
b62de7de2e zebra, tests: Connected and Local routes should have a weight of 1
All routes received by zebra from upper level protocols have a weight
of 1.  Let's just make everything extremely consistent in our code.
Lot's of tests needed to be fixed up to make this work.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-21 10:17:47 -04:00
Donald Sharp
db87ab3d86 zebra: Ensure we cannot send invalid range to kernel
The linux kernel adds 1 upon receipt of a weight, if you
send a 255 it gets unhappy.  Let's Limit range to 254 as
that kernel does not like sending of 255.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-21 10:15:55 -04:00
Jafar Al-Gharaibeh
d9775c690c
Merge pull request #16597 from kprovost/master
zebra: fix loading kernel routes without netlink
2024-08-19 13:02:36 -04:00
Donald Sharp
38b9df8e58 zebra: Do not assign time and then never use it
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-18 16:18:54 -04:00
Carmine Scarpitta
354f9e9009 zebra: Fix compilation warning
Make sure the variable `srv6` is not NULL before dereferencing it.

Fixes the following compilation warnings:

```
error	15-Aug-2024 14:20:01	zebra/zebra_srv6_vty.c:974:8: warning: Access to field 'locators' results in a dereference of a null pointer (loaded from variable 'srv6') [core.NullDereference]
error	15-Aug-2024 14:20:01	                for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, locator)) {
error	15-Aug-2024 14:20:01	                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 14:20:01	./lib/linklist.h:345:11: note: expanded from macro 'ALL_LIST_ELEMENTS_RO'
error	15-Aug-2024 14:20:01	        (node) = listhead(list), ((data) = NULL);                              \
error	15-Aug-2024 14:20:01	                 ^~~~~~~~~~~~~~
error	15-Aug-2024 14:20:01	./lib/linklist.h:63:22: note: expanded from macro 'listhead'
error	15-Aug-2024 14:20:01	#define listhead(X) ((X) ? ((X)->head) : NULL)
error	15-Aug-2024 14:20:01	                     ^
```

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-08-18 13:03:04 +02:00
Kristof Provost
f0aa8d4f42 zebra: fix loading kernel routs without netlink
Commit 605df8d44 zebra: Use zebra dplane for RTM link and addr broke loading of
kernel routes at startup for configurations without netlink.

It rearranged the startup sequence in zebra_ns_enable() to pass via
zebra_ns_startup_continue(), triggered through zebra_dplane_startup_stage()
calls. However, it neglected to make these calls in the non-netlink code path.
As a result zebra failed to load kernel routes at startup on platforms such
as FreeBSD.

Insert these calls so we run through all of the expected startup stages.

Signed-off-by: Kristof Provost <kprovost@netgate.com>
2024-08-16 10:42:33 +02:00
Donald Sharp
baa0a1df5b *: Fix spelling errors found
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-15 09:19:37 -04:00
Donald Sharp
90a50fd4af
Merge pull request #16576 from opensourcerouting/fix/free_opaque_data_of_route_entry
zebra: Do not forget to free opaque data for route entry
2024-08-13 14:14:36 -04:00
Donatas Abraitis
1e288c9b55 zebra: Do not forget to free opaque data for route entry
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-13 18:00:30 +03:00
Donald Sharp
5a1b61aeba zebra: Ensure non-equal id's are not same nhg's
The function zebra_nhg_hash_equal is only used
as a hash function for storage of NHG's and retrieval.
If you have say two nhg's:

31 (25/26)
32 (25/26)

This function would return them as being equal.  Which
of course leads to the problem when you attempt to
hash_release 32 but release 31 from the hash.  Then later
when you attempt to do hash comparisons 32 has actually
been freed leaving to use after free situations and shit
goes down hill fast.

This hash is only used as part of the hash comparison
function for nexthop group storage.  Since this is so
let's always return the 31/32 nhg's are not equal at all.

We possibly have a different problem where we are creating
31 and 32 ( when 31 should have just been used instead of 32 )
but we need to prevent any type of hash release problem at all.
This supercedes any other issue( that should be tracked down
on it's own ).  Since you can have use after free situation
that leads to a crash -vs- some possible nexthop group duplication
which is very minor in comparison.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-10 19:49:35 -04:00
Mark Stapp
0221ed2917 zebra: be consistent about v6 nexthops for v4 routes
Treat TYPE_IPV6 and TYPE_IPV6_IFINDEX nexthops the same way when
processing v4 (RFC 5549) routes.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-08-06 08:17:47 -04:00
Donatas Abraitis
2419fc5104 bgpd: Show which AFI is affected when prefix-list is not found
When the prefix-list is not found, show which AFI is the real one we are
looking for.

E.g.: looking at this output is not clear:

```
[RYF1Z-ZKDRS] route_match_address_prefix_list: Prefix List p1 specified does not exist defaulting to NO_MATCH
```

route_match_address_prefix_list() is called by route_match_ipv6_address_prefix_list(),
and route_match_ip_address_prefix_list().

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-07-31 13:20:59 +03:00
Donald Sharp
e53fa582bc zebra: Fix removal of routes on MetaQ when client goes down
It is possible that right before an upper level protocol dies
or is killed routes would be installed into zebra.  These routes
could be on the Meta-Q for early route-processing.  Leaving us with
a situation where the client is removed, and all it's routes that are
in the rib at that time, and then after that the MetaQ is run and the
routes are reprocessed leaving routes from an upper level daemon
post daemon going away from zebra's perspective.  These routes will
be abandoned.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-07-30 08:34:06 -04:00
mobash-rasool
3ddf5cf28f
Merge pull request #16041 from sri-mohan1/srib-24-zebra-d
zebra: changes for code maintainability
2024-07-25 22:36:17 +05:30
Carmine Scarpitta
846bbcba0d zebra: Remove duplicate #include "zebra/interface.h"
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:50:02 +02:00
Carmine Scarpitta
e2cb3ab5c6 zebra: Remove duplicate #include "zebra/interface.h"
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:41:29 +02:00
Carmine Scarpitta
bcf7bc1ce8 zebra: Remove duplicate #include "zebra/debug.h"
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:41:09 +02:00
Carmine Scarpitta
8b206b0cd7 zebra: Remove duplicate #include <stdio.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:39:34 +02:00
Carmine Scarpitta
4ca8332922 zebra: Remove duplicate #include <string.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:39:14 +02:00
Carmine Scarpitta
22aa0ffb81 zebra: Remove duplicate #include <stdlib.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:38:55 +02:00
Carmine Scarpitta
c432aa0bb4 zebra: Remove duplicate #include <arpa/inet.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:38:27 +02:00
Carmine Scarpitta
0a68626e48 zebra: Remove duplicate #include <netinet/in.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:38:04 +02:00
Russ White
aa9d66e922
Merge pull request #16410 from pguibert6WIND/show_zebra_dplane_nexthop
zebra: add nexthop counter to 'show zebra dplane' command
2024-07-23 16:42:41 -04:00
Russ White
9db9128c27
Merge pull request #16330 from donaldsharp/nhg_going_down
zebra: Properly note that a nhg's nexthop has gone down
2024-07-23 10:49:49 -04:00
Donatas Abraitis
8eb78b2d89
Merge pull request #16341 from crosser/preserve-needed-rmacs
zebra: evpn: not coerce VTEP IP to IPv4 in nh_list
2024-07-22 02:53:26 -07:00
Philippe Guibert
e36e570c6c zebra: add nexthop counter to 'show zebra dplane' command
The nexthop updates counter value was never displayed.
Add it.

> # show zebra dplane
> Zebra dataplane:
> Route updates:            7673010
> Route update errors:      0
> Nexthop updates:          1100
> Nexthop update errors:    0
> [..]

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-07-17 11:58:22 +02:00
sri-mohan1
c2f2dde5c1 zebra: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-07-15 19:13:47 +05:30