Commit Graph

228 Commits

Author SHA1 Message Date
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
Mark Stapp
96b663a381 ospfd: replace inet_ntoa
Stop using inet_ntoa, use %pI4 etc or inet_ntop instead

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22 13:37:25 -04:00
Donatas Abraitis
2dbe669bdf :* Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 09:07:41 +03:00
Kaushik
e6baea10a4 ospfd : Resolving conflict in distribute-list update during MaxAge LSA.
1. Fix for duplicating calls of ospf_external_lsa_refresh()
   in ospf_distribute_list_update_timer().
2. Added the comment and change from PR 6981.

Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-09-12 06:24:30 -07:00
Renato Westphal
beb91114ec
Merge pull request #6789 from volta-networks/feat_ldp_igp_sync
ldpd: Add support for LDP-IGP Synchronization
2020-09-11 15:55:04 -03:00
lynne
132a782eb8 ospfd: ldp-igp-sync feature: adding ospf support
Signed-off-by: Lynne Morrison <lynne@voltanet.io>
Signed-off-by: Karen Schoener <karen@voltanet.io>
2020-09-09 14:38:44 -04:00
Kaushik
e641623d90 ospfd : Fix in lsa refresh when redist is done with route-map using access-list.
1. Minor change in distribute-list update timer based on lsa flag.

Co-authored-by: harios <hari@niralnetworks.com>
Signed-off-by: Kaushik <kaushik@niralnetworks.com>
2020-09-02 02:44:25 -07:00
Olivier Dugeon
d81b8e0e1a ospfd: Add Label Manager for Segment Routing
Segment Routing Global Block is now using the Label Manager to reserved
label range. Label Manager connection uses the synchronous mode and dedicated
thread timer is used to establish the connection in safe manner without
blocking OSPFd is the Label Manager is not available.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-08-20 14:33:00 +02:00
Jakub Urbańczyk
aa530b627d ospfd: send ARP requests using zebra
Signed-off-by: Jakub Urbańczyk <xthaid@gmail.com>
2020-08-12 23:20:52 +02:00
Aaron LI
1a08238236 ospfd: Fix Zebra route add message truncation issue
The `INET_ADDRSTRLEN` is 16 and is only enough to format an IPv4 address.
So when there is a prefix (`/xx`), the debug output may get truncated.
Use `PREFIX2STR_BUFFER` macro instead to fix the issue.

Signed-off-by: Aaron LI <aly@aaronly.me>
2020-07-30 08:16:18 -07:00
Donald Sharp
3eb15671ee
Merge pull request #6731 from opensourcerouting/style-string-prep
*: string coding style
2020-07-15 20:06:55 -04:00
David Lamparter
3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00