summaryrefslogtreecommitdiff
path: root/zebra/zebra_vrf.c
AgeCommit message (Collapse)Author
2024-01-28zebra: convert to mgmtdIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28zebra: convert vrf configuration output to NBIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-28zebra: make vrf netns commands do nothingIgor Ryzhov
These commands don't really provide any functionality. VRF is associated with netns automatically based on its name, and it's not possible to associate VRF and netns with different names with these commands: - When trying to assosiate a VRF with an already existing netns with a different name: `NS /run/netns/test is already configured with VRF 1(test)` - When trying to assiciate a VRF with a non-existing netns, so they become linked once the netns is created: `Invalid pathname for /run/netns/test: No such file or directory` - When doing "no netns" to unlink the netns and link it back to the same VRF: `VRF 1 is already configured with VRF test` - When doing "no netns" to unlink the netns and link it to another VRF: `Can not associate NS 4294967295 with NETNS /run/netns/test` As shown above, not a single usecase is working. We can't remove them completely to preserve backwards-compatibility, so just make them empty. The main reason for this change is not to spend a lot of time trying to figure out how to convert them to northbound. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-12-11zebra: Properly unregister hook on shutdownDonald Sharp
the zebra pseudo wire code was registering a callback per vrf. These callbacks are not per vrf based. They are vrf agnostic so this was a mistake. Modify the code to on startup register once and on shutdown unregister once. Finally rename the zebra_pw_init and zebra_pw_exit functions to more properly reflect when they are called. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-13zebra: More memory free up on shutdownDonald Sharp
a) nl_batch_tx_buf was not being freed b) the mlag_fifo was not being freed c) the vrf->ns_ctxt was not being freed Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-09-13Merge pull request #14162 from ↵Russ White
opensourcerouting/feature/turn_on_nht_resolve_via_default_for_traditional_profile zebra: Turn on `nht resolve-via-default` by default for traditional profile
2023-08-22zebra: Make main routing table (RT_TABLE_MAIN) configurableMartin Pels
Signed-off-by: Martin Pels <mpels@ripe.net>
2023-08-17zebra: Enable `nht resolve-via-default` by default for traditional profileDonatas Abraitis
Lots of questions raising regarding unresolved nht, I think it's time to relax this and make it a default ON. Here is an example list of issues when `nht resolvia-via-default` solved the problem: https://github.com/FRRouting/frr/issues/3241 https://github.com/FRRouting/frr/issues/7420 https://github.com/FRRouting/frr/issues/3474 https://github.com/FRRouting/frr/issues/5023 https://github.com/FRRouting/frr/issues/6504 https://github.com/FRRouting/frr/issues/6680 https://github.com/FRRouting/frr/issues/7049 https://github.com/FRRouting/frr/issues/7862 https://github.com/FRRouting/frr/issues/7999 https://github.com/FRRouting/frr/issues/13215 https://github.com/FRRouting/frr/issues/14098 TL;DR; The BGP session does not come up if using multihop sessions and/or the peer(nexthop) is not accessible from the RIB, but only via default route. This is even valid for iBGP, and not only for eBGP peering. Adding a static /32, /128 route for the peer would do the trick, but it's a workaround. If the route has a nexthop marked as invalid, most likely this is due to it can't be resolved from the current RIB, but only via default route. For instance, Cisco allows this by default (can't find even a knob to turn it off or I'm blind). For eBGP sessions it might be also combined with `disable-ebgp-connected-route-check`. Some people asked if this could be a default, also for instance MetalLB is adding this by default for all the configs it generates. Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-07-05zebra: Move protodown_r_bit to a better spotDonald Sharp
Since we are moving some code handling out of the dataplane and into zebra proper, lets move the protodown r bit as well. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-07-05zebra: Rename vrf_lookup_by_tableid to zebra_vrf_lookup..Donald Sharp
Rename the vrf_lookup_by_id function to zebra_vrf_lookup_by_id and move to zebra_vrf.c where it nominally belongs, as that we need zebra specific data to find this vrf_id and as such it does not belong in vrf.c 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-12-09zebra: Free up routemap name memory on vrf deletion eventDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-10-26build, vtysh: extract vtysh commands from .xrefDavid Lamparter
Rather than running selected source files through the preprocessor and a bunch of perl regex'ing to get the list of all DEFUNs, use the data collected in frr.xref. This not only eliminates issues we've been having with preprocessor failures due to nonexistent header files, but is also much faster. Where extract.pl would take 5s, this now finishes in 0.2s. And since this is a non-parallelizable build step towards the end of the build (dependent on a lot of other things being done already), the speedup is actually noticeable. Also files containing CLI no longer need to be listed in `vtysh_scan` since the .xref data covers everything. `#ifndef VTYSH_EXTRACT_PL` checks are equally obsolete. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-09-07zebra: Reconfiguring netns for vrf is not a failureXiao Liang
When using namespace VRF backend, and frr.conf contains: vrf test netns /run/netns/test exit-vrf FRR fails to start: line 11: Failure to communicate[13] to zebra, line: netns /run/netns/test Fix this by returning CMD_WARNING rather than CMD_WARNING_CONFIG_FAILED when the same netns path is configured. Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-08-10zebra: Combine meta_queue_free and meta_queue_vrf_free functionsDonald Sharp
These functions essentially do the same thing. Combine them for the goodness of mankind. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-21zebra: clean up rtadv integrationDavid Lamparter
Move a few things into places they actually belong, and reduce the number of places we have `#ifdev HAVE_RTADV`. Just overall code prettification. ... I had actually done this quite a while ago while doing some other random hacking and thought it more useful to not be sitting on it on my disk... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-02-01zebra: fix cleanup of meta queues on vrf disableIgor Ryzhov
Current code treats all metaqueues as lists of route_node structures. However, some queues contain other structures that need to be cleaned up differently. Casting the elements of those queues to struct route_node and dereferencing them leads to a crash. The crash may be seen when executing bgp_multi_vrf_topo2. Fix the code by using the proper list element types. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-26zebra: Don't double delete the table we are cleaning upDonald Sharp
vrf_disable is always called first before vrf_delete. The rnh_table and rnh_table_multicast tables are already deleted as part of vrf_disable. No need to do it again. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
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-11zebra: fix disabling table managerIgor Ryzhov
42d4b30e introduced per-VRF table manager. Table manager is allocated when the VRF is created, but it is freed when the VRF is disabled. When this VRF is re-enabled, zebra ends up with table manager being NULL pointer and it crashes on any dereference. Table manager should be freed when the VRF is deleted, not when it's disabled. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-05zebra: don't register same hook multiple timesIgor Ryzhov
Before 42d4b30e, table_manager_enable was called only once and the hook was also registered once. After the change, the hook is registered per each VRF that is created in the system. This is wrong. 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-10-13Merge pull request #9676 from donaldsharp/import_registerDavid Lamparter
2021-09-27zebra: Create the SAFI_MULTICAST rnh tablesDonald Sharp
Actually create the SAFI_MULTICAST rnh tables. No code uses these yet. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-27zebra: remove zvrf->import_check_tableDonald Sharp
The import_check_table is no longer used, so let's remove it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-21zebra: extend table manager per vrf, add vty configurationPhilippe Guibert
Because vrf backend may be based on namespaces, each vrf can use in the [16-(2^32-1)] range table identifier for daemons that request it. Extend the table manager to be hosted by vrf. That possibility is disabled in the case the vrf backend is vrflite. In that case, all vrf context use the same table manager instance. Add a configuration command to be able to configure the wished range of tables to use. This is a solution that permits to give chunks to bgp daemon when it works with bgp flowspec entries and wants to use specific iptables that do not override vrf tables. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-08-27Merge pull request #9496 from idryzhov/vrf-cmd-init-unused-argDavid Lamparter
lib: remove unused argument from vrf_cmd_init
2021-08-26Merge pull request #9331 from idryzhov/explicit-exitChristian Hopps
*: explicitly print "exit" at the end of every node config
2021-08-26lib: remove unused argument from vrf_cmd_initIgor Ryzhov
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23lib, zebra: move vrf netns commands from lib to zebraIgor Ryzhov
"[no] netns NAME" commands are part of the lib, but they are actually zebra-only: - they are using vrf_netns_handler_create and its description clearly says that it "should be called from zebra only" - vtysh sends these commands only to zebra - only zebra outputs the netns related config - zebra notifies other daemons about netns attachment Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23*: explicitly print "exit" at the end of every node configIgor Ryzhov
There is a possibility that the same line can be matched as a command in some node and its parent node. In this case, when reading the config, this line is always executed as a command of the child node. For example, with the following config: ``` router ospf network 193.168.0.0/16 area 0 ! mpls ldp discovery hello interval 111 ! ``` Line `mpls ldp` is processed as command `mpls ldp-sync` inside the `router ospf` node. This leads to a complete loss of `mpls ldp` node configuration. To eliminate this issue and all possible similar issues, let's print an explicit "exit" at the end of every node config. This commit also changes indentation for a couple of existing exit commands so that all existing commands are on the same level as their corresponding node-entering commands. Fixes #9206. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-08zebra: rework RA handling for vrf-liteStephen Worley
Rework RA handling for vrf-lite scenarios. Before we were using a single FD descriptor for polling across multiple zvrf's. This would cause us to hit this assert() in some bgp unnumbered and vrrp configs: ``` /* * What happens if we have a thread already * created for this event? */ if (thread_array[fd]) assert(!"Thread already scheduled for file descriptor"); ``` We were scheduling a thread_read on the same FD for every zvrf. With vrf-lite, RAs and ARPs are not vrf-bound, so we can just use one rtadv instance to manage them for all VRFs. We will choose the default VRF for this. This patch removes the rtadv_sock altogether for zrouter and moves the functionality this represented to the default VRF. All RAs will be handled in the default VRF under vrf-lite configs with only one poll thread started for it. This patch also extends how we track subscribed interfaces (s or msec) to use an actual sorted list by interface names rather than just a counter. With multiple daemons turning interfaces/on/off these counters can get very wrong during ifup/down events. Making them a sorted list prevents this from happening by preventing duplicates. With netns-vrf's nothing should change other than the interface list. Signed-off-by: Stephen Worley <sworley@nvidia.com>
2021-05-05zebra: Allow the zvrf to know it's vrf when allocingDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.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-22zebra: kill zebra_memory.h, use MTYPE_STATICDavid Lamparter
This one also needed a bit of shuffling around, but MTYPE_RE is the only one left used across file boundaries now. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-12-09zebra: anticipate zns creation at vrf creation when backend is vrf-litePhilippe Guibert
in the case the namespace pointer is already available, feed it at vrf creation. this prevents from crashing if the netlink parsing already began, and the vrf-lite is not enabled yet. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-10-20zebra: clean up all router id listsMark Stapp
Clean up the ipv6 router-id lists associated with a zvrf - these were being leaked. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-09zebra: Allow router-id to be part of the vrf sub nodeDonald Sharp
Modify zebra to accept router-id's as part of the vrf subnode. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-04-02zebra: Don't kill the global rtadv socket when a vrf is deletedDonald Sharp
The rtadv code has two types of sockets: a) namespace -> Where each zvrf get's it's own socket b) vrf lite -> Where we get 1 socket for everything When we were terminating a vrf we were *always* killing the (b) socket. This is a mistake in that other vrf's may need to be communicating. Modify the code on vrf shutdown to only disable that vrf's event processing and when we actually terminate we shut the socket. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-23zebra: Synchronous client queues accumulate messages from zebra.Karen Schoener
Zebra is currently sending messages on interface add/delete/update, VRF add/delete, and interface address change - regardless of whether its clients had requested them. This is problematic for lde and isis, which only listens to label chunk messages, and only when it is waiting for one (synchronous client). The effect is the that messages accumulate on the lde synchronous message queue. With this change: - Zebra does not send unsolicited messages to synchronous clients. - Synchronous clients send a ZEBRA_HELLO to zebra. The ZEBRA_HELLO contains a new boolean field: sychronous. - LDP and PIM have been updated to send a ZEBRA_HELLO for their synchronous clients. Signed-off-by: Karen Schoener <karen@voltanet.io>
2019-11-01zebra: separate zebra_vrf_lookup_table_with_id()Stephen Worley
We were creating `other` tables in rib_del(), vty commands, and dataplane return callback via the zebra_vrf_table_with_table_id() API. Seperate the API into only a lookup, never create and added another with `get` in the name (following the standard we use in other table APIs). Then changed the rib_del(), rib_find_rn_from_ctx(), and show route summary vty command to use the lookup API instead. This was found via a crash where two different vrfs though they owned the table. On delete, one free'd all the nodes, and then the other tried to use them. It required specific timing of a VRF existing, going away, and coming back again to cause the crash. =23464== Invalid read of size 8 ==23464== at 0x179EA4: rib_dest_from_rnode (rib.h:433) ==23464== by 0x17ACB1: zebra_vrf_delete (zebra_vrf.c:253) ==23464== by 0x48F3D45: vrf_delete (vrf.c:243) ==23464== by 0x48F4468: vrf_terminate (vrf.c:532) ==23464== by 0x13D8C5: sigint (main.c:172) ==23464== by 0x48DD25C: quagga_sigevent_process (sigevent.c:105) ==23464== by 0x48F0502: thread_fetch (thread.c:1417) ==23464== by 0x48AC82B: frr_run (libfrr.c:1023) ==23464== by 0x13DD02: main (main.c:483) ==23464== Address 0x5152788 is 104 bytes inside a block of size 112 free'd ==23464== at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==23464== by 0x48B25B8: qfree (memory.c:129) ==23464== by 0x48EA335: route_node_destroy (table.c:500) ==23464== by 0x48E967F: route_node_free (table.c:90) ==23464== by 0x48E9742: route_table_free (table.c:124) ==23464== by 0x48E9599: route_table_finish (table.c:60) ==23464== by 0x170CEA: zebra_router_free_table (zebra_router.c:165) ==23464== by 0x170DB4: zebra_router_release_table (zebra_router.c:188) ==23464== by 0x17AAD2: zebra_vrf_disable (zebra_vrf.c:222) ==23464== by 0x48F3F0C: vrf_disable (vrf.c:313) ==23464== by 0x48F3CCF: vrf_delete (vrf.c:223) ==23464== by 0x48F4468: vrf_terminate (vrf.c:532) ==23464== Block was alloc'd at ==23464== at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==23464== by 0x48B24A2: qcalloc (memory.c:110) ==23464== by 0x48EA2FE: route_node_create (table.c:488) ==23464== by 0x48E95C7: route_node_new (table.c:66) ==23464== by 0x48E95E5: route_node_set (table.c:75) ==23464== by 0x48E9EA9: route_node_get (table.c:326) ==23464== by 0x48E1EDB: srcdest_rnode_get (srcdest_table.c:244) ==23464== by 0x16EA4B: rib_add_multipath (zebra_rib.c:2730) ==23464== by 0x1A5310: zread_route_add (zapi_msg.c:1592) ==23464== by 0x1A7B8E: zserv_handle_commands (zapi_msg.c:2579) ==23464== by 0x19D689: zserv_process_messages (zserv.c:523) ==23464== by 0x48F09F8: thread_call (thread.c:1599) Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
2019-09-25zebra: fix evpn prefix-routes-only for default vrfChirag Shah
asymmetric routing default vrf vni configuration is not displayed as part of running-config. Ticket:CM-26470 Reviewed By: Testing Done: T11# config t T11(config)# vni 4004 prefix-routes-only T11(config)# end Before: T11# show running-config ... vni 4004 ... After: T11# show running-config ... vni 4004 prefix-routes-only ... Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-09-19Zebra: Rectifying the log messages.vdhingra
This change addresses the following : 1. Ensures zlog_debug should be under DEBUG macro check 2. Ensures zlog_err and zlog_warn wherever applicable. 3. Removed few posivite logs from fpm handling, whose frequency is high. Signed-off-by: vishaldhingra <vdhingra@vmware.com>
2019-08-28zebra: nht resolution default configurable per vrfPhilippe Guibert
even if vty commands were available, the default resolution command was working only for the first vrf configured. others were ignored. Also, for nexthop, resolution was working for all vrfs, and not the specific one. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-21zebra: use MTYPE_STATICDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-04zebra: move rtadv service from zrouter to zvrfPhilippe Guibert
when network namespace is used as vrf backend, there is need to have separate contexts for rtadv contexts. route advertisements have to look for appropriate interface based on zvrf context. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-16Revert "zebra: move rtadv service from zrouter to zvrf"Donald Sharp
This reverts commit f20e2a09c8aef399698fa074b36f24becdf49cbb.
2019-05-16Merge pull request #4269 from donaldsharp/other_tablesRuss White
zebra Other tables
2019-05-14Merge pull request #4027 from pguibert6WIND/fix_interface_rtadvDavid Lamparter
Fix interface rtadv