Commit graph

41 commits

Author SHA1 Message Date
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 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 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
Iggy Frankovic 826f2510e6 ospf6d: Prevent heap-buffer-overflow with unknown type
When parsing a osf6 grace lsa field and we receive an
unknown tlv type, ospf6d was not incrementing the pointer
to get beyond the tlv.  Leaving a situation where ospf6d
would parse the packet incorrectly.

Signed-off-by: Iggy Frankovic <iggy07@gmail.com>
2024-05-30 08:02:25 -04:00
Donatas Abraitis 8f7bc620b5 ospfd, ospf6d: Remove deprecated JSON fields
restartSupoort

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-04-11 13:34:17 +03:00
Donatas Abraitis 02d8b80ce4 *: Do not cast to the same type as the destination is
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-09-29 10:24:16 +03:00
Donald Sharp 0cbd5855a9 ospf6d: Convert ospf6_lsa_unlock to a better api
Make the ospf6_lsa_unlock take the same parameters
that the ospf_lsa_unlock does to make it consistent
and to also ensure that no-one can make the mistake
of getting the pointer cleared up.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-12 17:56:29 -04:00
Mark Stapp a63fecfb56 ospf,ospf6: fix json key typo supoort
Fix json key 'supoort' -> 'support'; add 1-year deprecation
notice; fix topotests to use corrected json key.

Signed-off-by: Mark Stapp <mjs@labn.net>
2023-04-07 16:19:01 -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 4f830a0799 *: Convert thread_timer_remain_XXX to event_timer_remain_XXX
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 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
Donatas Abraitis ba427e6348 ospfd, ospf6d: Add more logging details
Basically just router-id or interface/IP.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-17 10:14:26 +02: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
Donatas Abraitis 1ce23106eb *: Drop deprecated incorrect JSON fields with wrong naming
Deprecation cycle already passed.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-31 10:18:28 +02:00
David Lamparter 89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
rgirada 239ccb07f2 ospf6d: adding missing json fields
Description:
	Active GR count field is missing in json o/p
	of 'show ipv6 ospf gr helper' command.

Issue: #12100

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2022-10-18 05:51:18 +00:00
sri-mohan1 abc14fa02b ospf6d: corrected the debug string
Corrected the gramatical error for debug string

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2022-07-27 22:29:02 +05:30
Donald Sharp c905f04c7c ospf6d: Clean up thread interface
a) Remove setting of thread pointer to NULL after
thread invocation, this is already done.

b) Use thread_is_scheduled()

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-20 09:52:16 -04:00
anlan_cs 905b12b263 ospf6d: add header size check for LSA
Add header size check for safe. If the check fails, just jump out of current
function.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-10 10:03:57 -04: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 7baebfb715
Merge pull request #10447 from ton31337/fix/json_with_whitespaces
*: Fix JSON keys with whitespaces and PascalCase
2022-03-13 18:19:33 -04: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 77a2f8e592 *: Add camelCase JSON keys in addition to PascalCase
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-03 10:48:06 +02: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 5a6c232bf8 ospf6d: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:50:37 +02:00
rgirada 6d1a5a1c54 ospf6d: Addressing few coverity issues.
Description:
	Addressed the following TAINTED_SCALAR issue which can possibly
	leads to memory currption.

	1. *** CID 1506514:  Insecure data handling  (TAINTED_SddddddCALAR)
	   /ospf6d/ospf6_gr_helper.c: 1222 in ospf6_grace_lsa_show_info()

	2. *** CID 1506513:  Insecure data handling  (TAINTED_SCALAR)
	   /ospf6d/ospf6_gr_helper.c: 160 in ospf6_extract_grace_lsa_fields()

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-10-29 11:04:06 -07: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
Renato Westphal 6b513b4c92 ospf6d: rename the "graceful-restart helper-only" command
Considering that both the GR helper mode and restarting mode can be
enabled at the same time, the "graceful-restart helper-only" command
can be a bit misleading since it implies that only the helper mode
is enabled. Rename the command to "graceful-restart helper enable"
to clarify what the command does.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-09-21 11:51:36 -03: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
Igor Ryzhov 390dce1275 ospf6d: fix possible NULL dereference
OSPF6_CMD_CHECK_RUNNING doesn't check that ospf6 is not NULL.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-15 13:48:29 +03:00
Renato Westphal 3ebc5e4be9 ospf6d: fix display of debug command in the running configuration
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-08-31 01:48:22 -03:00
Mark Stapp ea5e814cf7
Merge pull request #9457 from anlancs/ospf6-void
ospf6d: suppress coverity warning of return value
2021-08-24 15:30:45 -04:00
anlan_cs 37692712a5 ospf6d: fix lock leak of using ALL_LSDB in GR helper
The lsa and lsanext must be unlocked if break out of ALL_LSDB loop.

Incidentally correct the comment of ALL_LSDB.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-08-22 05:26:20 -04:00
anlan_cs 4d97dde2d1 ospf6d: suppress coverity warning of return value
Fix #CID 1506511

Signed-off-by: anlan_cs <anlan_cs@tom.com>
2021-08-21 22:04:12 -04:00
rgirada 0fc3e11323 ospf6d: GR helper configurations
Description:
	Adding the following cli commands to enable/disable GR helper
	functionality.
	1. [no] graceful-restart helper-only [A.B.C.D]
	2. [no] graceful-restart helper lsa-check-disable
	3. [no] graceful-restart helper planned-only
	4. [no] graceful-restart helper supported-grace-time (10-1800)

	show commands:
	show ipv6 ospf6 graceful-restart helper [detail] [json]

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-11 23:06:49 -07:00
rgirada 9a06f23d0b ospf6d: GR helper exit scenarios
Description:
	Changes to cover all the following  GR helper exit scenarios.
	1. Upon receiving max age grace lsa.( successful graceful restart)
	2. Topo change
	3. Grace timer expiry.
	4. User changes( like config deletion , interface down)

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00
rgirada 0d1753a7db ospf6d: Helper functionality changes
Description:
	1. changes to process GRACE LSA packet.
	2. Validation changes to enter Helper role.
	3. Helper functionality during graceful restart.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00
rgirada 0694366601 ospf6d: debug command support for helper support.
Description:
	Adding debug support for helper functionality.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00
rgirada 59790f521a ospf6d: Init/De-init gr helper functionality
Description:
	Graceful restart helper functionality initialisation and deinit apis.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
2021-08-10 02:57:23 -07:00