summaryrefslogtreecommitdiffstats
path: root/bgpd/rfapi/rfapi_rib.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* bgpd: fix labels static-analyserLouis Scalbert2024-08-261-1/+1
| | | | | | | | | | | Fix static-analyser warnings with BGP labels: > $ scan-build make -j12 > bgpd/bgp_updgrp_packet.c:819:10: warning: Access to field 'extra' results in a dereference of a null pointer (loaded from variable 'path') [core.NullDereference] > ? &path->extra->labels->label[0] > ^~~~~~~~~ Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
* bgpd: move labels from extra to extra->labelsLouis Scalbert2024-06-051-1/+1
| | | | | | | Move labels from extra to extra->labels. Labels are now stored in a hash list. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
* bgpd: add bgp_path_info_num_labels()Louis Scalbert2024-06-051-1/+1
| | | | | | | Add bgp_path_info_num_labels() to get the number of labels stored in a path_info structure. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
* bgpd: check and set extra num_labelsLouis Scalbert2024-06-051-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The handling of MPLS labels in BGP faces an issue due to the way labels are stored in memory. They are stored in bgp_path_info but not in bgp_adj_in and bgp_adj_out structures. As a consequence, some configuration changes result in losing labels or even a bgpd crash. For example, when retrieving routes from the Adj-RIB-in table ("soft-reconfiguration inbound" enabled), labels are missing. bgp_path_info stores the MPLS labels, as shown below: > struct bgp_path_info { > struct bgp_path_info_extra *extra; > [...] > struct bgp_path_info_extra { > mpls_label_t label[BGP_MAX_LABELS]; > uint32_t num_labels; > [...] To solve those issues, a solution would be to set label data to the bgp_adj_in and bgp_adj_out structures in addition to the bgp_path_info_extra structure. The idea is to reference a common label pointer in all these three structures. And to store the data in a hash list in order to save memory. However, an issue in the code prevents us from setting clean data without a rework. The extra->num_labels field, which is intended to indicate the number of labels in extra->label[], is not reliably checked or set. The code often incorrectly assumes that if the extra pointer is present, then a label must also be present, leading to direct access to extra->label[] without verifying extra->num_labels. This assumption usually works because extra->label[0] is set to MPLS_INVALID_LABEL when a new bgp_path_info_extra is created, but it is technically incorrect. Cleanup the label code by setting num_labels each time values are set in extra->label[] and checking extra->num_labels before accessing the labels. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
* bgpd: Save memory when using bgp_path_info_extra and vncDonald Sharp2024-02-011-14/+15
| | | | | | | | | | | | Structure size of bgp_path_info_extra when compiled with vnc is 184 bytes. Reduce this size to 72 bytes when compiled w/ vnc but not necessarily turned on vnc. With 2 full bgp feeds this saves aproximately 100mb when compiling with vnc and not using vnc. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bgpd: rfapi memleak fixesG. Paul Ziemba2023-04-111-0/+19
| | | | Signed-off-by: G. Paul Ziemba <paulz@labn.net>
* bgpd: Remove set but unused variablesDonald Sharp2023-03-281-15/+0
| | | | | | Found by clang 15. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert THREAD_XXX macros to EVENT_XXX macrosDonald Sharp2023-03-241-11/+11
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Convert thread_add_XXX functions to event_add_XXXDonald Sharp2023-03-241-2/+2
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Rename `struct thread` to `struct event`Donald Sharp2023-03-241-1/+1
| | | | | | | | | 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>
* Merge pull request #12248 from pguibert6WIND/bgpasdotRuss White2023-02-211-3/+3
|\ | | | | lib, bgp: add initial support for asdot format
| * bgpd: support for as notation format for route distinguisherPhilippe Guibert2023-02-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RD may be built based on an AS number. Like for the AS, the RD may use the AS notation. The two below examples can illustrate: RD 1.1:20 stands for an AS4B:NN RD with AS4B=65536 in dot format. RD 0.1:20 stands for an AS2B:NNNN RD with AS2B=0.1 in dot+ format. This commit adds the asnotation mode to prefix_rd2str() API so as to pick up the relevant display. Two new printfrr extensions are available to display the RD with the two above display methods. - The pRDD extension stands for dot asnotation format - The pRDE extension stands for dot+ asnotation format. - The pRD extension has been renamed to pRDP extension The code is changed each time '%pRD' printf extension is called. Possibly, the asnotation may change the output, then a macro defines the asnotation mode to use. A side effect of forging the mode to use is that the string could not be concatenated with other strings in vty_out and snprintfrr. Those functions have been called multiple times. When zlog_debug needs to display the RD with some other string, the prefix_rd2str() old API is used instead of the printf extension. Some code has been kept untouched: - code related to running-config. Actually, wherever an RD is displayed, its configured name should be dumped. - bgp rfapi code - bgp evpn multihoming code (partially done), since the logic is missing to get the asnotation of 'struct bgp_evpn_es'. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* | *: auto-convert to SPDX License IDsDavid Lamparter2023-02-091-14/+1
|/ | | | | | Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* bgpd: Use %pRD for prefix_rd2str()Donatas Abraitis2022-09-221-31/+7
| | | | | | Convert a bunch of prefix_rd2str() for json/vty stuff. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* bgpd: Replace rfapi_time() with monotime()Donald Sharp2022-08-241-8/+8
| | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bgpd: Convert from bgp_clock() to monotime()Donald Sharp2022-08-241-3/+3
| | | | | | | | Let's convert to our actual library call instead of using yet another abstraction that makes it fun for people to switch daemons. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bgpd: Convert thread_cancel to THREAD_OFF and use THREAD_ARGDonald Sharp2022-07-211-11/+11
| | | | | | | | Just convert all uses of thread_cancel to THREAD_OFF. Additionally use THREAD_ARG instead of t->arg to get the arguement. Individual files should never be accessing thread private data like this. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bgpd: rfapi code does not need to assert on memory allocationsDonald Sharp2022-07-191-5/+1
| | | | | | | cleanup memory allocations asserting that it didn't fail as well as clean up some thread shenanigans. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: Avoid casting to the same type as on the leftDonatas Abraitis2022-05-081-3/+2
| | | | | | Just not necessary. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
* *: Change thread->func to return void instead of intDonald Sharp2022-02-241-3/+1
| | | | | | | 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>
* Merge pull request #10496 from ton31337/fix/move_struct_ecommunity_to_extraDonald Sharp2022-02-081-3/+4
|\ | | | | bgpd: Use bgp_attr_[sg]et_ecommunity for struct ecommunity
| * bgpd: Use bgp_attr_[sg]et_ecommunity for struct ecommunityDonatas Abraitis2022-02-041-3/+4
| | | | | | | | | | | | This is an extra work before moving attr->ecommunity to attra_extra struct. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* | bgpd: Use AF_UNSPEC instead of setting to 0Donald Sharp2022-02-071-1/+1
|/ | | | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bgpd: Convert attr->vnc_subtlvs to use accessor functionsDonald Sharp2020-11-151-1/+2
| | | | | | Add a get/set accessor functions and use them. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* * : update signature of thread_cancel apiMark Stapp2020-10-231-18/+10
| | | | | | | | 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>
* :* Convert prefix2str to %pFXDonatas Abraitis2020-10-221-33/+12
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* *: Create/Use accessor functions for lock countDonald Sharp2020-10-171-4/+4
| | | | | | | | Create appropriate accessor functions for the rn->lock data. We should be accessing this data through accessor functions since it is private data to the data structure. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: un-split strings across linesDavid Lamparter2020-07-141-3/+1
| | | | | | | | | | | | | | | | | 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>
* *: Do not cast to the same typeDonatas Abraitis2020-04-081-2/+2
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* bgpd: Convert users of `rn->p` to use accessor functionDonald Sharp2020-03-261-2/+4
| | | | | | | | | Add new function `bgp_node_get_prefix()` and modify the bgp code base to use it. This is prep work for the struct bgp_dest rework. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd, lib, ripngd: Add agg_node_get_prefixDonald Sharp2020-03-241-43/+37
| | | | | | | | | Modify code to use lookup function agg_node_get_prefix() as the abstraction layer. When we rework bgp_node to bgp_dest this will allow us to greatly limit the amount of work needed to do that. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd, isisd, lib: Make key values const for skiplistDonald Sharp2020-03-241-3/+3
| | | | | | Make some key values const for the skiplist code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* treewide: fix some issues found with -Werror=undefRuben Kerkhof2020-03-101-8/+8
| | | | Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
* bgpd: agg_node_lookup not unlockingDonald Sharp2020-02-271-0/+1
| | | | | | | | | SA has found a case where we did a table lookup of a rn( and associated lock of that node ) where we did not unlock it. Unlock the node before moving on to the next one. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: `struct bgp_path_info *`->attr must not be NULLDonald Sharp2019-10-161-5/+0
| | | | | | | | We make the assumption that ->attr is not NULL throughout the code base. We are totally inconsistent about application of this though. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* Treewide: use ANSI function definitionsRuben Kerkhof2019-01-241-1/+1
| | | | Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
* bgpd: Rename various variable names to something more appropriateDonald Sharp2018-10-091-31/+31
| | | | | | | | | ri -> pi bi -> bpi info -> path info -> rmap_path ( for routemap applications ) Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: Convert `struct bgp_info` to `struct bgp_path_info`Donald Sharp2018-10-091-4/+4
| | | | | | | | | | | | Do a straight conversion of `struct bgp_info` to `struct bgp_path_info`. This commit will setup the rename of variables as well. This is being done because `struct bgp_info` is not descriptive of what this data actually is. It is path information for routes that we keep to build the actual routes nexthops plus some extra information. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: list_delete_and_null() -> list_delete()David Lamparter2018-10-021-4/+4
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* *: fix config.h/zebra.h include orderDavid Lamparter2018-09-081-2/+0
| | | | | | | | config.h (or, transitively, zebra.h) must be the first include file listed for autoconf things like _GNU_SOURCE and _POSIX_C_SOURCE to work correctly. Signed-off-by: David Lamparter <equinox@diac24.net>
* bgpd, ripngd: Convert to using new agg_table/routeDonald Sharp2018-08-301-100/+109
| | | | | | | | Switch bgp and ripngd to use the new aggregate table and route data structures. This was mainly a search and replace operation. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: Cleanup of bgp daemon codePascal Mathis2018-07-071-1/+0
| | | | | | | | This commit removes various parts of the bgpd implementation code which are unused/useless, e.g. unused functions, unused variable initializations, unused structs, ... Signed-off-by: Pascal Mathis <mail@pascalmathis.com>
* bgpd, lib, zebra: Switch to work_queue_free_and_nullDonald Sharp2018-03-091-4/+2
| | | | | | | | | The work_queue_free function free'd up the wq pointer but did not set it too NULL. This of course causes situations where we may use the work_queue after it is freed. Let's modify the work_queue to set the pointer for you. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-4/+6
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* zebra/bgpd: fix compilation issuesmitesh2018-01-241-1/+1
| | | | Signed-off-by: Mitesh Kanjariya <mitesh@cumulusnetworks.com>
* bgpd: Fixup buffer sizes for prefix_rd2strDonald Sharp2017-12-111-10/+10
| | | | | | | The prefix_rd2str uses a buffer size of RD_ADDRSTRLEN. Modify the code to consistently use this for all of BGP. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: Fix prefix2str using BUFSIZ to PREFIX_STRLENDonald Sharp2017-12-111-30/+31
| | | | | | | | PREFIX_STRLEN is the correct length for buffers needed to output a prefix2str. Additionally cleanup some setting of the last value to a `\0` this is handled by prefix2str. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd: Cleanup unneeded NULL checks.Donald Sharp2017-12-051-9/+6
| | | | | | All the NULL checks come after previous dereferences. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: fix coverity warnings - error handling issuesRenato Westphal2017-10-241-1/+1
| | | | | | | | | | | Ignore the return value of some functions in the places we know they can't fail, and other small fixes. Regarding the change in bgpd/rfapi/rfapi_rib.c, asserting that rfapiRaddr2Qprefix() didn't fail is the common idiom inside the rfapi code. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* *: Convert list_delete(struct list *) to ** to allow nullingDonald Sharp2017-10-051-8/+7
| | | | | | | | | | | | | | | | | | | Convert the list_delete(struct list *) function to use struct list **. This is to allow the list pointer to be nulled. I keep running into uses of this list_delete function where we forget to set the returned pointer to NULL and attempt to use it and then experience a crash, usually after the developer has long since left the building. Let's make the api explicit in it setting the list pointer to null. Cynical Prediction: This code will expose a attempt to use the NULL'ed list pointer in some obscure bit of code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>