Commit graph

2353 commits

Author SHA1 Message Date
Donald Sharp 848dcf3d03 *: remove sys/stat.h from zebra.h
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-09 12:39:23 -05:00
Donald Sharp 2bf051a577 *: Remove Crypto openSSL define from zebra.h
Only a couple of places use this.  Move these to a better
spot.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-01-04 14:02:34 -05:00
Acee dec87faab6 ospfd: Fix opaque functab leak and opaque AS cleanup problems
1. Fix ospf opaque LSA function table memory leak.
   2. Remove incorrect one-to-one association of OSPF info-per-type
      to function table (since there many be many).
   3. Fix a problem with opaque AS external cleanup that was exposed
      by #2.
   4. Fix LSA memory leak in ospf_opaque_type9_lsa_if_cleanup().

Signed-off-by: Acee <aceelindem@gmail.com>
2023-12-20 09:43:51 -05:00
Olivier Dugeon a3230323f7 ospfd: Correct LSA parser which fulfill the TED
Traffic Engineering Database (TED) is fulfill from the various LSA advertised
and received by the router. To remove information on the TED, 2 mechanisms are
used: i) parse TE Opaque LSA when there are flushed and ii) compare the list of
prefixes advertised in the Router LSA with the list of corresponding edges and
subnets contained in the TED. However, this second mechanism assumes that the
Router LSA is unique and contains all prefixes of the advertised router.
But, this is wrong. Prefixes could be advertised with several Router LSA.
This conduct to remove edge and subnet in the TED while it should be maintained.
The result is a faulty test with ospf_sr_te_topo1 topotest when server is heavy
loaded.

This simple patch removed deletion of edges and subnets when parsing the Router
LSA and only removed them when the corresponding TE Opaque LSA is flushed. In
addition, TE Opaque LSA are not flushed when OSPF ajacency goes down. This
patch also correct this second problem.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-12-14 18:39:16 +01:00
Bing Shui a1793303c0 ospfd: fix ospf dead-interval minimal hello-multiplier param range
Signed-off-by: Bing Shui <652023330037@smail.nju.edu.cn>
2023-12-13 22:23:58 +08:00
Olivier Dugeon 397dbbcae6 ospfd: Correct SID check size
Segment Router Identifier (SID) could be an index (4 bytes) within a range
(SRGB or SRLB) or an MPLS label (3 bytes). Thus, before calling check_size
macro to verify SID TLVs size, it is mandatory to determine the SID type to
avoid wrong assert.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-12-08 13:47:34 +01:00
Renato Westphal 3e2f053b12 ospfd: fix deferred shutdown handling
The ospfd cleanup code is relatively complicated given the need to
appropriately handle the "max-metric router-lsa on-shutdown (5-100)"
command. When that command is configured and an OSPF instance is
unconfigured, the removal of the instance should be deferred to allow
other routers sufficient time to find alternate paths before the
local Router-LSAs are flushed. When ospfd is killed, however, deferred
shutdown shouldn't take place and all instances should be cleared
immediately.

This commit fixes a problem where ospf_deferred_shutdown_finish()
was prematurely exiting the daemon when no instances were left,
inadvertently preventing ospf_terminate() from clearing the ospfd
global variables. Additionally, the commit includes code refactoring
to enhance readability and maintainability.

Fixes #14855.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-12-01 08:53:30 -03:00
Renato Westphal 37f861f1db ospfd: improve memory cleanup during shutdown
* On ospf_terminate(), proceed to clear the ospfd global variables even
  when no OSPF instance is configured
* Remove double call to route_map_finish()
* Call ospf_opaque_term() to clear the opaque LSA infrastructure
* Clear the `OspfRI.area_info` and `om->ospf` global lists.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-12-01 08:53:28 -03:00
Donatas Abraitis fc8a07433f
Merge pull request #14886 from LabNConsulting/aceelindem/ospf-link-local-fix
ospfd: Fix OSPF link-local opaque LSA crash and opaque memory corruption
2023-11-29 10:36:30 +02:00
Acee 5993c4aef9 ospfd: Fix OSPF link-local opaque LSA crash and opaque memory corruption
1. When an OSPF interface is deleted, remove the references in link-local
     LSA. Delete the LSA from the LSDB so that the callback has accessibily
     to the interface prior to deletion.
  2. Fix a double free for the opaque function table data structure.
  3. Assure that the opaque per-type information and opaque function table
     structures are removed at the same time since they have back pointers
     to one another.
  4. Add a topotest variation for the link-local opaque LSA crash.

Signed-off-by: Acee <aceelindem@gmail.com>
2023-11-28 16:18:55 -05:00
Christian Hopps bb6fe6beb9
Merge pull request #14811 from donaldsharp/zebra_final_shutdown_finally
Zebra final shutdown finally
2023-11-28 20:14:42 +01:00
Donald Sharp 0dc7704fd5
Merge pull request #14867 from opensourcerouting/zclient-options-cleanup
*: clean up `zclient` options
2023-11-25 09:15:07 -05:00
David Lamparter cc90c54b36 *: add zclient_options_sync
... 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-23 15:20:13 +01:00
David Lamparter 8b23c0b0bd *: convert struct interface->connected to DLIST
Replace `struct list *` with `DLIST(if_connected, ...)`.

NB: while converting this, I found multiple places using connected
prefixes assuming they were IPv4 without checking:

- vrrpd/vrrp.c: vrrp_socket()
- zebra/irdp_interface.c: irdp_get_prefix(), irdp_if_start(),
  irdp_advert_off()

(these fixes are really hard to split off into separate commits as that
would require going back and reapplying the change but with the old list
handling)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-22 23:00:30 +01:00
Donatas Abraitis b84476e0bb
Merge pull request #14850 from donaldsharp/IFNAMSIZ_GET_YOUR_SHIT_TOGETHER
*: Let's use the native IFNAMSIZ instead of INTERFACE_NAMSIZ
2023-11-22 09:13:58 +02:00
Donald Sharp 88a54b123d *: Cleanup keychain on shutdown
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 12:41:18 -05:00
Donald Sharp 01af05fbd5
Merge pull request #14834 from opensourcerouting/zclient-nexthop-update
*: move common NHT update decoding bits into lib/
2023-11-21 10:56:47 -05:00
Donald Sharp 07b91ca096 *: Let's use the native IFNAMSIZ instead of INTERFACE_NAMSIZ
INTERFACE_NAMSIZ is just a redefine of IFNAMSIZ and IFNAMSIZ
is the standard for interface name length on all platforms
that FRR currently compiles on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 08:08:29 -05:00
Donatas Abraitis 77ff93b8f5
Merge pull request #14710 from teletajp/fix_show_ospf_gr_helper_cmd
ospfd:fix show_ip_ospf_gr_helper
2023-11-21 11:39:31 +02:00
David Lamparter 53a82c1c2f ospfd: use zclient->nexthop_update
Same as before.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-20 11:28:20 +01:00
teletajp 62754e1029 ospfd: fix show_ip_ospf_gr_helper
Fix for the command "show ip ospf vrf NAME graceful-restart helper".
FRR did not show information by vrf's name.
If i have router ospf vrf red, vtysh's command
'show ip ospf vrf red graceful-restart helper' will not show anything.
But command 'show ip ospf vrf all graceful-restart helper' will work
normally. This fix fixes the display of information by vrf's name.

Example:
frr1# show ip ospf vrf vrf-1 graceful-restart helper
VRF Name: vrf-1

       OSPF Router with ID (192.168.255.81)

 Graceful restart helper support enabled.
 Strict LSA check is enabled.
 Helper supported for Planned and Unplanned Restarts.
 Supported Graceful restart interval: 1800(in seconds).

Signed-off-by: teletajp <teletajp@yandex.ru>
2023-11-15 16:18:46 +03:00
Donald Sharp d2aafaf5b6 ospfd: Cleanup route-map memory
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-13 09:16:45 -05:00
Donald Sharp 6de9f7fbf5 *: Move distance related defines into their own header
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-07 06:47:51 -05:00
David Lamparter d889055d8e lib: convert if_zapi_callbacks into actual hooks
...so that multiple functions can be subscribed.

The create/destroy hooks are renamed to real/unreal because that's what
they *actually* signal.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-11-02 17:10:43 -07:00
Mark Stapp b6b16d99f7
Merge pull request #14688 from opensourcerouting/fix/ospf_spacing_nit
ospfd, ospf6d: Fix spacing nit for `show ... summary-address` command
2023-10-30 08:49:03 -04:00
Donatas Abraitis 73914a3e73
Merge pull request #13576 from chiragshah6/mdev1
zebra:returns empty dict when evpn is disabled II
2023-10-30 08:55:49 +02:00
Donatas Abraitis ed2b593720 ospfd, ospf6d: Fix spacing nit for show ... summary-address command
```
r1# sh ipv6 ospf6 summary-address
VRF Name: default
aggregation delay interval :5(in seconds)
```

Just hit this random and looks ugly, let's fix it.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-10-30 08:40:19 +02:00
Chirag Shah 43443e828a *: modify empty json helper function
Modify empty json object to take input obj
instead of allocating always one.

There are situation where in error condition or no data
case print empty json (`{}`) with already allocated

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-10-29 11:20:37 -07:00
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
Rodrigo Nardi e0dbeff5bc
ospfd: Fixing infinite loop when listing OSPF interfaces
The problem was happening because the ospf->oiflist has this behaviour, each interface was removed and added at the end of the list in each ospf_network_run_subnet call, generation an infinite loop.
As a solution, a copy of the list was generated and we interacted with a fixed list.

Signed-off-by: Rodrigo Nardi <rnardi@netdef.org>
2023-10-10 15:39:59 -03:00
Donatas Abraitis 69a0d59990
Merge pull request #14451 from m-varasteh/ospf-coverity-issues
ospfd: a possible fix for TAINTED_SCALAR coverity issues
2023-10-10 09:01:03 +03:00
anlan_cs b580c52698 *: remove ZEBRA_INTERFACE_VRF_UPDATE
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-10-07 10:06:39 +08:00
Mahdi Varasteh 0f98ad8ffa ospfd: a possible fix for TAINTED_SCALAR coverity issues
Signed-off-by: Mahdi Varasteh <varasteh@amnesh.ir>
2023-10-03 10:13:03 +03:30
Russ White dbd08a31cc
Merge pull request #14356 from Keelan10/ospf_external_aggregator-leak
ospfd: Fix External Aggregator Leak
2023-09-26 10:18:08 -04:00
Mark Stapp 438ef98701 ospfd: fix some dicey pointer arith in snmp module
Coverity reports some uses of 'oid *' as if they were 'char *';
try to correct that.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-09-21 10:46:02 -04: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
Keelan10 40d441fb07 ospfd: Fix External Aggregator Leak
Fixes a memory leak in ospfd where the external aggregator
was not released after its associated route node is deleted.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in ospf_basic_functionality.test_ospf_asbr_summary_topo1/r0.asan.ospfd.31502

=================================================================
==31502==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 200 byte(s) in 5 object(s) allocated from:
    #0 0x7fdb30665d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7fdb300620da in qcalloc lib/memory.c:105
    #2 0x55e53c2da5fa in ospf_external_aggregator_new ospfd/ospf_asbr.c:396
    #3 0x55e53c2dead3 in ospf_asbr_external_aggregator_set ospfd/ospf_asbr.c:1123
    #4 0x55e53c27c921 in ospf_external_route_aggregation ospfd/ospf_vty.c:10264
    #5 0x7fdb2ffe5428 in cmd_execute_command_real lib/command.c:993
    #6 0x7fdb2ffe58ec in cmd_execute_command lib/command.c:1051
    #7 0x7fdb2ffe5d6b in cmd_execute lib/command.c:1218
    #8 0x7fdb3010ce2a in vty_command lib/vty.c:591
    #9 0x7fdb3010d2d5 in vty_execute lib/vty.c:1354
    #10 0x7fdb30115b9b in vtysh_read lib/vty.c:2362
    #11 0x7fdb30100b99 in event_call lib/event.c:1979
    #12 0x7fdb30045379 in frr_run lib/libfrr.c:1213
    #13 0x55e53c1ccab4 in main ospfd/ospf_main.c:249
    #14 0x7fdb2f65dc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7fdb30665d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7fdb300620da in qcalloc lib/memory.c:105
    #2 0x55e53c2da5fa in ospf_external_aggregator_new ospfd/ospf_asbr.c:396
    #3 0x55e53c2dedd3 in ospf_asbr_external_rt_no_advertise ospfd/ospf_asbr.c:1182
    #4 0x55e53c27cf10 in ospf_external_route_aggregation_no_adrvertise ospfd/ospf_vty.c:10626
    #5 0x7fdb2ffe5428 in cmd_execute_command_real lib/command.c:993
    #6 0x7fdb2ffe58ec in cmd_execute_command lib/command.c:1051
    #7 0x7fdb2ffe5d6b in cmd_execute lib/command.c:1218
    #8 0x7fdb3010ce2a in vty_command lib/vty.c:591
    #9 0x7fdb3010d2d5 in vty_execute lib/vty.c:1354
    #10 0x7fdb30115b9b in vtysh_read lib/vty.c:2362
    #11 0x7fdb30100b99 in event_call lib/event.c:1979
    #12 0x7fdb30045379 in frr_run lib/libfrr.c:1213
    #13 0x55e53c1ccab4 in main ospfd/ospf_main.c:249
    #14 0x7fdb2f65dc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 240 byte(s) leaked in 6 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-09-05 23:00:13 +04:00
Keelan10 35cf10a680 ospfd: fix area range memory leak
Addressed a memory leak in OSPF by fixing the improper deallocation of
area range nodes when removed from the table. Introducing a new function,
`ospf_range_table_node_destroy` for proper node cleanup, resolved the issue.

The ASan leak log for reference:

```
Direct leak of 56 byte(s) in 2 object(s) allocated from:
    #0 0x7faf661d1d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7faf65bce1e9 in qcalloc lib/memory.c:105
    #2 0x55a66e0b61cd in ospf_area_range_new ospfd/ospf_abr.c:43
    #3 0x55a66e0b61cd in ospf_area_range_set ospfd/ospf_abr.c:195
    #4 0x55a66e07f2eb in ospf_area_range ospfd/ospf_vty.c:631
    #5 0x7faf65b51548 in cmd_execute_command_real lib/command.c:993
    #6 0x7faf65b51f79 in cmd_execute_command_strict lib/command.c:1102
    #7 0x7faf65b51fd8 in command_config_read_one_line lib/command.c:1262
    #8 0x7faf65b522bf in config_from_file lib/command.c:1315
    #9 0x7faf65c832df in vty_read_file lib/vty.c:2605
    #10 0x7faf65c83409 in vty_read_config lib/vty.c:2851
    #11 0x7faf65bb0341 in frr_config_read_in lib/libfrr.c:977
    #12 0x7faf65c6cceb in event_call lib/event.c:1979
    #13 0x7faf65bb1488 in frr_run lib/libfrr.c:1213
    #14 0x55a66dfb28c4 in main ospfd/ospf_main.c:249
    #15 0x7faf651c9c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 56 byte(s) leaked in 2 allocation(s).
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-09-05 12:54:33 +04:00
Donald Sharp 530be6a4d0 ospfd: Prevent use after free( and crash of ospf ) when no router ospf
Consider this config:

router ospf
  redistribute kernel

Then you issue:

no router ospf

ospf will crash with a use after free.

The problem is that the event's associated with the
ospf pointer were shut off then the ospf_external_delete
was called which rescheduled the event.  Let's just move
event deletion to the end of the no router ospf.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-30 10:33:29 -04:00
Keelan10 64e0a47b2c ospfd: Delete q_space->vertex_list on No Backup Path
In scenarios where no backup paths are available, ensure proper
memory management by deleting `q_space->vertex_list`. This prevents
memory leaks.

The ASan leak log for reference:

```
Direct leak of 80 byte(s) in 2 object(s) allocated from:
    #0 0x7fcf8c70aa37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fcf8c2a8a45 in qcalloc ../lib/memory.c:105
    #2 0x7fcf8c27d0cc in list_new ../lib/linklist.c:49
    #3 0x55d6e8385e35 in ospf_spf_init ../ospfd/ospf_spf.c:540
    #4 0x55d6e838c30d in ospf_spf_calculate ../ospfd/ospf_spf.c:1736
    #5 0x55d6e83933cf in ospf_ti_lfa_generate_q_spaces ../ospfd/ospf_ti_lfa.c:673
    #6 0x55d6e8394214 in ospf_ti_lfa_generate_p_space ../ospfd/ospf_ti_lfa.c:812
    #7 0x55d6e8394c63 in ospf_ti_lfa_generate_p_spaces ../ospfd/ospf_ti_lfa.c:923
    #8 0x55d6e8396390 in ospf_ti_lfa_compute ../ospfd/ospf_ti_lfa.c:1101
    #9 0x55d6e838ca48 in ospf_spf_calculate_area ../ospfd/ospf_spf.c:1811
    #10 0x55d6e838cd73 in ospf_spf_calculate_areas ../ospfd/ospf_spf.c:1840
    #11 0x55d6e838cfb0 in ospf_spf_calculate_schedule_worker ../ospfd/ospf_spf.c:1871
    #12 0x7fcf8c3922e4 in event_call ../lib/event.c:1979
    #13 0x7fcf8c27c828 in frr_run ../lib/libfrr.c:1213
    #14 0x55d6e82eeb6d in main ../ospfd/ospf_main.c:249
    #15 0x7fcf8bd59d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-08-19 18:38:14 +04:00
Donald Sharp 77014daf3a
Merge pull request #14016 from mjstapp/event_exec_ptr
* : include event ptr in event_execute api
2023-08-15 11:52:49 -04:00
Donald Sharp 296645fc78 ospfd: Ensure listnode returns are usable
Coverity is complaining that listnode can return a NULL
value and thus FRR could derefence the returned value.
Since this is not crashing we know that this is not happening
in the wild.  Let's make this an assert or check that it is
legal to use the value.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-08-07 15:57:29 -04:00
Alexander Chernavin f050e57a2c ospfd: fix SPF calculation when changing ABR type
Currently, when changing ABR type on a working router, SPF recalculation
will only be initiated if the OSPF flags have changed after this.
Otherwise, SPF recalculation will be omitted and OSPF RIB update will
not occur. In other words, changing ABR type might not result in
inter-area routes addition/deletion.

With this fix, when ABR type is changed, the command handler initiates
SPF recalculation.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
2023-07-25 15:50:16 +00:00
Russ White 74630e42ef
Merge pull request #14056 from achernavin22/ospf-fix-def-metric-upd
ospfd: fix default-metric change if external LSAs already sent
2023-07-25 10:35:04 -04:00
Mark Stapp adca5c22c5 * : include event ptr in event_execute api
Include an event ptr-to-ptr in the event_execute() api
call, like the various schedule api calls. This allows the
execute() api to cancel an existing scheduled task if that
task is being executed inline.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-07-25 10:17:48 -04:00
Donatas Abraitis 3a58764e3a
Merge pull request #14034 from LabNConsulting/aceelindem/ospf_prefix_suppression
ospfd: Implement OSPF prefix-suppression as specified in RFC 6860
2023-07-21 10:14:22 +03:00
Acee e2eea4fe8e ospfd: Implement OSPF prefix-suppression as specified in RFC 6860
Signed-off-by: Acee <aceelindem@gmail.com>
2023-07-20 14:56:43 -04: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
Zhiyuan Wan 919b8f94b3 ospfd: Support show intra-area network type in 'show ip ospf route' command
User can now use 'show ip ospf route detail' command to distinguish
intra-area stub network and transit network.
Transit network will be displayed as 'N T prefix ...'.

NOTICE: Json output format has been changed, intra-area transit networks
will have a new attribute 'transit' and value is 'true'.
And 'adv' (means advertise router) change to 'advertisedRouter'.

Example output:

bsp-debianrt-exp1# show ip ospf route detail
Codes: N  - network     T - transitive
       IA - inter-area  E - external route
       D  - destination R - router

============ OSPF network routing table ============
N T  10.0.0.0/24           [32] area: 0.0.0.0
                           via 192.168.124.67, ens192
                           adv 10.0.0.5
N    10.0.30.0/24          [33] area: 0.0.0.0
                           via 192.168.124.67, ens192
                           adv 10.0.0.5
...

Signed-off-by: Zhiyuan Wan <h@iloli.bid>
2023-07-18 14:20:05 +08:00
Zhiyuan Wan 1960b6b967 ospfd: Fix wrong advertise router calculation in transit network
The ospfd mistakenly copy advertise router from vertex->id, which may
not be correct in an OSPF transit network.

Signed-off-by: Zhiyuan Wan <h@iloli.bid>
2023-07-18 14:20:05 +08:00
Zhiyuan Wan 0ce2d1aaa1 ospfd: Support show advertise router in 'show ip ospf route' command
Users can now use 'show ip ospf route [detail]' command to show the
originator of each OSPF route item.

Signed-off-by: Zhiyuan Wan <h@iloli.bid>
2023-07-18 14:20:05 +08:00
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
Russ White f46dc78367
Merge pull request #13880 from mjstapp/fix_ospf_intf_socket
ospfd: fix per-interface sockets
2023-07-11 10:23:37 -04:00
ryndia f0d1ea8fb6 ospf: fix lsa leak
In the function ospf_lsa_translated_nssa_new the newly created lsa is lock however, the return lsa from ospf_lsa_new already has a lock. Therefore removing the addition lock resolve the leak below.

ospf_basic_functionality.test_ospf_nssa#r3.asan.ospfd.5456

=================================================================
==5456==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 640 byte(s) in 5 object(s) allocated from:
    #0 0x7f294f354a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f294eeed562 in qcalloc ../lib/memory.c:105
    #2 0x561a16004f60 in ospf_lsa_new ../ospfd/ospf_lsa.c:186
    #3 0x561a160051a1 in ospf_lsa_new_and_data ../ospfd/ospf_lsa.c:205
    #4 0x561a1600f21d in ospf_exnl_lsa_prepare_and_flood ../ospfd/ospf_lsa.c:1762
    #5 0x561a1600fd71 in ospf_external_lsa_new ../ospfd/ospf_lsa.c:1863
    #6 0x561a160107d7 in ospf_lsa_translated_nssa_new ../ospfd/ospf_lsa.c:1985
    #7 0x561a16011cfb in ospf_translated_nssa_refresh ../ospfd/ospf_lsa.c:2152
    #8 0x561a16014bb2 in ospf_external_lsa_install ../ospfd/ospf_lsa.c:2871
    #9 0x561a1601596b in ospf_lsa_install ../ospfd/ospf_lsa.c:3076
    #10 0x561a16168b3c in ospf_flood ../ospfd/ospf_flood.c:482
    #11 0x561a160462f8 in ospf_ls_upd ../ospfd/ospf_packet.c:2115
    #12 0x561a1604c66c in ospf_read_helper ../ospfd/ospf_packet.c:3198
    #13 0x561a1604c88e in ospf_read ../ospfd/ospf_packet.c:3229
    #14 0x7f294efd6c33 in event_call ../lib/event.c:1995
    #15 0x7f294eec134a in frr_run ../lib/libfrr.c:1213
    #16 0x561a15fd3b6d in main ../ospfd/ospf_main.c:249
    #17 0x7f294e998d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Objects leaked above:
0x60c000062800 (128 bytes)
0x60c000062c80 (128 bytes)
0x60c0000631c0 (128 bytes)
0x60c000063700 (128 bytes)
0x60c000063d00 (128 bytes)

Direct leak of 640 byte(s) in 5 object(s) allocated from:
    #0 0x7f294f354a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f294eeed562 in qcalloc ../lib/memory.c:105
    #2 0x561a16004f60 in ospf_lsa_new ../ospfd/ospf_lsa.c:186
    #3 0x561a160051a1 in ospf_lsa_new_and_data ../ospfd/ospf_lsa.c:205
    #4 0x561a1600f21d in ospf_exnl_lsa_prepare_and_flood ../ospfd/ospf_lsa.c:1762
    #5 0x561a1600fd71 in ospf_external_lsa_new ../ospfd/ospf_lsa.c:1863
    #6 0x561a160107d7 in ospf_lsa_translated_nssa_new ../ospfd/ospf_lsa.c:1985
    #7 0x561a16010e10 in ospf_translated_nssa_originate ../ospfd/ospf_lsa.c:2034
    #8 0x561a16136559 in ospf_abr_translate_nssa ../ospfd/ospf_abr.c:668
    #9 0x561a161383da in ospf_abr_process_nssa_translates ../ospfd/ospf_abr.c:968
    #10 0x561a1613f9b8 in ospf_abr_nssa_task ../ospfd/ospf_abr.c:2054
    #11 0x561a161402e5 in ospf_abr_task_timer ../ospfd/ospf_abr.c:2168
    #12 0x7f294efd6c33 in event_call ../lib/event.c:1995
    #13 0x7f294eec134a in frr_run ../lib/libfrr.c:1213
    #14 0x561a15fd3b6d in main ../ospfd/ospf_main.c:249
    #15 0x7f294e998d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Objects leaked above:
0x60c00003e380 (128 bytes)
0x60c00003e740 (128 bytes)
0x60c00003eb00 (128 bytes)
0x60c00005fd40 (128 bytes)
0x60c00005ff80 (128 bytes)

Indirect leak of 180 byte(s) in 5 object(s) allocated from:
    #0 0x7f294f354a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f294eeed562 in qcalloc ../lib/memory.c:105
    #2 0x561a16005a43 in ospf_lsa_data_new ../ospfd/ospf_lsa.c:296
    #3 0x561a160051b1 in ospf_lsa_new_and_data ../ospfd/ospf_lsa.c:206
    #4 0x561a1600f21d in ospf_exnl_lsa_prepare_and_flood ../ospfd/ospf_lsa.c:1762
    #5 0x561a1600fd71 in ospf_external_lsa_new ../ospfd/ospf_lsa.c:1863
    #6 0x561a160107d7 in ospf_lsa_translated_nssa_new ../ospfd/ospf_lsa.c:1985
    #7 0x561a16011cfb in ospf_translated_nssa_refresh ../ospfd/ospf_lsa.c:2152
    #8 0x561a16014bb2 in ospf_external_lsa_install ../ospfd/ospf_lsa.c:2871
    #9 0x561a1601596b in ospf_lsa_install ../ospfd/ospf_lsa.c:3076
    #10 0x561a16168b3c in ospf_flood ../ospfd/ospf_flood.c:482
    #11 0x561a160462f8 in ospf_ls_upd ../ospfd/ospf_packet.c:2115
    #12 0x561a1604c66c in ospf_read_helper ../ospfd/ospf_packet.c:3198
   #13 0x561a1604c88e in ospf_read ../ospfd/ospf_packet.c:3229
    #14 0x7f294efd6c33 in event_call ../lib/event.c:1995
    #15 0x7f294eec134a in frr_run ../lib/libfrr.c:1213
    #16 0x561a15fd3b6d in main ../ospfd/ospf_main.c:249
    #17 0x7f294e998d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Objects leaked above:
0x60400003f890 (36 bytes)
0x60400003f990 (36 bytes)
0x60400003fa50 (36 bytes)
0x60400003fb10 (36 bytes)
0x60400003fbd0 (36 bytes)

Indirect leak of 180 byte(s) in 5 object(s) allocated from:
    #0 0x7f294f354a37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f294eeed562 in qcalloc ../lib/memory.c:105
    #2 0x561a16005a43 in ospf_lsa_data_new ../ospfd/ospf_lsa.c:296
    #3 0x561a160051b1 in ospf_lsa_new_and_data ../ospfd/ospf_lsa.c:206
    #4 0x561a1600f21d in ospf_exnl_lsa_prepare_and_flood ../ospfd/ospf_lsa.c:1762
    #5 0x561a1600fd71 in ospf_external_lsa_new ../ospfd/ospf_lsa.c:1863
    #6 0x561a160107d7 in ospf_lsa_translated_nssa_new ../ospfd/ospf_lsa.c:1985
    #7 0x561a16010e10 in ospf_translated_nssa_originate ../ospfd/ospf_lsa.c:2034
    #8 0x561a16136559 in ospf_abr_translate_nssa ../ospfd/ospf_abr.c:668
    #9 0x561a161383da in ospf_abr_process_nssa_translates ../ospfd/ospf_abr.c:968
    #10 0x561a1613f9b8 in ospf_abr_nssa_task ../ospfd/ospf_abr.c:2054
    #11 0x561a161402e5 in ospf_abr_task_timer ../ospfd/ospf_abr.c:2168
    #12 0x7f294efd6c33 in event_call ../lib/event.c:1995
    #13 0x7f294eec134a in frr_run ../lib/libfrr.c:1213
    #14 0x561a15fd3b6d in main ../ospfd/ospf_main.c:249
    #15 0x7f294e998d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Objects leaked above:
0x60400003c6d0 (36 bytes)
0x60400003c790 (36 bytes)
0x60400003c810 (36 bytes)
0x60400003c890 (36 bytes)
0x60400003c910 (36 bytes)

SUMMARY: AddressSanitizer: 1640 byte(s) leaked in 20 allocation(s).
Signed-off-by: ryndia <dindyalsarvesh@gmail.com>
2023-07-07 11:47:30 +04:00
Donatas Abraitis 9a0bb7bcd1
Merge pull request #13333 from donaldsharp/vrf_bitmap_cleanup
*: Rearrange vrf_bitmap_X api to reduce memory footprint
2023-07-04 22:11:11 +03:00
Donald Sharp 59402d840e ospfd: Ensure show ip ospf interface json code is guarded
When not using json, do not allocate json memory.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-03 12:56:38 -04:00
Mark Stapp 60b77869e5 ospfd: fix per-interface sockets
Some fixes for the per-interface write sockets: better align
opening and closing them with ospf config actions; set
read buffer to zero since these sockets are used only for
writing packets.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-07-03 09:37:25 -04:00
Donald Sharp 913f02f167
Merge pull request #13895 from mjstapp/fix_ospf_sync_json_null
ospfd: check for NULLs in ldp-igp sync json code
2023-07-02 15:40:14 -04:00
Donald Sharp 1f322e4cef
Merge pull request #13847 from opensourcerouting/fix/free_zclient_sync_on_destroy
Stop and free synchronous Zebra client on destroy
2023-07-01 14:35:42 -04:00
Mark Stapp 864a3bc185 ospfd: check for NULLs in vty code
There were a couple of cli paths that NULL-checked in the
vtysh output path, but not in the json path.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-06-30 13:58:16 -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
Mark Stapp 220dc6df98 isisd, ospfd: fix opaque zapi source parsing
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-27 16:32:54 -04:00
Donald Sharp 161972c9fe *: Rearrange vrf_bitmap_X api to reduce memory footprint
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-26 14:59:21 -04:00
Donatas Abraitis a9c81cc289 ospfd: Stop and free synchronous Zebra client on OSPF termination
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-06-26 16:31:47 +03: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 609491fe0d
Merge pull request #13612 from chiragshah6/fdev1
ospfd: fix interface param type update
2023-06-13 09:55:07 -04:00
Jafar Al-Gharaibeh f34076da81
Merge pull request #13596 from Pdoijode/pdoijode/ospf-intf-json-changes
ospfd: json hierarchy change for "show ip ospf interface json"
2023-06-08 14:03:14 -05:00
Donatas Abraitis 1c7d8fa8c3
Merge pull request #13390 from ryndia/master
ospfd: ospf_route.c memory leak fix
2023-06-08 10:02:28 +03:00
Chirag Shah 0d005b2d5c ospfd: fix interface param type update
interface link update event needs
to be handle properly in ospf interface
cache.

Example:
When vrf (interface) is created its default type
would be set to BROADCAST because ifp->status
is not set to VRF.
Subsequent link event sets ifp->status to vrf,
ospf interface update need to compare current type
to new default type which would be VRF (OSPF_IFTYPE_LOOPBACK).
Since ospf type param was created in first add event,
ifp vrf link event didn't update ospf type param which
leads to treat vrf as non loopback interface.

Ticket:#3459451
Testing Done:

Running config suppose to bypass rendering default
network broadcast for loopback/vrf types.

Before fix:

vrf vrf1
 vni 4001
exit-vrf
!
interface vrf1
 ip ospf network broadcast
exit

After fix: (interface vrf1 is not displayed).

vrf vrf1
 vni 4001
exit-vrf

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-06-01 10:39:21 -07:00
Renato Westphal 2882096fad ospfd, ospf6d: fix time_t truncation
Change timestamp parameter from int to time_t to avoid truncation.

Found by Coverity Scan (CID 1563226 and 1563222)

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-05-30 19:47:28 -03:00
ryndia ce0d06d921 ospfd: ospf_route.c memory leak fix
The rn variable has its info attribute being replaced with a new ospf route before being freed properly.

Signed-off-by: ryndia <dindyalsarvesh@gmail.com>
2023-05-30 20:44:30 +04:00
Pooja Jagadeesh Doijode be469ddc88 ospfd: re-added old json hierarchy for ospf intf json
Re-added the old JSON hierarchy for "show ip ospf interface json"
command in addition to new, so that the scripts don't break.
Old hierarchy will be deprecated after a year.

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-05-26 17:18:04 -07:00
Pooja Jagadeesh Doijode dac17990c4 ospfd: fix json object name for newly added fields
Fixed the JSON object name for "grHelloDelaySecs" and "p2mpDelayReflood"
JSON fields.

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-05-24 16:28:54 -07:00
Pooja Jagadeesh Doijode d540f9edfc ospfd: fix the json object name
Fixed the JSON object name for "drId" and "drAddress"
JSON fields

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-05-24 15:29:38 -07:00
Trey Aspelund 72eab6953d ospfd: add oi to show ip ospf interface json
Currently "show ip ospf interface json" will walk all oi's bound to a
given interface, but every oi overwrites the same json keys.
This adds a new hierarchy to the json output which will allow each oi to
have its info displayed separately (instead of stomping on each other).

Before:
```
tor-11# show ip ospf interface swp2 json
{
  "interfaces":{
    "swp2":{
      "ifUp":true,
      "ifIndex":4,
      "mtuBytes":9216,
      "bandwidthMbit":10000,
      "ifFlags":"<UP,BROADCAST,RUNNING,MULTICAST>",
      "ospfEnabled":true,
      "ipAddress":"100.64.3.15",
      "ipAddressPrefixlen":24,
      "ospfIfType":"Broadcast",
      "localIfUsed":"100.64.3.255",
      "area":"0.0.0.1",
      "routerId":"6.0.0.15",
      "networkType":"NBMA",
      "cost":10,
      "transmitDelaySecs":1,
      "state":"Backup",
      "priority":100,
      "bdrId":"6.0.0.15",
      "bdrAddress":"100.64.3.15",
      "mcastMemberOspfAllRouters":true,
      "timerMsecs":10000,
      "timerDeadSecs":40,
      "timerWaitSecs":40,
      "timerRetransmitSecs":5,
      "timerHelloInMsecs":2502,
      "nbrCount":1,
      "nbrAdjacentCount":1
    }
  }
}
```

After:
```
leaf-12# show ip ospf interface swp3 json
{
  "interfaces":{
    "swp3":{
      "ifUp":true,
      "ifIndex":5,
      "mtuBytes":9216,
      "bandwidthMbit":10000,
      "ifFlags":"<UP,BROADCAST,RUNNING,MULTICAST>",
      "ospfEnabled":true,
      "interfaceIp":{
        "100.64.2.6":{
          "ipAddress":"100.64.2.6",
          "ipAddressPrefixlen":24,
          "ospfIfType":"Broadcast",
          "localIfUsed":"100.64.2.255",
          "area":"0.0.0.0",
          "routerId":"6.0.0.6",
          "networkType":"NBMA",
          "cost":10,
          "transmitDelaySecs":1,
          "state":"DR",
          "priority":2,
          "bdrId":"6.0.0.15",
          "bdrAddress":"100.64.2.15",
          "networkLsaSequence":2147483652,
          "mcastMemberOspfAllRouters":true,
          "timerMsecs":10000,
          "timerDeadSecs":40,
          "timerWaitSecs":40,
          "timerRetransmitSecs":5,
          "timerHelloInMsecs":1559,
          "nbrCount":1,
          "nbrAdjacentCount":1
        },
        "100.64.3.6":{
          "ipAddress":"100.64.3.6",
          "ipAddressPrefixlen":24,
          "ospfIfType":"Broadcast",
          "localIfUsed":"100.64.3.255",
          "area":"0.0.0.1",
          "routerId":"6.0.0.6",
          "networkType":"NBMA",
          "cost":10,
          "transmitDelaySecs":1,
          "state":"DR",
          "priority":222,
          "bdrId":"6.0.0.15",
          "bdrAddress":"100.64.3.15",
          "networkLsaSequence":2147483651,
          "mcastMemberOspfAllRouters":true,
          "timerMsecs":10000,
          "timerDeadSecs":40,
          "timerWaitSecs":40,
          "timerRetransmitSecs":5,
          "timerHelloInMsecs":1559,
          "nbrCount":1,
          "nbrAdjacentCount":1
        }
      }
    }
  }
}
```

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2023-05-24 15:29:32 -07:00
Acee 0d8ef0477c ospfd: OSPF P2MP Delayed Reflooding configuration
Currently, delayed reflooding on P2MP interfaces for LSAs received
from neighbors on the interface is unconditionally (see commit
c706f0e32b). In some cases, this
change wasn't desirable and this feature makes delayed reflooding
configurable for P2MP interfaces via the CLI command:
"ip ospf network point-to-multipoint delay-reflood" in interface
submode.

Signed-off-by: Acee <aceelindem@gmail.com>
2023-05-22 15:51:41 -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
Keelan10 10ca618db9 ospf_ti_lfa: Free p_space memory allocation
Free p_space

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-05-12 15:05:46 +04:00
Jafar Al-Gharaibeh bc05bccbdc
Merge pull request #13489 from LabNConsulting/ospf-opaque-stale-fix
ospfd: OSPF opaque LSA stale processing fix and topotests.
2023-05-10 15:51:21 -05:00
Jafar Al-Gharaibeh 45625b6fa8
Merge pull request #13485 from donaldsharp/ospf_loopback_cost
ospfd: Respect loopback's cost that is set and set loopback costs to 0
2023-05-10 11:13:15 -05:00
Donald Sharp dd2bc4fb40 ospfd: Respect loopback's cost that is set and set loopback costs to 0
When setting an loopback's cost, set the value to 0, unless the operator
has assigned a value for the loopback's cost.

RFC states:

If the state of the interface is Loopback, add a Type 3
link (stub network) as long as this is not an interface
to an unnumbered point-to-point network. The Link ID
should be set to the IP interface address, the Link Data
set to the mask 0xffffffff (indicating a host route),
and the cost set to 0.

FRR is going to allow this to be overridden if the operator specifically
sets a value too.

Fixes: #13472
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-10 08:35:45 -04:00
Jeevesh Rishi Dindyal (Sarvesh) c824d9792e ospfd: opsf_abr.c memory leak fix, free range
The new create range attribute is send to add to ranges, but not use if the prefix already exist in the ranges.

Signed-off-by: ryndia <dindyalsarvesh@gmail.com>
2023-05-10 10:59:20 +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 0c05ceae00 ospfd, ospf6d: introduce the "graceful-restart hello-delay" command
This command makes unplanned GR more reliable by manipulating the
sending of Grace-LSAs and Hello packets for a certain amount of time,
increasing the chance that the neighboring routers are aware of
the ongoing graceful restart before resuming normal OSPF operation.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-05-08 21:47:44 -03:00
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
Donald Sharp 74e21732db ospfd: Fix memory leaks w/ show ip ospf int X json commands
FRR has a memory leak in the case when int X does not
exist and a memory leak when int X does exist.  Fix
these

Fixes: #13434
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-04 12:56:13 -04:00
Philippe Guibert 7b343a9ed5
Merge pull request #12933 from Orange-OpenSource/link_state
lib: Update edge key in link state database
2023-04-20 18:33:21 +02:00
Donatas Abraitis 5db1931962
Merge pull request #13166 from Jafaral/ospf-external-metric
ospfd: use rib metric as the base for set metric +/-
2023-04-19 21:11:25 +03:00
Russ White 59b2a1048f
Merge pull request #13236 from Orange-OpenSource/ospf-te
ospfd: Force Opaque LSA & co to default VRF
2023-04-18 08:32:20 -04:00
Olivier Dugeon 30ce6361b9 ospfd: Force Opaque LSA & co to default VRF
Ospf segfault when Router Information is enabled in a non default VRF,
see issue #13144.

This patch forces vrf_id to default VRF for Opaque LSA and extension based
on Opaque LSA: Router Information, Traffic Engineering, Extended Prefix,
Extended Link and Segment Routing. Indeed, non default VRF is not yet
supported for Opaque LSA & co.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-18 10:30:50 +02:00
Jafar Al-Gharaibeh f61cd36ada ospfd: handle type-7 routes
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2023-04-18 00:48:16 -05:00
Jafar Al-Gharaibeh 055355e104 lib, ospfd, yang: add route map set for min/max metric
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2023-04-18 00:48:16 -05: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
Donatas Abraitis eee1fca3eb
Merge pull request #13141 from mjstapp/fix_ospf_json_keys
ospfd: remove deprecated json attrs for neighbor show
2023-04-16 21:33:20 +03:00
Donald Sharp 13a1758a6a
Merge pull request #13177 from mjstapp/fix_ospf_supoort_typo
ospf,ospf6: fix json key typo supoort
2023-04-12 14:26:22 -04:00
Donald Sharp 6a5d103257
Merge pull request #13269 from Keelan10/ospf_lsa-memory-leak
ospfd: Fix ospf_lsa memory leak
2023-04-12 11:39:26 -04:00
Keelan10 c0ccfbfd45 ospfd: Fix ospf_lsa memory leak
Free translated LSA when LSA installation fails

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-04-12 13:52:08 +04: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
Russ White e80c797a1f
Merge pull request #13227 from mjstapp/ospf_sock_bufsizes
ospfd: support configuration of socket buffer sizes
2023-04-11 08:55:47 -04:00
Mark Stapp a63fecfb56 ospf,ospf6: fix json key typo supoort
Fix json key 'supoort' -> 'support'; add 1-year deprecation
notice; fix topotests to use corrected json key.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-04-07 16:19:01 -04:00
Mark Stapp f5419bf927 ospfd: remove deprecated json attrs for neighbor show
The date for removing some deprecated json attributes from
'show neighbor' has arrived, so remove the attrs (and the
CPP_NOTICE block).

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-04-07 16:17:59 -04:00
Olivier Dugeon dad17a2195 ospfd: Update TE to new Link State Edge key
Following the modification of the edge key in link state database
this patch updates the ospf_te.c file to replace the old uint64_t edge key by
the new ls_edge_key structure. For ospf, only IPv4 address is take into
account.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-07 16:40:25 +02:00
Donald Sharp b589466918 *: Use a struct prefix *p instead of a struct prefix in functions
When passing a prefix into a function let's pass by address instead
of pass by value.  Let's save our stack space.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-06 18:00:09 -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
Russ White 4d0f3e819d
Merge pull request #13160 from chiragshah6/fdev2
ospfd:display correct DR-BDR router-id in nbr cmd
2023-04-04 10:02:48 -04:00
Russ White 4af5e39b2c
Merge pull request #12969 from opensourcerouting/ospfd-nssa
ospfd: implement NSSA default routes & ranges
2023-04-04 09:38:55 -04:00
Russ White c0656e9040
Merge pull request #12837 from donaldsharp/unlikely_routemap
Unlikely routemap
2023-04-04 08:20:25 -04:00
Sindhu Parvathi Gopinathan d3aef77fa9 ospfd:display correct DR-BDR router-id in nbr cmd
ospf neighbor DR and BDR router-id wrongly displays with interface
ip-address instead of router-id.

It is fixed to display the correct DR & BDR router-id  for
JSON and CLI commands.

Commands:
```
show ip ospf vrf <vrf-name> neighbor detail json
show ip ospf vrf <vrf-name> neighbor detail
```

Before Fix:-
```
r1# show ip ospf vrf default neighbor  swp1 detail
 Neighbor 0.0.0.17, interface address 11.0.0.1
    In the area 0.0.0.0 via interface swp1 local interface IP 11.0.0.2
    Neighbor priority is 1, State is Full, Role is DR, 6 state changes
    Most recent state change statistics:
      Progressive change 1d15h05m ago
    DR is 11.0.0.1, BDR is 11.0.0.2 ======> DR and BDR shows the intef &
local intf ipaddress
    Options 2 *|-|-|-|-|-|E|-
    Dead timer due in 35.178s
    Database Summary List 0
    Link State Request List 0
    Link State Retransmission List 0
    Thread Inactivity Timer on
    Thread Database Description Retransmision off
    Thread Link State Request Retransmission on
    Thread Link State Update Retransmission on

r1#

r1# show ip ospf vrf default neighbor  swp1 detail json
{
  "0.0.0.17":[
    {
      "ifaceAddress":"11.0.0.1",
      "areaId":"0.0.0.0",
      "ifaceName":"swp1",
      "localIfaceAddress":"11.0.0.2",
      "nbrPriority":1,
      "nbrState":"Full",
      "role":"DR",
      "stateChangeCounter":6,
      "lastPrgrsvChangeMsec":141141533,
      "routerDesignatedId":"11.0.0.1", =============> interface ip
instead of DR rotuer-id
      "routerDesignatedBackupId":"11.0.0.2", =======> lo-interface ip
instead of BDR rotuer-id
      "optionsCounter":2,
      "optionsList":"*|-|-|-|-|-|E|-",
      "routerDeadIntervalTimerDueMsec":32272,
      "databaseSummaryListCounter":0,
      "linkStateRequestListCounter":0,
      "linkStateRetransmissionListCounter":0,
      "threadInactivityTimer":"on",
      "threadLinkStateRequestRetransmission":"on",
      "threadLinkStateUpdateRetransmission":"on"
    }
  ]
}
r1#
```

After Fix:-
```
r1# show ip ospf vrf default neighbor detail json
{
  "default":{
    "vrfName":"default",
    "vrfId":0,
    "neighbors":{
      "0.0.0.17":[
        {
          "ifaceAddress":"11.0.0.1",
          "areaId":"0.0.0.0",
          "ifaceName":"swp1",
          "localIfaceAddress":"11.0.0.2",
          "nbrPriority":1,
          "nbrState":"Full",
          "role":"DR",
          "stateChangeCounter":6,
          "lastPrgrsvChangeMsec":4531505,
          "routerDesignatedId":"0.0.0.17", =====> DR Router-Id
          "routerDesignatedBackupId":"0.0.0.12", =====> BDR Router-Id
          "optionsCounter":2,
          "optionsList":"*|-|-|-|-|-|E|-",
          "routerDeadIntervalTimerDueMsec":38495,
          "databaseSummaryListCounter":0,
          "linkStateRequestListCounter":0,
          "linkStateRetransmissionListCounter":0,
          "threadInactivityTimer":"on",
          "threadLinkStateRequestRetransmission":"on",
          "threadLinkStateUpdateRetransmission":"on"
        }
      ],
      "0.0.0.13":[
        {
          "ifaceAddress":"11.0.2.2",
          "areaId":"0.0.0.0",
          "ifaceName":"swp2",
          "localIfaceAddress":"11.0.2.1",
          "nbrPriority":1,
          "nbrState":"Full",
          "role":"DR",
          "stateChangeCounter":6,
          "lastPrgrsvChangeMsec":4522182,
          "routerDesignatedId":"0.0.0.13", =====> DR Router-Id
          "routerDesignatedBackupId":"0.0.0.12", =====> BDR Router-Id
          "optionsCounter":2,
          "optionsList":"*|-|-|-|-|-|E|-",
          "routerDeadIntervalTimerDueMsec":37840,
          "databaseSummaryListCounter":0,
          "linkStateRequestListCounter":0,
          "linkStateRetransmissionListCounter":0,
          "threadInactivityTimer":"on",
          "threadLinkStateRequestRetransmission":"on",
          "threadLinkStateUpdateRetransmission":"on"
        }
      ],
      "0.0.0.14":[
        {
          "ifaceAddress":"11.0.3.2",
          "areaId":"0.0.0.0",
          "ifaceName":"swp3",
          "localIfaceAddress":"11.0.3.1",
          "nbrPriority":1,
          "nbrState":"Full",
          "role":"DR",
          "stateChangeCounter":6,
          "lastPrgrsvChangeMsec":4522182,
          "routerDesignatedId":"0.0.0.14",  =====> DR Router-Id
          "routerDesignatedBackupId":"0.0.0.12", =====> BDR Router-Id
          "optionsCounter":2,
          "optionsList":"*|-|-|-|-|-|E|-",
          "routerDeadIntervalTimerDueMsec":37840,
          "databaseSummaryListCounter":0,
          "linkStateRequestListCounter":0,
          "linkStateRetransmissionListCounter":0,
          "threadInactivityTimer":"on",
          "threadLinkStateRequestRetransmission":"on",
          "threadLinkStateUpdateRetransmission":"on"
        }
      ]
    }
  }
}
r1#

r1# show ip ospf vrf default neighbor swp1 detail
 Neighbor 0.0.0.17, interface address 11.0.0.1
    In the area 0.0.0.0 via interface swp1 local interface IP 11.0.0.2
    Neighbor priority is 1, State is Full, Role is DR, 6 state changes
    Most recent state change statistics:
      Progressive change 1h18m11s ago
    DR is  0.0.0.17, BDR is 0.0.0.12  =======> correct DR and BDR
router-id
    Options 2 *|-|-|-|-|-|E|-
    Dead timer due in 38.339s
    Database Summary List 0
    Link State Request List 0
    Link State Retransmission List 0
    Thread Inactivity Timer on
    Thread Database Description Retransmision off
    Thread Link State Request Retransmission on
    Thread Link State Update Retransmission on

r1#

r1# show ip ospf vrf default neighbor swp
swp1  swp2  swp3  swp4
r1# show ip ospf vrf default neighbor swp2 detail
 Neighbor 0.0.0.13, interface address 11.0.2.2
    In the area 0.0.0.0 via interface swp2 local interface IP 11.0.2.1
    Neighbor priority is 1, State is Full, Role is DR, 6 state changes
    Most recent state change statistics:
      Progressive change 12m02s ago
    DR is 0.0.0.13, BDR is 0.0.0.12 =======> correct DR and BDR
router-id
    Options 2 *|-|-|-|-|-|E|-
    Dead timer due in 37.136s
    Database Summary List 0
    Link State Request List 0
    Link State Retransmission List 0
    Thread Inactivity Timer on
    Thread Database Description Retransmision off
    Thread Link State Request Retransmission on
    Thread Link State Update Retransmission on

r1#
```

Ticket:#3395270

Issue:3395270

Testing: UT done

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
2023-04-02 18:42:57 -07: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 271588ace0 ospfd: do not install blackhole routes for ranges with "not-advertise"
Adding blackhole routes is unnecessary in that case.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-31 19:28:15 -03:00
Renato Westphal 4312d66f9f ospfd: refactor range commands
* Update the "range" helpers to accept an area pointer instead of
  an area ID;
* Always call ospf_area_display_format_set() after every "range"
  command to ensure consistency.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-31 19:28:15 -03:00
Renato Westphal c2b55093a1 ospfd: use the ospf_area_range_active() helper function more consistently
A small change to improve code readability.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-31 19:28:15 -03:00
Renato Westphal 0bdd28850e ospfd: remove duplicated code
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
Pooja Jagadeesh Doijode 19f451913e ospfd: Fix for vitual-link crash in signal handler
Whenever OSPF virtual-link is created, a virtual interface is
associated with it. Name of the virtual interface is derived by
combining "VLINK" string with the value of vlink_count, which is a global
variable.

Problem:
Consider a scenario where 2 virtual links A and B are created in OSPF with
virtual interfaces VLINK0 and VLINK1 respectively. When virtual-link A is unconfigured
and reconfigured, new interface name derived for it will be VLINK1, which is already
associated with virtual-link B. Due to this, both virtual-links A and B will
point to the same interface, VLINK1.

During FRR restart when signal handler is called, OSPF goes through all the virtual
links and deletes the interface(oi) associated with it. During the deletion of interface
for virtual-link B,it accesses the interface which was deleted already(which was deleted
during deletion of virual-link A) and whose fields were set to NULL. This
leads to OSPF crash.

Fixed it by not decrementing vlink_count during unconfig/deletion for virtual-link.

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-03-27 14:20:10 -07:00
Jafar Al-Gharaibeh 06f54ff416
Merge pull request #12953 from donaldsharp/struct_event
Struct event
2023-03-24 13:48:53 -05:00
Donald Sharp d54d0ead76
Merge pull request #13093 from manojvn/ospf_mem_leaks
ospfd: Fix for memory leak issue in ospf related to flood_reduction tests.
2023-03-24 10:23:18 -04:00
Donald Sharp 02e701e49e *: Fixup formatting issues due to reordering
All the event changes exposed a bunch of places where
we were not properly following our standards.  Just
clean them up in one big fell swoop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:37:21 -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 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 70c35c11f2 *: Convert thread_should_yield and thread_set_yield_time
Convert thread_should_yield and thread_set_yield_time
to event_should_yield and event_set_yield_time

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 4f830a0799 *: Convert thread_timer_remain_XXX to event_timer_remain_XXX
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 8c1186d38e *: Convert thread_execute to event_execute
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 332beb64b8 *: Convert thread_cancelXXX to event_cancelXXX
Modify the code base so that thread_cancel becomes event_cancel

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
Donald Sharp 173786f6b5
Merge pull request #13065 from rgirada/ospf_abr_summary 2023-03-23 19:57:08 -04:00
Manoj Naragund 1746f71bc8 ospfd: Fix for memory leak issue in ospf related to flood_reduction tests.
Problem:
Multiple memory leaks after pr12366

RCA:
ospf_lsa_unlock was not happening for the few of the LSAs in
ospf_lsa_refresh_walker after pr12366 due to which memory
related to lsas was leaking.

Fix:
Moved the ospf_lsa_unlock outside if check.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-03-23 05:59:38 -07:00
Donald Sharp cc09ba4584 bgpd, ospfd, zebra: Use unlikely for DEBUG_ROUTEMAP_DETAIL
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-23 07:54:56 -04:00
Donald Sharp d8bc11a592 *: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it.  This function also takes a double
pointer to the hash to set it NULL.  Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-21 08:54:21 -04:00
Donald Sharp 7c8478ed28
Merge pull request #13031 from opensourcerouting/ospf-show-database
ospfd: Improve the "show ip ospf database" command
2023-03-21 07:03:05 -04:00
rgirada c8c1a240ab ospfd: Fixing Summary origination after range configuration
Description:
	After area range config, summary lsas are aggerated to configured
	route but later it was being flushed instead of the actual summary
	lsa. This was seen when prefix-id of the aggregated route is same
	as one of the actual summary route.
	Here, aggregated summary lsa need to be returned to set the flag
	SUMMARY_APPROVE after originating aggregated summary lsa but its not.
	Which is being cleaned up as part of unapproved summary cleanup.
	Corrected this now.

Issue: #13028

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2023-03-21 04:16:37 +00:00
Jafar Al-Gharaibeh 07b427d164
Merge pull request #13025 from donaldsharp/ospf_ti_lfa_leaks
Ospf ti lfa leaks
2023-03-18 23:44:37 -05:00
Donald Sharp 7773d0071a ospfd: Cleanup some memory leaks on shutdown in ospf_apiserver.c
Clean up some memory leaks found in ospf_apiserver.c  Also
a crash in the original implementation.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-18 15:35:34 -04:00
Renato Westphal f54232d0b2 ospfd: Fix inconsistency in LSDB JSON output
As it can be seen below, the LSDB JSON output varies depending
whether a filter option is specified or not (e.g. "adv-router",
"self-originate"):

> show ip ospf database router json
{
  "routerId":"3.3.3.3",
  "routerLinkStates":{
    "areas":{
      "0.0.0.0":[
        {
          "lsaAge":175,
          "options":"*|-|-|-|-|-|E|-",
          [snip]

> show ip ospf database router adv-router 2.2.2.2 json
{
  "routerId":"3.3.3.3",
  "Router Link States":{
    "0.0.0.0":{
      "2.2.2.2":{
        "lsaAge":193,
        "options":"*|-|-|-|-|-|E|-",
        [snip]

This inconsistency is undesirable since it makes this data harder to
consume programmatically. Also, in the second output, "Router Link
States" is used as a JSON key, which doesn't conform to our JSON
guidelines (JSON keys need to be camelCased).

Make the required changes to ensure the first output structure is used,
regardless if any output filter is used or not.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-17 23:00:31 -03:00
Renato Westphal a08f41b95b ospfd: Add "detail" option to "show ip ospf database"
This option is useful to dump detailed information about the LSDB using
a single command (instead of one command per LSA type).

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-17 23:00:31 -03:00
Renato Westphal b131b1ed9c ospfd: Refactor the "show ip ospf database" command
Combine all variations of this command into a single DEFPY to
improve maintainability. No behavioral changes intended.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-17 23:00:17 -03:00
Renato Westphal 7644097f61
Merge pull request #13019 from rgirada/ospf_type3_fix
ospfd: Ospf ABR doesnt Advertise LSA summary
2023-03-17 13:04:43 -03:00
Donald Sharp 52ff0e3ed4 ospfd: Free up q_space in early return path
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-17 10:58:08 -04:00
Donald Sharp eb7e14011f ospfd: Fix ospf_ti_lfa drop of an entire table
The new_rtrs variable was just generated and then dropped.  Let's
fix that entirely

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-17 10:37:40 -04:00
rgirada e6f3d0811d ospfd: Ospf ABR doesnt Advertise LSA summary
Description:
	OSPF ABR will summarise the networks based on configured range
	and re-advtertise the summarised route. But if configured range
	prefix id is same as one of the subset of routes prefix id then
	as per rcf2328 Appendex-E recommendation, it will prepare the LSID and originate.
	While re-advertising, it is using ospf LSDB instead of area specific
	LSDB which is making it fail to re-advertise the summary lsa.
	Fixed this by passing correct LSDB pointer.

Issue: #12995

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2023-03-17 10:11:28 +00:00
Martin Winter 386d232a1a ospfd: Log Adjacency Changes with Neighbor IP in addition to Neighbor ID
Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-17 10:17:52 +02: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
Russ White 6f5f572b9c
Merge pull request #12936 from opensourcerouting/ospf6d-out-filter-list
ospfd: correctly update outbound filter-list once prefix-list is updated
2023-03-14 11:33:44 -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