summaryrefslogtreecommitdiff
path: root/ospfd/ospf_te.c
AgeCommit message (Collapse)Author
2024-05-23ospfd: protect call to get_edge() in ospf_te.cOlivier Dugeon
During fuzzing, Iggy Frankovic discovered that get_edge() function in ospf_te.c could return null pointer, in particular when the link_id or advertised router IP addresses are fuzzed. As the null pointer returned by get_edge() function is not handlei by calling functions, this could cause ospfd crash. This patch introduces new verification of returned pointer by get_edge() function and stop the processing in case of null pointer. In addition, link ID and advertiser router ID are validated before calling ls_find_edge_by_key() to avoid the creation of a new edge with an invalid key. CVE-2024-34088 Co-authored-by: Iggy Frankovic <iggyfran@amazon.com> Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-05-23ospfd: Correct Opaque LSA Extended parserOlivier Dugeon
Iggy Frankovic discovered another ospfd crash when performing fuzzing of OSPF LSA packets. The crash occurs in ospf_te_parse_ext_link() function when attemping to read Segment Routing Adjacency SID subTLVs. The original code doesn't check if the size of the Extended Link TLVs and subTLVs have the correct length. In presence of erronous LSA, this will cause a buffer overflow and ospfd crashes. This patch introduces new verification of the subTLVs size for Extended Link TLVs and subTLVs. Similar check has been also introduced for the Extended Prefix TLV. Co-authored-by: Iggy Frankovic <iggyfran@amazon.com> Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-05-23ospfd: Solved crash in RI parsing with OSPF TEOlivier Dugeon
Iggy Frankovic discovered another ospfd crash when performing fuzzing of OSPF LSA packets. The crash occurs in ospf_te_parse_ri() function when attemping to read Segment Routing subTLVs. The original code doesn't check if the size of the SR subTLVs have the correct length. In presence of erronous LSA, this will cause a buffer overflow and ospfd crash. This patch introduces new verification of the subTLVs size for Router Information TLV. Co-authored-by: Iggy Frankovic <iggyfran@amazon.com> Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-27ospfd: Solved crash in OSPF TE parsingOlivier Dugeon
Iggy Frankovic discovered an ospfd crash when perfomring fuzzing of OSPF LSA packets. The crash occurs in ospf_te_parse_te() function when attemping to create corresponding egde from TE Link parameters. If there is no local address, an edge is created but without any attributes. During parsing, the function try to access to this attribute fields which has not been created causing an ospfd crash. The patch simply check if the te parser has found a valid local address. If not found, we stop the parser which avoid the crash. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2024-02-15ospfd: Fix assignment with never being usedDonald Sharp
SA finds this: error 14-Feb-2024 14:52:24 ospfd/ospf_te.c:3962:2: warning: Value stored to 'sub' is never read [deadcode.DeadStores] error 14-Feb-2024 14:52:24 sub = 0; error 14-Feb-2024 14:52:24 ^ ~ error 14-Feb-2024 14:52:24 1 warning generated. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-12ospfd: Decode TE TLVs for json outputOlivier Dugeon
When dumping ospf database with json output, decode Traffic Engineering TLVs and sub-TLVs. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-12-14ospfd: Correct LSA parser which fulfill the TEDOlivier Dugeon
Traffic Engineering Database (TED) is fulfill from the various LSA advertised and received by the router. To remove information on the TED, 2 mechanisms are used: i) parse TE Opaque LSA when there are flushed and ii) compare the list of prefixes advertised in the Router LSA with the list of corresponding edges and subnets contained in the TED. However, this second mechanism assumes that the Router LSA is unique and contains all prefixes of the advertised router. But, this is wrong. Prefixes could be advertised with several Router LSA. This conduct to remove edge and subnet in the TED while it should be maintained. The result is a faulty test with ospf_sr_te_topo1 topotest when server is heavy loaded. This simple patch removed deletion of edges and subnets when parsing the Router LSA and only removed them when the corresponding TE Opaque LSA is flushed. In addition, TE Opaque LSA are not flushed when OSPF ajacency goes down. This patch also correct this second problem. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-20Merge pull request #12933 from Orange-OpenSource/link_statePhilippe Guibert
lib: Update edge key in link state database
2023-04-18ospfd: Force Opaque LSA & co to default VRFOlivier Dugeon
Ospf segfault when Router Information is enabled in a non default VRF, see issue #13144. This patch forces vrf_id to default VRF for Opaque LSA and extension based on Opaque LSA: Router Information, Traffic Engineering, Extended Prefix, Extended Link and Segment Routing. Indeed, non default VRF is not yet supported for Opaque LSA & co. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-07ospfd: Update TE to new Link State Edge keyOlivier Dugeon
Following the modification of the edge key in link state database this patch updates the ospf_te.c file to replace the old uint64_t edge key by the new ls_edge_key structure. For ospf, only IPv4 address is take into account. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-06*: Use a `struct prefix *p` instead of a `struct prefix` in functionsDonald Sharp
When passing a prefix into a function let's pass by address instead of pass by value. Let's save our stack space. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Convert event.h to frrevent.hDonald Sharp
We should probably prevent any type of namespace collision with something else. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24*: Rename thread.[ch] to event.[ch]Donald Sharp
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-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-05-11*: Properly use memset() when zeroingDonatas Abraitis
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-01*: Fix spelling of FollowingDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-31isisd, lib, ospfd, pathd: Null out free'd pointerDonald Sharp
The commands: router isis 1 mpls-te on no mpls-te on mpls-te on no mpls-te on ! Will crash Valgrind gives us this: ==652336== Invalid read of size 8 ==652336== at 0x49AB25C: typed_rb_min (typerb.c:495) ==652336== by 0x4943B54: vertices_const_first (link_state.h:424) ==652336== by 0x493DCE4: vertices_first (link_state.h:424) ==652336== by 0x493DADC: ls_ted_del_all (link_state.c:1010) ==652336== by 0x47E77B: isis_instance_mpls_te_destroy (isis_nb_config.c:1871) ==652336== by 0x495BE20: nb_callback_destroy (northbound.c:1131) ==652336== by 0x495B5AC: nb_callback_configuration (northbound.c:1356) ==652336== by 0x4958127: nb_transaction_process (northbound.c:1473) ==652336== by 0x4958275: nb_candidate_commit_apply (northbound.c:906) ==652336== by 0x49585B8: nb_candidate_commit (northbound.c:938) ==652336== by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64) ==652336== by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250) ==652336== Address 0x6f928e0 is 272 bytes inside a block of size 320 free'd ==652336== at 0x48399AB: free (vg_replace_malloc.c:538) ==652336== by 0x494BA30: qfree (memory.c:141) ==652336== by 0x493D99D: ls_ted_del (link_state.c:997) ==652336== by 0x493DC20: ls_ted_del_all (link_state.c:1018) ==652336== by 0x47E77B: isis_instance_mpls_te_destroy (isis_nb_config.c:1871) ==652336== by 0x495BE20: nb_callback_destroy (northbound.c:1131) ==652336== by 0x495B5AC: nb_callback_configuration (northbound.c:1356) ==652336== by 0x4958127: nb_transaction_process (northbound.c:1473) ==652336== by 0x4958275: nb_candidate_commit_apply (northbound.c:906) ==652336== by 0x49585B8: nb_candidate_commit (northbound.c:938) ==652336== by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64) ==652336== by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250) ==652336== Block was alloc'd at ==652336== at 0x483AB65: calloc (vg_replace_malloc.c:760) ==652336== by 0x494B6F8: qcalloc (memory.c:116) ==652336== by 0x493D7D2: ls_ted_new (link_state.c:967) ==652336== by 0x47E4DD: isis_instance_mpls_te_create (isis_nb_config.c:1832) ==652336== by 0x495BB29: nb_callback_create (northbound.c:1034) ==652336== by 0x495B547: nb_callback_configuration (northbound.c:1348) ==652336== by 0x4958127: nb_transaction_process (northbound.c:1473) ==652336== by 0x4958275: nb_candidate_commit_apply (northbound.c:906) ==652336== by 0x49585B8: nb_candidate_commit (northbound.c:938) ==652336== by 0x495CE4A: nb_cli_classic_commit (northbound_cli.c:64) ==652336== by 0x495D6C5: nb_cli_apply_changes_internal (northbound_cli.c:250) ==652336== by 0x495D23E: nb_cli_apply_changes (northbound_cli.c:268) Let's null out the pointer. After this change. Valgrind no longer reports issues and isisd no longer crashes. Fixes: #10939 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-11-27*: Remove redundand braces for single statement blocksDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25ospfd: Convert vty_out to vty_json for JSONDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-15ospfd: Fix wrong parsing of TE subTLVOlivier Dugeon
Function ospf_te_parse_te() and ospf_te_delete_te() browse TE TLV but also subTLV. The loop that parse the subTLV check that cummulative read data doesn't exceed the total size of the TLV. However, the sum variable that counts the number of read data was wrongly intialize to 0 instead to 4 (i.e. the initial TLV Header size that is located at the TOP of subTLV). This patch adjust accordingly the initial value of the counter. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-10-08ospfd: fix display of plain-text data on "show ... json" commandsRenato Westphal
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-07-01*: Replace IPV4_MAX_PREFIXLEN to IPV4_MAX_BITLENDonatas Abraitis
Just drop IPV4_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-05-19ospfd: New code adds newline to log filesDonald Sharp
FRR is not using newlines in log messages. Remove them. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-19ospfd: Correct Coverity defectsOlivier Dugeon
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-04-28ospfd: Fixed some ASAN errorsErik Kooistra
This fixes 2 asan errors: If we only have a TLV_ROUTER_ADDR don't continue after we skipped it. Fixed length when parsing EXT_TLV_LINK_SIZE. Signed-off-by: Erik Kooistra <me@erikkooistra.nl>
2021-03-23ospfd: Add Link-State supportOlivier Dugeon
This patch allows to store Link State Information received through the various LSAs into a dedicated Traffic Engineering Database (TED). This feature is automatically activated once mpls-te is enabled. A new CLI command `mpls-te export` permits to export the TED to other daemons through the new ZAPI Opaque Link State messages. In complement, a new CLI command `show ip ospf mpls-te database ...` output the contains of the TED to the console. Major modifications take place in ospf_te.[c, h]. File ospf_zebra.c has been modified to handle TED synchronisation request. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-03-23ospfd: Correct Opaque Inter-AS LSA managementOlivier Dugeon
This patch corrects two problems that affect Inter-AS LSA: 1/ Inter-LSA are never flood due to an incorrect setting of specific flag. 2/ When looking to the detail of the OSPF LSA with the command `show ip ospf database opaque-xxx`, it appears that only the Inter-AS advertising router is abble to show the detail of the Inter-AS LSA. Foreign routers are only abble to show the header of this Inster-AS LSA. The problem comes from the registration of Inter-AS management functions which is done only on the advetising router. So, the function `ospf_mpls_te_show_info()` is never call on neighbor routers that have not resgistered Inter-AS management callback functions. First, this patch modify functions `set_linkparams_inter_as()` and `unset_linkparams_inter_as()` to respectively set and unset flags that control the Inter-AS LSA flooding. Flag & Type from `struct mpls_te_link` have been redefined: Flag is used to determine if flooding is AS or not and Type is only used to determine the type of the LSA. Second, this patch register Inter-AS management functions for both AS and Area flooding with a different function for LSA origination as parameter is passed as void and it is mandatory to determine the flooding context: `struct *ospf` for AS flooding and `struct *ospf_area` for Area flooding. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-03-23opsfd: Correct MPLS-TE bug with LSA FlushOlivier Dugeon
When an interface goes down, if it is MPLS-TE enabled, the corresponding TE Opaque LSA is not flushed and continue to be advertised. The problem is due to bugs in ISM and NSM handler functions of ospf_te.c file: - ospf_mpls_te_ism_change(): - flag associated with Link Parameters is reset - ISM_Down state is not correctly handle - ospf_mpls_te_nsm_change(): - flag associated with Link Parameters is reset - NSM_Down and NSM_Delete states are not handle This patch correct this problem. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2021-03-23ospfd: Improve MPLS-TE debugOlivier Dugeon
Add Macro to ospf_te.h to ease debug message in ospf_te.c Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2020-11-16ospfd: reset mpls-te prior to ospf router removalCarlo Galiotto
This commits attempts to fix a problem that occurs when mpls-te gets removed from ospfd config. Mpls-te has an inter-as option, which can be set to Off/Area/AS. Whenever the inter-as takes "Area" or "AS" as a value, this value will not be cleaned after removing mpls-te or after removing the ospf router. Therefore, if mpls-te is configured with inter-as AS or Area and we remove mpls-te or the ospf router, the inter-as will still preserve its value; therefore, next time mpls-te is enabled, it will automatically inherits the previous inter-as value (either Area or AS). This leads to wrong configuration, which can be a problem for frr_reload.py. The commits forces mpls-te to reset inter-as to Off before it mpls-te gets removed from the configuration and before the ospf router gets removed. Signed-off-by: Carlo Galiotto <carlo@voltanet.io>
2020-10-22ospfd: replace inet_ntoaMark Stapp
Stop using inet_ntoa, use %pI4 etc or inet_ntop instead Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-04-08*: Do not cast to the same typeDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-24*: remove tabs from log messagesDavid Lamparter
Some logging systems are, er, "allergic" to tabs in log messages. (RFC5424: "The syslog application SHOULD avoid octet values below 32") Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-12-02*: generously apply constDavid Lamparter
const const const your boat, merrily down the stream... Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-23Revert "Ospf missing interface handling 2"Donald Sharp
2019-06-12*: change if_lookup_by_name() api with vrfPhilippe Guibert
the vrf_id parameter is replaced by struct vrf * parameter. this impacts most of the daemons that look for an interface based on the name and the vrf identifier. Also, it fixes 2 lookup calls in zebra and sharpd, where the vrf_id was ignored until now. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-29ospfd: initialize maybe-uninitialized boolQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-04-30ospfd: Correct Link-ID and Remote IP for TE LSAOlivier Dugeon
Solve issue #4198 Link-ID and Remote IP address must be set accordingly to the interface type (Point-to-Point or Broadcast) from the neighbor information. However, this information are only valid once the Network State Machine (NSM) is Full i.e. when the adjacency is up. The original TE code only look to Interface State Machine (ISM) change which not allow to collect valid neighbor information. The patch move setup of Link-ID and Remote-IP TE parameters from ospf_mpls_te_ism_change() to ospf_mpls_te_nsm_change() function. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2019-01-24Treewide: use ANSI function definitionsRuben Kerkhof
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2018-12-10ospfd: remove call to if_lookup_all_vrfPhilippe Guibert
so as to isolate ospf contexts separately for each vrf, the interface used is cornered to the passed vrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-11-09ospf: unregister mpls-te inter-as only if mpls-te is enabledDmitrii Turlupov
Signed-off-by: Dmitrii Turlupov <dturlupov@factor-ts.ru>
2018-10-25*: spelchekDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02*: list_delete_and_null() -> list_delete()David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-24ospfd: remove unnecessary housekeeping code when using linked listsRenato Westphal
The head and tail pointers of linked lists should never be modified manually, the linked list API guarantees that these pointers are always valid and up-to-date. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-09-13ospfd: OSPF_[ERR|WARN] -> EC_OSPFQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06*: style for flog_warn conversionsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06ospfd: Add OSPF_WARN_LSA_INSTALL_FAILURE error codeDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06ospfd: Convert ospf_te.c to use new error-card subsystemDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06ospfd: Add OSPF_WARN_OPAQUE_REGISTRATIONDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-09-06ospfd: Cleanup some warnings that were not warningsDonald Sharp
1) stream allocation cannot fail 2) some warnings were removed when functions safely ignored the calling parameters being wrong. 3) some warnings were removed when functions did not consider the state as an error since we did not return an error code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>