Commit graph

156 commits

Author SHA1 Message Date
Mark Stapp 0561943a78 ospfd: clean up -Wshadow warnings
Clean up various "shadow" warnings.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Mark Stapp 72b31b96fc *: create a single registry of daemons' default port values
Create a single registry of default port values that daemons
are using. Most of these are vty ports, but there are some
others for features like ospfapi and zebra FPM.

Signed-off-by: Mark Stapp <mjs@labn.net>
2024-02-01 11:40:02 -05:00
Alexander Chernavin b1f759133b ospfd: fix default-metric change if external LSAs already sent
Currently, when redistribution of routes was configured, external LSAs
were already advertised to peers, and then default-metric is changed,
external LSAs refresh will not occur. In other words, the peers will not
receive the refreshed external LSAs with the new metric.

With this fix, changing default-metric will cause external LSAs to be
refreshed and flooded.

There is a similar task to refresh external LSAs when NSSA settings are
changed. And there is a function that accomplishes it -
ospf_schedule_asbr_nssa_redist_update(). Since the function does the
general work of refreshing external LSAs and is not specific to NSSA
settings, the idea is to give it a more general name and call it when
default-metric changes in order to fix the problem.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2023-07-19 13:12:40 +00: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
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
Mark Stapp 6e6e1020dd ospfd: support configuration of socket buffer sizes
Add configurable socket send and receive buffer sizes,
configured at the instance level.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-04-06 14:16:43 -04:00
Renato Westphal f07ff222f8 ospfd: add support for NSSA Type-7 address ranges
Implement NSSA address ranges as specified by RFC 3101:

   NSSA border routers may be configured with Type-7 address ranges.
   Each Type-7 address range is defined as an [address,mask] pair.  Many
   separate Type-7 networks may fall into a single Type-7 address range,
   just as a subnetted network is composed of many separate subnets.
   NSSA border routers may aggregate Type-7 routes by advertising a
   single Type-5 LSA for each Type-7 address range.  The Type-5 LSA
   resulting from a Type-7 address range match will be distributed to
   all Type-5 capable areas.

Syntax:
  area A.B.C.D nssa range A.B.C.D/M [<not-advertise|cost (0-16777215)>]

Example:
  router ospf
   router-id 1.1.1.1
   area 1 nssa
   area 1 nssa range 172.16.0.0/16
   area 1 nssa range 10.1.0.0/16
  !

Since regular area ranges and NSSA ranges have a lot in common,
this commit reuses the existing infrastructure for area ranges as
much as possible to avoid code duplication.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-31 19:28:15 -03: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
Renato Westphal e85194f572 ospfd: refactor the "area nssa" command using DEFPY
Combine all variation of the "area nssa" command into a single
DEFPY to improve code maintainability.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-31 19:28:15 -03: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 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
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 6f7bbc0cec ospfd: Datastructure changes for OSPFv2 Flood reduction.
Description:
Code changes involve following things.
	1. an additional structure containing flood reduction related info
           per area.
        2. a knob variable in the ospf structure for enabling/disabling the feature.
        3. initialization of above mentioned variables.

    Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-01-19 21:02:34 -08: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
Donatas Abraitis 3228977f58 Revert "ospfd: few fixes in rSPF calc when LSA received from non root node"
This reverts commit 9f2984d97c.
2023-01-17 18:09:55 +02:00
Madhuri Kuruganti 9f2984d97c ospfd: few fixes in rSPF calc when LSA received from non root node
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
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
Manoj Naragund b345a3d9b4 ospfd: Added clis to change default timers for LSA refresh and maxage remove delay.
Description:
Added hidden clis that will allow you to reset the default timers
for LSA refresh and LSA maxage remove delay, these will help in testing
LSA refresh scenarios in upcoming OSPFv2 Flood reduction feature(rfc4136).

IETF Link : https://datatracker.ietf.org/doc/html/rfc4136

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-08-31 23:10:09 -07: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
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
Christian Hopps b538baf352 ospfd: add all_rtrs route table when opaque enabled
The reachable router table is used by OSPF opaque clients in order to
determine if the router advertising the opaque LSA data is
reachable (i.e., 2-way conectivity check).

Signed-off-by: Christian Hopps <chopps@labn.net>
2022-06-02 16:37:16 -04:00
Donald Sharp 17be83bf99 *: Fix spelling of Gracefull
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:46:19 -04:00
anlan_cs 4b939ad230 ospfd: adjust type of "aggr_delay_interval"
Adjust type of "aggr_delay_interval":
Just replace `unsigned int` with `uint16_t` for range is (50..1800).

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-01-28 20:11:40 -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
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
Alexander Chernavin 1c1c342d2a ospfd: install Type-7 when NSSA area is configured after redistribution
Currently, if NSSA area is configured before redistribution is enabled,
Type-7 LSA's are installed and flooded. But if NSSA area is configured
after redistribution is enabled, Type-7 LSA's are not installed.

With this change, when NSSA area is configured, schedule a task that
scans for external LSA's. If they exist, install Type-7 and flood to
all NSSA Areas.

There already was an attempt to fix this problem in 0f321812f where
ospf_asbr_nssa_redist_task() was triggered in ospf_abr_task_timer().
This turns out to be incorrect place for this operation because it's
a one-off operation needed only after "area <ID> nssa" execution. And
ospf_abr_task_timer() is a periodic operation. Triggering
ospf_asbr_nssa_redist_task() in ospf_abr_task_timer() caused a problem
that was fixed in 945eec2b6 making the problem with NSSA area
configured after redistribution actual again.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2021-04-12 09:34:20 -04:00
Sarita Patra a623b52619 ospfd: North-bound implementation for ospfd rmaps
This commit introduces the implementation for the north-bound
callbacks for the ospfd-specific route-map match and set clauses.

Signed-off-by: NaveenThanikachalam <nthanikachal@vmware.com>
Signed-off-by: Sarita Patra <saritap@vmware.com>
2021-03-30 22:59:30 +03: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
Mark Stapp 5c9254bd52
Merge pull request #8362 from idryzhov/fix-ospf-cli-count
ospfd: fix counting of "ip ospf area" commands
2021-03-30 08:48:25 -04:00
Igor Ryzhov cbf32f74ef ospfd: fix counting of "ip ospf area" commands
Instead of trying to maintain if_ospf_cli_count, let's directly count
the number of configured interfaces when it is needed. Current approach
sometimes leads to an incorrect counter.

Fixes #8321.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-30 11:51:21 +03: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
ckishimo c317eddbce ospfd: add support for suppress_fa
This command will trigger the OSPF forwarding address suppression in
translated type-5 LSAs, causing a NSSA ABR to use 0.0.0.0 as a forwarding
address instead of copying the address from the type-7 LSA

Example: In a topology like: R1 --- R2(ABR) --- R3(ASBR)

R3 is announcing a type-7 LSA that is translated to type-5 by the R2 ABR.
The forwarding address in the type-5 is by default copied from the type-7

    r1# sh ip os da external

                    AS External Link States

      LS age: 6
      Options: 0x2  : *|-|-|-|-|-|E|-
      LS Flags: 0x6
      LS Type: AS-external-LSA
      Link State ID: 3.3.3.3 (External Network Number)
      Advertising Router: 10.0.25.2
      LS Seq Number: 80000001
      Checksum: 0xcf99
      Length: 36

      Network Mask: /32
            Metric Type: 2 (Larger than any link state path)
            TOS: 0
            Metric: 20
            Forward Address: 10.0.23.3    <--- address copied from type-7 lsa
            External Route Tag: 0

    r2# sh ip os database

                    NSSA-external Link States (Area 0.0.0.1 [NSSA])

    Link ID         ADV Router      Age  Seq#       CkSum  Route
    3.3.3.3         10.0.23.3          8 0x80000001 0x431d E2 3.3.3.3/32 [0x0]

                    AS External Link States

    Link ID         ADV Router      Age  Seq#       CkSum  Route
    3.3.3.3         10.0.25.2          0 0x80000001 0xcf99 E2 3.3.3.3/32 [0x0]

    r2# conf t
    r2(config)# router ospf
    r2(config-router)# area 1 nssa suppress-fa
    r2(config-router)# exit
    r2(config)# exit

    r2# sh ip os database

                    NSSA-external Link States (Area 0.0.0.1 [NSSA])

    Link ID         ADV Router      Age  Seq#       CkSum  Route
    3.3.3.3         10.0.23.3         66 0x80000001 0x431d E2 3.3.3.3/32 [0x0]

                    AS External Link States

    Link ID         ADV Router      Age  Seq#       CkSum  Route
    3.3.3.3         10.0.25.2         16 0x80000002 0x0983 E2 3.3.3.3/32 [0x0]

    r1# sh ip os da external

           OSPF Router with ID (11.11.11.11)

                    AS External Link States

      LS age: 34
      Options: 0x2  : *|-|-|-|-|-|E|-
      LS Flags: 0x6
      LS Type: AS-external-LSA
      Link State ID: 3.3.3.3 (External Network Number)
      Advertising Router: 10.0.25.2
      LS Seq Number: 80000002
      Checksum: 0x0983
      Length: 36

      Network Mask: /32
            Metric Type: 2 (Larger than any link state path)
            TOS: 0
            Metric: 20
            Forward Address: 0.0.0.0       <--- address set to 0
            External Route Tag: 0

    r2# conf t
    r2(config)# router ospf
    r2(config-router)# no area 1 nssa suppress-fa
    r2(config-router)# exit

    r1# sh ip os da external

           OSPF Router with ID (11.11.11.11)

                    AS External Link States

      LS age: 1
      Options: 0x2  : *|-|-|-|-|-|E|-
      LS Flags: 0x6
      LS Type: AS-external-LSA
      Link State ID: 3.3.3.3 (External Network Number)
      Advertising Router: 10.0.25.2
      LS Seq Number: 80000003
      Checksum: 0xcb9b
      Length: 36
      Network Mask: /32
            Metric Type: 2 (Larger than any link state path)
            TOS: 0
            Metric: 20
            Forward Address: 0.0.0.0       <--- address set to 0
            External Route Tag: 0

    r2# conf t
    r2(config)# router ospf
    r2(config-router)# no area 1 nssa suppress-fa
    r2(config-router)# exit

    r1# sh ip os da external

           OSPF Router with ID (11.11.11.11)

                    AS External Link States

      LS age: 1
      Options: 0x2  : *|-|-|-|-|-|E|-
      LS Flags: 0x6
      LS Type: AS-external-LSA
      Link State ID: 3.3.3.3 (External Network Number)
      Advertising Router: 10.0.25.2
      LS Seq Number: 80000003
      Checksum: 0xcb9b
      Length: 36

      Network Mask: /32
            Metric Type: 2 (Larger than any link state path)
            TOS: 0
            Metric: 20
            Forward Address: 10.0.23.3    <--- address copied from type-7 lsa
            External Route Tag: 0

Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2021-03-24 16:06:38 +01:00
David Lamparter 960b9a5383 *: require semicolon after DEFINE_<typesafe...>
Again, see previous commits.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:39 +01:00
David Lamparter 96244aca23 *: require semicolon after DEFINE_QOBJ & co.
Again, see previous commits.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:37 +01:00
Igor Ryzhov 409f98ab44 ospfd: don't rely on instance existence in vty
Store instance index at startup and use it when processing vty commands.
The instance itself may be created and deleted by the user in runtime
using `[no] router ospf X` command.

Fixes #7908

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-24 15:31:20 +03:00
Donald Sharp 153bdb3d03 ospfd: ospf_nbr_nbma_lookup_next always returns NULL
The calling function of ospf_nbr_nbma_lookup_next calls
this function and then immediately returns when it
gets the NULL.  Just cleanup a bit more code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-28 14:56:11 -05:00
GalaxyGorilla bdcfd34a41 ospfd: Add support for non-adjacent TI-LFA P/Q spaces
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-01-19 15:32:13 +00:00
GalaxyGorilla 9d3444f8d3 ospfd: TI-LFA backup path enhancements
Use a pre-built backup path from the post-convergence SPF tree to
make the overall calculation deterministic. This is also a
requirement for non-adjacent P/Q spaces since it's way easier
to organize multiple P and Q spaces using a 'fixed' backup path.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-01-19 15:32:13 +00:00
GalaxyGorilla 385a1e07b1 ospfd: Add support for TI-LFA node protection
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-01-19 15:32:13 +00:00
GalaxyGorilla 133e59cfad ospfd: Add support for reverse SPF (P2P only)
A reverse SPF is important in the context of TI-LFA, e.g. for
computing so called Q spaces. In case the weights of the links are
symmetric there is no difference to the 'normal' SPF and hence this
patch is really just needed for the case with asymmetric link
weights.

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
Mobashshera Rasool f91ce319d3 ospfd: Clear ip ospf process and clear ip ospf neighbor
Implement the below 2 CLIs to clear the current data in the process
and neighbor data structure.
1. clear ip ospf process
2. clear ip ospf neighbor

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-01-12 10:52:42 +00:00
Igor Ryzhov c3391da1f0 ospf: fix instance initialization when using multi-instance mode
OSPF instance initialization was moved from "router ospf" vty command to
ospf_get function some time ago but the same thing must be done in
ospf_get_instance function used when multi-instance mode is enabled.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-12-02 03:38:07 +03:00
ckishimo d12566a16b ospfd: fix a couple of typos
Signed-off-by: ckishimo <carles.kishimoto@gmail.com>
2020-11-24 07:35:49 -08:00
rgirada cb2bc4cb02 ospfd: summarisation specific data structures.
Description:
Data structures definitions for summary route.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2020-11-01 21:10:31 -08:00
Santosh P K 5a066545da
Merge pull request #7301 from idryzhov/ospf-fixes
many ospfd fixes
2020-10-28 20:26:02 +05:30