summaryrefslogtreecommitdiff
path: root/ospfd/ospf_zebra.c
AgeCommit message (Collapse)Author
2024-11-21ospfd: OSPF multi-instance default origination fixesAcee Lindem
When originating a default AS-External LSA in one OSPF instance, it wasn't working if the criteria route was installed by another OSPF instance. This required more flexible processing of the OSPF external route information. Also fix problem multi-instance display for "show ip ospf <instance> database ...". Signed-off-by: Acee Lindem <acee@lindem.com> (cherry picked from commit 6afd56da969821359ee1fdfbfd33259587f58184)
2024-09-18ospfd: Add vrf name to debug functions in ospf_zebra.cDonald Sharp
This file had a bunch of debugs that were operating on specific vrf's but not telling you which vrf this was happening in. Add code to allow operator debugging to understand what vrf is being worked on. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-04-18ospfd: Add prefix-list filtering of OSPF neighbors on OSPF interfaceAcee Lindem
This commit adds the capabiity to filter OSPF neighbors using a prefix-list with rules matching the neighbor's IP source address. Configuration, filtering, immediate neighbor pruning, topo-tests, and documentation are included. The command is: ip ospf neighbor-filter <prefix-list> [A.B.C.D] Signed-off-by: Acee Lindem <acee@lindem.com>
2023-11-23*: add `zclient_options_sync`David Lamparter
... and use it instead of fiddling with the `.synchronous` field. (Make it const while at it.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-20ospfd: use `zclient->nexthop_update`David Lamparter
Same as before. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-10-07*: remove ZEBRA_INTERFACE_VRF_UPDATEanlan_cs
Currently when one interface changes its VRF, zebra will send these messages to all daemons in *order*: 1) `ZEBRA_INTERFACE_DELETE` ( notify them delete from old VRF ) 2) `ZEBRA_INTERFACE_VRF_UPDATE` ( notify them move from old to new VRF ) 3) `ZEBRA_INTERFACE_ADD` ( notify them added into new VRF ) When daemons deal with `VRF_UPDATE`, they use `zebra_interface_vrf_update_read()->if_lookup_by_name()` to check the interface exist or not in old VRF. This check will always return *NULL* because `DELETE` ( deleted from old VRF ) is already done, so can't find this interface in old VRF. Send `VRF_UPDATE` is redundant and unuseful. `DELETE` and `ADD` are enough, they will deal with RB tree, so don't send this `VRF_UPDATE` message when vrf changes. Since all daemons have good mechanism to deal with changing vrf, and don't use this `VRF_UPDATE` mechanism. So, it is safe to completely remove all the code with `VRF_UPDATE`. Signed-off-by: anlan_cs <anlan_cs@tom.com>
2023-07-04Merge pull request #13333 from donaldsharp/vrf_bitmap_cleanupDonatas Abraitis
*: Rearrange vrf_bitmap_X api to reduce memory footprint
2023-07-01Merge pull request #13847 from ↵Donald Sharp
opensourcerouting/fix/free_zclient_sync_on_destroy Stop and free synchronous Zebra client on destroy
2023-06-27isisd, ospfd: fix opaque zapi source parsingMark Stapp
Opaque zapi messages carry the sender's zclient tuple now, daemons shouldn't try to parse those bits directly. Signed-off-by: Mark Stapp <mjs@labn.net>
2023-06-26*: Rearrange vrf_bitmap_X api to reduce memory footprintDonald Sharp
When running all daemons with config for most of them, FRR has sharpd@janelle:~/frr$ vtysh -c "show debug hashtable" | grep "VRF BIT HASH" | wc -l 3570 3570 hashes for bitmaps associated with the vrf. This is a very large number of hashes. Let's do two things: a) Reduce the created size of the actually created hashes to 2 instead of 32. b) Delay generation of the hash *until* a set operation happens. As that no hash directly implies a unset value if/when checked. This reduces the number of hashes to 61 in my setup for normal operation. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-26ospfd: Stop and free synchronous Zebra client on OSPF terminationDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-05-08ospfd, ospf6d: log when GR messages are sent to zebraRenato Westphal
This should be useful to troubleshoot possible GR problems in the future. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-05-08ospfd: add support for unplanned graceful restartRenato Westphal
In practical terms, unplanned GR refers to the act of recovering from a software crash without affecting the forwarding plane. Unplanned GR and Planned GR work virtually the same, except for the following difference: on planned GR, the router sends the Grace-LSAs *before* restarting, whereas in unplanned GR the router sends the Grace-LSAs immediately *after* restarting. For unplanned GR to work, ospf6d was modified to send a ZEBRA_CLIENT_GR_CAPABILITIES message to zebra as soon as GR is enabled. This causes zebra to freeze the OSPF routes in the RIB as soon as the ospfd daemon dies, for as long as the configured grace period (the defaults is 120 seconds). Similarly, ospfd now stores in non-volatile memory that GR is enabled as soon as GR is configured. Those two things are no longer done during the GR preparation phase, which only happens for planned GRs. Unplanned GR will only take effect when the daemon is killed abruptly (e.g. SIGSEGV, SIGKILL), otherwise all OSPF routes will be uninstalled while ospfd is exiting. Once ospfd starts, it will check whether GR is enabled and enter in the GR mode if necessary, sending Grace-LSAs out all operational interfaces. One disadvantage of unplanned GR is that the neighboring routers might time out their corresponding adjacencies if ospfd takes too long to come back up. This is especially the case when short dead intervals are used (or BFD). For this and other reasons, planned GR should be preferred whenever possible. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-04-18ospfd: use rib metric as the base for set metric +/-Jafar Al-Gharaibeh
When using route maps with external routes in OSPF as follows: ``` set metric +10 ``` The current behavior is to use the default ospf metric as the base and then add to 10 to it. The behavior isn't useful as-is. A value 30 (20 dfeault + 10) can be set directly instead. the behavior is also not consistent with bgp. bgp does use the rib metric in this case as the base. The current behavior also doesn't allow the metric to accumulate when crossing different routing domains such as vrfs causing the metric to reset every time the route enters a new vrf with a new ospf network. This PR changes the behavior such that the rib metric is used as a base for ospf exteral routes when used with `set metric -/+` Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2023-03-31ospfd: implement Type-7 default routes for NSSA areasRenato Westphal
Add the "default-information-originate" option to the "area X nssa" command. That option allows the origination of Type-7 default routes on NSSA ABRs and ASBRs. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert `struct event_master` to `struct event_loop`Donald Sharp
Let's find a better name for it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert struct thread_master to struct event_master and it's ilkDonald Sharp
Convert the `struct thread_master` to `struct event_master` across the code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert thread_add_XXX functions to event_add_XXXDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename `struct thread` to `struct event`Donald Sharp
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>
2023-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
This is a first in a series of commits, whose goal is to rename the thread system in FRR to an event system. There is a continual problem where people are confusing `struct thread` with a true pthread. In reality, our entire thread.c is an event system. In this commit rename the thread.[ch] files to event.[ch]. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-02ospfd: correctly update outbound filter-list once prefix-list is updatedRenato Westphal
Fix obvious bug where the wrong area filter-lists were being updated in response to a prefix-list update. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
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>
2023-01-17Revert "ospfd: rSPF calc and messaging for optimal route reflection"Donatas Abraitis
This reverts commit a3d3a14c09cf212c7d402670247c4d518b99d8b7.
2022-10-12ospfd: rSPF calc and messaging for optimal route reflectionMadhuri Kuruganti
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-06-08ospfd: Fixup ospfd.h to declare variable namesDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-11*: Properly use memset() when zeroingDonatas Abraitis
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-25ospfd: fix ospf default route wrongly sent backFrancois Dumontet
That commit aim is to fix an invalid behavior when default-information is activated on ospf router without always option. Consider an ASBR with: -one default route coming from ospf, -and another default route coming from another deaemon (such BGP or static). When the daemon bgp stops advertising its default route, -ospf continues to advertise its previous default route (with aging 0), -this may create default routing loops. Expected behavior: is to update the removed external default route with MAXAGING value. Updating with MAXAGING value will notify the fact the route is currently invalid. A later removal from ospf external LSA database will be made. Analysis: all default routes have their type overwritten by a DEFAULT_ROUTE type. Thus all default routes whatever its origin (ospf, bgp, static...) is treated in a same way. But this is not pertinent for ospf originated default routes. Fix: avoid overwiting of route type when default route is ospf type. Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2022-02-23*: Change thread->func to return void instead of intDonald Sharp
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-14ospfd: Fix spelling mistakesDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-15lib, ospfd, ospf6d, zebra: add OSPF opaque route attributesRenato Westphal
Update ospfd and ospf6d to send opaque route attributes to zebra. Those attributes are stored in the RIB and can be viewed using the "show ip[v6] route" commands (other than that, they are completely ignored by zebra). Example: ``` debian# show ip route 192.168.1.0/24 Routing entry for 192.168.1.0/24 Known via "ospf", distance 110, metric 20, best Last update 01:57:08 ago * 10.0.1.2, via eth-rt2, weight 1 OSPF path type : External-2 OSPF tag : 0 debian# debian# show ip route 192.168.1.0/24 json { "192.168.1.0\/24":[ { "prefix":"192.168.1.0\/24", "prefixLen":24, "protocol":"ospf", "vrfId":0, "vrfName":"default", "selected":true, [snip] "ospfPathType":"External-2", "ospfTag":"0" } ] } ``` Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-20*: convert zclient callbacks to tableDavid Lamparter
This removes a giant `switch { }` block from lib/zclient.c and harmonizes all zclient callback function types to be the same (some had a subset of the args, some had a void return, now they all have ZAPI_CALLBACK_ARGS and int return.) Apart from getting rid of the giant switch, this is a minor security benefit since the function pointers are now in a `const` array, so they can't be overwritten by e.g. heap overflows for code execution anymore. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-21ospfd: remove unnecessary memory allocationIgor Ryzhov
ospf_distribute_list_update currently passes two arguments to ospf_distribute_list_update_timer - pointer to the ospf structure and protocol type. The protocol type is only used for logging and is not even correct because if multiple changes happen during one ospf->min_ls_interval, then only the type of the first change is logged. It is better to completely remove the protocol type argument to have a correct log and eliminate the need for memory allocation. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-07-13Merge pull request #8767 from opensourcerouting/ospfd-grRuss White
ospfd: introduce support for Graceful Restart (restarting mode)
2021-07-09lib,ospfd,ospf6d: remove duplicated functionRafael Zalamena
Move `is_default_prefix` variations to `lib/prefix.h` and make the code use the library version instead of implementing it again. NOTE ---- The function was split into per family versions to cover all types. Using `union prefixconstptr` is not possible due to static analyzer warnings which cause CI to fail. The specific cases that would cause this failure were: - Caller used `struct prefix_ipv4` and called the generic function. - `is_default_prefix` with signature using `const struct prefix *` or `union prefixconstptr`. The compiler would complain about reading bytes outside of the memory bounds even though it did not take into account the `prefix->family` part. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-07-05ospfd: introduce support for Graceful Restart (restarting mode)Renato Westphal
RFC 3623 specifies the Graceful Restart enhancement to the OSPF routing protocol. This PR implements support for the restarting mode, whereas the helper mode was implemented by #6811. This work is based on #6782, which implemented the pre-restart part and settled the foundations for the post-restart part (behavioral changes, GR exit conditions, and on-exit actions). Here's a quick summary of how the GR restarting mode works: * GR can be enabled on a per-instance basis using the `graceful-restart [grace-period (1-1800)]` command; * To perform a graceful shutdown, the `graceful-restart prepare ospf` EXEC-level command needs to be issued before restarting the ospfd daemon (there's no specific requirement on how the daemon should be restarted); * `graceful-restart prepare ospf` will initiate the graceful restart for all GR-enabled instances by taking the following actions: o Flooding Grace-LSAs over all interfaces o Freezing the OSPF routes in the RIB o Saving the end of the grace period in non-volatile memory (a JSON file stored in `$frr_statedir`) * Once ospfd is started again, it will follow the procedures described in RFC 3623 until it detects it's time to exit the graceful restart (either successfully or unsuccessfully). Testing done: * New topotest featuring a multi-area OSPF topology (including stub and NSSA areas); * Successful interop tests against IOS-XR routers acting as helpers. Co-authored-by: GalaxyGorilla <sascha@netdef.org> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-07-01*: Replace IPV4_MAX_PREFIXLEN to IPV4_MAX_BITLENDonatas Abraitis
Just drop IPV4_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-28isisd, ospfd: update interface_link_params callback to check for changeKaren Schoener
Adding defensive code to the interface_link_params zebra callback to check if the link params changed before taking action. Signed-off-by: Karen Schoener <karen@voltanet.io>
2021-05-07Merge pull request #8634 from idryzhov/ospf-vrf-redistMark Stapp
ospf redistribution fixes
2021-05-05ospfd: fix redistribution config when vrf doesn't existIgor Ryzhov
Currently ospfd relies on vrf bitmaps in zclient to check that the redistribution is configured. This doesn't work when the VRF for OSPF instance doesn't exist yet, because vrf bitmaps ignore VRF_UNKNOWN id. Because of this, the following problems occur when the VRF doesn't exist: - repeated "redistribute smth" command is processed as a first-time instead of an update - "no redistribute smth" doesn't work at all This commit fixes both issues by relying on internal redistribution config instead of zclient vrf bitmaps. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-04ospfd: Fix indentation in ospf_is_type_redistributedDonald Sharp
clang-format was not happy. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04ospfd: Do not use `case default` for switches that have enumDonald Sharp
Found a couple spots where FRR was using `case default` when using a switch over an enum. In this case we *must* enumerate all states as part of the switch. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04ospfd: Cleanup some awful deep indentation in ospf_zebra.cDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-03-30Merge pull request #8058 from rgirada/ospf-ecmpMark Stapp
ospfd: Max multipath config support
2021-03-29ospfd: Max multipath config supportrgirada
Description: OSPF does not have an option to control the maximum multiple equal cost paths to reach a destination/route(ECMP). Currently, it is using the system specific max multiple paths. But Somtimes, It requires to control the multiple paths from ospf. This cli helps to configure the max number multiple paths in ospf. Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-03-23ospfd: Add Link-State supportOlivier Dugeon
This patch allows to store Link State Information received through the various LSAs into a dedicated Traffic Engineering Database (TED). This feature is automatically activated once mpls-te is enabled. A new CLI command `mpls-te export` permits to export the TED to other daemons through the new ZAPI Opaque Link State messages. In complement, a new CLI command `show ip ospf mpls-te database ...` output the contains of the TED to the console. Major modifications take place in ospf_te.[c, h]. File ospf_zebra.c has been modified to handle TED synchronisation request. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-09ospfd: Correct Segment Routing prefix bugsOlivier Dugeon
This patch solves 2 Segment Routing prefix bugs: - If Segment Routing is not enabled in the initial configuration, Extended Prefix Opaque LSA is not flood. This is due to a control flag which is set only when Segment Routing is enabled at startup and not latter. - Attempting to modify Segment Routing prefix flag e.g. adding or removing no-php or explicit-null flag, doesn't work as expected: Corresponding entry in the MPLS table is not updated, Extended Prefix Opaque LSA carry wrong flag value, and neighbor set a wrong configuration in the MPLS table for this Segment Routing prefix. The first bug is corrected in ospfd/ospf_ext.c: - Flag setting is moved from ospf_ext_ism_change() to set_ext_prefix() function The seconf one is corrected in ospfd/ospf_sr.c: - For self node, previous MPLS entry is removed if needed and flag reset before setting the new Segment Routing prefix configuration - For neighbor node, srnext field of sr_prefix structure is always set and not only for new SR Prefix. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-02-11ospfd: Debug race condition in Segment RoutingOlivier Dugeon
Issue #7926 hilight a race condition in Segment Routing processing. The problem occurs when Router Information Opaque LSA is received late, in particular after SPF run and after ospf_sr_nhlfe_update() was called. This scenario is unfrequent and takes place due to a slow DR election. In this particular case, SR Prefix are handle but not fully fill. In fact, SRGB for the nexthop is not yet received and thus, output label could not be computed. When Router Information Opaque LSA is received and processed, if the corresponding SR node is a direct neighbor of the self node, update_out_nhlfe() is called against all SR nodes to adjust SR prefix if the next hop is the new SR node. The function wrongly computes output label and configure a bad MPLS LFIB entries. Another way to hilight the problem is to change through CLI the SRGB of a node and look to MPLS LFIB of direct neighbor, in particular those who announce EXPLICIT NULL Prefix SID. This patch correct the update_out_nhlfe() function by calling the appropriate function (sr_prefix_out_label() instead of index2label()) to compute the output label. Some log debugs were adjusted and unused prefix route table was removed too. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>