summaryrefslogtreecommitdiff
path: root/lib/nexthop.h
AgeCommit message (Collapse)Author
2025-01-29lib: clean up nexthop hashing messDavid Lamparter
We were hashing 4 bytes of the address. Even for IPv6 addresses. Oops. The reason this was done was to try to make it faster, but made a complex maze out of everything. Time for a refactor. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-11-22lib, zebra: Do not have duplicate memory type problemsDonald Sharp
In zebra_mpls.c it has a usage of MTYPE_NH_LABEL which is defined in both lib/nexthop.c and zebra/zebra_mpls.c. The usage in zebra_mpls.c is a realloc. This leads to a crash: (gdb) bt 0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:44 1 __pthread_kill_internal (signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:78 2 __GI___pthread_kill (threadid=126487246404032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 3 0x0000730a1b442476 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26 4 0x0000730a1b94fb18 in core_handler (signo=6, siginfo=0x7ffeed1e07b0, context=0x7ffeed1e0680) at lib/sigevent.c:268 5 <signal handler called> 6 __pthread_kill_implementation (no_tid=0, signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:44 7 __pthread_kill_internal (signo=6, threadid=126487246404032) at ./nptl/pthread_kill.c:78 8 __GI___pthread_kill (threadid=126487246404032, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 9 0x0000730a1b442476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 10 0x0000730a1b4287f3 in __GI_abort () at ./stdlib/abort.c:79 11 0x0000730a1b9984f5 in _zlog_assert_failed (xref=0x730a1ba59480 <_xref.16>, extra=0x0) at lib/zlog.c:789 12 0x0000730a1b8f8908 in mt_count_free (mt=0x576e0edda520 <MTYPE_NH_LABEL>, ptr=0x576e36617b80) at lib/memory.c:74 13 0x0000730a1b8f8a59 in qrealloc (mt=0x576e0edda520 <MTYPE_NH_LABEL>, ptr=0x576e36617b80, size=16) at lib/memory.c:112 14 0x0000576e0ec85e2e in nhlfe_out_label_update (nhlfe=0x576e368895f0, nh_label=0x576e3660e9b0) at zebra/zebra_mpls.c:1462 15 0x0000576e0ec833ff in lsp_install (zvrf=0x576e3655fb50, label=17, rn=0x576e366197c0, re=0x576e3660a590) at zebra/zebra_mpls.c:224 16 0x0000576e0ec87c34 in zebra_mpls_lsp_install (zvrf=0x576e3655fb50, rn=0x576e366197c0, re=0x576e3660a590) at zebra/zebra_mpls.c:2215 17 0x0000576e0ecbb427 in rib_process_update_fib (zvrf=0x576e3655fb50, rn=0x576e366197c0, old=0x576e36619660, new=0x576e3660a590) at zebra/zebra_rib.c:1084 18 0x0000576e0ecbc230 in rib_process (rn=0x576e366197c0) at zebra/zebra_rib.c:1480 19 0x0000576e0ecbee04 in process_subq_route (lnode=0x576e368e0270, qindex=8 '\b') at zebra/zebra_rib.c:2661 20 0x0000576e0ecc0711 in process_subq (subq=0x576e3653fc80, qindex=META_QUEUE_BGP) at zebra/zebra_rib.c:3226 21 0x0000576e0ecc07f9 in meta_queue_process (dummy=0x576e3653fae0, data=0x576e3653fb80) at zebra/zebra_rib.c:3265 22 0x0000730a1b97d2a9 in work_queue_run (thread=0x7ffeed1e3f30) at lib/workqueue.c:282 23 0x0000730a1b96b039 in event_call (thread=0x7ffeed1e3f30) at lib/event.c:1996 24 0x0000730a1b8e4d2d in frr_run (master=0x576e36277e10) at lib/libfrr.c:1232 25 0x0000576e0ec35ca9 in main (argc=7, argv=0x7ffeed1e4208) at zebra/main.c:536 Clearly replacing a label stack is an operation that should be owned by lib/nexthop.c. So lets move this function into there and have zebra_mpls.c just call the function to replace the label stack. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-10Merge pull request #15259 from dmytroshytyi-6WIND/nexthop_resolutionRuss White
zebra: add LSP entry to nexthop via recursive (part 2)
2024-08-22lib, zebra: Modify nexthop_cmp to allow you to use weight or notDonald Sharp
Currently nexthop weight is a discriminator on whether or not a nexthop matches. There is a need to no use the weight as part of this comparison function so let's add a boolean to allow us to say use this or not. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-06-07zebra, lib: upon lsp install, iterate nexthop accordinglyPhilippe Guibert
There are two ways of iterating over nexthops of a given route entry. - Either only the main nexthop are taken into account (which is the case today when attempting to install an LSP entry on a BGP connected labeled route. - Or by taking into account nexthops that are resolved and linked in nexthop->resolved of the previous nexthop which has RECURSIVE flag set. This second case has to be taken into account in the case where recursive routes may be used to install an LSP entry. Introduce a new API in nexthop that will parse over the appropriate nexthop, if the nexthop-resolution flag is turned on or not on the given VRF. Use that API in the lsp_install() function so as to walk over the appropriate nexthops. Co-developed-by: Dmytro Shytyi <dmytro.shytyi@6wind.com> Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-05-15zebra, lib: move nexthop display helper to lib folderPhilippe Guibert
The zebra_nexthop_vty_helper() and zebra_nexthop_json_helper() functions could be very helpful to display nexthop information from whatever daemon. Move the core function in the nexthop_vty_helper() and the nexthop_json_helper() function. The zebra API call remains unchanged. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-04-22lib, zebra: Check for not being a blackhole routeDonald Sharp
In zebra_interface_nhg_reinstall zebra is checking that the nhg is a singleton and not a blackhole nhg. This was originally done with checking that the nexthop is a NEXTHOP_TYPE_IFINDEX, NEXTHOP_TYPE_IPV4_IFINDEX and NEXTHOP_TYPE_IPV6_IFINDEX. This was excluding NEXTHOP_TYPE_IPV4 and NEXTHOP_TYPE_IPV6. These were both possible to be received and maintained from the upper level protocol for when a route is being recursively resolved. If we have gotten to this point in zebra_interface_nhg_reinstall the nexthop group has already been installed at least once and we *know* that it is actually a valid nexthop. What the test is really trying to do is ensure that we are not reinstalling a blackhole nexthop group( Which is not possible to even be here by the way, but safety first! ). So let's change to test for that instead. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-20bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthopDmytro Shytyi
Append zebra and lib to use muliple SRv6 segs SIDs, and keep one seg SID for bgpd and sharpd. Note: bgpd and sharpd compilation relies on the lib and zebra files, i.e if we separate this: lib or zebra or bgpd or sharpd in different commits - this will not compile. Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-07-27lib, zebra: Fix EVPN nexthop config orderXiao Liang
Delay EVPN route addition to synchronize with rib_delete(), which now uses early route queue. Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2023-05-05zebra: re-install nhg on interface upAshwini Reddy
Intermittently zebra and kernel are out of sync when interface flaps and the add's/dels are in same processing queue and zebra assumes no change in nexthop. Hence we need to bring in a reinstall to kernel of the nexthops and routes to sync their states. Upon interface flap kernel would have deleted NHGs associated to a interface (the one flapped), zebra retains NHGs for 3 mins even though upper layer protocol removes the nexthops (associated NHG). As part of interface address add , re-add singleton NHGs associated to interface. Ticket: #3173663 Issue: 3173663 Signed-off-by: Ashwini Reddy <ashred@nvidia.com> Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-06-23lib, zebra: Notice when a nexthop is set linkdownDonald Sharp
When a nexthop is set RTNH_F_LINKDOWN, start noticing that this flag is set. Allow FRR to know about this flag but at this point do not do anything with it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23lib: Increase nexthop flags size to 16 bitsDonald Sharp
commit: 5609e70fb87a3b23b55629a33e5afb298974c142 Added a new flag to the `struct nexthop` and this addition of a flag caused the flags size to be too small. Increase the size of flags to allow more flags to be had. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-23Merge pull request #10629 from leonshaw/fix/mp-evpn-nhRuss White
lib, zebra, bgpd: Move route EVPN flag to nexthop
2022-06-14lib: Abstract usage of '%pNHs' so that nexthop groups can use it tooDonald Sharp
Abstract the usage of '%pNHs' so that when nexthop groups get a new special printfrr that it can take advantage of this functionality too. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-10lib, zebra, bgpd: Move route EVPN flag to nexthopXiao Liang
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>
2021-09-07bgpd: VRF-Lite fix nexthop typeKantesh Mundaragi
Description: Change is intended for fixing the following issues related to vrf route leaking: Routes with special nexthops i.e. blackhole/sink routes when imported, are not programmed into the FIB and corresponding nexthop is set as 'inactive', nexthop interface as 'unknown'. While importing/leaking routes between VRFs, in case of special nexthop(ipv4/ipv6) once bgp announces route(s) to zebra, nexthop type is incorrectly set as NEXTHOP_TYPE_IPV6_IFINDEX/NEXTHOP_TYPE_IFINDEX i.e. directly connected even though we are not able to resolve through an interface. This leads to nexthop_active_check marking nexthop !NEXTHOP_FLAG_ACTIVE. Unable to find the active nexthop(s), route is not programmed into the FIB. Whenever BGP leaks routes, set the correct nexthop type, so that route gets resolved and correctly programmed into the FIB, in the imported vrf. Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com> Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2021-06-02lib,sharpd,zebra: update nexthop object with nh_srv6Hiroki Shirokura
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02*: fix code format accourding to checkpatchHiroki Shirokura
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02lib: add new nexthop's attributes seg6 (step3)Hiroki Shirokura
This commit add new nexthop's addional object for SRv6 routing about seg6 route. Before this commit, we can add MPLS info as additional object on nexthop. This commit make it add more support about seg6 routes. seg6 routes are ones of the LWT routing mechanism, so configuration of seg6local routes is performed by ZEBRA_ROUTE_SEND, it's same as MPLS configuration. Real configuration implementation isn't implemented at this commit. later commit add that. This commit add only nexthop additional object and some misc functions. Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02lib: add new nexthop's attributes seg6local (step1)Hiroki Shirokura
This commit is a part of #5853 works that add new nexthop's addional object for SRv6 routing about seg6local route. Before this commit, we can add MPLS info as additional object on nexthop. This commit make it add more support about seg6local routes. seg6local routes are ones of the LWT routing mechanism, so configuration of seg6local routes is performed by ZEBRA_ROUTE_SEND, it's same as MPLS configuration. Real configuration implementation isn't implemented at this commit. later commit add that. This commit add only nexthop additional object and some misc functions. Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-05-04lib: add basic nexthop comparison apiMark Stapp
Add a simpler, more limited nexthop comparison function. This compares a few key attributes, such as vrf, gateway, labels. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-02lib: remove nexthop_same_firsthop() apiStephen Worley
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-08-07lib, zebra: Add SR-TE policy infrastructure to zebraSebastien Merle
For the sake of Segment Routing (SR) and Traffic Engineering (TE) Policies there's a need for additional infrastructure within zebra. The infrastructure in this PR is supposed to manage such policies in terms of installing binding SIDs and LSPs. Also it is capable of managing MPLS labels using the label manager, keeping track of nexthops (for resolving labels) and notifying interested parties about changes of a policy/LSP state. Further it enables a route map mechanism for BGP and SR-TE colors such that learned BGP routes can be mapped onto SR-TE Policies. This PR does not introduce any usable features by now, it is just infrastructure for other upcoming PRs which will introduce 'pathd', a new SR-TE daemon. Co-authored-by: Renato Westphal <renato@opensourcerouting.org> Co-authored-by: GalaxyGorilla <sascha@netdef.org> Signed-off-by: Sebastien Merle <sebastien@netdef.org>
2020-07-17lib: use const in nexthop_level() apiMark Stapp
Use const in nexthop_level() Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17lib: add nexthop_str2backupMark Stapp
Add an api to convert an input list into an array of backup nexthop indexes; useful for cli input. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-17lib,sharpd,zebra: initial support for multiple backup nexthopsMark Stapp
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-07lib: test vrfs in nexthop_same_firsthop()Mark Stapp
Test the two nexthops' vrfs, and convert api to 'bool' return. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-14zebra: data plane FPM add support RMAC VNIRafael Zalamena
Store VNI information in the data plane context so we can use it to build the FPM netlink update with that information later. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
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-27lib: add backup-nexthop value to nexthopMark Stapp
Add a field supporting a backup nexthop. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-03-27zebra,lib: use const in more apisMark Stapp
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-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-01-15lib,zebra: tighten up the nexthop_copy/nexthop_dup APIsStephen Worley
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>
2019-12-09lib, zebra: Allow for installation of a weighted nexthopDonald Sharp
Linux has the idea of allowing a weight to be sent down as part of a nexthop group to allow the kernel to weight particular nexthop paths a bit more or less than others. See: http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html Allow for installation into the kernel using the weight attribute associated with the nexthop. This code is foundational in that it just sets up the ability to do this, we do not use it yet. Further commits will allow for the pass through of this data from upper level protocols. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-22lib: add some nexthop ctorsMark Stapp
Add some apis that allocate and init nexthop objects from various kinds of arguments: ip addrs, interfaces, blackhole types. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-10-25lib: Make nexthop_next* use const for nexthopStephen Worley
Make nexthop_next() and nexthop_next_active_resolved() use const for the nexthop argument. They should not be modifying so it makes sense here. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-10-25lib: Add nexthop quick hash apiStephen Worley
Add a nexthop hashing api for only hashing on word-sized attributes. Calling the jhash/jhash2 function is quite slow in scaled envrionments but sometimes you do need a more granular hash. The tradeoff here is that hashtable buckets using this hash might be more full. 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-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-08-19lib: Sort zapi_nexthops on the encodeStephen Worley
Sort nexthops before we push them to zebra. This offloads the nexthop sorting zebra is doing onto the upper level protocols so that when it gets to zebra and we construct a group, it just has to append them to the tail for every nexthop. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25lib: Add a nexthop_dup() that allocates and copiesStephen Worley
Add a nexthop_dup() api that both allocates and copies a new nexthop from an old one. Still retain the old exposed function nexthop_copy() so we can copy without allocation. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-06-25lib: Put single nexthop copy into its own functionStephen Worley
Put the code to copy a single nexthop into a function of its own. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23lib,zebra,bgpd,pbrd: Compare nexthops without labelsStephen Worley
Allow label ignoring when comparing nexthops. Specifically, add another functon nexthop_same_no_labels() that shares a path with nexthop_same() but doesn't check labels. rib_delete() needs to ignore labels in this case. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23lib,zebra,bgpd: Remove nexthop_same_no_recurse()Stephen Worley
The functions nexthop_same() does not check the resolved nexthops so I don't think this function is even needed anymore. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23lib: Make labels_match function use labels_cmpStephen Worley
Update the nexthop_labels_match() function to use nexthop_labels_cmp(). Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-05-23lib: Add nexthop_cmpDonald Sharp
Add function to allow us to have a sorted order of nexthops. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-04-19zebra: stop sending invalid nexthops to clientsDon Slice
Found that zebra_rnh_apply_nht_rmap would set the NEXTHOP_FLAG_ACTIVE if not blocked by the route-map, even if the flag was not active prior to the check. This fix changes the flag used to denote the nexthop is filtered so that proper active state can be retained. Additionally, found two cases where we would send invalid nexthops via send_client, which would also cause this crash. All three fixed in this commit. Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
2019-04-18lib, zebra: Remove unused flagDonald Sharp
The NEXTHOP_FLAG_FILTERED went away when we started treating static routes like every other route in the system. This was a special case for handling static route code that just didn't get finished cleaning up. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>