Commit graph

300 commits

Author SHA1 Message Date
Igor Ryzhov 7d67b9ff28 build: add -Wimplicit-fallthrough
Also:
- replace all /* fallthrough */ comments with portable fallthrough;
pseudo keyword to accomodate both gcc and clang
- add missing break; statements as required by older versions of gcc
- cleanup some code to remove unnecessary fallthrough

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-10-12 21:23:18 +03:00
Mahdi Varasteh f5011cd5dd [ospfd]: add support for RFC 5709 HMAC-SHA Auth
This patch includes:
* Implementation of RFC 5709 support in OSPF. Using
openssl library and FRR key-chain,
one can use SHA1, SHA256, SHA384, SHA512 and
keyed-MD5( backward compatibility with RFC 2328) HMAC algs.
* Updating documentation of OSPF
* add topotests for new HMAC algorithms

Signed-off-by: Mahdi Varasteh <varasteh@amnesh.ir>
2023-09-16 07:38:23 +03:30
Russ White 6e89a5db22
Merge pull request #13691 from LabNConsulting/aceelindem/ospf-opaque-interface-disable
ospfd: Configurable interface-level 'capability opaque' support
2023-07-11 11:47:32 -04:00
Acee e72549c8f6 ospfd: Configurable interface-level 'capability opaque' support
Add support for "[no] ip ospf capbility opaque" at the interface
    level with the default being capability opaque enabled. The command
    "no ip ospf capability opaque" will disable opaque LSA database
    exchange and flooding on the interface. A change in configuration
    will result in the interface being flapped to update our options
    for neighbors but no attempt will be made to purge existing LSAs
    as in dense topologies, these may received by neighbors through
    different interfaces.

    Topotests are added to test both the configuration and the LSA
    opaque flooding suppression.

Signed-off-by: Acee <aceelindem@gmail.com>
2023-06-28 13:03:48 -04:00
Acee c6e3af3013 ospfd: Add config callbacks and suppress hello during config load.
Signed-off-by: Acee <aceelindem@gmail.com>
2023-06-23 07:20:35 -04:00
Russ White 425fc1f5b7
Merge pull request #12949 from opensourcerouting/ospf-unplanned-gr
OSPF GR for unplanned outages
2023-05-16 08:37:19 -04:00
Acee 4e7eb1e62c ospfd: OSPF opaque LSA stale processing fix and topotests.
1. Fix OSPF opaque LSA processing to preserve the stale opaque
            LSAs in the Link State Database for 60 seconds consistent with
            what is done for other LSA types.
         2. Add a topotest that tests for cases where ospfd is restarted
            and a stale OSPF opaque LSA exists in the OSPF routing domain
            both when the LSA is purged and when the LSA is reoriginagted
            with a more recent instance.

Signed-off-by: Acee <aceelindem@gmail.com>
2023-05-09 16:51:03 -04: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
Mark Stapp 04a0401f2d ospfd: support write socket per interface
Add support for a write socket per interface, enabled by
default at the ospf instance level. An ospf instance-level
config allows this to be disabled, reverting to the older
behavior where a single per-instance socket is used for
sending and receiving packets.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-04-11 10:16:07 -04: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 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 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
Donatas Abraitis ba427e6348 ospfd, ospf6d: Add more logging details
Basically just router-id or interface/IP.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-17 10:14:26 +02:00
Renato Westphal cb1f47c2eb ospfd, ospf6d: perform GR consistency check only when necessary
The GR code should check for topology changes only upon the receipt
of Router-LSAs and Network-LSAs. Other LSAs types don't affect the
topology as far as a restarting router is concerned.

This optimization reduces unnecessary computations when the
restarting router receives thousands of inter-area LSAs or external
LSAs while coming back up.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-02 19:38:03 -03:00
Russ White 62bd2580e3
Merge pull request #12366 from manojvn/ospfv2-flood-reduction
ospfd: Support OSPF Refresh and Flooding Reduction RFC4136.
2023-02-21 08:03:06 -05: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
Manoj Naragund ee09fbc0a5 ospfd: ospf hello changes.
Description:
	The changes involve setting DC bit on ospf hellos and
	addition of new DO_NOT_AGE flag.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-01-19 21:03:03 -08:00
Jafar Al-Gharaibeh 8935b0fac6 ospfd: report the router IP with Opaque capability mismatch
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2023-01-06 09:27:18 -06:00
Jafar Al-Gharaibeh eab190351f ospfd: add advertising router IP to Opaque capability mismatch error message
Submitted-by Marc Boucher <marc@airvitesse.net>
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2022-12-24 19:59:38 -06:00
Lou Berger 53674eaba6 ospfd: catch and report runt LSAs
Signed-off-by: Lou Berger <lberger@labn.net>
2022-10-29 12:33:23 +00:00
Lou Berger c706f0e32b ospf: optimization for FRR's P2MP mode
FRR implements a non-standard, but compatible approach for
	sending update LSAs (it always send to 224.0.0.5) on P2MP
	interfaces. This change makes it so acks are also sent to
	224.0.0.5.

	Since the acks are multicast, this allows an optimization
	where we don't send back out the incoming P2MP interface
	immediately allow time to rx multicast ack from neighbors
	on the same net that rx'ed the original (multicast) update.

Signed-off-by: Lou Berger <lberger@labn.net>
2022-10-25 15:31:44 +00:00
sri-mohan1 ea892800dd ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-25 23:48:24 +05:30
Donald Sharp fe61ceaee7 ospfd: Cleanup indentation surrounding oi->nbr
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-11 13:30:32 -04:00
Donald Sharp 812e6c78c1 ospfd: Increase packets sent at one time in ospf_write
ospf_write pulls an interface off the ospf->oi_write_q
then writes one packet and places it back on the queue,
keeping track of the first one sent.  Then it will
stop sending packets even if we get back to the first
interface written too but before we have sent the full
pkt_count.  I do not believe this makes a whole bunch
of sense and is very restrictive of how much data can
be sent especially if you have a limited number of peers
but large amounts of data.  Why be so restrictive?

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-11 13:30:32 -04:00
Donald Sharp bc1f09de73 ospfd: Convert thread_cancel to THREAD_OFF
Just convert all uses of thread_cancel to THREAD_OFF.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:27:35 -04:00
Donald Sharp cccd44f3b1 ospfd: Remove various macros that overlap THREAD_OFF
Let's just use THREAD_OFF consistently in the code base
instead of each daemon having a special macro that needs to
be looked at and remembered what it does.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:27:35 -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
Donald Sharp f526739897 *: Fix spelling of accomodate
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:29:58 -04:00
Donald Sharp 2ef62909a9 *: Fix spelling of atleast
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:25:03 -04: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
Igor Ryzhov 096f7609f9 *: cleanup ifp->vrf_id
Since f60a1188 we store a pointer to the VRF in the interface structure.
There's no need anymore to store a separate vrf_id field.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-22 20:47:23 +03:00
Donald Sharp b72aae2e04 *: Cleanup some documentation from quagga->frr
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-11 14:41:27 -05:00
Igor Ryzhov a1a8fb4ddd
Merge pull request #9368 from donaldsharp/ospf_ensure_lsa_length
ospfd: Ensure we have some non header lsa data
2021-10-29 13:37:09 +03:00
Donald Sharp 1afa7d5326
Merge pull request #9813 from opensourcerouting/ospf-gr-fixes
ospfd: more GR fixes
2021-10-15 09:21:40 -04:00
Igor Ryzhov bb3cd4189a
Merge pull request #9795 from opensourcerouting/ospf_get_name
ospfd: use ospf_get_name() wherever possible
2021-10-14 01:42:29 +03:00
Renato Westphal 3ebf9d3416 ospfd: fix another DR election issue during graceful restart
Commit 3551ee9e90304 introduced a regression that causes GR to fail
under certain circumstances. In short, while ISM events should
be ignored while acting as a helper for a restarting router, the
DR/BDR fields of the neighbor structure should still be updated
while processing a Hello packet. If that isn't done, it can cause
the helper to elect the wrong DR while exiting from the helper mode,
leading to a situation where there are two DRs for the same network
segment (and a failed GR by consequence). Fix this.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-12 17:33:32 -03:00
Russ White c5708d0b98
Merge pull request #9781 from opensourcerouting/ospfd-gr-dr-fix
ospfd: preserve DR status across graceful restarts
2021-10-12 10:58:39 -04:00
Renato Westphal 44076f4dc7 ospfd: use ospf_get_name() wherever possible
Small cleanup to reduce code duplication.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-09 20:36:47 -03:00
Renato Westphal ab6edbfeef ospfd: preserve DR status across graceful restarts
RFC 3623 says:
 "If the restarting router determines that it was the Designated
 Router on a given segment prior to the restart, it elects
 itself as the Designated Router again.  The restarting router
 knows that it was the Designated Router if, while the
 associated interface is in Waiting state, a Hello packet is
 received from a neighbor listing the router as the Designated
 Router".

Implement that logic when processing Hello messages to ensure DR
interfaces will preserve their DR status across a graceful restart.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-08 09:13:37 -03:00
Mobashshera Rasool 874a549d51 ospfd: ospf nbr in full although mismatch in hello packet contents
Issue:
===================
OSPF neighbors are not going down even after 10 mins when
having a mismatch in hello and dead interval.
First neighbors are formed and then a mismatch in the interval
is created, it is observed that the neighbor is not going down.

Root Cause Analysis:
====================
The event HelloReceived defined in RFC 2328 was named as PacketReceived
and this event was scheduled whenever LS Update, LS Ack, LS Request,
DD description packet or Hello packet is received.
Although there is a mismatch in the Hello packet contents, the
event PacketReceived gets triggered due to LS Update received and the
dead timer gets reset and hence the neighbor was never going Down and
remains FULL.

Fix:
==================
As per RFC 2328, the HelloReceived needs to be triggered only when
valid OSPF Hello packet is received and not when other OSPF packets
are received. Modified the function name as well.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-10-06 10:04:10 -07:00
Donald Sharp 07a62e585d ospfd: Add some small doc to what each one is for future people
min lsa packet sizes are not always directly corresponding
to the actual LSA.  Add a bit of comments so it's easier
for future people to figure out.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-14 13:13:32 -04:00
Donald Sharp cf680c38a9 ospfd: Ensure we have some non header lsa data
In some cases FRR is receiving a lsa data packet
with a length set to the length of the header only.
If we are expecting data from a peer in the form
of lsa data.  Let's enforce it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-14 13:07:06 -04:00
Russ White 12b5b2f9ff
Merge pull request #9551 from mobash-rasool/ospfv2-bug-fixes-04
ospfd: GR Conformance fix in Hello packet DR election
2021-09-07 10:47:09 -04:00
Mobashshera Rasool 3cb62bb387 ospfd: RFC conformance test case 25.23 issue fix
Problem Statement :
===================
LSA with InitialSequenceNumber is not originated
after MaxSequenceNumber.

ANVL Test case 25.33 states:
============================
As soon as this flooding of a LSA with LS sequence number
MaxSequenceNumber has been acknowledged by all adjacent neighbors,
a new instance can be originated with sequence number of InitialSequenceNumber.

RCA :
=====
DUT did not originated LSA with INITIAL_SEQUENCE number even
after receiving ACK for max sequence LSA.
Code is not present to handle this situation in the lsa ack flow.

Fix :
=====
Add code to originate LSA with initial sequence number in the
LSA ack flow in case of wrap around sequence number.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-09-03 06:44:56 -07:00
Mobashshera Rasool 44d1115ad6 ospfd: ANVL Test case 25.22, 25.23 and 28.11 fixes
ANVL Test case 28.11
If the database copy has LS age equal to MaxAge and LS sequence number
equal to MaxSequenceNumber, simply discard the received LSA
without acknowledging it.

ANVL Test Case 25.22
When an attempt is made to increment the sequence number past the maximum
value of N - 1 (0x7fffffff; also referred to as MaxSequenceNumber),
the current instance of the LSA must first be flushed from the routing domain.

ANVL Test Case 25.23
As soon as this flooding of a LSA with LS sequence number MaxSequenceNumber
has been acknowledged by all adjacent neighbors, a new instance can be
originated with sequence number of InitialSequenceNumber.

RCA:
When IXIA sent LS Seq num as MAX and LS Age as (MAX - 3),
DUT dropped the packet instead of sending ACK.
In function ospf_ls_upd, at Line 2106 the code is there to drop the LSA.
Hence its failing.

Fix:
LSAs ACK must be sent when received LSA is having max sequence number
but not max-aged.
Considering  /* CVE-2017-3224 */ issue, have corrected the existing
code to prevent attacker from sending LSAs with max sequence number
and higher checksum and blocking the flooding of the Max-sequence numbered LSAs.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-09-03 06:44:39 -07:00
Mobashshera Rasool d51715bb44 ospfd: GR Conformance fix for Hello packet DR election
Problem Statement:
===================
DUT selecting itself as DR when RR goes for reload.
Test Case 7.2

DUT (GR Helper) receives the Hello packet from the OSPF GR RESTARTER
(ANVL here) with DR and BDR set to 0.0.0.0 and DUT in its hello
neighbor list. DUT triggers the DR and BDR election although it is
in the Helper mode for that neighbor.

Root Cause Analysis:
====================
When hello packet is received with self router ID in the neighbor list,
there is no check in the code to handle this scenario. Hence the DR/BDR
election happens and it changes the DR although it is helper.

Fix:
===================
As per RFC 3623 Section 3.  Operation of Helper Neighbor, below point,
we need to maintain the DR relationship.
Also, if X was the Designated Router on network segment S when the
helping relationship began, Y maintains X as the Designated Router
until the helping relationship is terminated.

Adding the check when DUT is under neighbor helper mode, we need to avoid
ISM state change when hello packet is received with DR/BDR set to 0.0.0.0.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-09-03 06:40:14 -07: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
Renato Westphal cd52c44c00 ospfd: rename the graceful restart header
Both the GR helper code and the upcoming GR restarting code are going
to share a lot of definitions. As such, rename ospf_gr_helper.h to
ospf_gr.h, which will be the central point of all GR definitions
and prototypes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-07-05 11:43:02 -03:00