Commit graph

98 commits

Author SHA1 Message Date
Acee Lindem b44258413f ospfd: Replace LSDB callbacks with LSA Update/Delete hooks.
Replace the LSDB callbacks with LSA update and delete hooks using the
the FRR hook mechanism. Remove redundant callbacks by placing the LSA
update and delete hooks in a single place so that deletes don't need
to be handled by the update hook. Simplify existing OSPF TE and OSPF
API Server callbacks now that there is no ambiguity or redundancy.
Also cleanup the debugging by separating out opaque-lsa debugging
from the overloaded event debugging.

Signed-off-by: Acee Lindem <acee@lindem.com>
2025-02-12 08:21:34 -05: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
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
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
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 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 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
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
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
Donald Sharp 29a1a53d6c ospfd: Remove MTYPE_TMP
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-05 11:43:57 -05: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
sri-mohan1 4adc415e99 ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-22 12:48:35 +05:30
Donald Sharp bc1f09de73 ospfd: Convert thread_cancel to THREAD_OFF
Just convert all uses of thread_cancel to THREAD_OFF.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:27:35 -04:00
Christian Hopps 44038c7ae3 ospfd: add router id support to ospf api
Signed-off-by: Christian Hopps <chopps@labn.net>
2022-06-23 05:01:40 -04:00
Christian Hopps bd1188f904 ospfd: api: always ready to receive opaque from client
Signed-off-by: Christian Hopps <chopps@labn.net>
2022-06-02 16:37:16 -04:00
Christian Hopps 97355a6d92 ospfd: api: add new ISM and NSM sync requests
Signed-off-by: Christian Hopps <chopps@labn.net>
2022-06-02 16:37:16 -04:00
Christian Hopps b1e40ef0ea ospfd: api: remove unused api code/message creation
Signed-off-by: Christian Hopps <chopps@labn.net>
2022-06-02 16:37:16 -04:00
Christian Hopps 5349121b4c ospfd: api: fix recovery of LSA after restart of api client
Prior to this fix, restarting the client just failed b/c the code tried to
"refresh" the existing LSA being added, except that code checked for meta-data
to exist, which was deleted when the client disconnected previously (or had
never connected and the LSA state was picked up from the network).

Signed-off-by: Christian Hopps <chopps@labn.net>
2022-06-02 16:37:16 -04:00
Christian Hopps 149491af80 ospfd: api: add reachable router notifications
Reachable router information is used by OSPF opaque clients in order
to determine if the router advertising the opaque LSA data is
reachable (i.e., 2-way conectivity check).

Signed-off-by: Christian Hopps <chopps@labn.net>
2022-06-02 16:37:16 -04:00
Christian Hopps 97385dddf1 ospfd: cli: add opaque data to json output
Signed-off-by: Christian Hopps <chopps@labn.net>
2022-05-26 17:27:18 -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 78dfa0c754 *: Fix spelling of Following
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-01 16:27:55 -04:00
Donald Sharp 14416b1f33 ospfd: Convert enum event to enum ospf_apiserver_event
Let's name this something more appropriate to
what is being done.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-02 09:17:57 -05: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
Renato Westphal 3e63092b83 ospfd: fix display of plain-text data on "show ... json" commands
Add a 'json' parameter to the 'show_opaque_info' callback definition,
and update all instances of that callback to not display plain-text
data when the user requested JSON data.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-10-08 10:03:01 -03:00
Olivier Dugeon 8db278b5e3 ospfd: Correct Coverity defects
When browsing or parsing OSPF LSA TLVs, we need to use the LSA length which is
part of the LSA header. This length, encoded in 16 bits, must be first
converted to host byte order with ntohs() function. However, Coverity Scan
considers that ntohs() function return TAINTED data. Thus, when the length is
used to control for() loop, Coverity Scan marks this part of the code as defect
with "Untrusted Loop Bound" due to the usage of Tainted variable. Similar
problems occur when browsing sub-TLV where length is extracted with ntohs().

To overcome this limitation, a size attribute has been added to the ospf_lsa
structure. The size is set when lsa->data buffer is allocated. In addition,
when an OSPF packet is received, the size of the payload is controlled before
contains is processed. For OSPF LSA, this allow a secure buffer allocation.
Thus, new size attribute contains the exact buffer allocation allowing a
strict control during TLV browsing.

This patch adds extra control to bound for() loop during TLV browsing to
avoid potential problem as suggested by Coverity Scan. Controls are based
on new size attribute of the ospf_lsa structure to avoid any ambiguity.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-05-19 09:48:54 +02:00
Mark Stapp b3d6bc6ef0 * : update signature of thread_cancel api
Change thread_cancel to take a ** to an event, NULL-check
before dereferencing, and NULL the caller's pointer. Update
many callers to use the new signature.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-23 08:59:34 -04:00
Mark Stapp 96b663a381 ospfd: replace inet_ntoa
Stop using inet_ntoa, use %pI4 etc or inet_ntop instead

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-22 13:37:25 -04:00
David Lamparter 3efd0893d0 *: un-split strings across lines
Remove mid-string line breaks, cf. workflow doc:

  .. [#tool_style_conflicts] For example, lines over 80 characters are allowed
     for text strings to make it possible to search the code for them: please
     see `Linux kernel style (breaking long lines and strings)
     <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_
     and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_.

Scripted commit, idempotent to running:
```
python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'`
```

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-07-14 10:37:25 +02:00
Mark Stapp 9d1624669e ospfd: clean up SA warning
remove an unneeded initialization to clear up an SA report.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-12-05 16:12:09 -05:00
Donald Sharp 45559c4dfe ospfd: nbr->oi is never null
We test nbr->oi in a couple of places for null, but
in the majority of places of the nbr->oi data is being
used we just access it.  Touch up code to trust this
assertion and make the code more consistent in others.

Found in Coverity.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-11-21 18:47:13 -05:00
Mark Stapp d0a456858e ospfd: remove empty debug
Remove empty debug line - empty format string generates a
compile warning.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-03-19 10:47:00 -04:00
Quentin Young 9165c5f5ff *: remove trailing newlines from zlog messages
Zlog puts its own newlines on, and doing this makes logs look nasty.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-03-14 18:41:15 +00:00
David Lamparter 6a154c8812 *: list_delete_and_null() -> list_delete()
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02 11:40:52 +02:00
Quentin Young cf444bcf40 ospfd: OSPF_[ERR|WARN] -> EC_OSPF
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13 18:56:04 +00:00
Quentin Young ade6974def *: style for flog_warn conversions
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06 20:56:41 +00:00
Donald Sharp 542a208f3a ospfd: Add OSPF_WARN_LSA_INSTALL_FAILURE error code
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06 20:50:58 +00:00
Donald Sharp 85c9b43949 ospfd: Add OSPF_WARN_OPAQUE_REGISTRATION
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06 20:50:58 +00:00
Donald Sharp 5b3d4186de ospfd: Add ospf_lsa_new_and_data function and abstract away
In all but one instance we were following this pattern
with ospf_lsa_new:

ospf_lsa_new()
ospf_lsa_data_new()

so let's create a ospf_lsa_new_and_data to abstract
this bit of fun and cleanup all the places where
it assumes these function calls can fail.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-20 20:41:37 -04:00
Donald Sharp 0ce1ca805d *: ALLOC calls cannot fail
There is no need to check for failure of a ALLOC call
as that any failure to do so will result in a assert
happening.  So we can safely remove all of this code.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-11 17:14:58 +02:00
paco 4adf00f765
ospfd: null check (Coverity 23110)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-27 14:41:50 +02:00
paco ed35fc0593
ospfd: null check (Coverity 23110)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-06-20 18:35:20 +02:00
Quentin Young d7c0a89a3a
*: use C99 standard fixed-width integer types
The following types are nonstandard:
- u_char
- u_short
- u_int
- u_long
- u_int8_t
- u_int16_t
- u_int32_t

Replace them with the C99 standard types:
- uint8_t
- unsigned short
- unsigned int
- unsigned long
- uint8_t
- uint16_t
- uint32_t

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-27 15:13:34 -04:00
Lou Berger 996c93142d *: conform with COMMUNITY.md formatting rules, via 'make indent'
Signed-off-by: Lou Berger <lberger@labn.net>
2018-03-06 14:04:32 -05:00