Commit Graph

2348 Commits

Author SHA1 Message Date
Donald Sharp
01af91e5ff ospfd: Fix Coverity SA #1617470, 76 and 78
msg_new takes a uint16_t, the length passed
down variable is a unsigned int, thus 32 bit.
It's possible, but highly unlikely, that the
msglen could be greater than 16 bit.
Let's just add some checks to ensure that
this could not happen.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 283cc51178)
2025-02-06 16:16:48 +00:00
Acee Lindem
1c55cf27a2 ospfd: Prune duplicate next-hops when installing into zebra
Duplicate next-hops are maintained for OSPF inter-area and AS
external routes in the OSPF routing table as long as they
correspond to LSAs for different adverting routers. The
intra-area route computation will not result in duplicate
next-hops.

Signed-off-by: Acee Lindem <acee@lindem.com>
2025-01-23 15:13:53 +00:00
anlan_cs
a5ec72aa8c ospfd: avoid the redundant timers
Since the timer thread for ```OSPF_ROUTE_AGGR_DEL``` has been created,
the subsequent "no summary-address" commands shouldn't trigger redundant timers.

Signed-off-by: anlan_cs <anlan_cs@126.com>
2025-01-10 08:51:40 +08:00
anlan_cs
533d387a7f ospfd: fix wrong check for two commands
The users would know the failure of some case for the two commands, just
return the error ```CMD_WARNING_CONFIG_FAILED```.

Signed-off-by: anlan_cs <anlan_cs@126.com>
2025-01-07 10:58:03 +08:00
anlan_cs
3522ab21d0 ospfd: Correct one word
Signed-off-by: anlan_cs <anlan_cs@126.com>
2025-01-03 22:57:30 +08:00
Olivier Dugeon
1bcccb87cd ospfd: Correct invalid SR-MPLS output label
When OSPFd starts, there is 2 possible scenarios for Segment Routing:
1/ Routes associated to Prefixes are not yet available i.e. Segment Routing LSA
are received before LSA Type 1. In this case, the function
ospf_sr_nhlfe_update() is triggered when a new SPF is launch. Thus, neighbors
and output label are always synchronise with the routing table.
2/ Routes are already available i.e. LSA Type 1 are received before Segment
Routing LSA, in particular the Router Information which contains the SRGB.
During nhlfe computation, perfixes are leave with incomplete configuration, in
particular, the SR nexthop is set to NULL. If this scenario is handle through
the function update_out_nhlfe (triggered when SRGB is received or modified from
a neighbor node), the output label is not correctly configured as the nexthop
SR node associated to the prefix has been leave to NULL.

This patch correct this problem by calling the function compute_nhlfe() when
the nexthop SR Node associated to the prefix is NULL within the
update_out_nhlfe() function. Thus, we guarantee that the SR prefix is always
correctly configuration indpedently of the scenario i.e. arrival of the
different LSA.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-11-23 19:05:25 +01:00
Acee Lindem
6afd56da96 ospfd: OSPF multi-instance default origination fixes
When originating a default AS-External LSA in one OSPF instance,
it wasn't working if the criteria route was installed by another OSPF
instance. This required more flexible processing of the OSPF external
route information.

Also fix problem multi-instance display for "show ip ospf
 <instance> database ...".

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-11-17 13:33:48 +00:00
Jafar Al-Gharaibeh
905fc5c611
Merge pull request #17346 from LabNConsulting/aceelindem/fix_ospf_refresh_interval_assert
ospfd: Fix assert in LSA refresh interval setting
2024-11-05 13:30:24 -06:00
Russ White
408decfd77
Merge pull request #17319 from opensourcerouting/fix/no_ospf_router-id
ospfd: Use router_id what Zebra has if we remove a static router_id
2024-11-05 10:19:44 -05:00
Acee
64c67c1ce0 ospfd: Fix assert in LSA refresh interval setting
Under certain timing conditions, the current logic asserts in
ospf_lsa_refresh_delay(). While this isn't readily reproducible,
the only explanation is that the conversion from struct timeval
to milliseconds is 0 due to rounding off the microseconds.

Signed-off-by: Acee <aceelindem@gmail.com>
2024-11-05 10:03:28 -05:00
Russ White
77632a7ec3
Merge pull request #17194 from LabNConsulting/aceelindem/ospf-ls-refresh-interval-fix
ospfd: Fix opaque LSA refresh interval and modify LSA cmds.
2024-11-01 11:37:32 -04:00
Donald Sharp
dbc4ba99a9 Revert "ospfd: update ospf_asbr_status when using no_area_nssa command"
This reverts commit 71aa5ab7f6.
2024-10-31 21:35:51 -04:00
Donatas Abraitis
1073e0f9b3 ospfd: Use router_id what Zebra has if we remove a static router_id
If we set router-id, e.g. `router-id x.x.x.x`, then we have:

```
pc.donatas.net# show ip ospf | include Router ID
 OSPF Routing Process, Router ID: x.x.x.x
```

But once we remove it (`no router-id x.x.x.x`), the old router-id remains.

This is kinda OK, but to be consistent with OSPFv3 we should use what Zebra
already has, instead of retaining the old one.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-31 11:38:40 +02:00
Donatas Abraitis
80bfe6784f ospfd: Add a hidden command for old no router-id
A new command is `ospf router-id ...`, but the old one is also valid. Just a no
form was missed.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-10-31 11:37:49 +02:00
Donatas Abraitis
cf6a575cbd
Merge pull request #17189 from Shbinging/fix_some_ospf_unset_commands_syntax
ospfd:fix syntax of some ospf no commands
2024-10-29 10:43:53 +02:00
Acee Lindem
c735f25abb ospfd: Fix opaque LSA refresh interval and modify LSA cmds.
The configured OSPF refresh interval was not being used for opaque LSA (it always used the constant). Also, modified the timers lsa min-arrival command to have a maximum of 5000 msecs as well as providing a path for backward command compatibility.

Added missing user documentation for both timers lsa min-arrival and timers throttle lsa all.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-10-25 14:31:10 +00:00
Shbinging
03649ffde3 ospfd:fix syntax of some no commands
Fix syntax of the following no commands:
1. `no area virtual link A.B.C.D hello-interval <NUM>`, `<NUM>` can be omitted.
2. `no area nssa default-information-originate metric <NUM>`, `<NUM>` can be omitted.
3. `no area nssa range cost <NUM>`, `<NUM>` can be omitted.
4. `no area default cost <NUM>`, `<NUM>` can be omitted.
5. `no ospf write-multiplier <NUM>`, `<NUM>` can be omitted.
6. `no default-information originate metric <NUM>`, `<NUM>` can be omitted.
7. `no distance <NUM>`, `<NUM>` can be omitted.

Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-10-23 06:01:57 +00:00
Shbinging
baf604770e ospfd:fix the bug that the empty area was not free after no area range command was executed
When we use the no area X.X.X.X range A.B.C.D/M command, if the area no longer has an interface to which it belongs, then the area should be deleted from the LSDB. This processing logic is consistent with instructions such as no network area and no area authentication.

Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-10-22 05:34:36 +00:00
Donatas Abraitis
3f690542f5
Merge pull request #17134 from Shbinging/fix_no_area_nssa_command
ospfd: update ospf_asbr_status when using no_area_nssa command
2024-10-18 14:55:46 +03:00
Shbinging
71aa5ab7f6 ospfd: update ospf_asbr_status when using no_area_nssa command
In the processing of nssa, if the number of areas that need to be translated is greater than 0, then abr will be regarded as asbr, and it will be marked (0x3) in the flag of router lsa. When a certain area is set from nssa to a normal area, the areas that need to be translated may be reduced. The asbr should be re-interpreted as abr when the translated area is 0.

Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-10-17 06:37:21 +00:00
Donatas Abraitis
5fecb1f425
Merge pull request #17065 from Shbinging/fix_some_ospf_commands
ospfd: fix some ospf commands
2024-10-17 09:01:30 +03:00
Shbinging
774788d4c8 ospfd: fix no area shortcut MODE command, MODE can be default
Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-10-16 04:39:20 +00:00
Donald Sharp
573d807adf ospfd: Fixup ospf_lsa.[ch] to properly spell out parameters for functions
Our standard says when in a .h file and declaring a function all parameters
must have their variables spelled out.  Let's do this for ospf_lsa.h

Modified ospf_lsa.c to also use event instead of thread, and uint8_t instead
of unsigned short.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-15 18:32:14 -04:00
Shbinging
af0d1355c7 ospfd:fix the bug that the empty area was not free after the command was executed
When we use the no area X.X.X.X range A.B.C.D/M command, if the area no longer has an interface to which it belongs, then the area should be deleted from the LSDB. This processing logic is consistent with instructions such as no network area and no area authentication.

Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-10-15 08:10:52 +00:00
Shbinging
972308b174 ospfd: fix no_area_range_cost_NUM command, NUM can be omitted
Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-10-11 09:52:16 +00:00
Russ White
e17a9834ea
Merge pull request #16853 from Shbinging/no_ip_ospf_dead_interval_minimal
ospfd: fix snytax of some no commands
2024-09-24 10:03:29 -04:00
Russ White
849df49bbd
Merge pull request #16851 from Shbinging/fix_timer_throttle_spf
ospfd: reset spf_hold_multiplier when current SPF delay state is changed
2024-09-24 10:03:05 -04:00
Shbinging
4a26e53495 ospfd: reset spf_hold_multiplier when current SPF delay state is changed
Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-09-23 14:57:15 +08:00
Acee Lindem
77de5eeb80 ospfd: Interface 'ip ospf neighbor-filter' startup config not applied.
When 'ip ospf neighbor-filter <filter-name>' is configured in the startup
configuration, it is in the running configuration but not applied on the
interface.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-09-20 20:39:49 +00:00
Shbinging
d2c59d68c4 ospfd: fix no ospf abr-type syntax
Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-09-20 15:06:22 +08:00
Acee Lindem
0dc969185f ospfd: Fix heap corruption vulnerability when parsing SR-Algorithm TLV
When parsing the SR-Algorithm TLV in the OSPF Router Information Opaque
LSA, assure that not more than the maximum number of supported
algorithms are copied from the TLV.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-09-18 18:09:19 +00:00
Donald Sharp
9f149fabd4 ospfd: Add vrf name to debug functions in ospf_zebra.c
This file had a bunch of debugs that were operating on
specific vrf's but not telling you which vrf this was
happening in.  Add code to allow operator debugging
to understand what vrf is being worked on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-09-18 09:52:49 -04:00
Shbinging
be32e8afba ospfd: fix no ip ospf dead-interval minimal hello-multiplier syntax
Signed-off-by: Shbinging <bingshui@smail.nju.edu.cn>
2024-09-18 15:39:55 +08:00
Dmitrii Turlupov
69e31a547f ospfd: fix missing '[no]ip ospf graceful-restart hello-delay <N>' commands
Signed-off-by: Dmitrii Turlupov <turlupov@bk.ru>
2024-09-13 16:26:04 +03:00
Acee Lindem
d1e8903a37 ospfd: An OSPF Ack should be sent when P2MP reflooding is delayed.
When "ip ospf network point-to-multipoint delayed-reflooding" is configured,
LSAs received on an OSPF P2MP network are not reflooded. Since LSA reflooding
would normally serve as an implied LSA acknowledgment, an explicit OSPF ack
should be sent to avoid retransmission by the neighbor which orginally flooded
the LSA on the P2MP network.

Signed-off-by: Acee Lindem <acee@lindem.com>
2024-09-12 16:14:52 +00:00
Russ White
551469f323
Merge pull request #16759 from lsang6WIND/ospf_log
ospfd: logging behavior for area id mismatches
2024-09-10 10:18:22 -04:00
Loïc Sang
770863cfcc ospfd: logging behavior for area id mismatches
When an ospf interface is not in the backbone area, but it receives a
packet from the backbone, no logs are generated for this mismatch.
However, the opposite scenario does generate logs.
Add a log for this case.

Signed-off-by: Loïc Sang <loic.sang@6wind.com>
2024-09-09 10:36:07 +02:00
Mark Stapp
2b2a12b9c8 ospfd: add assert to resolve SA warning
Resolve a couple of SA warnings by asserting that pointers are
valid.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2024-09-06 09:15:50 -04:00
Donald Sharp
82bbf2e82d *: Spelling issues
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-18 16:15:56 -04:00
Acee
e42e58118f ospfd: Fix SA warnings in ospf_packet.c and ospf_vty.c
Fix SA warnings in ospf_packet.c and ospf_vty.c. The former was
    introduced by commit ed48014884.

Signed-off-by: Acee <aceelindem@gmail.com>
2024-08-16 13:49:41 -04:00
Mark Stapp
fa50fde954
Merge pull request #16590 from donaldsharp/spelling_in_master
*: Fix spelling errors found
2024-08-15 14:42:11 -04:00
Donald Sharp
baa0a1df5b *: Fix spelling errors found
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-08-15 09:19:37 -04:00
Donatas Abraitis
efcc1cacaf ospfd: Remove deprecated router_info_area_id_cmd
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-08-14 23:16:39 +03:00
Russ White
fba472e848
Merge pull request #16376 from c-po/ospfd-ldp-sync
ospfd: fix internal ldp-sync state flags when feature is disabled
2024-07-23 10:51:46 -04:00
Christian Breunig
5a70378a47 ospfd: fix internal ldp-sync state flags when feature is disabled
When enabling "mpls ldp-sync" under "router ospf" ospfd configures
SET_FLAG(ldp_sync_info->flags, LDP_SYNC_FLAG_IF_CONFIG) so internally knowing
that the ldp-sync feature is enabled. However the flag is not cleared when
turning of the feature using "nompls ldp-sync"!

https://github.com/FRRouting/frr/issues/16375

Signed-off-by: Christian Breunig <christian@breunig.cc>
2024-07-17 10:31:15 +02:00
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