Commit Graph

101 Commits

Author SHA1 Message Date
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
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
d8bc11a592 *: Add a hash_clean_and_free() function
Add a hash_clean_and_free() function as well as convert
the code to use it.  This function also takes a double
pointer to the hash to set it NULL.  Also it cleanly
does nothing if the pointer is NULL( as a bunch of
code tested for ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-21 08:54:21 -04:00
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
fe61ceaee7 ospfd: Cleanup indentation surrounding oi->nbr
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-11 13:30:32 -04:00
Donatas Abraitis
d2e02cbf64 ospfd: Remove local-block deprecated command
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-07 16:11:46 +03: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
anlan_cs
8e3aae66ce *: remove the checking returned value for hash_get()
Firstly, *keep no change* for `hash_get()` with NULL
`alloc_func`.

Only focus on cases with non-NULL `alloc_func` of
`hash_get()`.

Since `hash_get()` with non-NULL `alloc_func` parameter
shall not fail, just ignore the returned value of it.
The returned value must not be NULL.
So in this case, remove the unnecessary checking NULL
or not for the returned value and add `void` in front
of it.

Importantly, also *keep no change* for the two cases with
non-NULL `alloc_func` -
1) Use `assert(<returned_data> == <searching_data>)` to
   ensure it is a created node, not a found node.
   Refer to `isis_vertex_queue_insert()` of isisd, there
   are many examples of this case in isid.
2) Use `<returned_data> != <searching_data>` to judge it
   is a found node, then free <searching_data>.
   Refer to `aspath_intern()` of bgpd, there are many
   examples of this case in bgpd.

Here, <returned_data> is the returned value from `hash_get()`,
and <searching_data> is the data, which is to be put into
hash table.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-03 00:41:48 +08:00
Donald Sharp
78dfa0c754 *: Fix spelling of Following
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-01 16:27:55 -04:00
Philippe Guibert
7bd1ec9490 ospfd: show running-config displays also srgb on some cases
The following configuration:
router ospf
 segment-routing global-block 16000 23999 local-block 1000 2000
!

appears in the 'show running-config' like below:

router ospf
 local-block 1000 2000
!

When there are custom Adjacencies, display the SRGB even if SRGB
has the default settings.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-03-25 15:18:34 +01:00
Philippe Guibert
052a0cd025 ospfd: silently remove prefix sid already stored in config
There is no need to have an interface available to configure
SRGB. Conversely, it should be possible to remove the SRGB
when no interfaces are available.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-03-25 15:18:34 +01: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
Donatas Abraitis
c48349e346 *: Remove redundand braces for single statement blocks
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-27 11:20:59 +02:00
Donatas Abraitis
92ef007878 ospfd: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:50:30 +02:00
Igor Ryzhov
587cf8f170
Merge pull request #9683 from volta-networks/sr-minor-fixes
ospfd, isisd: minor SR fixes
2021-11-20 14:53:09 +03:00
Donatas Abraitis
4e9a98636f *: Remove unused variables
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:41 +02:00
Donatas Abraitis
20308be317 ospfd: Replace inet_ntop to %pI4/6 for JSON outputs
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-18 18:45:39 +02:00
Fredi Raspall
d97e415dd5 ospfd: fix processing of ext prefix in SR
The existing logic was not comparing the prefix of the extended
prefix TLV. As a result, the code was removing all of the prefix
SIDs except the one received on every LSA update.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:33 +02:00
Fredi Raspall
1a41378ecc ospfd: remove duplicate field update
In update_ext_prefix_sid(), the sr_prefix is associated to the
SR node and inherits the adv router ID regardless.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:33 +02:00
Fredi Raspall
d1db7359ad ospfd: fix logic on SR prefix configuration
The logic was broken in some corner cases.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:33 +02:00
Fredi Raspall
6c57d01073 ospfd: validate input SRGB and SRLB
The code was not checking if in these label ranges [a,b], a is
smaller than b, which is assumed in several places, including when
determining the size of the block as b-a+1. As a consequence, the
results of a bad configuration can be unpredictable. Some effects
observed were: 1) segfault 2) de-activation of SR due to label
reservation failure.

The added validation function also checks if the SR blocks are
larger than some minimal size. RFC 8665 mandates that the blocks
be srictly larger than zero. In this patch, the minimum sized is
arbitrarily defined to be 16.

Checking if ranges would fall outside [16,1048575] is omitted
since the vty filtering takes care of that.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:32 +02:00
Fredi Raspall
37a331f8c2 ospfd: fix condition to get label from SRLB
The prior condition was wrong since it ended up allowing for
labels past the end of the SRLB. Variable 'current' should be in
range [0, size-1] for labels not to exceed the SRLB upper boundary.

In addition, emit a warning log when all labels in the SRLB have
been used.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:32 +02:00
Fredi Raspall
4e10b4dfba ospfd: add util func to detect SR range overlap
Replaces several complex if conditions by a lookup to a utility
to determine if two ranges of numbers overlap.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:32 +02:00
Fredi Raspall
daaebd394c ospfd: homogenize reservation of SRGB & SRLB
Homogenize the code dealing with SRGBs and SRLBs by defining the
same set of utility functions for their reservation.

Unify also the logs and don't display function names since the
operations are only performed from the same functions.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:40:32 +02:00
Fredi Raspall
c181efbe14 ospfd: homogenize deletion of SRGB & SRLB
Homogenize the code dealing with SRGBs and SRLBs by defining the
same set of utility functions for the deletion of SR blocks.

Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:59 +02:00
Fredi Raspall
143661c17f ospfd: remove unnecessary assignment
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:59 +02:00
Fredi Raspall
5bd62f051d ospfd: use existing macro on initialization of SR
Signed-off-by: Fredi Raspall <fredi@voltanet.io>
2021-09-28 10:20:58 +02:00
David Lamparter
9fb83ab17d *: fix for -Wstrict-prototypes
Just some "void" missing between empty braces.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-09-02 13:00:35 +02:00
Emanuele Di Pascale
6443a4be57 ospfd, doc, tests: combined SRGB/SRLB command
similarly to what was done for IS-IS in commit 01d43141, combine
the SRGB and SRLB commands for OSPF-SR, so that we can replace
overlapping ranges in one sweep change.

Also allow the range configuration to be stored before SR is enabled.
There is no reason why we should not - in fact that constraint meant
that we were always requesting the default label ranges regardless
of what we actually wanted to use.

Finally, update the topotests now that we do not need to refresh
the SRGB/SRLB/MSD after disabling SR. Note that the prefix-sid still
needs to be re-added.

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2021-06-04 17:22:38 +02: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
Donald Sharp
5d8c8d0b1d ospfd: Do not use case default for switches that have enum
Found a couple spots where FRR was using `case default` when
using a switch over an enum.  In this case we *must* enumerate
all states as part of the switch.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-04 09:03:27 -04:00
Olivier Dugeon
270e66a2ce ospfd: Correct Segment Routing prefix bugs
This patch solves 2 Segment Routing prefix bugs:

- If Segment Routing is not enabled in the initial configuration, Extended
  Prefix Opaque LSA is not flood. This is due to a control flag which is
  set only when Segment Routing is enabled at startup and not latter.
- Attempting to modify Segment Routing prefix flag e.g. adding or removing
  no-php or explicit-null flag, doesn't work as expected: Corresponding entry
  in the MPLS table is not updated, Extended Prefix Opaque LSA carry wrong flag
  value, and neighbor set a wrong configuration in the MPLS table for this
  Segment Routing prefix.

The first bug is corrected in ospfd/ospf_ext.c:

- Flag setting is moved from ospf_ext_ism_change() to set_ext_prefix() function

The seconf one is corrected in ospfd/ospf_sr.c:

- For self node, previous MPLS entry is removed if needed and flag reset before
  setting the new Segment Routing prefix configuration
- For neighbor node, srnext field of sr_prefix structure is always set and not
  only for new SR Prefix.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-03-09 11:14:32 +01:00
Olivier Dugeon
56981b40e9 ospfd: Debug race condition in Segment Routing
Issue #7926 hilight a race condition in Segment Routing processing.

The problem occurs when Router Information Opaque LSA is received late, in
particular after SPF run and after ospf_sr_nhlfe_update() was called. This
scenario is unfrequent and takes place due to a slow DR election.
In this particular case, SR Prefix are handle but not fully fill. In fact,
SRGB for the nexthop is not yet received and thus, output label could not
be computed.

When Router Information Opaque LSA is received and processed, if the
corresponding SR node is a direct neighbor of the self node, update_out_nhlfe()
is called against all SR nodes to adjust SR prefix if the next hop is the new
SR node. The function wrongly computes output label and configure a bad MPLS
LFIB entries.

Another way to hilight the problem is to change through CLI the SRGB of a node
and look to MPLS LFIB of direct neighbor, in particular those who announce
EXPLICIT NULL Prefix SID.

This patch correct the update_out_nhlfe() function by calling the appropriate
function (sr_prefix_out_label() instead of index2label()) to compute the output
label.

Some log debugs were adjusted and unused prefix route table was removed too.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-02-11 14:52:40 +01:00
GalaxyGorilla
cc1725bd34 ospfd: Make use of adjacency SIDs in TI-LFA
When P and Q spaces are adjacent then it makes sense to use adjacency SIDs to
from the P node to the Q node. There are some other corner cases where this
makes also sense like when a P/Q node adjacent to root node.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-01-19 15:32:13 +00:00
GalaxyGorilla
7fd0729f76 ospfd: TI-LFA basic infrastructure and algorithms
Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2021-01-19 15:32:13 +00:00
Donald Sharp
4d347f0cb6
Merge pull request #7380 from Orange-OpenSource/ospf-sr
Add more Segment Routing controls
2020-10-23 21:28:06 -04:00
Olivier Dugeon
a351b3e4d2 ospfd: Add more Segment Routing controls
When Segment Routing is not enabled, some related output messages are
printed on the console especially when Segment Routing Debug is enabled.

This patch adds additional controls to check whether segment routing
is enabled or not.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-10-23 19:01:15 +02:00
Mark Stapp
5047884528 *: unify thread/event cancel macros
Replace all lib/thread cancel macros, use thread_cancel()
everywhere. Only the THREAD_OFF macro and thread_cancel() api are
supported. Also adjust thread_cancel_async() to NULL caller's pointer (if
present).

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-10-23 12:16:52 -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
Olivier Dugeon
edb368e930 ospfd: Store neighbor Adjacency SID in SR database
For TI-LFA, it is necessay to known the Adjacency SID advetise by the nieghbor
routers. However, the current Segment Routing code skip neighbor Adjacency SID
and thus, don't store them into the Segment Routing database.

This PR takes care of neighbor Adjacency SID by allowing to store them in the
Segment Routing database. Corresponding MPLS table entry is only configured if
the advertised Adjacency SID is global i.e. with L-Flag unset.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-10-14 14:17:58 +02:00
Olivier Dugeon
83df36e845 ospfd: Coverity corrections
Following PR #6726, Coverity Scan detected some new errors in the OSPF Segment
Routing code. This patch corrects them.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-08-26 17:27:16 +02:00
Olivier Dugeon
f786c4d7c9 OSPFd: Explicit Null option for Segment-Routing
Add new option to `segment-routing prefix` command to set the
Explcit Null flag in addition to the No-PHP flag. MPLS LFIB configuration
has been also updated to take into account the Explicit Null flag.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-08-20 15:51:48 +02:00
Olivier Dugeon
6f751f1493 ospfd: Add Segment Routing Local Block
RFC 8665 defines a Segment Routing Local Block for Adjacency SID.
This patch provides the possibility to modify the SRLB as well as
reserved the block range from the Label Manager.

 - Introduce new CLI 'segment-routing local-block'
 - Add local block to SRDB structure
 - Parse / Serialize SRLB in Router Information LSA
 - Update OSPF-SR topotest
 - Update documentation

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-08-20 14:37:40 +02:00
Olivier Dugeon
d81b8e0e1a ospfd: Add Label Manager for Segment Routing
Segment Routing Global Block is now using the Label Manager to reserved
label range. Label Manager connection uses the synchronous mode and dedicated
thread timer is used to establish the connection in safe manner without
blocking OSPFd is the Label Manager is not available.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-08-20 14:33:00 +02:00
GalaxyGorilla
29df0fc749 ospfd: fix processing of SR RI LSAs
Router Information are contained in opaque LSAs and when such a LSA
is received a new SR node for the advertising router is created.

However, the RI related data is currently not set when such a SR node
already exists. This can happen when e.g. link and prefix information
arrive before the RI and therefore an SR node is created.

This is now fixed by setting the data everytime the RI is received,
independent of the SR node already existing or not.

Signed-off-by: GalaxyGorilla <sascha@netdef.org>
2020-08-10 13:52:08 +00: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
Olivier Dugeon
43e7abb555 ospfd: Move Segment Routing Zebra functions
For coherency, move and rename functions that send MPLS labels configurations
from ospf_sr.c to ospf_zebra.c:
 - ospf_zebra_update_prefix_sid()
 - ospf_zebra_delete_prefix_sid()
 - ospf_zebra_send_adjacency_sid()

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-06-03 19:35:47 +02:00
Olivier Dugeon
21baf89aff ospfd: Update Prefix & Adjacency SIDs Management
SIDs are not uninstall in LFIB when ospf adjacenyi or loopback goes down as
self LSA flusing is not handle by ospf_ext_link_lsa_update(). The patch
introduces new functions ospf_sr_ext_itf_add() and ospf_sr_ext_itf_delete() in
ospf_sr.c to directly manage LFIB for SIDs when change is detected in
ospf_ext_link_ism_change() and ospf_ext_link_nsm_change().

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-06-03 19:35:47 +02:00