summaryrefslogtreecommitdiff
path: root/lib/prefix.h
AgeCommit message (Collapse)Author
2023-10-11Revert "lib: add link-state prefixes"Donald Sharp
This reverts commit c8172af6825ad4b10e68b33b8edc22e6e2dc1524. (cherry picked from commit bbe3163a1b4573c76aedb2b766dc1563f2e488fa)
2023-10-11Revert "bgpd, lib: extend the size of the prefix string buffer"Donald Sharp
This reverts commit bdb3fa3b9216aede64c5b982011fb04ef25c67f7. (cherry picked from commit 8b3e765d19158e3be146304d40d0563bf945310d)
2023-09-18bgpd, lib: extend the size of the prefix string bufferLouis Scalbert
BGP Link-State prefixes are special prefixes that contains a lot of data. Extend the length of the prefix string buffer in order to display properly this type of prefixes with the next commits. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-18lib: add link-state prefixesLouis Scalbert
Add to the library the link-state type of prefixes. Link-state prefixes contain much more data than the current prefixes and they only make sense for BGP Link-State. Storing all the data in "struct prefix" is not relevant because it would increase the memory usage of all daemons. Instead a pointer to a structure that contains all the information is used. Printing link-state prefixes can be delegated to a hook function. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-08lib: fixup prefix.h to our standardsDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-19bgpd: Fix coverity for EVPNKantesh Mundaragi
Reported Warning: Compare member by member to check object equality RCA: struct evpn_addr contains padding Authored-by: Kantesh Mundaragi <kmundaragi@vmware.com> Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2023-04-03pim6d: Impelmenting "ipv6 mld join"Abhishek N R
Fixes: #12014 Signed-off-by: Abhishek N R <abnr@vmware.com>
2023-03-21bgpd: Allow peering via 127.0.0.0/8Donatas Abraitis
There are some specific edge-cases when is a need to run FRR and another FRR and/or another BGP implementation on the same box. Relaxing 127.0.0.0/8 for this case might be reasonable. An example below peering via 127.0.0.0/8 between FRR and GoBGP: ``` % ss -ntlp | grep 179 LISTEN 0 4096 127.0.0.1:179 0.0.0.0:* LISTEN 0 128 127.0.0.2:179 0.0.0.0:* % grep 127.0.0.2 /etc/frr/daemons bgpd_options=" -A 127.0.0.1 -l 127.0.0.2" % grep local /etc/gobgp/config.toml local-address-list = ["127.0.0.1"] donatas-pc# sh ip bgp summary IPv4 Unicast Summary (VRF default): BGP router identifier 192.168.10.17, local AS number 65001 vrf-id 0 BGP table version 0 RIB entries 0, using 0 bytes of memory Peers 1, using 725 KiB of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc 127.0.0.1 4 65002 7 7 0 0 0 00:02:02 0 0 N/A Total number of neighbors 1 donatas-pc# ``` Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-02-23lib, bgpd: bmp was not specifying l2vpn afiDonald Sharp
The l2vpn afi was not being properly displayed when a show run was being issued. Add a afi2str_lower function and use it. Fixes: #12867 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-02-21Merge pull request #12248 from pguibert6WIND/bgpasdotRuss White
lib, bgp: add initial support for asdot format
2023-02-10bgpd: support for as notation format for route distinguisherPhilippe Guibert
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>
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-11-28lib: handle visual studio code C/C++ extensionRafael Zalamena
Add some `pragma`s to handle errors that the C/C++ extension is not able to understand. Move `TRANSPARENT_UNION` to `lib/compiler.h` for consistency. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-10-18Merge pull request #8647 from sworleys/DVNI-Config-ChangesDonatas Abraitis
bgpd: EVPN D-VNI L3 RT Config Enhancements
2022-09-22bgpd: Use %pRD for prefix_rd2str()Donatas Abraitis
Convert a bunch of prefix_rd2str() for json/vty stuff. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-23bgpd,lib: route-map/plist matching via type-2/5 routesStephen Worley
Implement the ability to match type-2 and type-5 routes via a route-map and a prefix-list. Add some library code to convert an evpn prefix into a general ipv4/ipv6 prefix for type-2 and type-5 routes. evpn prefix is really just another subtype of prefix so all the info needed can be extracted right there. Add a special handler to bgp_routemap for evpn type routes when applying the outbound route-map. This calls the library code to convert the evpn_prefix to a ipv4/ipv6 prefix and run it through the plist code. In this we assume type-2 routes are a /32. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2022-07-12pimd: Fix description for PIM_SG_LENSarita Patra
Signed-off-by: Sarita Patra <saritap@vmware.com>
2022-07-01lib: Convert ipv4_martian to boolDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-01lib: Allow using IPv4 (Class E) reserved block if enabledDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-21lib: Add an api is_ipv6_global_unicastMobashshera Rasool
Add api is_ipv6_global_unicast to identify whether a given ipv6 address is global unicast or not. Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
2022-06-13bgpd: Wrap IPV4_CLASS_DE into ipv4_unicast_valid() helperDonatas Abraitis
Linux kernel allows (FreeBSD/OpenBSD too) using reserved class E IP ranges. This is a preparation commit that ease the global switch to allow/deny class E IP ranges in FRR. https://datatracker.ietf.org/doc/html/draft-chen-ati-adaptive-ipv4-address-space Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-27lib: prefix unionizationDavid Lamparter
Ahead of May 1st, the workers of the prefix have decided on more unionization. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-27lib: remove unused `struct prefix_ptr`David Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-24lib: prefix_afi() helperDavid Lamparter
Just quick shorthand to get an afi_t from a prefix. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-07lib, pimd: add a bunch of address helpersDavid Lamparter
Just simple helpers to get a scope value, never-forward, and is-SSM for a given address. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-03-18lib, bgpd: changes for EAD-per-ES fragmentationAnuradha Karuppiah
The EAD-per-ES route carries ECs for all the ES-EVI RTs. As the number of VNIs increase all RTs do not fit into a standard BGP UPDATE (4K) so the route needs to be fragmented. Each fragment is associated with a separate RD and frag-id - 1. Local ES-per-EAD - ES route table - {ES-frag-ID, ESI, ET=0xffffffff, VTEP-IP} global route table - {RD-=ES-frag-RD, ESI, ET=0xffffffff} 2. Remote ES-per-EAD - VNI route table - {ESI, ET=0xffffffff, VTEP-IP} global route table - {RD-=ES-frag-RD, ESI, ET=0xffffffff} Note: The fragment ID is abandoned in the per-VNI routing table. At this point that is acceptable as we dont expect more than one-ES-per-EAD fragment to be imported into the per-VNI routing table. But that may need to be re-worked at a later point. CLI changes (sample with 4 VNIs per-fragment for experimental pruposes) - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> root@torm-11:mgmt:~# vtysh -c "show bgp l2vpn evpn es 03:44:38:39:ff:ff:01:00:00:01" ESI: 03:44:38:39:ff:ff:01:00:00:01 Type: LR RD: 27.0.0.21:3 Originator-IP: 27.0.0.21 Local ES DF preference: 50000 VNI Count: 10 Remote VNI Count: 10 VRF Count: 3 MACIP EVI Path Count: 33 MACIP Global Path Count: 198 Inconsistent VNI VTEP Count: 0 Inconsistencies: - Fragments: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 27.0.0.21:3 EVIs: 4 27.0.0.21:13 EVIs: 4 27.0.0.21:22 EVIs: 2 VTEPs: 27.0.0.22 flags: EA df_alg: preference df_pref: 32767 27.0.0.23 flags: EA df_alg: preference df_pref: 32767 root@torm-11:mgmt:~# vtysh -c "show bgp l2vpn evpn es-evi vni 1002 detail" VNI: 1002 ESI: 03:44:38:39:ff:ff:01:00:00:01 Type: LR ES fragment RD: 27.0.0.21:13 >>>>>>>>>>>>>>>>>>>>>>>>> Inconsistencies: - VTEPs: 27.0.0.22(EV),27.0.0.23(EV) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PS: The number of EVIs per-fragment has been set to 128 and may need further tuning. Ticket: #2632967 Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2022-01-17pimd: add more dual-family address bitsDavid Lamparter
Another few definitions to aid in dealing with IPv4 and IPv6. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-01-12pimd: move `%pSG4` to `%pPSG4`David Lamparter
Since this is only used in very few places, moving it out of the way is reasonable. (`%pSG` will be pim_sgaddr) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-09-14lib,zebra: use more constMark Stapp
Use const in ipX_martian apis, and in some zebra apis. Signed-off-by: Mark Stapp <mjs.ietf@gmail.com>
2021-07-09lib,ospfd,ospf6d: remove duplicated functionRafael Zalamena
Move `is_default_prefix` variations to `lib/prefix.h` and make the code use the library version instead of implementing it again. NOTE ---- The function was split into per family versions to cover all types. Using `union prefixconstptr` is not possible due to static analyzer warnings which cause CI to fail. The specific cases that would cause this failure were: - Caller used `struct prefix_ipv4` and called the generic function. - `is_default_prefix` with signature using `const struct prefix *` or `union prefixconstptr`. The compiler would complain about reading bytes outside of the memory bounds even though it did not take into account the `prefix->family` part. Signed-off-by: Rafael Zalamena <rzalamena@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-07-01*: Replace IPV6_MAX_PREFIXLEN to IPV6_MAX_BITLENDonatas Abraitis
Just drop IPV6_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-29*: unify prefix copyingIgor Ryzhov
There are a few places in the code where we use PREFIX_COPY(_IPV4/IPV6) macro to copy a prefix. Let's always use prefix_copy function for this. This should fix CID 1482142 and 1504610. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-01Merge pull request #8353 from opensourcerouting/llvm-20210327Quentin Young
2021-03-31lib: remove inet6_ntoa apiMark Stapp
Remove inet6_ntoa() - used static buffer, not needed. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-03-27lib: fix transparent_union for clang++David Lamparter
clang does not accept __attribute__((transparent_union)) in C++ source code. We don't need it there anyway so let's just limit it to C. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-09*: remove more sprintf()Quentin Young
Should be just a couple non-development, non-test occurrences of this function left now. Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
2020-11-18lib: fix macro styleIgor Ryzhov
We prefer semicolon in the actual code instead of macro elsewhere in the code. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-10-26bgpd: support for DF election in EVPN-MHAnuradha Karuppiah
DF (Designated forwarder) election is used for picking a single BUM-traffic forwarded per-ES. RFC7432 specifies a mechanism called service carving for DF election. However that mechanism has many disadvantages - 1. LBs poorly. 2. Doesn't allow for a controlled failover needed in upgrade scenarios. 3. Not easy to hw accelerate. To fix the poor performance of service carving alternate DF mechanisms have been proposed via the following drafts - draft-ietf-bess-evpn-df-election-framework draft-ietf-bess-evpn-pref-df This commit adds support for the pref-df election mechanism which is used as the default. Other mechanisms including service-carving may be added later. In this mechanism one switch on an ES is elected as DF based on the preference value; higher preference wins with IP address acting as the tie-breaker (lower-IP wins if pref value is the same). Sample output ============= >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> torm-11# sh bgp l2vpn evpn es 03:00:00:00:00:01:11:00:00:01 ESI: 03:00:00:00:00:01:11:00:00:01 Type: LR RD: 27.0.0.15:6 Originator-IP: 27.0.0.15 Local ES DF preference: 100 VNI Count: 10 Remote VNI Count: 10 Inconsistent VNI VTEP Count: 0 Inconsistencies: - VTEPs: 27.0.0.16 flags: EA df_alg: preference df_pref: 32767 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> torm-11# sh bgp l2vpn evpn route esi 03:00:00:00:00:01:11:00:00:01 *> [4]:[03:00:00:00:00:01:11:00:00:01]:[32]:[27.0.0.15] 27.0.0.15 32768 i ET:8 ES-Import-Rt:00:00:00:00:01:11 DF: (alg: 2, pref: 100) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-09-21*: Remove solaris from FRRDonald Sharp
The Solaris code has gone through a deprecation cycle. No-one has said anything to us and worse of all we don't have any test systems running Solaris to know if we are making changes that are breaking on Solaris. Remove it from the system so we can clean up a bit. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-08-21lib: add family attribute for flowspec prefix structurePhilippe Guibert
to recognize whether a flowspec prefix has been carried out by ipv4 flowspec or ipv6 flowspec ( actually, the hypothesis is that only ipv4 flowspec is supported), then a new attribute should contain the family value: AF_INET or AF_INET6. That value will be further used in the BGP flowspec code. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-05bgpd, lib: move EVPN route type def to lib and use it in the prefix macrosAnuradha Karuppiah
Use route names instead of route type number in the EVPN prefix macros. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05lib, bgpd: Remove unused variable from structureDonald Sharp
The `struct evpn_ead_addr` structure had a prefix length associated with it. This value was only ever set never used. Remove this from our system. The other nice thing about this change is that it puts back the sizeof struct route_node to 192 bytes. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-08-05bgpd: support for Ethernet Segments and Type-1/EAD routesAnuradha Karuppiah
This is the base patch that brings in support for Type-1 routes. It includes support for - - Ethernet Segment (ES) management - EAD route handling - MAC-IP (Type-2) routes with a non-zero ESI i.e. Aliasing for active-active multihoming - Initial infra for consistency checking. Consistency checking is a fundamental feature for active-active solutions like MLAG. We will try to levarage the info in the EAD-ES/EAD-EVI routes to detect inconsitencies in access config across VTEPs attached to the same Ethernet Segment. Functionality Overview - ======================== 1. Ethernet segments are created in zebra and associated with access VLANs. zebra sends that info as ES and ES-EVI objects to BGP. 2. BGP advertises EAD-ES and EAD-EVI routes for the locally attached ethernet segments. 3. Similarly BGP processes EAD-ES and EAD-EVI routes from peers and translates them into ES-VTEP objects which are then sent to zebra as remote ESs. 4. Each ES in zebra is associated with a list of active VTEPs which is then translated into a L2-NHG (nexthop group). This is the ES "Alias" entry 5. MAC-IP routes with a non-zero ESI use the alias entry created in (4.) to forward traffic i.e. a MAC-ECMP is done to these remote-ES destinations. EAD route management (route table and key) - ============================================ 1. Local EAD-ES routes a. route-table: per-ES route-table key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP) b. route-table: per-VNI route-table Not added c. route-table: global route-table key: {RD=ES-RD, ESI, ET=0xffffffff) 2. Remote EAD-ES routes a. route-table: per-ES route-table Not added b. route-table: per-VNI route-table key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP) c. route-table: global route-table key: {RD=ES-RD, ESI, ET=0xffffffff) 3. Local EAD-EVI routes a. route-table: per-ES route-table Not added b. route-table: per-VNI route-table key: {RD=0, ESI, ET=0, VTEP-IP) c. route-table: global route-table key: {RD=L2-VNI-RD, ESI, ET=0) 4. Remote EAD-EVI routes a. route-table: per-ES route-table Not added b. route-table: per-VNI route-table key: {RD=0, ESI, ET=0, VTEP-IP) c. route-table: global route-table key: {RD=L2-VNI-RD, ESI, ET=0) Please refer to bgp_evpn_mh.h for info on how the data-structures are organized. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05lib: prefix: Add VTEP-IP to the EAD route prefixAnuradha Karuppiah
In the global evpn routing table RD is part of the key. However in the per-VNI routing table the key doesn't include the RD and we need more than the ESI to distinguish between EAD routes from different VTEPs attached to the same Ethernet Segment. This commit also includes other definitions needed for managing an ESI. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-07-14lib: add %pEA for struct ethaddr *David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-06-22lib: clarify usage of prefix_bit functionQuentin Young
"prefixlen" is really a bit index Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-06-15lib: prefix: add prefix_rd typestreambinder
Signed-off-by: streambinder <posta@davidepucci.it>
2020-04-30lib: constify a few parameters of helper functionsRenato Westphal
Parameters should be const whenever possible to improve code readability and remove the need to cast away the constness of const arguments. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-03-29lib: prepare for plugin-based frr_format checkDavid Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>