Commit graph

2353 commits

Author SHA1 Message Date
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
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
Donatas Abraitis ba995a720b
Merge pull request #12751 from Pdoijode/pdoijode/ospf-vrf-neighbor-detail-1
ospfd: Added missing fields and option to query specific neighbor in VRF
2023-02-24 11:56:28 +02:00
Donald Sharp b2a4c02cc9 ospfd: Remove unused function
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-23 16:47:47 -05: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
Christian Hopps 156a904cae ospfd: compare prefix values in host order
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-02-20 11:58:30 -05:00
Christian Hopps 1eea62bb1c ospfd: small bugfix for miscounting A[S]BRs
- improve the debug for the second add router call.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-02-20 11:58:30 -05:00
Christian Hopps 1794afe010 ospfd: inc. opaque data in show opaque info detail json output
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-02-20 11:58:30 -05:00
Donald Sharp 8383d53e43
Merge pull request #12780 from opensourcerouting/spdx-license-id
*: convert to SPDX License identifiers
2023-02-17 09:43:05 -05:00
Russ White bb7f02328f
Merge pull request #12796 from donaldsharp/routemap_debugging
Routemap debugging
2023-02-14 09:35:06 -05:00
Stephen Worley 4645cb6bc2 lib,zebra,bgpd,staticd: use label code to store VNI info
Use the already existing mpls label code to store VNI
info for vxlan. VNI's are defined as labels just like mpls,
we should be using the same code for both.

This patch is the first part of that. Next we will need to
abstract the label code to not be so mpls specific. Currently
in this, we are just treating VXLAN as a label type and storing
it that way.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
Donald Sharp 1df4bd1854 ospfd: Warn operator about prefix lists not existing in routemaps
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-13 09:40:47 -05:00
Donald Sharp 46b2a036a5 ospfd: Add access-list lookup failures to routemap code
When using access-list and the access-list is not specified
let's give the operator some clue about what is going on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-13 09:40:47 -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
Pooja Jagadeesh Doijode 2e86198322 ospfd: Fix "show ip ospf neighbor swp1 detail json" output
1. When OSPF unnumbered neighbor doesn't exist in any VRF,
   OSPFD prints a bunch of empty JSON objects. Fixed it
   by adding an outer JSON object with VRF information in it
2. Added "vrf" option to this command so that per VRF
   unnumbered OSPF neighbor information can be retrieved

JSON output:
    nl1# show ip ospf neighbor swp1 detail json
        {
          "default":{
          },
          "vrf1012":{
          },
          "vrf1013":{
          },
          "vrf1014":{
          }
        }

    nl1# show ip ospf vrf vrf1012 neighbor swp4.2 detail json
        {
          "9.9.12.10":[
            {
              "ifaceAddress":"200.254.2.46",
              "areaId":"0.0.0.0",
              "ifaceName":"swp4.2",
              "localIfaceAddress":"200.254.2.45",
              "nbrPriority":1,
              "nbrState":"Full",
              "role":"DR",
              "stateChangeCounter":6,
              "lastPrgrsvChangeMsec":1462758,
              "routerDesignatedId":"200.254.2.46",
              "routerDesignatedBackupId":"200.254.2.45",
              "optionsCounter":2,
              "optionsList":"*|-|-|-|-|-|E|-",
              "routerDeadIntervalTimerDueMsec":37140,
              "databaseSummaryListCounter":0,
              "linkStateRequestListCounter":0,
              "linkStateRetransmissionListCounter":0,
              "threadInactivityTimer":"on",
              "threadLinkStateRequestRetransmission":"on",
              "threadLinkStateUpdateRetransmission":"on"
            }
          ]
        }
        nl1#

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-02-08 14:34:06 -08:00
Pooja Jagadeesh Doijode a8e6c2c6d0 ospfd: Option to query specific neighbor in VRF
Added VRF option to
"show ip ospf [vrf NAME] neighbor X.X.X.X [detail] [json]"
command so that the user can query information regarding a
specific neighbor within a VRF.

r1# show ip ospf vrf default neighbor 10.0.255.2
10.0.255.2        1 Full/-          33m10s             9.891s 10.0.3.2        r1-eth1:10.0.3.4                     0     0     0

r1# show ip ospf vrf default neighbor 10.0.255.2 json
    {
      "10.0.255.2":[
        {
          "priority":1,
          "state":"Full/-",
          "nbrPriority":1,
          "nbrState":"Full/-",
          "converged":"Full",
          "role":"DROther",
          "upTimeInMsec":13877947,
          "deadTimeMsecs":9498,
          "routerDeadIntervalTimerDueMsec":9498,
          "upTime":"3h51m17s",
          "deadTime":"9.498s",
          "address":"10.0.3.2",
          "ifaceAddress":"10.0.3.2",
          "ifaceName":"r1-eth1:10.0.3.4",
          "retransmitCounter":0,
          "linkStateRetransmissionListCounter":0,
          "requestCounter":0,
          "linkStateRequestListCounter":0,
          "dbSummaryCounter":0,
          "databaseSummaryListCounter":0
        }
      ]
    }
r1# show ip ospf vrf default neighbor 10.0.255.2 detail
     Neighbor 10.0.255.2, interface address 10.0.3.2
        In the area 0.0.0.0 via interface r1-eth1 local interface IP 10.0.3.4
        Neighbor priority is 1, State is Full/-, Role is DROther, 5 state changes
        Most recent state change statistics:
          Progressive change 3h51m27s ago
        DR is 0.0.0.0, BDR is 0.0.0.0
        Options 2 *|-|-|-|-|-|E|-
        Dead timer due in 8.458s
        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

        Graceful restart Helper info:
          Graceful Restart HELPER Status : None

r1# show ip ospf vrf default neighbor 10.0.255.2 detail json
    {
      "10.0.255.2":[
        {
          "ifaceAddress":"10.0.3.2",
          "areaId":"0.0.0.0",
          "ifaceName":"r1-eth1",
          "localIfaceAddress":"10.0.3.4",
          "nbrPriority":1,
          "nbrState":"Full/-",
          "role":"DROther",
          "stateChangeCounter":5,
          "lastPrgrsvChangeMsec":13889856,
          "routerDesignatedId":"0.0.0.0",
          "routerDesignatedBackupId":"0.0.0.0",
          "optionsCounter":2,
          "optionsList":"*|-|-|-|-|-|E|-",
          "routerDeadIntervalTimerDueMsec":9715,
          "databaseSummaryListCounter":0,
          "linkStateRequestListCounter":0,
          "linkStateRetransmissionListCounter":0,
          "threadInactivityTimer":"on",
          "threadLinkStateRequestRetransmission":"on",
          "threadLinkStateUpdateRetransmission":"on",
          "grHelperStatus":"None"
        }
      ]
    }
r1#

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-02-07 15:29:31 -08:00
Donatas Abraitis 96475dfde9
Merge pull request #12707 from donaldsharp/missed_enums
Missed enums
2023-02-07 22:22:27 +02:00
Pooja Jagadeesh Doijode 5bec85d971 ospfd: Added missing fields to "show ip ospf neighbor detail"
"role" and "local interface address" fields were missing in
"show ip ospf neighbor detail" command.

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-02-06 15:41:44 -08:00
Donald Sharp ba5c958716 ospfd: Add missing enum's to switch statement
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-01-31 15:15:59 -05:00
Donatas Abraitis 1ce23106eb *: Drop deprecated incorrect JSON fields with wrong naming
Deprecation cycle already passed.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-31 10:18:28 +02:00
Russ White 9b1b028cc2
Merge pull request #12682 from opensourcerouting/time-cs
*: fix time truncation in many places
2023-01-24 10:51:44 -05:00
mobash-rasool c6188284fb
Merge pull request #12677 from opensourcerouting/fix/ospf_potential_memory_leak
ospfd: Free memory for JSON allocated object before return
2023-01-24 09:54:44 +05:30
Donatas Abraitis 88c5852b72 ospfd: Free memory for JSON allocated object before return
For show_ip_ospf_database_type_adv_router_common().

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-23 13:46:42 +02:00
Donatas Abraitis cb2689d3e5 ospfd: Free memory for JSON allocated object before return
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-22 21:15:44 +02:00
Chirag Shah 1ffbb2e487 ospfd: fix crash show ip ospf border-routers json
When show ip ospf border-routers json (without vrf)
specificed, it leads to crash if there no border-routers
information.

Fix:
Do not free json object if use_vrf flag (means vrf option
is not passed) is not set.

Ticket:#3229017
Issue:3229017
Testing Done:

with fix:
l1# show ip ospf border-routers json
{
}
l1# show ip ospf vrf default border-routers json
{
}

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-01-20 23:24:44 -08:00
Rafael Zalamena fce7f209fc *: introduce function for sequence numbers
Don't directly use `time()` for generating sequence numbers for two
reasons:
1. `time()` can go backwards (due to NTP or time adjustments)
2. Coverity Scan warns every time we truncate a `time_t` variable for
   good reason (verify that we are Y2K38 ready).

Found by Coverity Scan (CID 1519812, 1519786, 1519783 and 1519772)

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-01-20 15:40:28 -03:00
Manoj Naragund 3d4e02e230 ospfd: generation of indication LSAs on area border routers.
Description:

code changes involve changes on abr routers to generate and flush
indication LSAs, on backbone and non-backbone areas in different
scenarios.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-01-19 21:03:03 -08:00
Manoj Naragund 516c4c665a ospfd: Core logic implementation.
Description:
Code changes involves.
	1. Count the no.of router LSAs received with DC options bit set,
	   supporting do not age(DNA).
	2. If no of router LSAs received with DC bit set is equal to total
	   no of LSAs in the router lsdb, then all the routers in the
	   area support do not age processing.
	3. Flood the self originated LSAs with DNA flag if all routers in the area
	   supports the feature.
	4. Stop aging of the LSAs recived with DO_NOT_AGE bit set from
	   other routers.
	5. Self originated DO_NOT_AGE lsas will still be aging in their own
	   database.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-01-19 21:03:03 -08: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
Manoj Naragund 75b837a3d5 ospfd: CLI changes to enable/disable OSPFv2 Flood reduction.
Description:
	The CLIs for enabling/disabling FR, at instance level and
	at the area.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-01-19 21:03:03 -08: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 1ea57af264 Revert "bgpd, ospfd: BGP ORR CI warning fixes"
This reverts commit d6b2761134.
2023-01-17 18:10:04 +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
Donatas Abraitis 731d0769e2 Revert "bgpd, ospfd: update BGP when routes are removed from OSPF routing table"
This reverts commit bba9435157.
2023-01-17 18:07:41 +02:00
Donatas Abraitis e993b11c23 Revert "bgpd: code review comments addressed"
This reverts commit 80f6ea8b99.
2023-01-17 18:07:36 +02: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
Donatas Abraitis aca2d29f1e
Merge pull request #12571 from Shikugawa/ospfd-json
ospfd: show ospf database info using formatted json
2023-01-04 22:45:34 +02:00
Rei Shimizu ff68181eda ospfd: show ospf database info using formatted json
Signed-off-by: Rei Shimizu <rshimizu@apache.org>
2023-01-03 02:06:35 +00: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
Russ White 971930a5f6
Merge pull request #12543 from donaldsharp/ospf_json_mem_leak
ospfd: Fix some json mem leaks and some issues
2022-12-20 11:15:28 -05:00
Donald Sharp f9f19fef9d ospfd: Fix some json mem leaks and some issues
a) if show_function happened to be NULL we would leak json memory
b) json_lsa_type was being allocated but only used in the default case, leaking memory
c) json output would sometimes produce text output and that is incorrect

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-20 08:45:51 -05:00
Rafael Zalamena 9bf19426e0 ospfd: fix SPF table memory leak
After `free()`ing a table also set it to NULL so when the instance
release function is called we know whether the pointer is valid or not.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-12-20 08:51:13 -03:00
Sindhu Parvathi Gopinathan 2c248c3ed2 ospfd: json support for show ip ospf border-routers
show ip ospf border-routers json support added.
commands:
  - show ip ospf vrf default border-routers json
  - show ip ospf vrf all border-routers json
  - show ip ospf border-routers json

Testing Done: Unit testing completed.

rut# show ip ospf vrf all border-routers json
{
  "default":{
    "vrfName":"default",
    "vrfId":0,
    "routers":{
      "0.0.0.8":{
        "routeType":"R ",
        "cost":10,
        "area":"0.0.0.1",
        "routerType":"abr",
        "nexthops":[
          {
            "ip":"12.0.0.2",
            "via":"swp1"
          }
        ]
      },
      "0.0.0.9":{
        "routeType":"R ",
        "cost":10,
        "area":"0.0.0.1",
        "routerType":"abr",
        "nexthops":[
          {
            "ip":"12.0.1.2",
            "via":"swp2"
          }
        ]
      }
    }
  }
}

rut#
rut# show ip ospf vrf all border-routers json
{
  "default":{
	"vrfName":"default",
	"vrfId":0,
        "routers":{
  	  "0.0.0.15":{
	    "routeType":"R ",
	    "cost":30,
	    "area":"0.0.0.0",
	    "routerType":"abr",
	    "nexthops":[
		{
		  "ip":"11.0.0.2",
		  "via":"br1"
		}
	     ]
	  }
      }
  }
}

rut# show ip ospf border-routers json
{
  "routers":{
    "0.0.0.15":{
      "routeType":"R ",
      "cost":30,
      "area":"0.0.0.0",
      "routerType":"abr",
      "nexthops":[
        {
	  "ip":"11.0.0.2",
          "via":"br1"
	}
      ]
   }
 }
}

Ticket:#3229017
Issue:3229017

Co-authored-by: Chirag Shah <chirag@nvidia.com>
Signed-off-by: Sindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
2022-12-16 08:46:10 -08:00
Donald Sharp 5519e0eb14
Merge pull request #12499 from opensourcerouting/ospf-vertex-leak
ospfd: fix memory leak on SPF calculation
2022-12-12 18:36:07 -05:00
Rafael Zalamena b3bcfd3dc6 ospfd: fix memory leak on SPF calculation
Fix the following problems:
- Always free vertex next hops on `vertex_parent_free`
- Signalize failure on `ospf_spf_add_parent` when parent already exists
  so the caller has the chance to `free()` any allocated resources.
- Don't reuse vertex next hops without the reference count logic in
  `ospf_nexthop_calculation`. Instead allocate a new copy so it can be
  `free()`d later without complications

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-12-12 15:16:45 -03:00
Jafar Al-Gharaibeh bf8d8a5451 ospfd: fix typo and report the link name in the warning
Submitted-by: Marc Boucher <marc@airvitesse.net>
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2022-12-12 09:17:27 -06:00
Donald Sharp 253113bcb8 ospfd, ospfclient: Do not just include .c files in another .c
ospfclient.c includes .c files directly from ospfd.  Let's separate
these out a bit.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05 11:55:14 -05:00
Donald Sharp 29a1a53d6c ospfd: Remove MTYPE_TMP
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05 11:43:57 -05:00
Russ White c0a4793035
Merge pull request #12367 from rgirada/ospf_valgrind_fix
ospfd: Fixing a memleak.
2022-11-29 11:23:27 -05:00
Russ White 1407cbaea6
Merge pull request #12334 from ylopez/patch-1
Increase maximum packet size in ospf API
2022-11-29 10:11:32 -05:00
Donald Sharp 7b7ca2d319 ospfd: Do not auto-debug DR-Election notifications
Every 1/2 hour my logs are filling up with this:
2022-11-26 13:54:47.531 [DEBG] ospfd: [P4PQ9-K4XFD] DR-Election[1st]: Backup 192.168.119.229
2022-11-26 13:54:47.531 [DEBG] ospfd: [HBZ7F-65Y86] DR-Election[1st]: DR     192.168.119.229
2022-11-26 13:54:47.531 [DEBG] ospfd: [H01MF-RN00N] DR-Election[2nd]: Backup 0.0.0.0
2022-11-26 13:54:47.531 [DEBG] ospfd: [R7BJ4-KP8JT] DR-Election[2nd]: DR     192.168.119.229

This should be guarded by an if check to ensure that the operator really
wants to see this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-28 08:57:38 -05:00
Donald Sharp 15e78e64b4 ospfd: Do not always debug joining AllDRouters Multicast group
My log file is filling up with:
2022-11-26 13:24:47.532 [DEBG] ospfd: [RY794-DQ7AK] interface 192.168.119.229 [2] join AllDRouters Multicast group.

Every 1/2 hour.  There is nothing an operator needs to do here and nothing
that they can change.  Let's guard this output.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-28 08:53:20 -05:00
rgirada 594f80c83f ospfd: Fixing memleak.
Description:
	As part of signal handler ospf_finish_final(),  lsas are originated
	and added to refresh queues are not freed.

	One such leak is :
	==2869285== 432 (40 direct, 392 indirect) bytes in 1 blocks are definitely lost in loss record 159 of 221
	==2869285==    at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
	==2869285==    by 0x4910EC3: qcalloc (memory.c:116)
	==2869285==    by 0x199024: ospf_refresher_register_lsa (ospf_lsa.c:4017)
	==2869285==    by 0x199024: ospf_refresher_register_lsa (ospf_lsa.c:3979)
	==2869285==    by 0x19A37F: ospf_network_lsa_install (ospf_lsa.c:2680)
	==2869285==    by 0x19A37F: ospf_lsa_install (ospf_lsa.c:2941)
	==2869285==    by 0x19C18F: ospf_network_lsa_update (ospf_lsa.c:1099)
	==2869285==    by 0x1931ED: ism_change_state (ospf_ism.c:556)
	==2869285==    by 0x1931ED: ospf_ism_event (ospf_ism.c:596)
	==2869285==    by 0x494E0B0: thread_call (thread.c:2006)
	==2869285==    by 0x494E395: _thread_execute (thread.c:2098)
	==2869285==    by 0x19FBC6: nsm_change_state (ospf_nsm.c:695)
	==2869285==    by 0x19FBC6: ospf_nsm_event (ospf_nsm.c:861)
	==2869285==    by 0x494E0B0: thread_call (thread.c:2006)
	==2869285==    by 0x494E395: _thread_execute (thread.c:2098)
	==2869285==    by 0x19020B: ospf_if_cleanup (ospf_interface.c:322)
	==2869285==    by 0x192D0C: ism_interface_down (ospf_ism.c:393)
	==2869285==    by 0x193028: ospf_ism_event (ospf_ism.c:584)
	==2869285==    by 0x494E0B0: thread_call (thread.c:2006)
	==2869285==    by 0x494E395: _thread_execute (thread.c:2098)
	==2869285==    by 0x190F10: ospf_if_down (ospf_interface.c:851)
	==2869285==    by 0x1911D6: ospf_if_free (ospf_interface.c:341)
	==2869285==    by 0x1E6E98: ospf_finish_final (ospfd.c:748)
	==2869285==    by 0x1E6E98: ospf_deferred_shutdown_finish (ospfd.c:578)
	==2869285==    by 0x1E7727: ospf_finish (ospfd.c:682)
	==2869285==    by 0x1E7727: ospf_terminate (ospfd.c:652)
	==2869285==    by 0x18852B: sigint (ospf_main.c:105)
	==2869285==    by 0x493BE12: frr_sigevent_process (sigevent.c:130)
	==2869285==    by 0x494DCD4: thread_fetch (thread.c:1775)
	==2869285==    by 0x4905022: frr_run (libfrr.c:1197)
	==2869285==    by 0x187891: main (ospf_main.c:235)

	Added a fix to cleanup all these queue pointers and corresponing lsas in it.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-11-22 09:59:40 +00:00
Mobashshera Rasool ca5997cd01 ospfd: Fix RFC conformance test cases 25.19 and 27.6
Steps to reproduce:
--------------------------
1. ANVL: Establish full adjacency with DUT for neighbor Rtr-0-A on DIface-0 with DUT as DR.
2. ANVL: Listen (for up to 2 * <RxmtInterval> seconds) on DIface-0.
3. DUT: Send <OSPF-LSU> packet.
4. ANVL: Verify that the received <OSPF-LSU> packet contains a Network- LSA for network N1
   originated by DUT, and the LS Sequence Number is set to <InitialSequenceNumber>.
5. ANVL: Establish full adjacency with DUT for neighbor Rtr-0-B on DIface-0 with DUT as DR.
6. ANVL: Listen (for up to 2 * <RxmtInterval> seconds) on DIface-0.
7. DUT: Send <OSPF-LSU> packet.
8. ANVL: Verify that the received <OSPF-LSU> packet contains a new instance of the
   Network-LSA for network N1 originated by DUT, and the LS Sequence Number
   is set to (<InitialSequenceNumber> + 1).

Both the test cases were failing while verifying the initial sequence number for network LSA.

This is because currently OSPF does not reset its LSA sequence number when it is going down.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-11-21 03:19:33 -08:00
ylopez 319cfdc765 ospfd: increase API maximum message size
OSPF_MAX_LSA_SIZE does not represent the actual maximum size of LSA packets which may be larger than 1500 bytes. If relaying a large OSPF packet to the OSPF API, we do not allocate a big enough buffer to send over the API. This patch increases the maximum size of OSPF packets transmitted over the API.

Signed-off-by: ylopez <yoann.lopez@gmail.com>
2022-11-18 09:30:09 +01:00
Jafar Al-Gharaibeh 2bb16f6472
Merge pull request #12269 from pguibert6WIND/ospf_external_lsa_crash
ospfd: prevent from crashing when processing external lsa
2022-11-10 13:20:50 -06:00
Philippe Guibert e5309c1a6e ospfd: prevent from crashing when processing external lsa
When using debug mode, the ei parameter may be NULL. In that
case, do not display the log trace, otherwise a crash will
happen.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-11-10 15:11:53 +01:00
Donatas Abraitis 0b280b334c
Merge pull request #11302 from punith-shivakumar/master
ospf6d: add missing ABR task on interface start and change default task delay to 5
2022-11-08 21:28:30 +02:00
Donatas Abraitis bd162aae09 ospfd: Get route-map name for default-information originate
LR1.wue3(config)# route-map foo-bar-baz10 permit 10
LR1.wue3(config-route-map)# exit
LR1.wue3(config)# router ospf
LR1.wue3(config-router)#  ospf router-id 172.18.254.201
LR1.wue3(config-router)#  log-adjacency-changes
LR1.wue3(config-router)# default-information originate metric 50 metric-type 1 route-map foo-bar-baz10
LR1.wue3(config-router)# end

Results in:

LR1.wue3# show run
...
!
router ospf
 ospf router-id 172.18.254.201
 log-adjacency-changes
 default-information originate metric 50 metric-type 1 route-map oute-map
exit
!
route-map foo-bar-baz10 permit 10
exit
!
end

Let's fix this.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-07 22:23:07 +02:00
Donald Sharp d7cde18c63
Merge pull request #12196 from opensourcerouting/xref-vtysh
*: rewrite `extract.pl` using `xref` infra
2022-11-03 08:54:09 -04:00
Donald Sharp eec5525e9d
Merge pull request #12195 from anlancs/fix/ospfd-missing-max-metric
ospfd: fix missing max-metric in show running config
2022-10-31 07:40:26 -04:00
Jafar Al-Gharaibeh 5ac678c599
Merge pull request #12215 from LabNConsulting/working/lb/ospf-allow-for-zero
ospfd: remove asster on zero length LSA - which is permitted by spec
2022-10-29 16:58:50 -05:00
Jafar Al-Gharaibeh d353152de7
Merge pull request #12222 from LabNConsulting/working/lb/fix-p2X-acks
ospfd: fix bug where acks were not be generated to incoming P2P/P2MP peers
2022-10-29 16:57:12 -05:00
Lou Berger dd3b58a00a ospfd: fix bug where acks were not be generated to incoming P2P/P2MP neighbors
Signed-off-by: Lou Berger <lberger@labn.net>
2022-10-29 17:17:56 +00:00
Russ White 854b0ce9ec
Merge pull request #12172 from LabNConsulting/working/lb/api-zero-len-del-flag
OSPF opaques LSA API - fix bug with LL API delete, add option for zero data length withdrawals
2022-10-29 10:38:27 -04: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 15c4dd82db ospfd: remove assert on zero length LSA - which is permitted by spec
Signed-off-by: Lou Berger <lberger@labn.net>
2022-10-28 16:06:14 +00:00
David Lamparter 89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
anlan_cs 6c3aae9c56 ospfd: fix missing max-metric in show running config
```
(ospf)  max-metric router-lsa administrative
```

Currently this running config depends at least one `area` with *active*
`network`, otherwise it will not occur.

The check on this dependency is redundant and wrong, just remove it.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-10-26 08:50:17 -04: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
Lou Berger 2f30cb2574 ospfd/ospfclient: add option to flush/withdrawal with zero length
default behavior is unchanged, i.e., to not zero

Signed-off-by: Lou Berger <lberger@labn.net>
2022-10-21 15:27:58 +00:00
Lou Berger 08172828f6 ospfd: ospf_apiserver.c - fix link local opaque LSA delete
Signed-off-by: Lou Berger <lberger@labn.net>
2022-10-21 15:08:53 +00:00
Jafar Al-Gharaibeh 7c7db42f46
Merge pull request #12155 from LabNConsulting/working/lb/opaque-lsa-zero-len
OSPF: allow for zero length opaque LSAs
2022-10-20 09:19:45 -05:00
Lou Berger 0b91fce78b ospfd: allow for zero length opaque LSAs (which is permitted per RFC 5250)
Signed-off-by: Lou Berger <lberger@labn.net>
2022-10-19 11:50:41 +00:00
Russ White 1ef56168a6
Merge pull request #12124 from anlancs/ospfd-len
ospfd: pass the length of string to function
2022-10-18 11:40:21 -04:00
Russ White fd30c2467a
Merge pull request #12115 from donaldsharp/ospf_unnumbered_showdown
ospfd: Allow unnumbered and numbered addresses to co-exist better
2022-10-13 11:02:17 -04:00
anlan_cs 87d454cce9 ospfd: pass the length of string to function
Fix CID 1526337: (SIZEOF_MISMATCH)

Needs to pass the correct length to the function.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-10-13 21:30:46 +08:00
Donald Sharp 5136e67294 ospfd: Allow unnumbered and numbered addresses to co-exist better
When forming a neighbor relationship on an interface, ospf is
currently evaluating unnumbered as highest priority, without
any consideration for if you have /32's and non /32's on the
interface.  Effectively if I have something like this:

int foo0
  ip address 192.168.119.1/24
!
router ospf
  network 0.0.0.0/0 area 0
!

ospf will form a neighbor on foo0 if it exists.  Now
suppose someone does this:

int foo0
  ip address 192.168.120.1/32

This will create the unnumbered interface on foo0 and
the peering will come down immediately.

The problem here is that the original designers of the unnumbered
code for ospf didn't envision end operators mixing and matching
addresses on an interface like this ( for perfectly legitimate
reasons I might add ).

So if ospf has both numbered and unnumbered let's match against
the numbered first and then unnumbered.  This solves the problem

Fixes: #6823
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-12 16:20:30 -04:00
Punith Kumar S d19cae9f34 ospfd: change default ospf schedule abr task timer
Signed-off-by: Punith Kumar S <punith.shivakumar@sophos.com>
2022-10-12 15:27:43 +00:00
Madhuri Kuruganti 80f6ea8b99 bgpd: code review comments addressed
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:48:23 +05:30
Madhuri Kuruganti bba9435157 bgpd, ospfd: update BGP when routes are removed from OSPF routing table
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
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 d6b2761134 bgpd, ospfd: BGP ORR CI warning fixes
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
Donatas Abraitis 69c736ec06
Merge pull request #12074 from donaldsharp/lib_debugs
*: Create and use infrastructure to show debugs in lib
2022-10-12 10:38:21 +03:00
Donatas Abraitis a957e14cdf
Merge pull request #11961 from maduri111/ospfd-debug-cmds
ospfd: fix for some of ospf debug commands config lost after reboot
2022-10-09 21:16:01 +03:00
Donald Sharp cf00164b69 *: Create and use infrastructure to show debugs in lib
There are lib debugs being set but never show up in
`show debug` commands because there was no way to show
that they were being used.  Add a bit of infrastructure
to allow this and then use it for `debug route-map`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-07 12:39:05 -04:00
Donatas Abraitis 083e241235 ospfd: Remove deprecated command graceful-restart helper-only
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-23 22:10:44 +03:00
Madhuri Kuruganti 77ea5710b3 ospfd: fix for few debug commands lost in config after debug ospf packet is enabled
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-09-20 00:51:52 +05:30
Madhuri Kuruganti 132f7b21b0 ospfd: fix for debug ospf <inst> packet fails with instance not running
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-09-20 00:27:00 +05:30
Madhuri Kuruganti cc75c9dc59 ospfd: fix for some of ospf debug commands config lost after reboot
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-09-19 20:40:03 +05:30
Jafar Al-Gharaibeh 1762461ca8
Merge pull request #11911 from mruprich/ospf-api
ospfd: Adding SUPPORT_OSPF_API define in ospf_spf.c
2022-09-06 22:55:58 -05:00
Donatas Abraitis cbe4fd18fc
Merge pull request #11864 from manojvn/clis
ospfd: Added clis to change default timers for LSA refresh and maxage remove delay.
2022-09-06 18:32:56 +03:00
Michal Ruprich ec3bb054c3 ospfd: Adding SUPPORT_OSPF_API define in ospf_spf.c
It is not possible to build ospf_spf.c file with --disable-ospfapi because
ospf_apiserver.c has SUPPORT_OSPF_API around all function definitions and
that results in an undefined reference to the ospf_apiserver_notify_reachable
function error while building.

Signed-off-by: Michal Ruprich <mruprich@redhat.com>
2022-09-06 12:34:15 +02:00
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
rgirada ef151af79b ospfd: crash when router acts as GR helper upon a topo change
Description:
	ospf process is crashing when  the current router acts
	as GR helper and it received a new lsa.

	Here, ospf_lsa_different() is being called without checking
	'old' pointer. It is asserted in ospf_lsa_different() api
	if the 'old' pointer is NULL.

	corrected this by validaing old pointer before calling
	ospf_lsa_different() api.

	back tarce:
	Program terminated with signal SIGABRT, Aborted.
	0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
	[Current thread is 1 (Thread 0x6b84348827c0 (LWP 3155))]
	0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
	1  0x00006b8433aa4801 in __GI_abort () at abort.c:79
	2  0x00006b8433a9439a in __assert_fail_base (fmt=0x6b8433c1b7d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x162ffc0630bc "l1", file=file@entry=0x162ffc062ff7 "ospfd/ospf_lsa.c", line=line@entry=3520, function=function@entry=0x162ffc0646f0 <__PRETTY_FUNCTION__.18732> "ospf_lsa_different") at assert.c:92
	3  0x00006b8433a94412 in __GI___assert_fail (assertion=assertion@entry=0x162ffc0630bc "l1", file=file@entry=0x162ffc062ff7 "ospfd/ospf_lsa.c", line=line@entry=3520, function=function@entry=0x162ffc0646f0 <__PRETTY_FUNCTION__.18732> "ospf_lsa_different") at assert.c:101
	4  0x0000162ffc008c25 in ospf_lsa_different (l1=l1@entry=0x0, l2=l2@entry=0x162ffe535c60, ignore_rcvd_flag=ignore_rcvd_flag@entry=true) at ospfd/ospf_lsa.c:3520
	5  0x0000162ffc00a8e8 in ospf_lsa_install (ospf=ospf@entry=0x162ffe513650, oi=oi@entry=0x162ffe531c30, lsa=lsa@entry=0x162ffe535c60) at ospfd/ospf_lsa.c:2892
	6  0x0000162ffc059d16 in ospf_flood (ospf=0x162ffe513650, nbr=nbr@entry=0x162ffe52cc90, current=current@entry=0x0, new=new@entry=0x162ffe535c60) at ospfd/ospf_flood.c:429
	7  0x0000162ffc01838f in ospf_ls_upd (size=<optimized out>, oi=0x162ffe531c30, s=<optimized out>, ospfh=<optimized out>, iph=<optimized out>, ospf=<optimized out>) at ospfd/ospf_packet.c:2162
	8  ospf_read_helper (ospf=<optimized out>) at ospfd/ospf_packet.c:3241
	9  ospf_read (thread=<optimized out>) at ospfd/ospf_packet.c:3272
	10 0x00006b843450139c in thread_call (thread=thread@entry=0x7780f42c7480) at lib/thread.c:1692
	11 0x00006b84344cfb18 in frr_run (master=0x162ffe34d130) at lib/libfrr.c:1068

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-08-30 00:48:32 -07:00
mobash-rasool 6c231c2e38
Merge pull request #11867 from sri-mohan1/sri-ospf-dbg1
ospfd: changes for code maintainability
2022-08-29 11:50:54 +05:30
sri-mohan1 70ad0b6627 ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-28 20:48:29 +05:30
Donald Sharp 43bb6fc8d4
Merge pull request #11863 from sri-mohan1/sri-ospf-dbg1
ospfd: changes for code maintainability
2022-08-26 10:50:21 -04:00
sri-mohan1 1396917dde ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-26 13:01:37 +05:30