summaryrefslogtreecommitdiffstats
path: root/ldpd/lde_lib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ldpd: changes for code maintainabilitysri-mohan12023-05-081-11/+8
| | | | | | these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
* ldpd: changes for code maintainabilitysri-mohan12023-05-051-40/+30
| | | | | | these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
* *: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp2023-03-241-2/+2
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_add_XXX functions to event_add_XXXDonald Sharp2023-03-241-2/+1
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Rename `struct thread` to `struct event`Donald Sharp2023-03-241-2/+2
| | | | | | | | | Effectively a massive search and replace of `struct thread` to `struct event`. Using the term `thread` gives people the thought that this event system is a pthread when it is not Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: auto-convert to SPDX License IDsDavid Lamparter2023-02-091-12/+1
| | | | | | Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* ldpd: Add missing enum's to switch statementDonald Sharp2023-01-311-3/+3
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* ldpd: Convert thread_cancel to THREAD_OFFDonald Sharp2022-07-211-2/+2
| | | | | | Just convert all uses of thread_cancel to THREAD_OFF Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Change thread->func to return void instead of intDonald Sharp2022-02-241-4/+1
| | | | | | | 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>
* ldpd: Do not explicitly set the thread pointer to NULLDonatas Abraitis2021-10-041-1/+0
| | | | | | | | FRR should only ever use the appropriate THREAD_ON/THREAD_OFF semantics. This is espacially true for the functions we end up calling the thread for. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* ldpd: fix sporadic failures in the ldp-topo1 topotestRenato Westphal2021-01-151-8/+0
| | | | | | | | | | | | | | | | | | | Commit 220e848cc5 introduced an optimization that would prevent ldpd from sending redundant label mappings when it receives notifications from zebra about routes that didn't effectively change (such notifications can happen under certain circumstances). The problem is that that commit didn't take into account the metric of the received routes, so it would dismiss a notification of a route with a better metric taking the place of another route in the RIB, preventing the newly selected route from receiving the label mappings it needs. Revert 220e848cc5 temporarily to fix sporadic failures in the CI system until we have a better solution. Debugged-by: Lynne Morrison lynne@voltanet.io Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: add support for RLFA clientsRenato Westphal2021-01-091-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an API that allows IGP client daemons to register/unregister RLFAs with ldpd. IGP daemons need to be able to query the LDP labels needed by RLFAs and monitor label updates that might affect those RLFAs. This is similar to the NHT mechanism used by bgpd to resolve and monitor recursive nexthops. This API is based on the following ZAPI opaque messages: * LDP_RLFA_REGISTER: used by IGP daemons to register an RLFA with ldpd. * LDP_RLFA_UNREGISTER_ALL: used by IGP daemons to unregister all of their RLFAs with ldpd. * LDP_RLFA_LABELS: used by ldpd to send RLFA labels to the registered clients. For each RLFA, ldpd needs to return the following labels: * Outer label(s): the labels advertised by the adjacent routers to reach the PQ node; * Inner label: the label advertised by the PQ node to reach the RLFA destination. For the inner label, ldpd automatically establishes a targeted neighborship with the PQ node if one doesn't already exist. For that to work, the PQ node needs to be configured to accept targeted hello messages. If that doesn't happen, ldpd doesn't send a response to the IGP client daemon which in turn won't be able to activate the previously computed RLFA. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: detect when route received from zebra hasn't changedRenato Westphal2021-01-091-0/+8
| | | | | | | | Add some code to detect when a route received from zebra hasn't changed and ignore the notification in that case, preventing ldpd from sending unnecessary label mappings. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* *: unify thread/event cancel macrosMark Stapp2020-10-231-2/+2
| | | | | | | | | Replace all lib/thread cancel macros, use thread_cancel() everywhere. Only the THREAD_OFF macro and thread_cancel() api are supported. Also adjust thread_cancel_async() to NULL caller's pointer (if present). Signed-off-by: Mark Stapp <mjs@voltanet.io>
* ldpd: Fix issue when starting up LDP with no configuration.lynne2020-09-041-5/+15
| | | | | | | | LDP would mark all routes as learned on a non-ldp interface. Then when LDP was configured the labels were not updated correctly. This commit fixes issues 6841 and 6842. Signed-off-by: Lynne Morrison <lynne@voltanet.io>
* ldpd: ldp-oc withdraw fixlynne2020-08-051-9/+23
| | | | | | | | When LDP is configured in Order Control mode and we receive a label withdraw message, we should only resend label withdraws to peers that are the NH for that fec being withdrawn. Signed-off-by: Lynne Morrison <lynne@voltanet.io>
* ldpd: process pw-status in received orderKaren Schoener2020-07-201-4/+13
| | | | | | | | Update LDP to process received pw-status in received order. Update LDP to save pw-status regardless of whether the PW is configured. When the PW is configured, LDP checks for any saved PW pw-status. Signed-off-by: Karen Schoener <karen@voltanet.io>
* ldpd: adding support for LDP ordered label distribution controlKaren Schoener2020-03-201-3/+88
| | | | | | | | | | | | LDP ordered label distribution control only binds a label to a FEC if it is the egress LSR, or the router received a label binding for a FEC from the next hop router. In this mode, an MPLS router will create a label binding for each FEC and distribute it to its neighbors so long as he has a entry in the RIB for the destination. Signed-off-by: Lynne Morrison <lynne@voltanet.io> Signed-off-by: Karen Schoener <karen@voltanet.io>
* zebra: identify MPLS FTNs by route type and instanceRenato Westphal2019-09-071-10/+14
| | | | | | | | | Use the route type and instance instead of the route distance to identify MPLS FTNs. This is a more robust approach since the routing daemons can modify the distance of their announced routes via configuration, which can cause inconsistencies. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: Fix to release MPLS label if its not used anymoreBinu Abraham2019-07-151-0/+3
| | | | | | LDP should release labels allocated from zebra if its not getting used. Signed-off-by: Binu <binu_abraham@looptelecom.com>
* *: Make assignment from RB_ROOT in while loop work betterDonald Sharp2018-02-231-1/+3
| | | | | | | Fix up the assignment of the variable = RB_ROOT inside of while loop patter we were using. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* ldpd: sprinkle in some asserts to make scan-build happyRenato Westphal2017-10-061-1/+3
| | | | | | While here, fix the other SA warnings. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: fix missing label mappingsRenato Westphal2017-08-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | In some scenarios, it's possible to send a Label Withdraw to a neighbor and not receive a corresponding Label Release right away. This can happen during reconvergence after a network failure or configuration change. When this happens, the list of upstream mappings of a given FEC might not be empty even after sending a Label Withdraw to all neighbors. This situation holds until all neighbors either send a Label Release or are torn down (e.g. keepalive timeout). With that said, we shouldn't check for 'RB_EMPTY(&fn->upstream)' in lde_kernel_update() because it can prevent ldpd from sending label mappings in such circumstances. This check was introduced to avoid sending the same label mapping more than once to the same neighbor, but we need to remove this optimization for now until we find a better solution (which probably involves refactoring the whole zebra<->ldpd communication). While here, add a new debug message in lde_send_labelmapping() which can aid in troubleshooting label problems in the future. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: integrate with the pseudowire manager in zebraRenato Westphal2017-08-091-0/+7
| | | | | | | | | If we receive a notification from zebra indicating that the installation of a pseudowire has failed (e.g. no reachability), send a PW Status notification to the remote peer (or a Label Withdraw if the remote peer doesn't support the PW Status TLV). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: improve the RB implementationRafael Zalamena2017-06-161-13/+14
| | | | | | | | | | | | | | | | | | | | | Switch the RB tree implementation completely to the new dlg@'s version that uses pre-declared functions instead of macros for tree functions. Original e-mail/diff: https://marc.info/?l=openbsd-tech&m=147087487111068&w=2 Pros: * Reduces the amount of code that the usage of those macros generate * Allows the compiler to do a better compile-time check job * Might have better i-cache utilization since the tree code is shared Con: * dlg@ benchmarks shows it has 'very slightly slower' insertions * imported RB_* code must adapt the following calls: RB_INIT(), RB_GENERATE(), RB_ROOT(), RB_EMPTY(), make compare functions use 'const' (if not already) and maybe others.
* ldpd: remove variable that is not necessary anymoreRenato Westphal2017-06-031-7/+0
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* *: update thread_add_* callsQuentin Young2017-05-091-2/+3
| | | | | | | | | | | | Pass pointer to pointer instead of assigning by return value. See previous commit message. To ensure that the behavior stays functionally correct, any assignments with the result of a thread_add* function have been transformed to set the pointer to null before passing it. These can be removed wherever the pointer is known to already be null. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: remove THREAD_ON macros, add nullity checkQuentin Young2017-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way thread.c is written, a caller who wishes to be able to cancel a thread or avoid scheduling it twice must keep a reference to the thread. Typically this is done with a long lived pointer whose value is checked for null in order to know if the thread is currently scheduled. The check-and-schedule idiom is so common that several wrapper macros in thread.h existed solely to provide it. This patch removes those macros and adds a new parameter to all thread_add_* functions which is a pointer to the struct thread * to store the result of a scheduling call. If the value passed is non-null, the thread will only be scheduled if the value is null. This helps with consistency. A Coccinelle spatch has been used to transform code of the form: if (t == NULL) t = thread_add_* (...) to the form thread_add_* (..., &t) The THREAD_ON macros have also been transformed to the underlying thread.c calls. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* ldpd: schedule the sending of label messages when necessaryRenato Westphal2017-04-261-10/+26
| | | | | | | | | | | | | | | | | Once we send a Label Withdraw, we can't send a Label Mapping for the same FEC until we receive a Label Release from the peer. This is due to some limitations in the LDP algorithms described in Appendix A. ("LDP Label Distribution Procedures") of RFC 5036. To workaround this issue, make it possible to schedule the sending of a Label Mapping as soon as a Label Release is received for the same FEC. The easiest way to test this patch is by typing the "label local advertise explicit-null" command. ldpd will withdraw all null labels using a Wildcard FEC and then send new Label Mappings as soon the corresponding Label Releases are received. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: be more conservative with labelsRenato Westphal2017-04-261-8/+11
| | | | | | | | | | | | On unstable networks, routes can be lost and relearned very often. If we deallocate the input label every time a route is lost and allocate a new one when the route is relearned, a lot of changes are made in vain. This patch introduces a logic in which labels are preserved for at least five minutes before being deallocated by the LIB garbage collector. This is consistent with what other implementations do. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: provide more detailed information in some show commandsRenato Westphal2017-03-211-11/+18
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: implement RFC 6667 (Typed Wildcard FEC for PWid)Renato Westphal2017-03-031-0/+7
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: implement RFC 5918 (Typed Wildcard FEC)Renato Westphal2017-03-031-0/+56
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: implement support for PWid group wildcardsRenato Westphal2017-03-031-10/+46
| | | | | | | | | | | This was missing from our original RFC 4447 VPLS implementation. Now ldpd understands group wildcards as mandated by the RFC, but we still don't send them ourselves. I can't see any case in which sending a group wildcard would be useful, but nonetheless this patch provides a function called lde_send_labelwithdraw_pwid_wcard() which is ready to be used in the future anytime we feel like it might be useful. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: fix processing of Label Withdraw messagesRenato Westphal2017-03-031-4/+9
| | | | | | | | | | | | | | Whenever we receive a Label Withdraw message with an optional Label TLV, we should check if this label matches the label previously received from this neighbor for this FEC. If they don't match then we shouldn't uninstall the previous label from the kernel. This fixes a misinterpretation from the "Receive Label Withdraw" algorithm described in the A.1.5 section of RFC 5036. Also, simplify the check of pending withdraws in lde_check_release() and lde_check_release_wcard(). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: minor tweaksRenato Westphal2017-03-031-3/+3
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: update local labels when necessaryRenato Westphal2017-02-061-52/+56
| | | | | | | | | | | | | | | | | ldpd allocates null labels for directly connected routes. If a connected route is removed (interface goes down) and an IGP learned route takes its place in the RIB, ldpd must update the local label of the associated FEC entry with a non-null label. The same applies for the other way around (an interface goes up and a connected route is selected in favour of an IGP route). Labels should be dynamic and change when necessary. Additionally, this patch fixes the processing of route delete messages from zebra. Route delete messages don't contain any nexthop, meaning that whenever we receive such messages we must delete all nexthop previously received. Based on a patch from Bingen Eguzkitza <bingen@voltanet.io>. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: introduce advanced filtering capabilitiesRenato Westphal2017-02-021-25/+28
| | | | | | | | This patch introduces several new configuration commands to ldpd. These commands should allow the operator to define advanced filtering policies for things like label advertisement, label allocation, etc. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: use red-black trees to store 'lde_map' elementsRenato Westphal2017-01-041-9/+9
| | | | | | | | | | | | | Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* zebra/ldpd: allow MPLS ECMP on unnumbered interfacesRenato Westphal2016-12-141-9/+11
| | | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org> (cherry picked from commit 7144dc12b55e05c9ae3d784dfb75817c9f881eb6)
* ldpd: always advertise labels upon receiving a redistributed routeRenato Westphal2016-09-281-0/+1
| | | | | | | | | | | | | | | | | | | Whenever a routing daemon advertises a new version of a route to zebra, zebra removes the old version of this route (implicit withdraw) and then create a new 'rib' structure for the new version of the route. In this process, the previously received label(s) from ldpd are lost. This is because upon receiving a ZEBRA_MPLS_LABELS_ADD message, zebra only adds a label to a nexthop of an existing route. And routes are volatile, they can be removed while being updated. To workaround this issue, this patch makes ldpd always advertise the appropriate labels whenever it receives a redistributed route, even if it was already received before (an older version). This way, when ldpd receives the updated version of a route, it will readvertise the appropriate label(s) and zebra will reinstall them. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: fix processing of redistributed routesRenato Westphal2016-09-281-1/+30
| | | | | | | | | | | Commit 5048fe changed the way zebra behave when a route is updated. Now, whenever a route is changed, zebra advertises its new version without withdrawing the old one. This patch adapts ldpd to understand this new behavior. After processing a ZEBRA_REDISTRIBUTE_IPV[46]_ADD message, we need to check for nexthops that were removed and, for each of them (if any), withdraw the associated labels from zebra. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: adapt the code for QuaggaRenato Westphal2016-09-231-24/+14
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* ldpd: copy original sources from OpenBSD (14/09/2016)Renato Westphal2016-09-231-0/+784
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>