summaryrefslogtreecommitdiff
path: root/zebra/zebra_rib.c
AgeCommit message (Collapse)Author
2020-06-01zebra: init dest's list of routesMark Stapp
Use the dlist init api on the zebra dest object's list of routes. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-06-01ldpd: Relay data plane pseudowire status in LDP notificationKaren Schoener
Provide a way for the data plane to indicate pseudowire status (such as: not forwarding, AC failure). On a data plane pseudowire install failure, data plane sets the pseudowire status. Zebra relays the pseudowire status to LDP. LDP includes the pseudowire status in the LDP notification to the LDP peer. Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-05-14zebra: avoid using c++ keywords in headersEmanuele Di Pascale
to make sure that c++ code can include them, avoid using reserved keywords like 'delete' or 'new'. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2020-05-08zebra: remove typedef rib_update_event_t from systemDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-05-08zebra: Remove typedef rib_table_info_t from systemDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-29Merge pull request #5786 from mjstapp/fix_notif_empty_nhgStephen Worley
zebra: fix handling of failed route install via notification
2020-04-27zebra: fix handling of failed route install via notificationMark Stapp
An async route notification can indicate that installation has failed, but the handling code wasn't dealing with that possibility correctly. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-20*: sprintf -> snprintfQuentin Young
Replace sprintf with snprintf where straightforward to do so. - sprintf's into local scope buffers of known size are replaced with the equivalent snprintf call - snprintf's into local scope buffers of known size that use the buffer size expression now use sizeof(buffer) - sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp buffer followed by strlcat Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-12zebra: Add vrf name and id to debugsJakub Urbańczyk
In some places we log the interface but not the vfr the interface is in. In others we only output the vrf id, which can be difficult for human to read. This commit makes zebra debugs more vrf aware. Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-04-08*: Do not cast to the same typeDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-30Merge pull request #5901 from mjstapp/backup_nh_prepStephen Worley
zebra, lib: Backup nexthop (path) prep work
2020-03-29lib: prepare for plugin-based frr_format checkDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-27zebra: handle backup nexthops in nhe/nhgsMark Stapp
Include backup nexthops in nhe processing; connect incoming zapi route data with updated rib/nhg apis; add more debugs in nhg processing. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27zebra: improve route debugging and add support for backupsMark Stapp
Refactor the detailed route debugging so that the dump of nexthops can be used for both normal/active nexthops and backups (if they are present). Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27zebra: add per-nexthop backup indexMark Stapp
Use a backup index in a nexthop directly (if it has a backup nexthop); revise the zebra nhe/nhg code; revise zapi route decoding to match; revise the dataplane route datastructs. Refactor some of the rib_add_multipath code to be prepared to be called with an nhe, carrying nexthop and (possibly) backup info together. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-05*: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__Donatas Abraitis
Just keep the code cool. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04zebra: fix typo in debug log messageRuben Kerkhof
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-02-27zebra: Embed lib nexthop-group in zebra hash entryMark Stapp
Embed nexthop-group, which is just a pointer, in the zebra nexthop-hash-entry object, rather than mallocing one. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-14zebra: Add vrf name to debug outputDonald Sharp
The vrf id is insufficient of a discriminator in people's head Give them what they need. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-12Merge pull request #5794 from mjstapp/remove_nexthop_matched_flagQuentin Young
lib,zebra: remove unused MATCHED nexthop flag
2020-02-11lib,zebra: remove unused MATCHED nexthop flagMark Stapp
Remove an unused flag value from the nexthop struct. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-02-06Merge pull request #5722 from donaldsharp/kernel_routesRuss White
Kernel routes
2020-02-03*: don't null after XFREE; XFREE does this itselfQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-01-23zebra: Kernel routes w/ AD were not being marked as installedDonald Sharp
When we are receiving a kernel route, with an admin distance of 255 we are not marking it as installed. This route should be marked as installed. New behavior: K>* 4.5.7.0/24 [255/8192] via 192.168.209.1, enp0s8, 00:10:14 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-01-06zebra: route changes via notify path trigger nht and mplsMark Stapp
Changes to a route via the dataplane notify path should trigger nht and mpls lsp processing. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-16zebra: null check re->nhe not re->nhe->nhg on attachStephen Worley
We should be NULL checking the entire re->nhe struct, not the group inside of it. When we get routes from the kernel using a nexthop group (and future protocols) they will only pass us an ID to use. Hence, this struct can (and will be) NULL on first attach when only passed an ID. There shouldn't be a situation where we have an re->nhe and don't have an re->nhe->nhg anyway. Before this patch you can easily make zebra crash by creating a route in the kernel using a nexthop group and starting zebra. `ip next add dev lo id 111` `ip route add 1.1.1.1/32 nhid 111` Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-12-12zebra: handle route notification with no nexthopsMark Stapp
Handle the special case where a route update contains no installed nexthops - that means the route is not installed. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-11zebra: accept async notification for un-installMark Stapp
Handle an async notification when a route-update operation uninstalls one route in favor of another. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-09zebra: align dplane notify processing with nhg workMark Stapp
The processing of dataplane route notifications was a little off-target after the nexthop-group re-work. This should allow notifications to work better. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-04Merge pull request #5416 from mjstapp/re_nhe_pointerDonald Sharp
lib,zebra: use shared nexthop-group in route_entry
2019-12-04lib,zebra: use nhg_hash_entry pointer in route_entryMark Stapp
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-02*: generously apply constDavid Lamparter
const const const your boat, merrily down the stream... Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-21zebra: clean up rib and nhg headersMark Stapp
Clean up the relationships between zebra's rib and nexthop-group headers as prep for adding a nexthop-group pointer to the route_entry. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-11-12zebra: Don't clear nexthop fib flag on rib_installStephen Worley
We cannot clear the NEXTHOP_FLAG_FIB nexthop flag when sending routes to the dataplane anymore since nexthops are now shared. We were seeing a situation where if we delete a route using a nexthop group that is still active with another route, the fib flag was being unset by this code path despite them still being valid fib nexthops with the other route. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-11-01zebra: separate zebra_vrf_lookup_table_with_id()Stephen Worley
We were creating `other` tables in rib_del(), vty commands, and dataplane return callback via the zebra_vrf_table_with_table_id() API. Seperate the API into only a lookup, never create and added another with `get` in the name (following the standard we use in other table APIs). Then changed the rib_del(), rib_find_rn_from_ctx(), and show route summary vty command to use the lookup API instead. This was found via a crash where two different vrfs though they owned the table. On delete, one free'd all the nodes, and then the other tried to use them. It required specific timing of a VRF existing, going away, and coming back again to cause the crash. =23464== Invalid read of size 8 ==23464== at 0x179EA4: rib_dest_from_rnode (rib.h:433) ==23464== by 0x17ACB1: zebra_vrf_delete (zebra_vrf.c:253) ==23464== by 0x48F3D45: vrf_delete (vrf.c:243) ==23464== by 0x48F4468: vrf_terminate (vrf.c:532) ==23464== by 0x13D8C5: sigint (main.c:172) ==23464== by 0x48DD25C: quagga_sigevent_process (sigevent.c:105) ==23464== by 0x48F0502: thread_fetch (thread.c:1417) ==23464== by 0x48AC82B: frr_run (libfrr.c:1023) ==23464== by 0x13DD02: main (main.c:483) ==23464== Address 0x5152788 is 104 bytes inside a block of size 112 free'd ==23464== at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==23464== by 0x48B25B8: qfree (memory.c:129) ==23464== by 0x48EA335: route_node_destroy (table.c:500) ==23464== by 0x48E967F: route_node_free (table.c:90) ==23464== by 0x48E9742: route_table_free (table.c:124) ==23464== by 0x48E9599: route_table_finish (table.c:60) ==23464== by 0x170CEA: zebra_router_free_table (zebra_router.c:165) ==23464== by 0x170DB4: zebra_router_release_table (zebra_router.c:188) ==23464== by 0x17AAD2: zebra_vrf_disable (zebra_vrf.c:222) ==23464== by 0x48F3F0C: vrf_disable (vrf.c:313) ==23464== by 0x48F3CCF: vrf_delete (vrf.c:223) ==23464== by 0x48F4468: vrf_terminate (vrf.c:532) ==23464== Block was alloc'd at ==23464== at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==23464== by 0x48B24A2: qcalloc (memory.c:110) ==23464== by 0x48EA2FE: route_node_create (table.c:488) ==23464== by 0x48E95C7: route_node_new (table.c:66) ==23464== by 0x48E95E5: route_node_set (table.c:75) ==23464== by 0x48E9EA9: route_node_get (table.c:326) ==23464== by 0x48E1EDB: srcdest_rnode_get (srcdest_table.c:244) ==23464== by 0x16EA4B: rib_add_multipath (zebra_rib.c:2730) ==23464== by 0x1A5310: zread_route_add (zapi_msg.c:1592) ==23464== by 0x1A7B8E: zserv_handle_commands (zapi_msg.c:2579) ==23464== by 0x19D689: zserv_process_messages (zserv.c:523) ==23464== by 0x48F09F8: thread_call (thread.c:1599) Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib,pbrd,zebra: Use one api to delete nexthops/groupStephen Worley
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-25zebra: Zebra nexthop group re-work checkpatch fixesStephen Worley
Checkpatch fixes for the zebra nexthop group re-work. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Optimize the fib/notified nexthop matchingStephen Worley
Optimize the fib and notified nexthop group comparison algorithm to assume ordering. There were some pretty serious performance hits with this on high ecmp routes. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib,zebra: Move nexthop dup marking into creationStephen Worley
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-25zebra: Use nexthop object id on route deleteStephen Worley
When we receive a route delete from the kernel and it contains a nexthop object id, use that to match against route gateways with instead of explicit nexthops. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Sweep our nexthop objects out on restartStephen Worley
On restart, if we failed to remove any nexthop objects due to a kill -9 or such event, sweep them if we aren't using them. Add a proto field to handle this and remove the is_kernel bool. Add a dupicate flag that indicates this nexthop group is only present in our ID hashtable. It is a dupicate nexthop we received from the kernel, therefore we cannot hash on it. Make the idcounter globally accessible so that kernel updates increment it as soon as we receive them, not when we handle them. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: TODO for handling upper level nhe_id passingStephen Worley
We need to handle refcnt differently if we ever start making upper level protocols aware of nhg_hash_entry IDs. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Move resolve/add depend install into apiStephen Worley
Move the resolving and installing of a single nhg_hash_entry into the install function itself, rather than letting zebra_rib handle it. Further, ensure depends are installed/queued before installing a group. The ordering should be find here since only one thread will call this API. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Install the nhe along with the routeStephen Worley
Move the installation of an nhe out of nexthop_active_update() and into the rib install path. So, only install the nhe when a route using it is being installed. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Use nexthop/interface vrf, not the routesStephen Worley
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>
2019-10-25zebra: Remove route only if NHE is installed checkStephen Worley
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>
2019-10-25zebra: Put NHE ref updating into a functionStephen Worley
When the referenced NHE changes for a route_entry, use this function to handle it. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add recursive functionality to NHE'sStephen Worley
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-25zebra: Use a nhe context dataplane and rib metaqStephen Worley
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>
2019-10-25zebra: Check for nexthop group before free on failStephen Worley
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>