summaryrefslogtreecommitdiff
path: root/zebra/zebra_rib.c
AgeCommit message (Collapse)Author
2019-10-25zebra: VRF ID should be null if a nexthop groupStephen Worley
A nexthop group should not have a VRF ID. Only individual nexthops need to be using a VRF. Fixed this both kernel and proto side. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Re-organize/expose nhg_connectedStephen Worley
Re-organize and expose the nhg_connected functions so that it can be used outside zebra_nhg.c. And then abstract those into zebra_nhg_depends_* and zebra_nhg_depenents_* functons. Switch the ifp struct to use an RB tree for its dependents, making use of the nhg_connected functions. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Abstract the RB nodes/add dependents treeStephen Worley
Create a nhg_depenents tree that will function as a way to get back pointers for NHE's depending on it. Abstract the RB nodes into nhg_connected for both depends and dependents. This same struct is used for both. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra,lib: Refactor depends to RB treeStephen Worley
Refactor the depends to use an RB tree instead of a list. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Protocol side nhg_hash_entry afi fixStephen Worley
Default the afi of the nexthop to the route entry using it. If it turns out to be a group, update the afi to AFI_UNSPEC. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Update rib_add_multipath with increment nheStephen Worley
Update rib_add_multipath to use the reference count increment function for nexthop group hash entries. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add equivalence function for nhg_dependsStephen Worley
Add a helper function to allow us to check if two nhg_hash_entry's dependency lists are equal. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Always copy nhg and depends on nhe allocStephen Worley
Changed our alloc function to just copy the nhg and nhg_depends. This makes the zebra_nhg_find code a little bit cleaner, hopefully preventing bugs. The only issue with this is that it makes us have to loop over the nexthops in a group an extra time for the copies. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Refactor nexthop group creation code to use allocated memoryStephen Worley
Simplify the code for nexthop hash entry creation. I made nexthop hash entry creation expect the nexthop group and depends to always be allocated before lookup. Before, it was only allocated if it had dependencies. I think it makes the code a bit more readable to go ahead an allocate even for single nexthops as well. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Read in nexthop dependencies from the kernelStephen Worley
Add functionality to read in a group from the kernel, create a hash entry for it, and add its nexthops to its dependency list. Further, we create its nhg struct separtely from this, copying over any nexthops it should reference directly into it. Thus, we have two types for representation of the nexthop group: nhe->nhg_depends->[nhe, nhe, nhe] nhe->nhg->nexthop->nexthop->nexthop Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25Revert "zebra: Remove afi field in nexthop hash entry"Stephen Worley
This reverts commit be73fe9393aac58c7f4bdb5c8a98c24c6cda6d5d. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add ifp to zebra-side rib_addStephen Worley
Add an interface pointer for an nexthop group hash entry when we are getting a rib_add for a new route. Also, add the interface index to the `show nexthop-group` command. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Make route entry nexthop groups point to our hash entryStephen Worley
Make our route entry struct's re->ng nexthop group pointer just point to the nhe->nhg nexthop hash entry nexthop group. This will allow updates to the nexthop itself to propogate to our routes immediately. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Update rib_add to take a nexthop IDStephen Worley
Add a parameter to the rib_add function so that it takes a nexthop ID from the kernel if one is passed along with the route. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add calls to the nexthop context process result functionStephen Worley
Added in case statements to handle finished dataplane contexts and then handle them with the nexthop process result function. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Route entries use nexthop entry ID's instead of pointersStephen Worley
Switched the route entries to use ID's instead of pointers. Perform lookups with the ID and then check if its null. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Add functionality to parse RTM_NEWNEXTHOP and RTM_DELNEXTHOP messagesStephen Worley
Add the functionality to parse new nexthop group messages from the kernel and insert them into the appropriate hash tables. Parsing is done at startup between interface and interface address lookup. Add functionality to parse changes to nexthops we already have. Add functionality to parse delete nexthop messages from the kernel and remove them from our table. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Remove afi field in nexthop hash entryStephen Worley
I do not believe we should be hashing based on AFI in for our upper level nexthop group entries. These should be ambiguous with regards to address families since an ipv4 or ipv6 address can have the same interface nexthop. This can be seen in NEXTHOP_TYPE_IFINDEX. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25zebra: Remove nexthop_active_num from route entryDonald Sharp
The nexthop_active_num data structure is a property of the nexthop group. Move the keeping of this data to that. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25zebra: Remove re->nexthop_num from reDonald Sharp
The nexthop_num is not a function of the re. It is owned by the nexthop group. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25zebra: Replace nexthop_group with pointer in route entryDonald Sharp
In the route_entry we are keeping a non pointer based nexthop group, switch the code to use a pointer for all operations here and ensure we create and delete the memory. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25zebra: Add code to create/remove nexthop groupsDonald Sharp
Add some code to create/remove nexthop groups. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-18zebra: Handle rib updates as a thread eventStephen Worley
If we need to batch process the rib (all tables or specific vrf), do so as a scheduled thread event rather than immediately handling it. Further, add context to the events so that you narrow down to certain route types you want to reprocess. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-03Merge pull request #5079 from mjstapp/fix_dplane_drop_at_shutDonald Sharp
zebra: during shutdown processing, drop dplane results
2019-09-27zebra: during shutdown processing, drop dplane resultsMark Stapp
Don't process dataplane results in zebra during shutdown (after sigint has been seen). The dplane continues to run in order to clean up, but zebra main just drops results. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-09-26zebra: if_is_loopback_or_vrf crash if if_lookup_by_index return NULLdturlupov
Function if_lookup_by_index() can return NULL, but in if_is_loopback_or_vrf() we don't chech NULL and get next: Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(zlog_backtrace_sigsafe+0x48) [0x7fb5f704cf18] Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(zlog_signal+0x378) [0x7fb5f704d728] Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(+0x6b495) [0x7fb5f706b495] Sep 2 07:44:34 XXX zebra[4616]: /lib64/libpthread.so.0(+0x123b0) [0x7fb5f6d573b0] Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(if_is_loopback+0) [0x7fb5f7045160] Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(if_is_loopback_or_vrf+0x11) [0x7fb5f7045191] Sep 2 07:44:34 XXX zebra[4616]: /usr/sbin/zebra() [0x43b26d] Sep 2 07:44:34 XXX zebra[4616]: /usr/sbin/zebra() [0x43db6f] Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(work_queue_run+0xc8) [0x7fb5f7080de8] Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(thread_call+0x47) [0x7fb5f7077d27] Sep 2 07:44:34 XXX zebra[4616]: /usr/lib64/libfrr.so.0(frr_run+0xd8) [0x7fb5f704b448] Signed-off-by: Dmitrii Turlupov dturlupov@factor-ts.ru
2019-09-24Merge pull request #4972 from mjstapp/fix_notif_installedDonald Sharp
zebra: route updates from dataplane need to check all nexthops
2019-09-18Merge pull request #4731 from mjstapp/fix_redist_updateDonald Sharp
zebra: redistribute deletes when updating selected route
2019-09-17zebra: check all dplane nexthops when processingMark Stapp
When processing route updates from the dataplane, we were terminating the checking of nexthops prematurely, and we could miss meaningful changes. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-09-16zebra: remove empty, unused internal apiMark Stapp
Remove a leftover, empty nht api call from zebra. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-09-12zebra: revise redistribution delete to improve update caseMark Stapp
When selecting a new best route, zebra sends a redist update when the route is installed. There are cases where redist clients may not see that redist add - clients who are not subscribed to the new route type, e.g. In that case, attempt to send a redist delete for the old/previous route type. Revised the redist delete api to accomodate both cases; also tightened up the const-ness of a few internal redist apis. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-09-04zebra: move EVPN VTEP programming to dataplaneMark Stapp
Move VTEP install/uninstall to the zebra dataplane. Remove synch kernel-facing apis and helper functions. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-09-04Merge pull request #4877 from mjstapp/dplane_neighsDonald Sharp
zebra: move evpn neighbors to dataplane
2019-09-03lib: add frr_with_mutex() block-wrapperDavid Lamparter
frr_with_mutex(...) { ... } locks and automatically unlocks the listed mutex(es) when the block is exited. This adds a bit of safety against forgetting the unlock in error paths & co. and makes the code a slight bit more readable. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-08-23zebra: Use dataplane for evpn neighbor changesMark Stapp
Move neighbor programming to the dataplane; remove old apis; remove some ifdef'd use of direct netlink code points, using neutral values outside of the netlink- specific files. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-08-21Merge pull request #4778 from mjstapp/dplane_macsDonald Sharp
zebra: use dataplane for evpn macs
2019-08-05zebra: clear route QUEUED flag in async notification handlerMark Stapp
Ensure that the route-entry QUEUED flag is cleared in the async notification path, as it is in the normal results processing code path. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-08-02zebra: use dataplane for vxlan remote mac programmingMark Stapp
Move vxlan remote MAC install and uninstall to the async dataplane. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-08-01zebra: Redistribution should be told about the old routeDonald Sharp
When we are sending a redistribute_update, pass the old_re in so that if we still have it around we can update the calling protocol. Test: router ospf redistribute sharp ! sharp install route 4.5.6.7 nexthop 192.168.201.1 1 Now add a `ip route 4.5.6.7/32 192.168.201.1`. This causes zebra to replace the sharp route with the static route. No update is sent to ospf and debug: 2019/08/01 19:02:38.271998 ZEBRA: 0:4.5.6.7/32: Redist update re 0x12fdbda0 (static), old 0x0 (None) With fix: 2019/08/01 19:15:09.644499 ZEBRA: 0:4.5.6.7/32: Redist update re 0x1ba5bce0 (static), old 0x1beea4e0 (sharp) 2019/08/01 19:15:09.645462 OSPF: ospf_zebra_read_route: from client sharp: vrf_id 0, p 4.5.6.7/32 Ticket: CM-25847 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-30Merge pull request #4746 from donaldsharp/zebra_rib_improvementsRuss White
Zebra rib improvements
2019-07-29zebra, tests: Remove ROUTE_ENTRY_NEXTHOPS_CHANGEDDonald Sharp
The flag ROUTE_ENTRY_NEXTHOPS_CHANGED is only ever set or unset. Since this flag is not used for anything useful, remove from system. By changing this flag we have re-ordered `internalStatus' of json output of zebra rib routes. Go through and fix up tetsts to use the new values. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-29zebra: Remove repeated enqueueing of system routes for rethinkingDonald Sharp
The code as written before this code change point would enqueue every system route type to be refigured when we have an interface event. I believe this was to originally handle bugs in the way nexthop tracking was handled, mainly that if you keep asking the question you'll eventually get the right answer. Modify the code to not do this, we have fixed nexthop tracking to not be so brain dead and to know when it needs to refigure a route that it is tracking. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-26zebra: skip queued entries when resolving nexthopDon Slice
Problem reported where certain routes were not being passed on to clients if they were operated on while still queued for kernel installation. Changed it to defer working on entries that were queued to dplane so we could operate on them after getting an answer back from kernel installatino. Ticket: CM-25480 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-07-25zebra: consolidate dataplane interface name and ifindex attrsMark Stapp
Move interface name and index to shared data struct, and remove operation-specific values. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-07-09zebra: Modify zebra to order nexthops receivedDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-03lib: Add a couple functions to nexthop_group.c (#4323)David Lamparter
lib: Add a couple functions to nexthop_group.c Co-authored-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-07-02Merge pull request #4622 from donaldsharp/import_table_fixSri Mohana Singamsetty
Import table fix
2019-07-01*: s/TRUE/true/, s/FALSE/false/Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-25lib: Private api for nexthop_group manipulationStephen Worley
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-25zebra: Push VRF_DEFAULT outside of import table codeDonald Sharp
The import table code assumes that they will only work in the default vrf. This is ok, but we should push the vrf_id and zvrf to be passed in instead of just using VRF_DEFAULT. This will allow us to fix a couple of things: 1) A bug in import where we are not creating the route entry with the appropriate table so the imported entry is showing up in the wrong spot. 2) In the future allow `ip import-table X` to become vrf aware very easily. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>