Commit graph

2353 commits

Author SHA1 Message Date
David Lamparter 54b72028c6 ospfd: fix state location mixup
In the "2x2 matrix" of these, I accidentally edited "row-wise" when I
should've edited "column-wise"...  *sigh*

Reported-by: github.com/rbfnet
Fixes: #16349
Fixes: 110945ba0d ("ospfd: fix GR state location")
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-10 09:52:25 +02:00
Acee Lindem ed48014884 ospfd: Fix several problems with direct acknowledgments and improved delay acks.
1. On P2MP interfaces, direct ack would include the same LSA multiple times
      multiple packets are processed before the OSPF interfae direct LSA
      acknowledgment event is processed. Now duplicates LSA in the same event
      are suppressed.
   2. On non-broadcast interfaces, direct acks for multiple neighbors would be
      unicast to the same neighbor due to the multiple OSPF LS Update packets
      being process prior to the OSPF interface direct ack event. Now, separate
      direct acks are unicast to the neighbors requiring them.
   3. The interface delayed acknowledgment timer runs would run continously
      (every second as long as the interace is up). Now, the timer is set
      when delayed acknowledgments are queued and all queued delayed
      acknowledges are sent when it fires.
   4. For non-broadcast interface delayed acknowledgments, the logic to send
      to multiple neighbors wasn't working because the list was emptied while
      building the packet for the first neighbor.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-07-06 13:42:40 +00:00
Acee Lindem c494702929 ospfd: Improve OSPF neighbor retransmission list granularity and precision
The current OSPF neighbor retransmission operates on a single per-neighbor
periodic timer that sends all LSAs on the list when it expires.
Additionally, since it skips the first retransmission of received LSAs so
that at least the retransmission interval (resulting in a delay of between
the retransmission interval and twice the interval. In environments where
the links are lossy on P2MP networks with "delay-reflood" configured (which
relies on neighbor retransmission in partial meshs), the implementation
is sub-optimal (to say the least).

This commit reimplements OSPF neighbor retransmission as follows:

   1. A new data structure making use the application managed
      typesafe.h doubly linked list implements an OSPF LSA
      list where each node includes a timestamp.
   2. The existing neighbor LS retransmission LSDB data structure
      is augmented with a pointer to the list node on the LSA
      list to faciliate O(1) removal when the LSA is acknowledged.
   3. The neighbor LS retransmission timer is set to the expiration
      timer of the LSA at the top of the list.
   4. When the timer expires, LSAs are retransmitted that within
      the window of the current time and a small delta (50 milli-secs
      default). The LSAs that are retransmited are given an updated
      retransmission time and moved to the end of the LSA list.
   5. Configuration is added to set the "retransmission-window" to a
      value other than 50 milliseconds.
   6. Neighbor and interface LSA retransmission counters are added
      to provide insight into the lossiness of the links. However,
      these will increment quickly on non-fully meshed P2MP networks
      with "delay-reflood" configured.
   7. Added a topotest to exercise the implementation on a non-fully
      meshed P2MP network with "delay-reflood" configured. The
      alternative was to use existing mechanisms to instroduce loss
      but these seem less determistic in a topotest.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-06-20 15:31:07 +00:00
Donatas Abraitis e8f5caa21b ospfd: Fix memory leak after cleaning cleaning up interfaceIp JSON field
```
=================================================================
==6717==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1008 byte(s) in 14 object(s) allocated from:
    0 0x7f9ea0dc7d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    1 0x7f9ea034d51f in json_object_new_object (/lib/x86_64-linux-gnu/libjson-c.so.3+0x351f)
    2 0x564b56d0fed6 in show_ip_ospf_interface_common ospfd/ospf_vty.c:4011
    3 0x564b56d1068c in show_ip_ospf_interface ospfd/ospf_vty.c:4285
    4 0x7f9ea06fe1c0 in cmd_execute_command_real lib/command.c:1002
    5 0x7f9ea06fe684 in cmd_execute_command lib/command.c:1060
    6 0x7f9ea06feb03 in cmd_execute lib/command.c:1227
    7 0x7f9ea08415b2 in vty_command lib/vty.c:616
    8 0x7f9ea0841a5d in vty_execute lib/vty.c:1379
    9 0x7f9ea084b367 in vtysh_read lib/vty.c:2374
    10 0x7f9ea08350cd in event_call lib/event.c:2011
    11 0x7f9ea0764386 in frr_run lib/libfrr.c:1217
    12 0x564b56c25b18 in main ospfd/ospf_main.c:295
    13 0x7f9e9fd5bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 7168 byte(s) in 14 object(s) allocated from:
    0 0x7f9ea0dc7d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    1 0x7f9ea0350fa4 in lh_table_new (/lib/x86_64-linux-gnu/libjson-c.so.3+0x6fa4)

Indirect leak of 1232 byte(s) in 14 object(s) allocated from:
    0 0x7f9ea0dc7d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    1 0x7f9ea0350f82 in lh_table_new (/lib/x86_64-linux-gnu/libjson-c.so.3+0x6f82)

SUMMARY: AddressSanitizer: 9408 byte(s) leaked in 42 allocation(s).
***********************************************************************************
```

Fixes: e24ff4c275 ("ospfd: Drop `interfaceIp` from `show ip ospf neigh json")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-06-12 16:28:38 +03:00
Donatas Abraitis e24ff4c275 ospfd: Drop interfaceIp from show ip ospf neigh json
Deprecated. Now it's under interface field directly:

```
{
  "interfaces":{
    "enp3s0":{
      "ifUp":true,
      "ifIndex":2,
      "mtuBytes":1500,
      "bandwidthMbit":100,
      "ifFlags":"<UP,LOWER_UP,BROADCAST,RUNNING,MULTICAST>",
      "ospfEnabled":true,
      "ipAddress":"192.168.10.19",
      "ipAddressPrefixlen":24,
      "ospfIfType":"Broadcast",
      "localIfUsed":"192.168.10.255",
      "area":"0.0.0.0",
      "routerId":"100.100.100.100",
      "networkType":"POINTOPOINT",
      "cost":1000,
      "transmitDelaySecs":1,
      "state":"Point-To-Point",
      "priority":1,
      "opaqueCapable":true,
      "mcastMemberOspfAllRouters":true,
      "timerMsecs":10000,
      "timerDeadSecs":40,
      "timerWaitSecs":40,
      "timerRetransmitSecs":5,
      "timerHelloInMsecs":2924,
      "nbrCount":0,
      "nbrAdjacentCount":0,
      "grHelloDelaySecs":10,
      "prefixSuppression":false,
      "nbrFilterPrefixList":"N\/A"
    }
  }
}
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-06-11 11:59:37 +03:00
Donald Sharp cccb0cd805
Merge pull request #16075 from anlancs/ospfd/fix-cmd-instance
ospfd: add instance id for one command
2024-05-28 13:06:43 -04:00
anlan_cs d15cc4741b ospfd: add instance id for one command
Add the specific instance id for the command:
```
show ip ospf [{(1-65535)$instance|vrf <NAME|all>}] graceful-restart helper [detail] [json]
```

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2024-05-25 19:44:39 +08:00
Olivier Dugeon 8c177d69e3 ospfd: protect call to get_edge() in ospf_te.c
During fuzzing, Iggy Frankovic discovered that get_edge() function in ospf_te.c
could return null pointer, in particular when the link_id or advertised router
IP addresses are fuzzed. As the null pointer returned by get_edge() function is
not handlei by calling functions, this could cause ospfd crash.

This patch introduces new verification of returned pointer by get_edge()
function and stop the processing in case of null pointer. In addition, link ID
and advertiser router ID are validated before calling ls_find_edge_by_key() to
avoid the creation of a new edge with an invalid key.

CVE-2024-34088

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-05-23 10:47:34 +02:00
Olivier Dugeon 5557a289ac ospfd: Correct Opaque LSA Extended parser
Iggy Frankovic discovered another ospfd crash when performing fuzzing of OSPF
LSA packets. The crash occurs in ospf_te_parse_ext_link() function when
attemping to read Segment Routing Adjacency SID subTLVs. The original code
doesn't check if the size of the Extended Link TLVs and subTLVs have the correct
length. In presence of erronous LSA, this will cause a buffer overflow and ospfd
crashes.

This patch introduces new verification of the subTLVs size for Extended Link
TLVs and subTLVs. Similar check has been also introduced for the Extended
Prefix TLV.

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-05-23 10:46:10 +02:00
Olivier Dugeon f69d1313b1 ospfd: Solved crash in RI parsing with OSPF TE
Iggy Frankovic discovered another ospfd crash when performing fuzzing of OSPF
LSA packets. The crash occurs in ospf_te_parse_ri() function when attemping to
read Segment Routing subTLVs. The original code doesn't check if the size of
the SR subTLVs have the correct length. In presence of erronous LSA, this will
cause a buffer overflow and ospfd crash.

This patch introduces new verification of the subTLVs size for Router
Information TLV.

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-05-23 10:46:10 +02:00
Donald Sharp 73ad64a6f4 *: Modify agentx to be allowed to be called
If you had a situation where an operator turned on
ospfd with snmp but not ospf6d and agentx was configured
then you get into a situation where ospf6d would complain
that the config for agentx did not exist.  Let's modify
the code to allow this situation to happen.

Fixes: #15896
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-05-10 10:16:29 -04:00
Russ White 5fe0c5923b
Merge pull request #15846 from Shbinging/fix_ip_ospf_dead_interval_fast_hello
ospfd: fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset hello timer
2024-05-07 09:58:29 -04:00
Bing Shui d733fe2c04 ospfd:fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset hello timer
Signed-off-by: Bing Shui <652023330037@smail.nju.edu.cn>
2024-04-30 12:07:11 +00:00
Donald Sharp edae839119
Merge pull request #15824 from opensourcerouting/fix/ospf_show_non_default
vtysh: Show `ip ospf network ...` even if it's not the same as the interface type
2024-04-29 09:21:09 -04:00
Donatas Abraitis 24a9f1c9ae
Merge pull request #15796 from LabNConsulting/aceelindem/ospf-ospfapi-options
ospfd: OSPFAPI Server options to limit to local connections and per-instance TCP
2024-04-26 23:31:38 +03:00
Acee Lindem 3b75723061 ospfd: OSPFAPI Server options to limit to local connections and per-instance TCP
This commit include OSPFAPI Server options to:

 1. Allow specification of the OSPFAPI server local address.
 2. Allow different OSPFAPI server TCP ports to be specified for different
    OSPF instances in /etc/services.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-04-25 16:20:50 +00:00
Donatas Abraitis 0d0350aef0
Merge pull request #15783 from LabNConsulting/aceelindem/ospf-neighbor-filter
ospfd: Add prefix-list filtering of OSPF neighbors on OSPF interface
2024-04-24 22:30:11 +03:00
Donatas Abraitis 1ce626aea6 vtysh: Show ip ospf network ... even if it's not the same as the interface type
ospfv3 shows this unconditionally, and ospfv2 does not show `ip ospf network ...` if the type of the interface matches the specified network.

Fixes: https://github.com/FRRouting/frr/issues/15817

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-04-23 17:13:46 +03:00
Louis Scalbert c7895ba320 Revert "ospfd: fix some dicey pointer arith in snmp module"
This reverts commit 438ef98701.

The previous code was correct even if the coverity scanner was
complaining.

Fixes: https://github.com/FRRouting/frr/issues/15680
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-04-23 11:36:14 +02:00
Acee Lindem 0ccad8a2b0 ospfd: Add prefix-list filtering of OSPF neighbors on OSPF interface
This commit adds the capabiity to filter OSPF neighbors using a
prefix-list with rules matching the neighbor's IP source address.
Configuration, filtering, immediate neighbor pruning, topo-tests,
and documentation are included. The command is:

     ip ospf neighbor-filter <prefix-list> [A.B.C.D]

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-04-18 15:32:58 +00:00
Bing Shui 913567c0e0 ospfd: fix 'no write-multiplier' command
Signed-off-by: Bing Shui <652023330037@smail.nju.edu.cn>
2024-04-17 10:41:11 +00:00
Bing Shui d249a7c9f5 ospfd: fix 'no maximum-paths' command
Signed-off-by: Bing Shui <652023330037@smail.nju.edu.cn>
2024-04-17 10:39:02 +00:00
Donald Sharp 572b6f3145
Merge pull request #15724 from opensourcerouting/fix/ospfd_cleanup_deprecation
ospfd, ospf6d: Remove deprecated JSON fields
2024-04-15 11:29:04 -04:00
Donatas Abraitis f003ccf16b ospfd: Fix compile warning with -Wformat-truncation
ospfd/ospf_sr.c: In function ‘show_sr_node.part.5’:
ospfd/ospf_sr.c:2745:32: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=]
    snprintf(tmp, sizeof(tmp), "%u", i);
                                ^~
ospfd/ospf_sr.c:2745:31: note: directive argument in the range [0, 2147483646]
    snprintf(tmp, sizeof(tmp), "%u", i);

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-04-13 22:41:43 +03:00
Donatas Abraitis 8f7bc620b5 ospfd, ospf6d: Remove deprecated JSON fields
restartSupoort

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-04-11 13:34:17 +03:00
Acee Lindem 58e623714b ospfd: Implement non-broadcast support for point-to-multipoint networks
This extends non-broadcast support to point-to-multipoint networks.
Neighbors will be explicitly configured and polled in lieu of multicast
dicovery. Toptotests and documentation updates are included.

Additionally, the ospf neighbor commands have been greatly simplified taking
advantage of DEFPY() capabilities.

The AllOSPFRouters (224.0.0.5) is still joined for non-broadcast networks
since it is joined for NBMA networks. It seems this could be removed but
it should done be in a separate commit.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-04-02 21:34:29 +00:00
Mark Stapp 3249853709
Merge pull request #15593 from LabNConsulting/acee/ospf-link-flap-ase-route-change
ospfd: Assure OSPF AS External routes are installed after link flap
2024-03-22 08:35:42 -04:00
Acee 7ac19946b5 ospfd: Assure OSPF AS External routes are installed after link flap
OSPF intra/inter area routes were previously marked to assure they
are re-installed after a fast link flap in the commit:

commit effee18744
Author: Donald Sharp <sharpd@nvidia.com>
Date:   Mon May 24 13:45:29 2021 -0400

    ospfd: Fix quick interface down up event handling in ospf

This commit extends this fix to OSPF AS External routes as well.

Signed-off-by: Acee <aceelindem@gmail.com>
2024-03-21 16:18:59 -04:00
Acee Lindem def1455dc8 ospfd: Send LS Updates in response to LS Request as unicast.
With this fix, OSPF LS Updates sent in response to OSPF LS Requests during the DB Exchange process will be sent as unicasts. Unless the timing of multiple database exchanges coincides, there is little chance that the LSAs in the LS Update are required by OSPF routers other than the one which elicited the LS Update.

This is somewhat ambigous in RFC 2328 and two errata have been filed for clarification:

https://www.rfc-editor.org/errata/eid7850
https://www.rfc-editor.org/errata/eid7851

FRR OSPFv3 (ospf6d) already does it correctly - see ospf6_lsupdate_send_neighbor(struct event *thread). Also, if there is any doubt, one can refer to the C++ code at ospf.org (John Moy's seminal OSPF reference implementation).

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-03-18 14:35:43 +00:00
Donald Sharp 7e058c201a
Merge pull request #15469 from LabNConsulting/chopps/keychain-yang
add ietf-key-chain YANG module support
2024-03-08 08:15:02 -05:00
Christian Hopps 4caffbda8e lib: add keychain northbound support
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-03-04 20:00:15 -05:00
Alexander Rose 561ad925e9 ospfd: Send update for route with new metric
When an AS-external-route is deleted on our system and later added again
with a new metric, then the ospfd would first send a LS-update to remove
the old route and later another LS-update to add the route with the new
metric again.
But when this metric-change happens with no time inbetween the ospfd
recognizes this as the same route and does not send any LS-update.
With the change made here, the ospfd will interpret this route as a
different route, when the metric has changed.

Signed-off-by: Alexander Rose <alexander.rose@secunet.com>
2024-03-01 13:10:43 +01:00
Donatas Abraitis 541503eecd
Merge pull request #15431 from Orange-OpenSource/ospf-te
ospfd: Solved crash in OSPF TE parsing
2024-02-27 17:41:19 +02:00
Olivier Dugeon a73e66d073 ospfd: Solved crash in OSPF TE parsing
Iggy Frankovic discovered an ospfd crash when perfomring fuzzing of OSPF LSA
packets. The crash occurs in ospf_te_parse_te() function when attemping to
create corresponding egde from TE Link parameters. If there is no local
address, an edge is created but without any attributes. During parsing, the
function try to access to this attribute fields which has not been created
causing an ospfd crash.

The patch simply check if the te parser has found a valid local address. If not
found, we stop the parser which avoid the crash.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-27 12:37:33 +01:00
Russ White 3472d1635d
Merge pull request #15339 from opensourcerouting/fix/add_deprecation
ospfd: Add deprecation cycle for `router-info X [A.B.C.D]` command
2024-02-26 14:59:17 -05:00
Russ White 5362d43456
Merge pull request #15367 from rampxxxx/ldp_sync_cleanup
ospfd: fix cli shown in running config when turning off ldp-sync
2024-02-20 10:15:39 -05:00
Donald Sharp 0f7b5fcffb ospfd: Fix assignment with never being used
SA finds this:

error	14-Feb-2024 14:52:24	ospfd/ospf_te.c:3962:2: warning: Value stored to 'sub' is never read [deadcode.DeadStores]
error	14-Feb-2024 14:52:24	        sub = 0;
error	14-Feb-2024 14:52:24	        ^     ~
error	14-Feb-2024 14:52:24	1 warning generated.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-15 23:27:38 -05:00
lynnemorrison 5d5ac73b67 ospfd: fix cli shown in running config when turning off ldp-sync
LDP-Sync is automatically enabled on interfaces when turned on in
router ospf context.   The user can remove ldp-sync from running
on an interface, by issuing a "no ip ospd mpls ldp-sync" command.
To remove all ldp-sync interface commands the user must delete
ldp-sync at the router level.  The code was not correctly removing
the config.   This PR fixes that issue.   Now the extra cli
ldp-sync commands are removed when ldp-sync is disabled.

Signed-off-by: Lynne Morrison <lynne.morrison@ibm.com>
2024-02-13 10:20:11 -05:00
Olivier Dugeon 6fcc86d37a ospfd: Decode Extended Link & Prefix TLVs for json
When dumping ospf database with json output, decode Extended Link and Extended
Prefix TLVs and sub-TLVs.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Olivier Dugeon b27d9e4d3b ospfd: Decode Router Info. TLVs for json output
When dumping ospf database with json output, decode Router Information TLVs
and sub-TLVs.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Olivier Dugeon 95c9cb9aa9 ospfd: Decode TE TLVs for json output
When dumping ospf database with json output, decode Traffic Engineering TLVs
and sub-TLVs.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Olivier Dugeon aa2b539bf5 ospfd: Prepare Opaque LSA for json output
Instead of output bulk of data with json output, prepare json context to decode
opaque TLVs and sub-TLVs.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-12 17:52:00 +01:00
Donatas Abraitis e4a9565137 ospfd: Add deprecation cycle for router-info X [A.B.C.D] command
Specifying an area is not relevant anymore. Use it for some time as a hidden
command to avoid breaking the scripts.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-09 12:48:11 +02:00
Donatas Abraitis b7987eca20
Merge pull request #15333 from c-po/issue-14910
ospfd: can not delete "segment-routing node-msd" when SR if off
2024-02-09 12:34:58 +02:00
Christian Breunig e744db5098 ospfd: add support for "no router-info [<area|as>] command"
frr-reload.py will walk through all config contexts and prepend no to the CLI
command. This requires that the vtysh shell code accepts a full command.

To Reproduce

vtysh -c "conf t" -c "router ospf" -c "router-info area"
vtysh -c "conf t" -c "router ospf" -c "no router-info area"
% Unknown command: no router-info area
vtysh -c "conf t" -c "router ospf" -c "no router-info"

Signed-off-by: Christian Breunig <christian@breunig.cc>
2024-02-08 22:40:54 +01:00
Christian Breunig ba45aa62e7 ospfd: can not delete "segment-routing node-msd" when SR if off
This fixes the initial implementation of commit 7743f2f8c0 ("OSPFd: Update
Segment Routing PR following review") where it wsa not possible to remove
the "segment-routing node-msd" CLI nodes via vtysh once segment-routing got
disabled.

Closes #14910

Signed-off-by: Christian Breunig <christian@breunig.cc>
2024-02-08 21:56:08 +01:00
Igor Ryzhov c1b4976786 *: use af-specific autocompletion for prefix-lists when possible
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-04 22:26:48 +02:00
Mark Stapp 72b31b96fc *: create a single registry of daemons' default port values
Create a single registry of default port values that daemons
are using. Most of these are vty ports, but there are some
others for features like ospfapi and zebra FPM.

Signed-off-by: Mark Stapp <mjs@labn.net>
2024-02-01 11:40:02 -05:00
David Lamparter 110945ba0d ospfd: fix GR state location
This belongs in `/var/lib`, not `/var/run`.

Use library facility to load/save, support previous path as fallback,
and do proper fsync().

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27 19:02:52 +01:00
David Lamparter 634f481113 *: fix frr_daemon_info indentation
clang-format doesn't understand FRR_DAEMON_INFO is a long macro where
laying out items semantically makes sense.

(Also use only one `FRR_DAEMON_INFO(` in isisd so editors don't get
confused with the mismatching `( ( )`.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27 19:02:51 +01:00
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