Commit Graph

737 Commits

Author SHA1 Message Date
Donald Sharp
d7ac4c4d88 zebra: Introduce early route processing on the MetaQ
Currently if an operator does this operation:

sharpd@eva ~/frr8> sudo ip nexthop add id 5000 via 192.168.119.44 dev enp39s0 ; sudo ip route add 10.0.0.1 nhid 5000
2022/06/30 08:52:40 ZEBRA: [ZHQK5-J9M1R] proto2zebra: Please add this protocol(0) to proper rt_netlink.c handling
2022/06/30 08:52:40 ZEBRA: [PS16P-365FK][EC 4043309076] Zebra failed to find the nexthop hash entry for id=5000 in a route entry
sharpd@eva ~/frr8> vtysh -c "show ip route 10.0.0.1"
Routing entry for 0.0.0.0/0
  Known via "kernel", distance 0, metric 100, best
  Last update 00:01:58 ago
  * 192.168.119.1, via enp39s0

The route is dropped by zebra with no warnings.  This is not good,
but unlikely to happen at this point in time.  In order to fix
this issue route processing from inputs needs to happen after nexthop
group processing from inputs.  This was not possible because
nexthop groups are placed on the metaQ.  As such the above
nexthop group creation is placed on the metaQ for processing
in META_QUEUE_NHG.  Then the route is read in and processed
immediately.  The nexthop group is not found ( not processed yet!)
and the route is dropped in zebra.

Modify the code to have early route processing of validity
on the MetaQ.  This preserves the order of operations.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-17 16:04:50 -04:00
Donald Sharp
53216dff6e zebra: Convert label processing to Meta-Q
Convert label processing that comes from zapi messages
into being handled by the meta-Q.  This is because early
route processing is going to be moved to the meta-Q as
well and we will have a chicken and egg problem without
moving this code to be processed by the meta-Q.

Ordering of messages from ospf as an example:
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:48] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:62] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:43] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:61] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_ROUTE_ADD:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:66] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36]
2022/08/09 08:55:52.740 ZEBRA: [YXG8K-BCYMV] zebra message[ZEBRA_MPLS_LABELS_REPLACE:0:47] comes from socket [36]

The ZEBRA_MPLS_LABELS_REPLACE immediately turn around and attempt to replace nexthop labels on routes that
were added.  If the route add is placed on the metaQ, it will not exist yet and as such the label replace
will fail.

Modify the zebra code to take the label operations and place them on the metaQ as well.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-17 10:44:33 -04:00
Siger Yang
449a30edf6
zebra: add tc netlink and dplane ops
This commit implements necessary netlink encoders for traffic control
including QDISC, TCLASS and TFILTER, and adds basic dplane operations.

Co-authored-by: Stephen Worley <sworley@nvidia.com>
Signed-off-by: Siger Yang <siger.yang@outlook.com>
2022-08-11 02:32:43 +08:00
Donald Sharp
a310ebc114 zebra: Combine meta_queue_free and meta_queue_vrf_free functions
These functions essentially do the same thing.  Combine them
for the goodness of mankind.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10 07:14:43 -04:00
Donald Sharp
57a5524578 zebra: System routes should be processed the same time as kernel
For whatever reason.  ZEBRA_ROUTE_SYSTEM routes were being processed
last.  Since a system route is just another kernel route type.  Let's
just switch it to be processed the same time as kernel routes.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10 07:14:43 -04:00
Donald Sharp
014e732d3e zebra: Let's use enum for META Queue indexes
Convert the meta queue values to an enum and use
them.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10 07:14:43 -04:00
Donald Sharp
4bbbd1f6b3 zebra: Explicitly call out the correct queue name
There were more than a few places where the NHG meta
queue was not being explicitly called out.  Let's
be consistent and use the same nomenclature as much
as possible when talking about metaQ's.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-10 07:14:43 -04:00
Donald Sharp
cb1991af8c *: frr_with_mutex change to follow our standard
convert:
	frr_with_mutex(..)

to:
	frr_with_mutex (..)

To make all our code agree with what clang-format is going to produce

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-20 15:50:32 -04:00
Russ White
1dc900fe27
Merge pull request #11502 from donaldsharp/zebra_dplane_fini
zebra: make rib_process_dplane_results own ctx freeing
2022-07-05 09:49:02 -04:00
Donatas Abraitis
484cc1bd97
Merge pull request #11514 from donaldsharp/zebra_odds_and_ends
Zebra odds and ends
2022-07-04 08:11:29 +03:00
Donald Sharp
7a96ccc7b4 zebra: Add a subqueue2str function to give more useful data in debugs
New output example:

2022-07-03 09:40:29.310 [DEBG] zebra: [JF0K0-DVHWH] rib_meta_queue_add: (0:254):4.5.6.8/32: queued rn 0x55937f586ee0 into sub-queue Kernel Routes
2022-07-03 09:40:29.321 [DEBG] zebra: [HH6N2-PDCJS] default(0:254):4.5.6.8/32 rn 0x55937f586ee0 dequeued from sub-queue Kernel Routes

Let's make it a bit more human readable.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-03 09:41:31 -04:00
Donald Sharp
88b0baa648 zebra: move allow_delete to zrouter.allow_delete
Instead of having global allow_delete move it to
where it belongs in the zrouter data structure.

Additionally show this data in `show zebra`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-01 07:59:53 -04:00
Donald Sharp
f00b37e710 zebra: make rib_process_dplane_results own ctx freeing
The rib_process_dplane_results function was having each
sub function handler process the results and then
free the ctx.  Lot's of functionality that needs to remember
to free the context.  Let's just free it in the main loop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-29 15:24:20 -04:00
Russ White
98b3ab772e
Merge pull request #10629 from leonshaw/fix/mp-evpn-nh
lib, zebra, bgpd: Move route EVPN flag to nexthop
2022-06-23 07:00:33 -04:00
anlan_cs
f1f4a65288 zebra: remove redundant calling hook for fpm
Since the calling hook for old fpm is done in `rib_uninstall_kernel()`
inside, this calling place outside should be redundant. Just remove it.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-06-17 17:42:12 -04:00
Xiao Liang
5609e70fb8 lib, zebra, bgpd: Move route EVPN flag to nexthop
Multipath route may have mixed nexthops of EVPN and IP unicast. Move
EVPN flag to nexthop to support such cases.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-06-10 17:12:48 +08:00
Donald Sharp
20ceb5475d zebra: Remove unused function route_entry_copy_nexthops
This function is no longer used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-13 16:11:09 -04:00
Donatas Abraitis
6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
David Lamparter
425fd200c9 zebra: add rib_match_ipv6_multicast variant
... for IPv6, analogous to v4.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-26 16:15:00 +02:00
Stephen Worley
5d41413833 zebra: add support for protodown reason code
Add support for setting the protodown reason code.

829eb208e8

These patches handle all our netlink code for setting the reason.

For protodown reason we only set `frr` as the reason externally
but internally we have more descriptive reasoning available via
`show interface IFNAME`. The kernel only provides a bitwidth of 32
that all userspace programs have to share so this makes the most sense.

Since this is new functionality, it needs to be added to the dplane
pthread instead. So these patches, also move the protodown setting we
were doing before into the dplane pthread. For this, we abstract it a
bit more to make it a general interface LINK update dplane API. This
API can be expanded to support gernal link creation/updating when/if
someone ever adds that code.

We also move a more common entrypoint for evpn-mh and from zapi clients
like vrrpd. They both call common code now to set our internal flags
for protodown and protodown reason.

Also add debugging code for dumping netlink packets with
protodown/protodown_reason.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-03-09 17:52:44 -05:00
Donald Sharp
16d91fce15 zebra: Prevent crash if ZEBRA_ROUTE_ALL is used for a route type
FRR will crash when the re->type is a ZEBRA_ROUTE_ALL and it
is inserted into the meta-queue.  Let's just put some basic
code in place to prevent a crash from happening.  No routing
protocol should be using ZEBRA_ROUTE_ALL as a value but
bugs do happen.  Let's just accept the weird route type
gracefully and move on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-28 09:50:35 -05:00
Mark Stapp
cd787a8a45 zebra: use dataplane to read interface NETCONF info
Use the dataplane to query and read interface NETCONF data;
add netconf-oriented data to the dplane context object, and
add accessors for it. Add handler for incoming update
processing.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-25 10:18:32 -05:00
Mark Stapp
728f2017ae zebra: add dplane type for NETCONF data
Add a new dplane op for interface NETCONF data; add the new
enum value to several switch statements.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-02-25 09:53:02 -05:00
Donald Sharp
cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
Donald Sharp
ce649b9d11 zebra: Abstract nhg deletion to reduce code duplication
Reduce code duplication when we are cleaning up nexthop
groups.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-07 16:10:36 -05:00
Donald Sharp
c6eee91f66 zebra: Fix ships in the night issue
When using wait for install there exists situations where
zebra will issue several route change operations to the kernel
but end up in a state where we shouldn't be at the end
due to extra data being received.  Example:

a) zebra receives from bgp a route change, installs sends the
route to the kernel.
b) zebra receives a route deletion from bgp, removes the
struct route entry and then sends to the kernel a deletion.
c) zebra receives an asynchronous notification that (a) succeeded
but we treat this as a new route.

This is the ships in the night problem.  In this case if we receive
notification from the kernel about a route that we know nothing
about and we are not in startup and we are doing asic offload
then we can ignore this update.

Ticket: #2563300
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-07 16:10:03 -05:00
Mark Stapp
3d1ff4bfdb
Merge pull request #10409 from idryzhov/zebra-mq-clean-crash
zebra: fix cleanup of meta queues on vrf disable
2022-02-02 08:35:00 -05:00
Igor Ryzhov
0ef6eacc95 zebra: fix cleanup of meta queues on vrf disable
Current code treats all metaqueues as lists of route_node structures.
However, some queues contain other structures that need to be cleaned up
differently. Casting the elements of those queues to struct route_node
and dereferencing them leads to a crash. The crash may be seen when
executing bgp_multi_vrf_topo2.

Fix the code by using the proper list element types.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-02-01 18:20:30 +03:00
Mark Stapp
b86c1f4fcc zebra: name the route_entry opaque struct more specifically
The name 'opaque' is a little general - call the route_entry
struct 're_opaque' to make it more specific.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2022-01-31 08:50:50 -05:00
Donald Sharp
5ef3568f22 zebra: Use %pRN instead of %pFX whenver possible
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:41 -05:00
Donald Sharp
a7704e1b98 zebra: Modify route_notify_internal to use a route_node
Pass in the route_node that is under consideration
into route_notify_internal to allow calling functions
to reduce stack size as well as looking up data.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:41 -05:00
Donald Sharp
69a2d597d2 zebra: Cleanup %pFX to %pRN in rib_process_result
The dest_pfx was pretty much only ever used for
debug output and FRR already knows the rn.  So
use that instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:41 -05:00
Donald Sharp
085e8f8f6b zebra: Reduce unneeded lookup in rib_process
the lookup of the src_p and dest_p is not needed
since the values are never used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:40 -05:00
Donald Sharp
898b4a6d3b zebra: Reduce lookups in rib_process_dplane_notify
the dest_p and src_p values were only ever used for
debugs and %pFX, when we already have the rn.
There is no need to do this lookup

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:40 -05:00
Donald Sharp
ee78ed680b zebra: Convert redistribute_update to use a route_node
FRR is passing around a bunch of data that is encapsulated
within the route node.  Let's just pass that around instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:40 -05:00
Donald Sharp
b3a9fca150 zebra: Convert redistribute_delete to use a route_node
FRR is passing around a bunch of data that is encapsulated
within the route node.  Let's just pass that around instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:40 -05:00
Sarita Patra
f99f1ff50a zebra: Fix for route node having no tracking NHT
Topology:
IXIA-----(ens192)FRR(ens224)------iXIA

Configuration:
1. Create 8 sub-interfaces on ens192 under Default VRF and configure 8
EBGP session between FRR and IXIA.
2. Create 1000 sub-interfaces on ens224 under Default VRF and configure
1000 EBGP session between FRR and IXIA.
3. 2M prefixes distributed from Left side Ixia each with 8 ECMP path.
4. So in total, there are 2M prefixes * 8 ECMP = 16M prefixes entries
in RIB and FIB.

Issue:
Shut ens192 and ens224, this is taking 1hr 15 mins to clean up the routes.

Root Cause:
In the case of route deletion, if the particular route node is having
nht count = 0, we are going to the parent and doing nht evaluation,
which is not needed.

Fix:
If the deleted the route node is having nht count > 0, then do a nht
evaluation on the parent node.
Shut ens192 and ens224, it is taking 1 min to clean up the routes
with the fix.

Signed-off-by: Sarita Patra <saritap@vmware.com>
2022-01-13 14:15:05 -05:00
Mark Stapp
002930f7bb zebra: add installed nexthop-group id value
In some cases, zebra may install a nexthop-group id that is
different from the id of the nhe struct attached to a
route-entry. This happens for a singleton recursive nexthop,
for example, where a route is installed with the resolving
nexthop's id.

The installed value is the most useful value - that corresponds
to information in the kernel on linux/netlink platforms that
support nhgs. Display both values if they differ in ascii
output, and include both values in the json form.

Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2021-11-23 11:23:26 -05:00
Igor Ryzhov
608c887069 *: unify if_is_loopback/if_is_loopback_or_vrf
We should always treat the VRF interface as a loopback. Currently, this
is not the case, because in some old pre-VRF code we use if_is_loopback
instead of if_is_loopback_or_vrf. To avoid any future problems, the
proposal is to rename if_is_loopback_or_vrf to if_is_loopback and use it
everywhere. if_is_loopback is renamed to if_is_loopback_exact in case
it's ever needed, but currently it's not used anywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-16 18:07:11 +03:00
Donald Sharp
68275b093b
Merge pull request #9870 from opensourcerouting/zebra-rib-select-order
zebra: set SELECTED before going into dplane code
2021-10-28 07:59:54 -04:00
Quentin Young
0c124f75db
Merge pull request #9440 from dlqs/dplanehook2 2021-10-26 15:26:32 -04:00
David Lamparter
f68ce97627 zebra: set SELECTED before going into dplane code
There is a bit of an impedance mismatch in the sequence of events here.
Depending on the dplane behavior, the `ROUTE_ENTRY_SELECTED` bit will be
inconsistent for rib_process_result().

With an asynchronous dataplane:
0. rib_process() is called
1. rib_install_kernel() is called, dplane action is queued
2. rib_install_kernel() returns
3. rib_process() sets the SELECTED bit appropriately, returns
4. dplane is done, triggers rib_process_result()
5. SELECTED bit is seen in "after" state
(5a. NHT code looks at the SELECTED bit, works correctly.)

With a synchronous dataplane:
0. rib_process() is called
1. rib_install_kernel() is called, dplane action is executed
2. dplane (should) trigger rib_process_result()
3. SELECTED bit is seen in "before" state
(3a. NHT code looks at the SELECTED bit, fails.)
4. rib_install_kernel() returns
5. rib_process() sets the SELECTED bit appropriately, too late.

Essentially, poking the dataplane is a sequencing point where control is
handed over to the dplane.  Control may or may not return immediately.
Doing /anything/ after triggering the dataplane is a recipe for odd race
conditions.

(FWIW, I'm not sure rib_process_result() is called correctly in the
synchronous case, but that's a separate problem.)

Unfortunately, this change might have some unforeseen side effects.  I
haven't dug through the code to see if anything breaks.  There
/shouldn't/ be anything looking at the SELECTED bit here, but who knows.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-22 12:13:46 +02:00
Donald Sharp
e13f12a7d1 zebra: modify rib_update to be a bit smarter about malloc
rib_update() was mallocing memory then attempting to schedule
and if the schedule failed( it was already going to be run )
FRR would then free the memory.  Fix this memory usage pattern

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-20 08:28:52 -04:00
Donald Lee
1247efcce4 zebra: Add dplane hook point
Signed-off-by: Donald Lee <dlqs@gmx.com>
2021-10-20 00:56:00 +08:00
Donald Sharp
d597533a9d zebra: Start carrying safi for rnh processing
PIM is going to need to be able to send down the address it is
trying to resolve in the multicast rib.  We need a way to signal
this to the end developer.  Start the conversion by adding the
ability to have a safi.  But only allow SAFI_UNICAST at the moment.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-27 12:38:08 -04:00
Donald Sharp
6071e5e96e zebra: remove 'enum rnh_type' from system
This code is now dead code since there are not two
nexthop resolution types.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-27 12:38:08 -04:00
Mark Stapp
d166308be0 zebra: use the dataplane to read netlink intf addr changes
Read incoming interface address change notifications in the
dplane pthread; enqueue the events to the main pthread
for processing. This is netlink-only for now - the bsd
kernel socket path remains unchanged.

Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-09-14 11:07:30 -04:00
Mark Stapp
9d59df634c zebra: add new dplane op codes for interface addr events
Add new dplane op values for incoming interface address add
and delete events.

Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-09-14 11:07:30 -04:00
Mark Stapp
1722cef455
Merge pull request #9304 from donaldsharp/zebra_random_stuff
Zebra random stuff
2021-08-12 10:16:46 -04:00
Donald Sharp
38c764dde4 zebra: Properly note add/update for rib_add_multipath_nhe
When calling rib_add_multipath_nhe ensure that we have
well aligned return codes that mean something so that
interersted parties can properly handle the situation.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-08-09 08:06:33 -04:00