summaryrefslogtreecommitdiff
path: root/lib/vrf.h
AgeCommit message (Collapse)Author
2025-01-15lib: remove VRF_BACKEND_UNKNOWNIgor Ryzhov
The backend type cannot be unknown. It is configured to VRF_LITE by default in zebra anyway, so just init to VRF_LITE in the lib and remove the UNKNOWN type. Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-13lib: vrf: track oper-state inlineChristian Hopps
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-03-15zebra: fix route deletion during zebra shutdownAlexander Skorichenko
Split zebra's vrf_terminate() into disable() and delete() stages. The former enqueues all events for the dplane thread. Memory freeing is performed in the second stage. Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com>
2024-02-04lib, mgmtd: don't register NB config callbacks in mgmtdIgor Ryzhov
mgmtd is supposed to only register CLI callbacks. If configuration callbacks are registered, they are getting called on startup when mgmtd reads config files, and they can use infrastructure that is not initialized on mgmtd, or allocate some memory that is never freed. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-06-26*: Rearrange vrf_bitmap_X api to reduce memory footprintDonald Sharp
When running all daemons with config for most of them, FRR has sharpd@janelle:~/frr$ vtysh -c "show debug hashtable" | grep "VRF BIT HASH" | wc -l 3570 3570 hashes for bitmaps associated with the vrf. This is a very large number of hashes. Let's do two things: a) Reduce the created size of the actually created hashes to 2 instead of 32. b) Delay generation of the hash *until* a set operation happens. As that no hash directly implies a unset value if/when checked. This reduces the number of hashes to 61 in my setup for normal operation. 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>
2021-12-21*: rework renaming the default VRFIgor Ryzhov
Currently, it is possible to rename the default VRF either by passing `-o` option to zebra or by creating a file in `/var/run/netns` and binding it to `/proc/self/ns/net`. In both cases, only zebra knows about the rename and other daemons learn about it only after they connect to zebra. This is a problem, because daemons may read their config before they connect to zebra. To handle this rename after the config is read, we have some special code in every single daemon, which is not very bad but not desirable in my opinion. But things are getting worse when we need to handle this in northbound layer as we have to manually rewrite the config nodes. This approach is already hacky, but still works as every daemon handles its own NB structures. But it is completely incompatible with the central management daemon architecture we are aiming for, as mgmtd doesn't even have a connection with zebra to learn from it. And it shouldn't have it, because operational state changes should never affect configuration. To solve the problem and simplify the code, I propose to expand the `-o` option to all daemons. By using the startup option, we let daemons know about the rename before they read their configs so we don't need any special code to deal with it. There's an easy way to pass the option to all daemons by using `frr_global_options` variable. Unfortunately, the second way of renaming by creating a file in `/var/run/netns` is incompatible with the new mgmtd architecture. Theoretically, we could force daemons to read their configs only after they connect to zebra, but it means adding even more code to handle a very specific use-case. And anyway this won't work for mgmtd as it doesn't have a connection with zebra. So I had to remove this option. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-22*: cleanup ifp->vrf_idIgor Ryzhov
Since f60a1188 we store a pointer to the VRF in the interface structure. There's no need anymore to store a separate vrf_id field. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-19lib: move zebra-only netns stuff to zebraIgor Ryzhov
When something is used only from zebra and part of its description is "should be called from zebra only" then it belongs to zebra, not lib. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-09-07vrf_name_to_id(): removeG. Paul Ziemba
vrf_name_to_id() returned VRF_DEFAULT when the vrf name was unknown, hiding errors. Per community recommendation, vrf_name_to_id() is now removed and the few callers now use vrf_lookup_by_name() directly. Signed-off-by: G. Paul Ziemba <paulz@labn.net>
2021-09-02lib: Remove unused function vrf_generate_idDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-08-26lib: remove unused argument from vrf_cmd_initIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-31lib: fix binding to a vrfIgor Ryzhov
There are two possible use-cases for the `vrf_bind` function: - bind socket to an interface in a vrf - bind socket to a vrf device For the former case, there's one problem - success is returned when the interface is not found. In that case, the socket is left unbound without throwing an error. For the latter case, there are multiple possible problems: - If the name is not set, then the socket is left unbound (zebra, vrrp). - If the name is "default" and there's an interface with that name in the default VRF, then the socket is bound to that interface. - In most daemons, if the router is configured before the VRF is actually created, we're trying to open and bind the socket right after the daemon receives a VRF registration from zebra. We may not receive the VRF-interface registration from zebra yet at that point. Therefore, `if_lookup_by_name` fails, and the socket is left unbound. This commit fixes all the issues and updates the function description. Suggested-by: Pat Ruddy <pat@voltanet.io> Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-29*: modify VRF_CONFIGURED flag only in VRF NB layerIgor Ryzhov
This is to fix the crash reproduced by the following steps: * ip link add red type vrf table 1 Creates VRF. * vtysh -c "conf" -c "vrf red" Creates VRF NB node and marks VRF as configured. * ip route 1.1.1.0/24 2.2.2.2 vrf red * no ip route 1.1.1.0/24 2.2.2.2 vrf red (or similar l3vni set/unset in zebra) Marks VRF as NOT configured. * ip link del red VRF is deleted, because it is marked as not configured, but NB node stays. Subsequent attempt to configure something in the VRF leads to a crash because of the stale pointer in NB layer. Fixes #8357. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-17*: require semicolon after DEFINE_QOBJ & co.David Lamparter
Again, see previous commits. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-22lib: add definitions for vrf xpathsIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-02-10Merge pull request #7508 from sudhanshukumar22/zebra-vrf-deleteStephen Worley
zebra: treat vrf add for existing vrf as update
2021-02-02lib: add utility to count interfaces connected to a vrfPat Ruddy
Run through the vrf's interface list and return a count, skipping the l3mdev which has a name which matches the vrf name. Signed-off-by: Pat Ruddy <pat@voltanet.io>
2021-02-01zebra: treat vrf add for existing vrf as updatesudhanshukumar22
Description: When we get a new vrf add and vrf with same name, but different vrf-id already exists in the database, we should treat vrf add as update. This happens mostly when there are lots of vrf and other configuration being replayed. There may be a stale vrf delete followed by new vrf add. This can cause timing race condition where vrf delete could be missed and further same vrf add would get rejected instead of treating last arrived vrf add as update. Treat vrf add for existing vrf as update. Implicitly disable this VRF to cleanup routes and other functions as part of vrf disable. Update vrf_id for the vrf and update vrf_id tree. Re-enable VRF so that all routes are freshly installed. Above 3 steps are mandatory since it can happen that with config reload stale routes which are installed in vrf-1 table might contain routes from older vrf-0 table which might have got deleted due to missing vrf-0 in new configuration. Signed-off-by: sudhanshukumar22 <sudhanshu.kumar@broadcom.com>
2020-11-09lib: change limit of netns name from 15 to 35 charactersLouis Scalbert
Extend the size of netns name to match linux permitted netns name size Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2020-09-21vrf: VRF_DEFAULT must be 0, remove useless codeChristophe Gouault
Code was added in the past to support a value of VRF_DEFAULT different from 0. This option was abandoned, the default vrf id is always 0. Remove this code, this will simplify the code and improve performance (use a constant value instead of a function that performs tests). Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
2020-08-18zebra, lib: store relative default ns id in each namespacePhilippe Guibert
to be able to retrieve the network namespace identifier for each namespace, the ns id is stored in each ns context. For default namespace, the netns id is the same as that value. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-05evpn-netns: Revert PR5077, has been re-worked post-refactorPat Ruddy
Revert "zebra: support for macvlan interfaces" This reverts commit bf69e212fd053af3298fc3cba38458b396467849. Revert "doc: add some documentation about bgp evpn netns support" This reverts commit 89b97c33d7a6d9dc427d56fea52fa27334dde81d. Revert "zebra: dynamically detect vxlan link interfaces in other netns" This reverts commit de0ebb25404fe984f084a0d57b7f873618423876. Revert "bgpd: sanity check when updating nexthop from bgp to zebra" This reverts commit ee9633ed87f0ff5da1373a42d6c044f0a682c8d3. Revert "lib, zebra: reuse and adapt ns_list walk functionality" This reverts commit c4d466c830083e8ba58881d7ad03a90f6baf0754. Revert "zebra: local mac entries populated in correct netnamespace" This reverts commit 40424548910887f3bbbf544ce964d3b736048ae5. Revert "zebra: when parsing local entry against dad, retrieve config" This reverts commit 3acc394bc5e5c225e9258fd0d57a6cebea0c0ccd. Revert "bgpd: evpn nexthop can be changed by default" This reverts commit a2342a241253c41b798845cae155b4caab4bcda5. Revert "zebra: zvni_map_to_vlan() adaptation for all namespaces" This reverts commit db81d18647bbd81a2c335620c9a03e32e4a5b2be. Revert "zebra: add ns_id attribute to mac structure" This reverts commit 388d5b438e22cddc6740e362763c0922edbb242a. Revert "zebra: bridge layer2 information records ns_id where bridge is" This reverts commit b5b453a2d6af58692bee0e256fe1dffe99824801. Revert "zebra, lib: new API to get absolute netns val from relative netns val" This reverts commit b6ebab34f664ba1cc9479fc1287f127c12077509. Revert "zebra, lib: store relative default ns id in each namespace" This reverts commit 9d3555e06ccc68fe37e0a00100029ac4bad8dee2. Revert "zebra, lib: add an internal API to get relative default nsid in other ns" This reverts commit 97c9e7533bd22029ac19838c043cfca82d2f6eb3. Revert "zebra: map vxlan interface to bridge interface with correct ns id" This reverts commit 7c990878f20efff335c1211deda3ec50071ae2b5. Revert "zebra: fdb and neighbor table are read for all zns" This reverts commit f8ed2c5420106314a940cb67264494e0110fc4c0. Revert "zebra: zvni_map_to_svi() adaptation for other network namespaces" This reverts commit 2a9dccb6475bfc11af2b855c4c8ff9e500ba21f4. Revert "zebra: display interface slave type" This reverts commit fc3141393ad95651d31fccd144b5c029d00e5f3a. Revert "zebra: zvni_from_svi() adaptation for other network namespaces" This reverts commit 6fe516bd4b85569b3b8b4bcc2910afc5569aa026. Revert "zebra: importation of bgp evpn rt5 from vni with other netns" This reverts commit 28254125d06f65cc4344b6156eec76a37ec6aede. Revert "lib, zebra: update interface name at netlink creation" This reverts commit 1f7a68a2ff0ba1424131f30112e0cc1572f0bee3. Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-05-18zebra, lib: store relative default ns id in each namespacePhilippe Guibert
to be able to retrieve the network namespace identifier for each namespace, the ns id is stored in each ns context. For default namespace, the netns id is the same as that value. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-04-16lib: vrf northbound callbacksChirag Shah
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-13lib: handle bogus VRF backend typeQuentin Young
And use an enum... Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-14lib: Add a macro to allow for quick/easy display of vrf nameDonald Sharp
Add a quick macro to allow for safe dereference of the vrf since it may or may not exist in all cases. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-12-18lib: document vrf_socket(), vrf_bind()Quentin Young
These two don't really do what you might expect, document them Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-06-23Revert "Ospf missing interface handling 2"Donald Sharp
2019-06-12*: change interface structure, from vrf_id to vrfPhilippe Guibert
Field vrf_id is replaced by the pointer of the struct vrf *. For that all other code referencing to (interface)->vrf_id is replaced. This work should not change the behaviour. It is just a continuation work toward having an interface API handling vrf pointer only. some new generic functions are created in vrf: vrf_to_id, vrf_to_name, a zebra function is also created: zvrf_info_lookup an ospf function is also created: ospf_lookup_by_vrf it is to be noted that now that interface has a vrf pointer, some more optimisations could be thought through all the rest of the code. as example, many structure store the vrf_id. those structures could get the exact vrf structure if inherited from an interface vrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12zebra, lib: upon entering interface, create vrf contextPhilippe Guibert
the interface search is based on vrfs. As at startup, some interfaces may be configured, there is need to have vrfs contexts present. A macro is being appended with an extra parameter that permits create a vrf and return the context. This macro is also used by some show routines, but will not create vrfs, because that extra parameter will be set to false, on that case. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-12lib: create interface upon accessing interface NB API.Philippe Guibert
Upon accessing interface NB API, the interface is created, if the vrf is available. the commit does not change the behaviour, since at this commit, this is not yet possible to have vrf contexts, while zebra did not connect to daemons. However, that commit adds some work, so that it will be possible to work on a vrf context, without having the vrf_id completely resolved. for instance, if we suppose a vrf is created by command 'vrf TOTO' in the starting configuration of a daemon, then 'interface TITI vrf TOTO' will permit to create interface TITI within vrf TOTO. the macro VRF_GET_INSTANCE will return the vrf context, if available or not. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-04-04Merge pull request #3548 from opensourcerouting/rip-vrfDonald Sharp
rip(ng)d: add VRF support
2019-03-29Merge remote-tracking branch 'frr/master' into rip-vrfRenato Westphal
Merge commit to solve a bunch of conflicts with other PRs that were merged in the previous weeks. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-03-25Merge pull request #3772 from pguibert6WIND/vrf_backend_unknownDonald Sharp
Vrf backend unknown
2019-02-11lib: add extern "C" {} blocks to all libfrr headersRenato Westphal
These are necessary to use functions defined in these headers from C++. Signed-off-by: David Lamparter <equinox@diac24.net> Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-11libs, daemons: changes to permit c++ compilationMark Stapp
Some misc changes to resolve some c++ compilation errors. The goal is only to permit an external module - a plugin, for example - to see frr headers, not to support or encourage contributions in c++. The changes include: avoiding use of keywords like 'new', 'delete'; cleaning up implicit type-casting from 'void *' in several places. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-02-11lib: interface handling where zebra not yet readyPhilippe Guibert
other daemons need to sync with zebra to get to know which vrf backend is available. in that time, there may be interface configuration available. in that specific case, the vrf backend returned is not known. A specific return value is sent back. This will be useful to know which specific algorithm to apply. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-01-19lib: remove the vrf_is_mapped_on_netns() functionRenato Westphal
Now that all daemons receive the VRF backend from zebra, we can get rid of vrf_is_mapped_on_netns() in favor of using the more convenient vrf_is_backend_netns() function, which doesn't require any argument. This commit also fixes the following problem: debian(config)# ip route 50.0.0.0/8 blackhole vrf FAKE table 2 % table param only available when running on netns-based vrfs Even when zebra was started with the --vrfwnetns, the error above would be displayed since the VRF FAKE didn't exist, which would make vrf_is_mapped_on_netns() return 0 incorrectly. Using vrf_is_backend_netns() this problem doesn't happen anymore. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-01-18lib: constify a few parameters in the VRF codeRenato 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>
2018-11-21lib, zebra: default vrf configured will not be overwritten by discoveryPhilippe Guibert
the netns discovery process executed when vrf backend is netns, allows the zebra daemon to dynamically change the default vrf name value. This option is disabled, when the zebra is forced to a default vrf value with option -o. PR=61513 Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com> Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
2018-11-13bgpd: allow vrf validity and bgp vrf import/export, when zebra is offPhilippe Guibert
if zebra is not started, then vrf identifiers are not available. This prevents import/exportation to be available. This commit permits having import/export available, even when zebra is not started. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-09-20lib: redundant parentheses (SA)F. Aragon
Redundant parentheses surrounding declarator removed. Can be detected via static analysis with e.g. ./configure CFLAGS=-Wredundant-parens CC=clang Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-13bgpd lib ospf6d pbrd tests zebra: shadowing fixesF. Aragon
This fixes all remaining local variable shadowing cases Signed-off-by: F. Aragon <paco@voltanet.io>
2018-08-28*: add a vrf update hook to be informed of the vrf namePhilippe Guibert
The Vrf aliases can be known with a specific hook. That hook will then, from zebra propagate the information to the relevant zapi clients. The registration hook function is the same for all daemons. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-28lib: offer an API to get and set default vrf namePhilippe Guibert
The get API is used each time the VRF_DEFAULT_NAME macro is used. The set API is not yet used. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-22lib: change vrf_is_mapped_on_netns APIPhilippe Guibert
The function handles not a vrf pointer instead of a vrf_id value. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-08-02lib: Fix vrf check output to only have 1 lineDonald Sharp
When we issue this command, we are getting: robot# show ip route vrf green json {} % VRF green not found robot# show ip route vrf green % VRF green not found % VRF green not found robot# Fix the command so it only displays one line of output for json or non-json output. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-07-27lib,zebra: fix json output when vrf1 when not activeNathan Van Gheem
When I did a show ip route with `json` on a vrf when it didn't exist, frr would output invalid json. Signed-off-by: Nathan Van Gheem <nathan@cumulusnetworks.com>
2018-04-13zebra: add an indirection table for ns_idPhilippe Guibert
This list "table" is created in the case the netns backend for VRF is used. This contains the mapping between the NSID value read from the 'ip netns list' and the ns id external used to create the VRF value from vrf context. This mapping is necessary in order to reserve default 0 value for vrf_default. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>