Commit Graph

239 Commits

Author SHA1 Message Date
Renato Westphal
d8cf2fc52f ospfd, ospf6d: log when GR messages are sent to zebra
This should be useful to troubleshoot possible GR problems in the
future.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-05-08 21:47:44 -03:00
Renato Westphal
ab749e7eea ospfd: add support for unplanned graceful restart
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-05-08 21:47:44 -03:00
Jafar Al-Gharaibeh
6af89f8f03 ospfd: use rib metric as the base for set metric +/-
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-04-18 00:21:05 -05:00
Renato Westphal
017714e3ad ospfd: implement Type-7 default routes for NSSA areas
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-31 19:28:15 -03:00
Donald Sharp
24a58196dd *: Convert event.h to frrevent.h
We should probably prevent any type of namespace collision
with something else.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
e16d030c65 *: Convert THREAD_XXX macros to EVENT_XXX macros
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
907a2395f4 *: Convert thread_add_XXX functions to event_add_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
e6685141aa *: Rename struct thread to struct event
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 08:32:17 -04:00
Donald Sharp
cb37cb336a *: Rename thread.[ch] to event.[ch]
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-24 08:32:16 -04:00
Renato Westphal
9629b44f45 ospfd: correctly update outbound filter-list once prefix-list is updated
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-03-02 19:38:03 -03:00
David Lamparter
acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donatas Abraitis
405e1c848f Revert "ospfd: rSPF calc and messaging for optimal route reflection"
This reverts commit a3d3a14c09.
2023-01-17 18:11:56 +02:00
Madhuri Kuruganti
a3d3a14c09 ospfd: rSPF calc and messaging for optimal route reflection
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
Donald Sharp
2d4093ee30 ospfd: Fixup ospfd.h to declare variable names
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-08 11:38:22 -04:00
Donatas Abraitis
6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
Francois Dumontet
5e43330e5c ospfd: fix ospf default route wrongly sent back
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-03-25 15:40:46 +01:00
Donald Sharp
cc9f21da22 *: Change thread->func to return void instead of int
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-23 19:56:04 -05:00
Donald Sharp
1461559c24 ospfd: Fix spelling mistakes
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-14 12:53:16 -05:00
Renato Westphal
5b5d66c431 lib, ospfd, ospf6d, zebra: add OSPF opaque route attributes
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>
2022-01-15 17:22:27 +01:00
David Lamparter
a243d1db93 *: convert zclient callbacks to table
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-10-20 13:28:46 +02:00
Igor Ryzhov
dcaed63d2f ospfd: remove unnecessary memory allocation
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-21 13:49:52 +03:00
Russ White
000df71ccd
Merge pull request #8767 from opensourcerouting/ospfd-gr
ospfd: introduce support for Graceful Restart (restarting mode)
2021-07-13 06:39:53 -04:00
Rafael Zalamena
1fe59b44fc lib,ospfd,ospf6d: remove duplicated function
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-09 07:55:25 -03:00
Renato Westphal
1051417011 ospfd: introduce support for Graceful Restart (restarting mode)
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-05 11:43:02 -03:00
Donatas Abraitis
936fbaef47 *: Replace IPV4_MAX_PREFIXLEN to IPV4_MAX_BITLEN
Just drop IPV4_MAX_PREFIXLEN at all, no need keeping both.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01 17:44:09 +03:00
Karen Schoener
0b4124c18c isisd, ospfd: update interface_link_params callback to check for change
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-06-28 10:32:52 -04:00
Mark Stapp
f94b1d526b
Merge pull request #8634 from idryzhov/ospf-vrf-redist
ospf redistribution fixes
2021-05-07 15:22:19 -04:00
Igor Ryzhov
7bced643b9 ospfd: fix redistribution config when vrf doesn't exist
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-05 19:31:22 +03:00
Donald Sharp
b259f5af14 ospfd: Fix indentation in ospf_is_type_redistributed
clang-format was not happy.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04 09:03:27 -04:00
Donald Sharp
5d8c8d0b1d ospfd: Do not use case default for switches that have enum
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-04 09:03:27 -04:00
Donald Sharp
6ec9c6a899 ospfd: Cleanup some awful deep indentation in ospf_zebra.c
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04 09:03:27 -04:00
Mark Stapp
ea631ac834
Merge pull request #8058 from rgirada/ospf-ecmp
ospfd: Max multipath config support
2021-03-30 11:57:33 -04:00
rgirada
3d5b985577 ospfd: Max multipath config support
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-29 22:04:46 -07:00
Olivier Dugeon
f173deb352 ospfd: Add Link-State support
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-23 15:39:29 +01:00
David Lamparter
bf8d3d6aca *: require semicolon after DEFINE_MTYPE & co
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-17 06:18:17 +01:00
Olivier Dugeon
270e66a2ce ospfd: Correct Segment Routing prefix bugs
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-03-09 11:14:32 +01:00
Olivier Dugeon
56981b40e9 ospfd: Debug race condition in Segment Routing
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>
2021-02-11 14:52:40 +01:00
GalaxyGorilla
f026b24ed9 ospfd: Fix backup path RIB handling
* Inject backup paths with proper flags
  * Add outgoing label on top of the backup label stack
  * Ignore explicit/implicit outgoing labels
  * Adjust tests

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-01-19 15:32:13 +00:00
GalaxyGorilla
4ea5353bfd ospfd: Add TI-LFA Prefix-SID Protection
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-01-19 15:32:13 +00:00
GalaxyGorilla
7fd0729f76 ospfd: TI-LFA basic infrastructure and algorithms
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-01-19 15:32:13 +00:00
Karen Schoener
4d1e5644b7 ldpd, isisd, ospfd: Remove periodic ldp-sync hello message
Removing the obsolete ldp-sync periodic 'hello' message.

When ldp-sync is configured, IGPs take action if the LDP process goes down.

The IGPs have been updated to use the zapi client close callback to detect
the LDP process going down.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-12-09 14:11:38 -05:00
Karen Schoener
cb135cc943 isisd, ospfd: IGPs detect LDP down via zapi client close message
When ldp-sync is configured, IGPs take action if the LDP process goes down.

Currently, IGPs detect the LDP process is down if they do not receive a
periodic 'hello' message from LDP within 1 second.

Intermittently, this heartbeat mechanism causes false topotest failures.
When the failure occurs, LDP is busy receiving messages from zebra for a
few seconds.  During this time, LDP does not send the expected periodic
message.

With this change, IGPs detect LDP down via zapi client close message.

Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-12-09 08:41:42 -05:00
Mark Stapp
926bc58f78
Merge pull request #7478 from donaldsharp/buffer
Buffer
2020-11-18 08:30:47 -05:00
Donald Sharp
7cfdb48554 *: Convert all usage of zclient_send_message to new enum
The `enum zclient_send_status` enum needs to be extended
throughout the code base to use the new states and
to fix up places where we tested against the return
value being non zero.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-15 15:04:52 -05:00
Donald Sharp
1782514fb9 *: Remove route_map_object_t from the system
The route_map_object_t was being used to track what protocol we were
being called against.  But each protocol was only ever calling itself.
So we had a variable that was only ever being passed in from route_map_apply
that had to be carried against and everyone was testing if that variable
was for their own stack.

Clean up this route_map_object_t from the entire system.  We should
speed some stuff up.  Yes I know not a bunch but this will add up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-11-13 19:35:20 -05:00
rgirada
960417cf06 ospfd: OSPF external summarisation scenarios
Description:
	Aggergation handled in the following scenarios.
	1. Route update from Zebra.
	2. Refresh external LSA.
	3. Processing routemap update.
	4. Self originated lsa processing.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2020-11-01 22:34:11 -08:00
rgirada
63f0e9415c ospfd: ospf summarisation core handlers
Description:
Apis for creating/deleting aggregate routes.
Origination of summary route on behalf of matched external routes.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2020-11-01 21:17:26 -08:00
Donald Sharp
02c671af40 *: Correct spelling stuff
Pretty obvious.  WE R SPELL GOOD

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-29 16:16:00 -04:00