summaryrefslogtreecommitdiff
path: root/bgpd/bgp_label.c
AgeCommit message (Collapse)Author
2023-11-13bgpd: Used %pBD instead of %pRNDonald Sharp
Let's use the natural data structure in bgp for the prefix display instead of a bunch of places where we call a translator function. The %pBD does this and actually ensures data is correct. Also fix a few spots in bgp_zebra.c where the cast to a NULL pointer causes the catcher functionality to not work and fix the resulting crash that resulted. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-11bgpd: bgp_reg_for_label_callback ensure dest existDonald Sharp
More dest may be freed so let's ensure it is not. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-06-16bgpd: add a function to compare two label listsPhilippe Guibert
Create a bgp_labels_same() function that does the same operations as the static function labels_same from bgp_mplsvpn.c. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.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-03-05bgpd: Do not send notification twice when parsing NLRI labelsDonatas Abraitis
This is already handled in bgp_nlri_parse() by checking error code. Even more, we should send error sub-code to be according the NLRI type. If it's MP_UPDATE/MP_WITHDRAW, sub-code should be an Optional Attribute error. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-03-03bgpd: Fix use beyond end of stream of labeled unicast parsingDonald Sharp
Fixes a couple crashes associated with attempting to read beyond the end of the stream. Reported-by: Iggy Frankovic <iggyfran@amazon.com> Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-21bgpd: Drop struct attr from bgp_withdraw()Donatas Abraitis
It's not used at all. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
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-06-01bgpd: Drop label_ntop/label_pton functionsDonatas Abraitis
Start using mpls_lse_encode/mpls_lse_decode, that is endian-aware, because we always use host-byte order, should use network-byte. Signed-off-by: Donatas Abraitis <donatas@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-03-31bgpd: Add `%pBP` printfrr() extension to print `IP(hostname)` for BGP peerDonatas Abraitis
Replace existing bgp_peer_hostname() function. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-02-01bgpd: Convert bgp_addpath_encode_[tr]x() to bool from intDonatas Abraitis
Rename addpath_encode[d] to addpath_capable to be consistent. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-12-01bgpd: clearer safi handling for BGP-LU route updatesMark Stapp
Don't hide the LABELED_UNICAST safi when processing route updates; map it where necessary (to use the UNICAST table for instance). Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2021-10-08bgpd: BGP-LU use implicit-null in some casesMark Stapp
In some cases where bgp is at the mpls edge, where it has a BGP-LU peer downstream but an IP peer upstream, it can advertise the IMPLICIT_NULL label instead of a per-prefix label. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
2021-07-01*: Convert numeric 32 into IPV4_MAX_BITLEN for prefixlenDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01*: Convert numeric 128 into IPV6_MAX_BITLEN for prefixlenDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-22bgpd: Make sure we don't miss to unlock for bgp_dest before returningDonatas Abraitis
bgp_node_lookup() increases `lock` which is not decreased on return. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-03-09bgpd: Convert remaining string output to our internal typesDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-01-04bgpd: release label to labelpool on deregPat Ruddy
when we de-register for a label associated with a prefix then release it back to the labelpool to clean up the stale reference held in the ledger and inuse lists. Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-01-04bgpd: refactor label allocation codePat Ruddy
To prepare for fixing an issue where labels do not get released back to the labelpool when the route is deleted some refactoring is necessary. There are 2 parts to this. 1. restructure the code to remove the circular nature of label allocations via the labelpool and decouple the label type decision from the notification fo the FEC. The code to notify the FEC association to zebra has been split out into a separate function so that it can be called from the synchronous path (for registration of index-based labels and de-registration of all labels), and from the asynchronous path where we need to wait for a callback from the labelpool code with a label allocation. The decision about whether we are using an index-based label or an allocated label is reflected in the state of the BGP_NODE_LABEL_REQUESTED flag so the checks on the path_info in the labelpool callback code are no longer required. 2. change the owned of a labelpool allocated label from the path info structure to the bgp_dest structure. This allows labels to be released (in a subsequent commit) when the owner (bgp_dest) goes away. Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-10-22:* Convert prefix2str to %pFXDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-18bgpd: Convert inet_ntoa to %pI4/inet_ntopDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-07-14*: un-split strings across linesDavid Lamparter
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-06-23bgp: rename bgp_node to bgp_destDonald Sharp
This is the bulk part extracted from "bgpd: Convert from `struct bgp_node` to `struct bgp_dest`". It should not result in any functional change. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-03-29*: fix format string warningsDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-26bgpd: Convert users of `rn->p` to use accessor functionDonald Sharp
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>
2020-01-07bgpd: fix unaligned access to addpath idSantosh P K
uint8_t * cannot be cast to uint32_t * unless the pointed-to address is aligned according to uint32_t's alignment rules. And it usually is not. Signed-off-by: Santosh P K <sapk@vmware.com>
2019-06-24bgpd: fix LU label callback crashEmanuele Di Pascale
under some conditions, the callback to get a label for a LU bgp path could be called after the path had already been freed. In this case we would be reading garbage and potentially crash. Lock the path info before queueing the callback, and unlock as the first step of the callback, exiting gracefully if the path info is now NULL. Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
2019-04-24bgpd: Do not send UPDATE message with maximum-prefixDonatas Abraitis
When using maximum-prefix and count is overflow BGP sends UPDATE message: Apr 15 20:45:06 exit1-debian-9 bgpd[9818]: 192.168.0.2 [Error] Error parsing NLRI Apr 15 20:45:06 exit1-debian-9 bgpd[9818]: %NOTIFICATION: sent to neighbor 192.168.0.2 3/10 (UPDATE Message Error/Invalid Network Field) 0 bytes Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2018-12-20bgpd, zebra: auto assign labels from label pool to regular prefixes in BGP ↵Anton Degtyarev
labeled unicast This commit is the last missing piece to complete BGP LU support in bgpd. To this moment, bgpd (and zebra) supported auto label assignment only for prefixes leaked from VRFs to vpn and for MPLS SR prefixes. This adds auto label assignment to other routes types in bgpd. The following enhancements have been made: * bgp_route.c:bgp_process_main_one() now sets implicit-null local_label to all local, aggregate and redistributed routes. * bgp_route.c:bgp_process_main_one() now will request a label from the label pool for any prefix that loses the label for some reason (for example, when the static label assignment config is removed) * bgp_label.c:bgp_reg_dereg_for_label() now requests labels from label pool for routes which have no associated label index * zebra_mpls.c:zebra_mpls_fec_register() now expects both label and label_index from the calling function, one of which must be set to MPLS_INVALID_LABEL or MPLS_INVALID_LABEL_INDEX, based on this it will decide how to register the provided FEC. Signed-off-by: Anton Degtyarev <anton@cumulusnetworks.com>
2018-10-09bgpd: Rename various variable names to something more appropriateDonald Sharp
ri -> pi bi -> bpi info -> path info -> rmap_path ( for routemap applications ) Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-09bgpd: Convert `struct bgp_info` to `struct bgp_path_info`Donald Sharp
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>
2018-09-13*: style for EC replacementsQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-13bgpd: BGP_[WARN|ERR] -> EC_BGPQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-09-06bgpd: Modify bgp_label to use flog_warnDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-14*: rename zlog_fer -> flog_errQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-08-14bgpd: implement zlog_ferr facility for enhance error messages in bgpDon Slice
Signed-off-by: Don Slice <dslice@cumulusnetworks.com<
2018-07-02bgpd zebra: element overflow (PVS-Studio)F. Aragon
The warning given by PVS-Studio is related to per-element overflow (there is no real overflow, because of how elements are mapped in the union). This same warning is typically reported by Coverity, too. Signed-off-by: F. Aragon <paco@voltanet.io>
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-16bgpd: Clean up peer status checking for a received nlriDonald Sharp
In bgp_update_receive the first thing we do is establish that the peer->status is Established. We then do a bunch of work and call bgp_nlri_parse where we break out for each address family. Each AFI is then checking for being peer->status is Established again. There is no point in checking this again. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-01-23bgpd: carry two MPLS labels in EVPN NLRIsMitesh Kanjariya
When doing symmetric routing, EVPN type-2 (MACIP) routes need to be advertised with two labels (VNIs) the first being the L2 VNI (identifying the VLAN) and the second being the L3 VNI (identifying the VRF). The receive processing needs to handle one or two labels too. Ticket: CM-18489 Review: CCR-6949 Testing: manual and bgp/evpn/mpls smoke Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2017-11-13bgpd, zebra: Ensure that passed flags is 0 for unregister eventDonald Sharp
The flags passed in should be 0 for an unregister event. Ensure that we respect that. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-08bgpd: fix clang warningVincent JARDIN
Remove stored value to llen that is never used. Signed-off-by: Vincent Jardin <vincent.jardin@6wind.com>
2017-07-22Revert "*: reindent pt. 2"David Lamparter
This reverts commit c14777c6bfd0a446c85243d3a9835054a259c276. clang 5 is not widely available enough for people to indent with. This is particularly problematic when rebasing/adjusting branches. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindent pt. 2whitespace / reindent
w/ clang 5 * reflow comments * struct members go 1 per line * binpack algo was adjusted
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-12bgpd: Refactor 'struct attr_extra' into 'struct attr'Donald Sharp
Most of the attributes in 'struct attr_extra' allow for the more interesting cases of using bgp. The extra overhead of managing it will induce errors as we add more attributes and the extra memory overhead is negligible on anything but full bgp feeds. Additionally this greatly simplifies the code for the handling of data. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> bgpd: Fix missing label set Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-06-20bgpd: Install SAFI_LABELED_UNICAST routes in SAFI_UNICAST tableDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
2017-06-16bgpd: Install SAFI_LABELED_UNICAST routes in SAFI_UNICAST tableDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> - All ipv4 labeled-unicast routes are now installed in the ipv4 unicast table. This allows us to do things like take routes from an ipv4 unicast peer, allocate a label for them and TX them to a ipv4 labeled-unicast peer. We can do the opposite where we take routes from a labeled-unicast peer, remove the label and advertise them to an ipv4 unicast peer. - Multipath over a labeled route and non-labeled route is not allowed. - You cannot activate a peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast' - The 'tag' variable was overloaded for zebra's route tag feature as well as the mpls label. I added a 'mpls_label_t mpls' variable to avoid this. This is much cleaner but resulted in touching a lot of code.