Commit graph

143 commits

Author SHA1 Message Date
Acee Lindem 06af50eace ospf6d: Fix use after free of router in OSPFv3 ABR route calculation.
This PR fixes FRR issue https://github.com/FRRouting/frr/issues/18040. The
OSPFv3 route is locked during the ABR calculation since there are
scenarios under which it is freed. The OSPFv3 ABR computation is
sub-optimal and this PR doesn't attempt to rework it.

Signed-off-by: Acee Lindem <acee@lindem.com>
2025-02-24 21:54:10 +00:00
Donatas Abraitis 1df6c57e69
Merge pull request #17363 from acooks-at-bda/fix-redundant-null-ptr-check-CID-1599962
ospf6d: remove redundant null ptr check
2024-11-06 08:10:00 +02:00
Andrew Cooks 8c5a0bb456 ospf6d: remove redundant null ptr check
Fix defect flagged by Coverity:

*** CID 1599957:  Null pointer dereferences  (REVERSE_INULL)
/ospf6d/ospf6_intra.c: 581 in ospf6_link_lsa_get_prefix_str()
575                                                int buflen, int pos)
576     {
577             struct ospf6_link_lsa *link_lsa = lsa_after_header(lsa->header);
578             struct ospf6_prefix *prefix = nth_prefix(lsa->header, pos);
579             struct in6_addr in6 = { 0 };
580
>>>     CID 1599957:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "lsa" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
581             if (!lsa || !prefix || !buf || buflen < (1 + INET6_ADDRSTRLEN))
582                     return NULL;
583
584             /* position zero is used for the lladdr in the body of the LSA */
585             if (pos == 0) {
586                     inet_ntop(AF_INET6, &link_lsa->linklocal_addr, buf, buflen);

The check for lsa being not-null happens in ospf6_lsdb_show() and
first dereference happens in ospf6_lsa_show_summary()

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-11-06 11:06:31 +10:00
Andrew Cooks 24d8d95dd1 ospf6d: remove redundant null ptr check
Fix defect flagged by Coverity:

*** CID 1599962:  Null pointer dereferences  (REVERSE_INULL)
/ospf6d/ospf6_intra.c: 775 in ospf6_intra_prefix_lsa_get_prefix_str()
769     {
770             struct ospf6_prefix *prefix = nth_prefix(lsa->header, pos);
771             struct in6_addr in6 = { 0 };
772             char tbuf[16];
773
774             /* ensure buflen >= INET6_ADDRSTRLEN + '/128\0' */
>>>     CID 1599962:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "lsa" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
775             if (!lsa || !prefix || !buf || buflen < (5 + INET6_ADDRSTRLEN))
776                     return NULL;
777
778             memcpy(&in6, OSPF6_PREFIX_BODY(prefix),
779                    OSPF6_PREFIX_SPACE(prefix->prefix_length));
780             inet_ntop(AF_INET6, &in6, buf, buflen);

The check for lsa being not-null happens in ospf6_lsdb_show() and
first dereference happens in ospf6_lsa_show_summary()

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-11-06 11:00:13 +10:00
Andrew Cooks b2526ddc3f ospf6d: apply CI style suggestions
Apply formatting changes suggested by CI frrbot.

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:17 +10:00
Andrew Cooks 9eef5e6483 ospf6d: use nth_prefix() in ospf6_intra_prefix_lsa_get_prefix_str()
Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:17 +10:00
Andrew Cooks 6a7751b38a ospf6d: use nth_prefix() in ospf6_link_lsa_get_prefix_str()
Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:17 +10:00
Andrew Cooks b3f72964f2 ospf6d: use nth_lsdesc() in ospf6_router_lsa_get_nbr_id()
Improves code readability by reducing pointer casting and arithmetic,
and intendation.

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:16 +10:00
Andrew Cooks 8ea50a44b5 ospf6d: use nth_lsdesc() in ospf6_network_lsa_get_ar_id()
Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:16 +10:00
Andrew Cooks d0366de57c ospf6d: replace TLV_HDR_TOP macro with lsdesc_start function
The original TLV_HDR_TOP implementation only worked for Graceful Restart
LSAs, because they had no "LSA body".

This change introduces a body size lookup table and changes the
macro to a function that accounts for the LSA body for all LSA types,
and provides type checking on the provided pointer before arithmetic.

It also removes the open type casting and pointer arithmetic.

The introduced lsdesc_start() is used to find the start of a descriptor,
and will be used for TLVs in E-LSAs as well as old LSA.

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:16 +10:00
Andrew Cooks 1bb4955371 ospf6d: use lsa_after_header pointer arithmetic
Replaces open type casting and pointer arithmetic for readability.

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:16 +10:00
Andrew Cooks 1b64893e23 ospf6d: replace ospf6_lsa_header_end()
The void * return type of the replacement enables the removal of a
cast at every point of use, and the name no longer suggests that it
points to the last byte of the header.

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:16 +10:00
Andrew Cooks 7c9a79f182 ospf6d: factor out generic TLV handling
In preperation for Extended LSA types and their TLVs, factor out the TLV
handling from the Gracefull Restart functionality.

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-09-16 18:38:16 +10:00
Andrew Cooks 954f2ac581 ospf6d: replace OSPF6_LSA_END with ospf6_lsa_end
Replacing the macro with an inline function enables better type
checking.

No functional change.

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-05-28 14:06:25 +10:00
Andrew Cooks 4d06e27569 ospf6d: replace OSPF6_LSA_HEADER_END macro
Replacing the macro with an inline function allows the compiler to
check the parameter type.

Use the replacement function consistently to reduce the number of
open coded pointer cast plus offset calculations.

use tools/indent.py to reformat all occurences of its use.

Signed-off-by: Andrew Cooks <acooks.at.bda@gmail.com>
2024-05-28 14:05:56 +10:00
David Lamparter 5c0eed0c85 ospf6d: add point-to-multipoint interface mode
This adds the PtMP interface type, which is effectively identical to PtP
except that all the database flooding & updates are unicast.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-10-10 08:08:20 +10:00
David Lamparter 65e955890c ospf6d: allow configuring PtP neighbors & cost
Add a list of configured neighbors for each interface.  Only stores cost
(and "existence") for now.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-10-10 07:57:43 +10:00
David Lamparter 55bbef1356 ospf6d: fix uninitialized warnings
GCC 13.2.0 complains:

```
ospf6d/ospf6_intra.c:139:25: error: ‘json_arr’ may be used uninitialized [-Werror=maybe-uninitialized]
ospf6d/ospf6_intra.c:485:20: error: ‘json_arr’ may be used uninitialized [-Werror=maybe-uninitialized]
```

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-09-16 14:17:24 +02: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 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 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
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
anlan_cs 22ce5803e4 ospf6d: combine two conditions for lsa prefix
For both router and network LSAs, combine the two conditions and process lsa
prefix uniformly.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-08-02 21:09:33 -04:00
Donatas Abraitis 6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
Donald Sharp cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
Abhinay Ramesh 6cb85350df ospf6d: Stitching the auth trailer code with rest of ospf6.
Problem Statement:
==================
RFC 7166 support for OSPF6 in FRR code.

RCA:
====
This feature is newly supported in FRR

Fix:
====
Core functionality implemented in previous commit is
stitched with rest of ospf6 code as part of this commit.

Risk:
=====
Low risk

Tests Executed:
===============
Have executed the combination of commands.

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2022-02-09 01:57:08 +00:00
Donatas Abraitis ce4b236f61 ospf6d: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:41 +02:00
Donatas Abraitis d573b8f863 ospf6d: Do not explicitly set the thread pointer to NULL
FRR should only ever use the appropriate THREAD_ON/THREAD_OFF
semantics.  This is espacially true for the functions we
end up calling the thread for.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-08 08:56:42 +03:00
Igor Ryzhov c6ff5b66e2
Merge pull request #9740 from caracall/forked-upstream/debug_ospf6
ospf6: add the ability of specifying router-id/area-id in no debug ospf6
2021-10-07 18:38:22 +03:00
Manoj Naragund bc465fb6cc ospf6d: code cleanup.
removal of some of the deadcode in ospf6d.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2021-10-06 08:54:47 -07:00
Ahmad Caracalli b25a110347 ospf6: add the ability of specifying router-id/area-id in no debug ospf6
Add the ability to specify the router-id/area-id when deleting the debug
ospf6 configuration.

The new commands are as follow:

no debug ospf6 border-routers router-id [A.B.C.D]
no debug ospf6 border-routers area-id [A.B.C.D]

Update the doc as well.

Signed-off-by: Ahmad Caracalli <ahmad.caracalli@6wind.com>
2021-10-06 15:46:19 +02:00
Manoj Naragund 25dd89e398 ospf6d: minor struct compare issues.
Problem Statement:
Multiple struct compare using memcmp, which might result in issue due to
structure padding/alignment.

Fix:
The code changes involve structure member by member comparison to
remove any issues related to padding/alignment.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
(cherry picked from commit 67db821a1d6d68b19862d50b68ed19278c5f2422)
2021-09-30 09:53:26 -07:00
David Lamparter 16c3485e74
Merge pull request #9635 from donaldsharp/ospf6_unit 2021-09-22 14:25:46 +02:00
Donald Sharp 6926bedfb3 ospf6d: Fix debug string in rare case
When looking up the o_path->ls_prefix if it is not found
the debug statement was using a buf that was never initialized.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-21 07:54:54 -04:00
Donald Sharp cbcf3335b3 ospf6d: Use bool instead of an int
intra_brouter_calc is a int that is being used a bool,
convert to a bool.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-19 07:55:19 -04:00
Renato Westphal 7116509803 ospf6d: introduce support for Graceful Restart (restarting mode)
RFC 5187 specifies the Graceful Restart enhancement to the OSPFv3
routing protocol. This commit implements support for the GR
restarting mode.

Here's a quick summary of how the GR restarting mode works:
* GR can be enabled on a per-instance basis using the `graceful-restart
  [grace-period (1-1800)]` command;
* To perform a graceful shutdown, the `graceful-restart prepare ipv6
  ospf` EXEC-level command needs to be issued before restarting the
  ospf6d daemon (there's no specific requirement on how the daemon
  should be restarted);
* `graceful-restart prepare ospf` will initiate the graceful restart
  for all GR-enabled instances by taking the following actions:
  o Flooding Grace-LSAs over all interfaces
  o Freezing the OSPF routes in the RIB
  o Saving the end of the grace period in non-volatile memory (a JSON
    file stored in `$frr_statedir`)
* Once ospf6d is started again, it will follow the procedures
  described in RFC 3623 until it detects it's time to exit the graceful
  restart (either successfully or unsuccessfully).

Testing done:
* New topotest featuring a multi-area OSPF topology (including stub
  and NSSA areas);
* Successful interop tests against IOS-XR routers acting as helpers.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-16 12:26:48 -03:00
Russ White 3e2321b88c
Merge pull request #9019 from pjdruddy/ospfv3-early-break-list-walk
ospf6d: break early on route prefix mismatch
2021-09-10 14:29:53 -04:00
Russ White e448fefbb4
Merge pull request #9028 from mobash-rasool/ospfv3-asbr-summarisation
Ospfv3 ASBR summarisation feature
2021-07-30 06:37:50 -04:00
Igor Ryzhov 36d3fcccb4
Merge pull request #8944 from opensourcerouting/ospf6-mtu-revert
ospf6d: revert PR #8622
2021-07-27 16:06:40 +03:00
Mobashshera Rasool 22813fdb86 ospf6d: Store ospf6 back pointer in route struct
Storing the pointer to ospf6 struct in route struct.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2021-07-21 05:20:30 +00:00
Pat Ruddy 0c7f982a38 ospf6d: break early on route prefix mismatch
The route linked list in ospf6d is ordered in prefix batches which
are associated with a the route node denoting the prefix. So if
you look up the prefix in the tree and start walking the list, if you
find a prefix which differs from the one you are interested in then
you have gone beyond the batch of routes for that prefix.

In some cases the route database linked list is used on a per-prefix
basis. The existing code simply does a continue when the prefix does
not match and continues to walk. This works with small numbers of
routes because the walk continues through unrelated prefix batches and
never finds anything to operate on. However if we have many thousands
of routes these walks become expensive and can cause the SPF thread
(amongst others) to run very long, causing issues with adjacencies
where the dead timer is short.

Add a break to these prefix-based loops to exit early if we get a
prefix mismatch to avoid continuing down the route list if we have
overshot.

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-07-20 11:19:48 +01:00
David Lamparter 4699ad7296 ospf6d: move prefix_options from _path to _route
Prefix options are per-prefix, not per-path.  As evident by the fact
that the field is never used on ECMP paths.  Move it where it belongs.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-07-20 11:22:21 +02:00
David Lamparter 0c3a104a7a Revert "ospf6d: Limit the number of interface addresses being supported"
This reverts commit f85b76195a.
2021-06-29 15:17:01 +02:00
lynne 1b1f7b4f15 ospf6d: move error logs out from behind debug flags
The logging in ospf6 is very verbose.  If you turn on logging on a scaled
system you get too many logs.   The problem is that there are some errors
that occur that are hidden behind the debug flags, and to see these errors
we currently need to turn on the debug logging.  This change converts these
error logs to warnings and removes the debug flags.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
2021-06-14 15:46:49 -04:00
Donald Sharp 95b3f03d89 ospf6d: Rename ospf6_is_router_abr to more accurately reflect what it does
The ospf6_is_router_abr is checking to see if ospfv3 is an abr router
and also setting values.  Let's rename it too `ospf6_check_and_set_router_abr`
to more accurately reflect what it is doing.

Additionally fix coverity #1505176 where we were not checking the return
value of ospf6_is_router_abr like we did every other time.  In this
case we don't care about the return value so indicate that we do not.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-10 07:59:06 -04:00
Kaushik 35769de430 ospf6d: support for nssa in ospfv3
Fix for the routes which is not classified as best routes.

Signed-off-by: Kaushik <kaushiknath.null@gmail.com>
2021-06-04 07:23:10 -03:00
Kaushik ad500b22b5 ospf6d: Support for nssa in ospfv3
The following is implemented.
1. Configuring area as NSSA.
2. Generating Type 7 LSA.
3. Conversion of Type 7 to Type 5 ( Default Behavior).
4. NSSA ABR selection.

Reviewed-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Co-authored-by: Kaushik <kaushiknath.null@gmail.com>
Co-authored-by: Soman K.S <somanks@gmail.com>
Signed-off-by: Kaushik <kaushiknath.null@gmail.com>
2021-06-04 07:23:10 -03:00
lynne f85b76195a ospf6d: Limit the number of interface addresses being supported
The code had no limits on addresses configured on an interface running
ospf6d.  The code would crash when more than 100 addresses were added.
This change limits the number of interface address to 100 if mtu is set
to the default value.  If the mtu is set to a jumbo packet size or larger
we will support 200 interface addresses.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
2021-05-11 09:43:07 -04:00
lynne f6c5f2e0c3 ospf6d: Fix when an "export-list" or "filter-list out" is applied.
When an "export-filter" or "filter-list out" was configured on an area the
filter was not applied to existing database.    The user would either have
to restart the neighboring router in the other area or issue a "clear ipv6
ospf6 interface" to cause the neighbor router to resend it's LSAs.   The
new filter would then be applied to these LSAs and permit or deny summary
LSAs from being added/removed from the database.  The code now applies the
filters to the existing database without user needing to take any action
to clear ospfv3 adjacencies.

The second part of the problem was if a rule changed the updated filter was
not applied.  The code has been modifed to now process the rule update and
reapply the filter.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
2021-05-04 15:28:56 -04:00