Commit Graph

248 Commits

Author SHA1 Message Date
Donald Sharp
dd2bc4fb40 ospfd: Respect loopback's cost that is set and set loopback costs to 0
When setting an loopback's cost, set the value to 0, unless the operator
has assigned a value for the loopback's cost.

RFC states:

If the state of the interface is Loopback, add a Type 3
link (stub network) as long as this is not an interface
to an unnumbered point-to-point network. The Link ID
should be set to the IP interface address, the Link Data
set to the mask 0xffffffff (indicating a host route),
and the cost set to 0.

FRR is going to allow this to be overridden if the operator specifically
sets a value too.

Fixes: #13472
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-05-10 08:35:45 -04:00
Jafar Al-Gharaibeh
f61cd36ada ospfd: handle type-7 routes
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2023-04-18 00:48:16 -05:00
Donald Sharp
6a5d103257
Merge pull request #13269 from Keelan10/ospf_lsa-memory-leak
ospfd: Fix ospf_lsa memory leak
2023-04-12 11:39:26 -04:00
Keelan10
c0ccfbfd45 ospfd: Fix ospf_lsa memory leak
Free translated LSA when LSA installation fails

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-04-12 13:52:08 +04:00
Renato Westphal
0bdd28850e ospfd: remove duplicated code
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-31 19:28:15 -03:00
Renato Westphal
017714e3ad ospfd: implement Type-7 default routes for NSSA areas
Add the "default-information-originate" option to the "area X nssa"
command. That option allows the origination of Type-7 default routes
on NSSA ABRs and ASBRs.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2023-03-31 19:28:15 -03:00
Jafar Al-Gharaibeh
06f54ff416
Merge pull request #12953 from donaldsharp/struct_event
Struct event
2023-03-24 13:48:53 -05:00
Donald Sharp
d54d0ead76
Merge pull request #13093 from manojvn/ospf_mem_leaks
ospfd: Fix for memory leak issue in ospf related to flood_reduction tests.
2023-03-24 10:23:18 -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
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
70c35c11f2 *: Convert thread_should_yield and thread_set_yield_time
Convert thread_should_yield and thread_set_yield_time
to event_should_yield and event_set_yield_time

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp
8c1186d38e *: Convert thread_execute to event_execute
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
Manoj Naragund
1746f71bc8 ospfd: Fix for memory leak issue in ospf related to flood_reduction tests.
Problem:
Multiple memory leaks after pr12366

RCA:
ospf_lsa_unlock was not happening for the few of the LSAs in
ospf_lsa_refresh_walker after pr12366 due to which memory
related to lsas was leaking.

Fix:
Moved the ospf_lsa_unlock outside if check.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-03-23 05:59:38 -07:00
rgirada
c8c1a240ab ospfd: Fixing Summary origination after range configuration
Description:
	After area range config, summary lsas are aggerated to configured
	route but later it was being flushed instead of the actual summary
	lsa. This was seen when prefix-id of the aggregated route is same
	as one of the actual summary route.
	Here, aggregated summary lsa need to be returned to set the flag
	SUMMARY_APPROVE after originating aggregated summary lsa but its not.
	Which is being cleaned up as part of unapproved summary cleanup.
	Corrected this now.

Issue: #13028

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2023-03-21 04:16:37 +00:00
rgirada
e6f3d0811d ospfd: Ospf ABR doesnt Advertise LSA summary
Description:
	OSPF ABR will summarise the networks based on configured range
	and re-advtertise the summarised route. But if configured range
	prefix id is same as one of the subset of routes prefix id then
	as per rcf2328 Appendex-E recommendation, it will prepare the LSID and originate.
	While re-advertising, it is using ospf LSDB instead of area specific
	LSDB which is making it fail to re-advertise the summary lsa.
	Fixed this by passing correct LSDB pointer.

Issue: #12995

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2023-03-17 10:11:28 +00:00
Russ White
62bd2580e3
Merge pull request #12366 from manojvn/ospfv2-flood-reduction
ospfd: Support OSPF Refresh and Flooding Reduction RFC4136.
2023-02-21 08:03:06 -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
Manoj Naragund
516c4c665a ospfd: Core logic implementation.
Description:
Code changes involves.
	1. Count the no.of router LSAs received with DC options bit set,
	   supporting do not age(DNA).
	2. If no of router LSAs received with DC bit set is equal to total
	   no of LSAs in the router lsdb, then all the routers in the
	   area support do not age processing.
	3. Flood the self originated LSAs with DNA flag if all routers in the area
	   supports the feature.
	4. Stop aging of the LSAs recived with DO_NOT_AGE bit set from
	   other routers.
	5. Self originated DO_NOT_AGE lsas will still be aging in their own
	   database.

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2023-01-19 21:03:03 -08:00
Donatas Abraitis
405e1c848f Revert "ospfd: rSPF calc and messaging for optimal route reflection"
This reverts commit a3d3a14c09.
2023-01-17 18:11:56 +02:00
Donatas Abraitis
3228977f58 Revert "ospfd: few fixes in rSPF calc when LSA received from non root node"
This reverts commit 9f2984d97c.
2023-01-17 18:09:55 +02:00
Jafar Al-Gharaibeh
bf8d8a5451 ospfd: fix typo and report the link name in the warning
Submitted-by: Marc Boucher <marc@airvitesse.net>
Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2022-12-12 09:17:27 -06:00
Mobashshera Rasool
ca5997cd01 ospfd: Fix RFC conformance test cases 25.19 and 27.6
Steps to reproduce:
--------------------------
1. ANVL: Establish full adjacency with DUT for neighbor Rtr-0-A on DIface-0 with DUT as DR.
2. ANVL: Listen (for up to 2 * <RxmtInterval> seconds) on DIface-0.
3. DUT: Send <OSPF-LSU> packet.
4. ANVL: Verify that the received <OSPF-LSU> packet contains a Network- LSA for network N1
   originated by DUT, and the LS Sequence Number is set to <InitialSequenceNumber>.
5. ANVL: Establish full adjacency with DUT for neighbor Rtr-0-B on DIface-0 with DUT as DR.
6. ANVL: Listen (for up to 2 * <RxmtInterval> seconds) on DIface-0.
7. DUT: Send <OSPF-LSU> packet.
8. ANVL: Verify that the received <OSPF-LSU> packet contains a new instance of the
   Network-LSA for network N1 originated by DUT, and the LS Sequence Number
   is set to (<InitialSequenceNumber> + 1).

Both the test cases were failing while verifying the initial sequence number for network LSA.

This is because currently OSPF does not reset its LSA sequence number when it is going down.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-11-21 03:19:33 -08:00
Philippe Guibert
e5309c1a6e ospfd: prevent from crashing when processing external lsa
When using debug mode, the ei parameter may be NULL. In that
case, do not display the log trace, otherwise a crash will
happen.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-11-10 15:11:53 +01:00
Jafar Al-Gharaibeh
5ac678c599
Merge pull request #12215 from LabNConsulting/working/lb/ospf-allow-for-zero
ospfd: remove asster on zero length LSA - which is permitted by spec
2022-10-29 16:58:50 -05:00
Lou Berger
15c4dd82db ospfd: remove assert on zero length LSA - which is permitted by spec
Signed-off-by: Lou Berger <lberger@labn.net>
2022-10-28 16:06:14 +00: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
Madhuri Kuruganti
9f2984d97c ospfd: few fixes in rSPF calc when LSA received from non root node
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
Madhuri Kuruganti
a3d3a14c09 ospfd: rSPF calc and messaging for optimal route reflection
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
Donatas Abraitis
cbe4fd18fc
Merge pull request #11864 from manojvn/clis
ospfd: Added clis to change default timers for LSA refresh and maxage remove delay.
2022-09-06 18:32:56 +03:00
Manoj Naragund
b345a3d9b4 ospfd: Added clis to change default timers for LSA refresh and maxage remove delay.
Description:
Added hidden clis that will allow you to reset the default timers
for LSA refresh and LSA maxage remove delay, these will help in testing
LSA refresh scenarios in upcoming OSPFv2 Flood reduction feature(rfc4136).

IETF Link : https://datatracker.ietf.org/doc/html/rfc4136

Signed-off-by: Manoj Naragund <mnaragund@vmware.com>
2022-08-31 23:10:09 -07:00
rgirada
ef151af79b ospfd: crash when router acts as GR helper upon a topo change
Description:
	ospf process is crashing when  the current router acts
	as GR helper and it received a new lsa.

	Here, ospf_lsa_different() is being called without checking
	'old' pointer. It is asserted in ospf_lsa_different() api
	if the 'old' pointer is NULL.

	corrected this by validaing old pointer before calling
	ospf_lsa_different() api.

	back tarce:
	Program terminated with signal SIGABRT, Aborted.
	0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
	[Current thread is 1 (Thread 0x6b84348827c0 (LWP 3155))]
	0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
	1  0x00006b8433aa4801 in __GI_abort () at abort.c:79
	2  0x00006b8433a9439a in __assert_fail_base (fmt=0x6b8433c1b7d8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x162ffc0630bc "l1", file=file@entry=0x162ffc062ff7 "ospfd/ospf_lsa.c", line=line@entry=3520, function=function@entry=0x162ffc0646f0 <__PRETTY_FUNCTION__.18732> "ospf_lsa_different") at assert.c:92
	3  0x00006b8433a94412 in __GI___assert_fail (assertion=assertion@entry=0x162ffc0630bc "l1", file=file@entry=0x162ffc062ff7 "ospfd/ospf_lsa.c", line=line@entry=3520, function=function@entry=0x162ffc0646f0 <__PRETTY_FUNCTION__.18732> "ospf_lsa_different") at assert.c:101
	4  0x0000162ffc008c25 in ospf_lsa_different (l1=l1@entry=0x0, l2=l2@entry=0x162ffe535c60, ignore_rcvd_flag=ignore_rcvd_flag@entry=true) at ospfd/ospf_lsa.c:3520
	5  0x0000162ffc00a8e8 in ospf_lsa_install (ospf=ospf@entry=0x162ffe513650, oi=oi@entry=0x162ffe531c30, lsa=lsa@entry=0x162ffe535c60) at ospfd/ospf_lsa.c:2892
	6  0x0000162ffc059d16 in ospf_flood (ospf=0x162ffe513650, nbr=nbr@entry=0x162ffe52cc90, current=current@entry=0x0, new=new@entry=0x162ffe535c60) at ospfd/ospf_flood.c:429
	7  0x0000162ffc01838f in ospf_ls_upd (size=<optimized out>, oi=0x162ffe531c30, s=<optimized out>, ospfh=<optimized out>, iph=<optimized out>, ospf=<optimized out>) at ospfd/ospf_packet.c:2162
	8  ospf_read_helper (ospf=<optimized out>) at ospfd/ospf_packet.c:3241
	9  ospf_read (thread=<optimized out>) at ospfd/ospf_packet.c:3272
	10 0x00006b843450139c in thread_call (thread=thread@entry=0x7780f42c7480) at lib/thread.c:1692
	11 0x00006b84344cfb18 in frr_run (master=0x162ffe34d130) at lib/libfrr.c:1068

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-08-30 00:48:32 -07:00
sri-mohan1
e6f3b2621b ospfd: changes for code maintainability
these changes are for improving the code maintainability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-08-24 23:34:41 +05:30
Donald Sharp
c33e80d5f7 ospfd: Coverity warns that we could possibly use unininted data
In ospf_handle_exnl_lsa_lsId_chg there is a code path
where that we may be using uninitialized data for decisions.
Doubtful that this happens but let's make it less likely to
even more.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-27 12:17:50 -04:00
Donald Sharp
cccd44f3b1 ospfd: Remove various macros that overlap THREAD_OFF
Let's just use THREAD_OFF consistently in the code base
instead of each daemon having a special macro that needs to
be looked at and remembered what it does.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:27:35 -04:00
anlan_cs
5cf2f9a7ea ospfd: correct one debug info for lsa
The index about slots should be displayed as `slot`. Additionally, adjust format.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-07-20 02:34:59 -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
f526739897 *: Fix spelling of accomodate
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:29:58 -04:00
Donald Sharp
ce5002c659 *: Fix spelling of comparision
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:18:43 -04:00
rgirada
ab31275cf6 ospfd: Default route becomes stale route in nbrs even after flush from originator.
Description:
	Default route is not getting flushed from neighbours though originator
        triggered flush and deleted LSA from its database. It become as stale
        LSA in  neighbours databse forever. This could seen in the following
        sequence of configurations with less than a second interval b/w configs.
        And this could happen only when originator shouldnt have default route
        in its rib so it originates default route only when configure with 'always'
        option.

        step-1:default-information originate always
        step-2:no default-information originate always
        step-3:default-information originate

        In step-1, default route will be originated to AS.
        In step-2, default route will be flushed to AS, but neighbours will be
                   discarding this update due to minlsainterval condition.
                   And it is expected that DUT need to keep send this update
                   until it receives the ack from neighbours by adding each
                   neighbour's retransmission list.
        In Step-3: It is deleting the lsas from nbr's retransmission list
                   by assuming it initiated the flush. This is cuasing to not
                   send the lsa update anymore to neighbours which makes
                   stale lsa in nbrs forever.

Fix:
        Allowed to delete the lsa from retransmission list only when lsa is
        not in maxage during flushing procedure.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-03-21 02:55:29 -07:00
rgirada
c16241898a ospfd: NULL passed instead of ei pointer in external lsa origination
Description:
	NULL pointer wrongly passed instead of 'ei' pointer to
	ospf_external_lsa_originate() API in opaque capability enable/disable
	which always make it to fail in origination.
	Corrected it by passing actual ei pointer.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-02-24 09:33:08 -08: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
Russ White
3f544261af
Merge pull request #10293 from rgirada/ospf_lsid
ospfd: Modifying LSID generation algorithm
2022-02-08 08:33:33 -05:00
Donald Sharp
abb1bf8d32 ospfd: Use AF_UNSPEC instead of setting to 0
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-07 13:20:43 -05:00
rgirada
a8c22275fe ospfd: Modifying LSID generation algorithm
Description:
	This LSID alogithm added as per rcf2328 Appendex-E recommendation.
	This applies only for AS-external lsas and summary lsas.

	As an example of the algorithm, consider its operation when the
        following sequence of events occurs in a single router (Router A).

        (1) Router A wants to originate an AS-external-LSA for
            [10.0.0.0,255.255.255.0]:

            (a) A Link State ID of 10.0.0.0 is used.

        (2) Router A then wants to originate an AS-external-LSA for
            [10.0.0.0,255.255.0.0]:

            (a) The LSA for [10.0.0,0,255.255.255.0] is reoriginated using a
                new Link State ID of 10.0.0.255.

            (b) A Link State ID of 10.0.0.0 is used for
                [10.0.0.0,255.255.0.0].

        (3) Router A then wants to originate an AS-external-LSA for
            [10.0.0.0,255.0.0.0]:
            (a) The LSA for [10.0.0.0,255.255.0.0] is reoriginated using a
                new Link State ID of 10.0.255.255.

            (b) A Link State ID of 10.0.0.0 is used for
                [10.0.0.0,255.0.0.0].

            (c) The network [10.0.0.0,255.255.255.0] keeps its Link State ID
                of 10.0.0.255.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-01-22 04:07:59 -08:00
Donald Sharp
ffa484b4bd ospfd: Get default-information originate working for ospf instances
The ospf instance code is not properly handling the default route
when using default-information originate.  This is because
the code is looking for the default route to be saved with an
instance of <ospf instance id> but we always save it as a instance
id of 0.  In fact OSPF asks zebra for the default route as a special
case in instance 0, always.

Here is the correct behavior:

eva# show ip ospf data

OSPF Instance: 3

       OSPF Router with ID (192.168.122.1)

                AS External Link States

Link ID         ADV Router      Age  Seq#       CkSum  Route
0.0.0.0        192.168.122.1      8 0x80000001 0xdb08 E2 0.0.0.0/0 [0x0]

eva# show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

K>* 0.0.0.0/0 [0/100] via 192.168.119.1, enp39s0, 00:02:03

Fixes: #10251
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-01-18 08:39:40 -05:00
Renato Westphal
1bb2674ce4 ospfd: fix incorrect detection of topology changes in helper mode
This commit fixes a rather obscure bug that was causing the GR
topotest to fail on a frequent basis.

RFC 3623 specifies that a router acting as a helper to a restarting
neighbor should monitor topology changes and abort the GR procedures
when one is detected, falling back to normal OSPF operation.

ospfd uses the ospf_lsa_different() function to detect when the
content of an LSA has changed, which is considered as a topology
change. The problem is that ospf_lsa_different() can return true
even when the two LSAs passed as parameters are identical, provided
one LSA has the OSPF_LSA_RECEIVED flag set and the other not.

In the context of the ospf_gr_topo1 test, router rt6 performs
a graceful restart and a few seconds later acts as a helper for
router rt7. When it's acting as a helper for rt7, it still didn't
translate its NSSA Type-7 LSAs, something that happens only after 7
seconds (OSPF_ABR_TASK_DELAY) of the first SPF run. The translated
Type-5 LSAs on its LSDB were learned from the helping neighbors
(rt3 and rt7). It's then possible that the NSSA Type-7 LSAs might
be translated while rt6 is acting as helper for rt7, which causes
the daemon to detect a non-existent topology change only because
the OSPF_LSA_RECEIVED flag is unset in the recently originated
Type-5 LSA.

Fix this problem by ignoring the OSPF_LSA_RECEIVED flag when
comparing LSAs for the purpose of topology change detection.

In short, the bug would only show up when the restarting router
would start acting as a helper immediately after coming back up
(which would be hard to happen in the real world). The topotest
failures became more frequent after commit 6255aad0bc because of
the removal of the 'sleep' calls, which used to give ospfd more time
to converge before start acting as a helper for other routers. The
problem still occurred from time to time though.

Fixes #9983.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 15:31:39 -03:00
Igor Ryzhov
ee1455dd98 lib: change thread_add_* API
Do not return pointer to the newly created thread from various thread_add
functions. This should prevent developers from storing a thread pointer
into some variable without letting the lib know that the pointer is
stored. When the lib doesn't know that the pointer is stored, it doesn't
prevent rescheduling and it can lead to hard to find bugs. If someone
wants to store the pointer, they should pass a double pointer as the last
argument.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-20 20:07:15 +03:00